documentation.d.ts 3.6 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573745747457574576745777457874579745807458174582745837458474585745867458774588745897459074591745927459374594745957459674597745987459974600746017460274603746047460574606746077460874609746107461174612746137461474615746167461774618746197462074621746227462374624746257462674627746287462974630746317463274633746347463574636746377463874639746407464174642746437464474645746467464774648746497465074651746527465374654746557465674657746587465974660746617466274663746647466574666746677466874669746707467174672746737467474675746767467774678746797468074681746827468374684746857468674687746887468974690746917469274693746947469574696746977469874699747007470174702747037470474705747067470774708747097471074711747127471374714747157471674717747187471974720747217472274723747247472574726747277472874729747307473174732747337473474735747367473774738747397474074741747427474374744747457474674747747487474974750747517475274753747547475574756747577475874759747607476174762747637476474765747667476774768747697477074771747727477374774747757477674777747787477974780747817478274783747847478574786747877478874789747907479174792747937479474795747967479774798747997480074801748027480374804748057480674807748087480974810748117481274813748147481574816748177481874819748207482174822748237482474825748267482774828748297483074831748327483374834748357483674837748387483974840748417484274843748447484574846748477484874849748507485174852748537485474855748567485774858748597486074861748627486374864748657486674867748687486974870748717487274873748747487574876748777487874879748807488174882748837488474885748867488774888748897489074891748927489374894748957489674897748987489974900749017490274903749047490574906749077490874909749107491174912749137491474915749167491774918749197492074921749227492374924749257492674927749287492974930749317493274933749347493574936749377493874939749407494174942749437494474945749467494774948749497495074951749527495374954749557495674957749587495974960749617496274963749647496574966749677496874969749707497174972749737497474975749767497774978749797498074981749827498374984749857498674987749887498974990749917499274993749947499574996749977499874999750007500175002750037500475005750067500775008750097501075011750127501375014750157501675017750187501975020750217502275023750247502575026750277502875029750307503175032750337503475035750367503775038750397504075041750427504375044750457504675047750487504975050750517505275053750547505575056750577505875059750607506175062750637506475065750667506775068750697507075071750727507375074750757507675077750787507975080750817508275083750847508575086750877508875089750907509175092750937509475095750967509775098750997510075101751027510375104751057510675107751087510975110751117511275113751147511575116751177511875119751207512175122751237512475125751267512775128751297513075131751327513375134751357513675137751387513975140751417514275143751447514575146751477514875149751507515175152751537515475155751567515775158751597516075161751627516375164751657516675167751687516975170751717517275173751747517575176751777517875179751807518175182751837518475185751867518775188751897519075191751927519375194751957519675197751987519975200752017520275203752047520575206752077520875209752107521175212752137521475215752167521775218752197522075221752227522375224752257522675227752287522975230752317523275233752347523575236752377523875239752407524175242752437524475245752467524775248752497525075251752527525375254752557525675257752587525975260752617526275263752647526575266752677526875269752707527175272752737527475275752767527775278752797528075281752827528375284752857528675287752887528975290752917529275293752947529575296752977529875299753007530175302753037530475305753067530775308753097531075311753127531375314753157531675317753187531975320753217532275323753247532575326753277532875329753307533175332753337533475335753367533775338753397534075341753427534375344753457534675347753487534975350753517535275353753547535575356753577535875359753607536175362753637536475365753667536775368753697537075371753727537375374753757537675377753787537975380753817538275383753847538575386753877538875389753907539175392753937539475395753967539775398753997540075401754027540375404754057540675407754087540975410754117541275413754147541575416754177541875419754207542175422754237542475425754267542775428754297543075431754327543375434754357543675437754387543975440754417544275443754447544575446754477544875449754507545175452754537545475455754567545775458754597546075461754627546375464754657546675467754687546975470754717547275473754747547575476754777547875479754807548175482754837548475485754867548775488754897549075491754927549375494754957549675497754987549975500755017550275503755047550575506755077550875509755107551175512755137551475515755167551775518755197552075521755227552375524755257552675527755287552975530755317553275533755347553575536755377553875539755407554175542755437554475545755467554775548755497555075551755527555375554755557555675557755587555975560755617556275563755647556575566755677556875569755707557175572755737557475575755767557775578755797558075581755827558375584755857558675587755887558975590755917559275593755947559575596755977559875599756007560175602756037560475605756067560775608756097561075611756127561375614756157561675617756187561975620756217562275623756247562575626756277562875629756307563175632756337563475635756367563775638756397564075641756427564375644756457564675647756487564975650756517565275653756547565575656756577565875659756607566175662756637566475665756667566775668756697567075671756727567375674756757567675677756787567975680756817568275683756847568575686756877568875689756907569175692756937569475695756967569775698756997570075701757027570375704757057570675707757087570975710757117571275713757147571575716757177571875719757207572175722757237572475725757267572775728757297573075731757327573375734757357573675737757387573975740757417574275743757447574575746757477574875749757507575175752757537575475755757567575775758757597576075761757627576375764757657576675767757687576975770757717577275773757747577575776757777577875779757807578175782757837578475785757867578775788757897579075791757927579375794757957579675797757987579975800758017580275803758047580575806758077580875809758107581175812758137581475815758167581775818758197582075821758227582375824758257582675827758287582975830758317583275833758347583575836758377583875839758407584175842758437584475845758467584775848758497585075851758527585375854758557585675857758587585975860758617586275863758647586575866758677586875869758707587175872758737587475875758767587775878758797588075881758827588375884758857588675887758887588975890758917589275893758947589575896758977589875899759007590175902759037590475905759067590775908759097591075911759127591375914759157591675917759187591975920759217592275923759247592575926759277592875929759307593175932759337593475935759367593775938759397594075941759427594375944759457594675947759487594975950759517595275953759547595575956759577595875959759607596175962759637596475965759667596775968759697597075971759727597375974759757597675977759787597975980759817598275983759847598575986759877598875989759907599175992759937599475995759967599775998759997600076001760027600376004760057600676007760087600976010760117601276013760147601576016760177601876019760207602176022760237602476025760267602776028760297603076031760327603376034760357603676037760387603976040760417604276043760447604576046760477604876049760507605176052760537605476055760567605776058760597606076061760627606376064760657606676067760687606976070760717607276073760747607576076760777607876079760807608176082760837608476085760867608776088760897609076091760927609376094760957609676097760987609976100761017610276103761047610576106761077610876109761107611176112761137611476115761167611776118761197612076121761227612376124761257612676127761287612976130761317613276133761347613576136761377613876139761407614176142761437614476145761467614776148761497615076151761527615376154761557615676157761587615976160761617616276163761647616576166761677616876169761707617176172761737617476175761767617776178761797618076181761827618376184761857618676187761887618976190761917619276193761947619576196761977619876199762007620176202762037620476205762067620776208762097621076211762127621376214762157621676217762187621976220762217622276223762247622576226762277622876229762307623176232762337623476235762367623776238762397624076241762427624376244762457624676247762487624976250762517625276253762547625576256762577625876259762607626176262762637626476265762667626776268762697627076271762727627376274762757627676277762787627976280762817628276283762847628576286762877628876289762907629176292762937629476295762967629776298762997630076301763027630376304763057630676307763087630976310763117631276313763147631576316763177631876319763207632176322763237632476325763267632776328763297633076331763327633376334763357633676337763387633976340763417634276343763447634576346763477634876349763507635176352763537635476355763567635776358763597636076361763627636376364763657636676367763687636976370763717637276373763747637576376763777637876379763807638176382763837638476385763867638776388763897639076391763927639376394763957639676397763987639976400764017640276403764047640576406764077640876409764107641176412764137641476415764167641776418764197642076421764227642376424764257642676427764287642976430764317643276433764347643576436764377643876439764407644176442764437644476445764467644776448764497645076451764527645376454764557645676457764587645976460764617646276463764647646576466764677646876469764707647176472764737647476475764767647776478764797648076481764827648376484764857648676487764887648976490764917649276493764947649576496764977649876499765007650176502765037650476505765067650776508765097651076511765127651376514765157651676517765187651976520765217652276523765247652576526765277652876529765307653176532765337653476535765367653776538765397654076541765427654376544765457654676547765487654976550765517655276553765547655576556765577655876559765607656176562765637656476565765667656776568765697657076571765727657376574765757657676577765787657976580765817658276583765847658576586765877658876589765907659176592765937659476595765967659776598765997660076601766027660376604766057660676607766087660976610766117661276613766147661576616766177661876619766207662176622766237662476625766267662776628766297663076631766327663376634766357663676637766387663976640766417664276643766447664576646766477664876649766507665176652766537665476655766567665776658766597666076661766627666376664766657666676667766687666976670766717667276673766747667576676766777667876679766807668176682766837668476685766867668776688766897669076691766927669376694766957669676697766987669976700767017670276703767047670576706767077670876709767107671176712767137671476715767167671776718767197672076721767227672376724767257672676727767287672976730767317673276733767347673576736767377673876739767407674176742767437674476745767467674776748767497675076751767527675376754767557675676757767587675976760767617676276763767647676576766767677676876769767707677176772767737677476775767767677776778767797678076781767827678376784767857678676787767887678976790767917679276793767947679576796767977679876799768007680176802768037680476805768067680776808768097681076811768127681376814768157681676817768187681976820768217682276823768247682576826768277682876829768307683176832768337683476835768367683776838768397684076841768427684376844768457684676847768487684976850768517685276853768547685576856768577685876859768607686176862768637686476865768667686776868768697687076871768727687376874768757687676877768787687976880768817688276883768847688576886768877688876889768907689176892768937689476895768967689776898768997690076901769027690376904769057690676907769087690976910769117691276913769147691576916769177691876919769207692176922769237692476925769267692776928769297693076931769327693376934769357693676937769387693976940769417694276943769447694576946769477694876949769507695176952769537695476955769567695776958769597696076961769627696376964769657696676967769687696976970769717697276973769747697576976769777697876979769807698176982769837698476985769867698776988769897699076991769927699376994769957699676997769987699977000770017700277003770047700577006770077700877009770107701177012770137701477015770167701777018770197702077021770227702377024770257702677027770287702977030770317703277033770347703577036770377703877039770407704177042770437704477045770467704777048770497705077051770527705377054770557705677057770587705977060770617706277063770647706577066770677706877069770707707177072770737707477075770767707777078770797708077081770827708377084770857708677087770887708977090770917709277093770947709577096770977709877099771007710177102771037710477105771067710777108771097711077111771127711377114771157711677117771187711977120771217712277123771247712577126771277712877129771307713177132771337713477135771367713777138771397714077141771427714377144771457714677147771487714977150771517715277153771547715577156771577715877159771607716177162771637716477165771667716777168771697717077171771727717377174771757717677177771787717977180771817718277183771847718577186771877718877189771907719177192771937719477195771967719777198771997720077201772027720377204772057720677207772087720977210772117721277213772147721577216772177721877219772207722177222772237722477225772267722777228772297723077231772327723377234772357723677237772387723977240772417724277243772447724577246772477724877249772507725177252772537725477255772567725777258772597726077261772627726377264772657726677267772687726977270772717727277273772747727577276772777727877279772807728177282772837728477285772867728777288772897729077291772927729377294772957729677297772987729977300773017730277303773047730577306773077730877309773107731177312773137731477315773167731777318773197732077321773227732377324773257732677327773287732977330773317733277333773347733577336773377733877339773407734177342773437734477345773467734777348773497735077351773527735377354773557735677357773587735977360773617736277363773647736577366773677736877369773707737177372773737737477375773767737777378773797738077381773827738377384773857738677387773887738977390773917739277393773947739577396773977739877399774007740177402774037740477405774067740777408774097741077411774127741377414774157741677417774187741977420774217742277423774247742577426774277742877429774307743177432774337743477435774367743777438774397744077441774427744377444774457744677447774487744977450774517745277453774547745577456774577745877459774607746177462774637746477465774667746777468774697747077471774727747377474774757747677477774787747977480774817748277483774847748577486774877748877489774907749177492774937749477495774967749777498774997750077501775027750377504775057750677507775087750977510775117751277513775147751577516775177751877519775207752177522775237752477525775267752777528775297753077531775327753377534775357753677537775387753977540775417754277543775447754577546775477754877549775507755177552775537755477555775567755777558775597756077561775627756377564775657756677567775687756977570775717757277573775747757577576775777757877579775807758177582775837758477585775867758777588775897759077591775927759377594775957759677597775987759977600776017760277603776047760577606776077760877609776107761177612776137761477615776167761777618776197762077621776227762377624776257762677627776287762977630776317763277633776347763577636776377763877639776407764177642776437764477645776467764777648776497765077651776527765377654776557765677657776587765977660776617766277663776647766577666776677766877669776707767177672776737767477675776767767777678776797768077681776827768377684776857768677687776887768977690776917769277693776947769577696776977769877699777007770177702777037770477705777067770777708777097771077711777127771377714777157771677717777187771977720777217772277723777247772577726777277772877729777307773177732777337773477735777367773777738777397774077741777427774377744777457774677747777487774977750777517775277753777547775577756777577775877759777607776177762777637776477765777667776777768777697777077771777727777377774777757777677777777787777977780777817778277783777847778577786777877778877789777907779177792777937779477795777967779777798777997780077801778027780377804778057780677807778087780977810778117781277813778147781577816778177781877819778207782177822778237782477825778267782777828778297783077831778327783377834778357783677837778387783977840778417784277843778447784577846778477784877849778507785177852778537785477855778567785777858778597786077861778627786377864778657786677867778687786977870778717787277873778747787577876778777787877879778807788177882778837788477885778867788777888778897789077891778927789377894778957789677897778987789977900779017790277903779047790577906779077790877909779107791177912779137791477915779167791777918779197792077921779227792377924779257792677927779287792977930779317793277933779347793577936779377793877939779407794177942779437794477945779467794777948779497795077951779527795377954779557795677957779587795977960779617796277963779647796577966779677796877969779707797177972779737797477975779767797777978779797798077981779827798377984779857798677987779887798977990779917799277993779947799577996779977799877999780007800178002780037800478005780067800778008780097801078011780127801378014780157801678017780187801978020780217802278023780247802578026780277802878029780307803178032780337803478035780367803778038780397804078041780427804378044780457804678047780487804978050780517805278053780547805578056780577805878059780607806178062780637806478065780667806778068780697807078071780727807378074780757807678077780787807978080780817808278083780847808578086780877808878089780907809178092780937809478095780967809778098780997810078101781027810378104781057810678107781087810978110781117811278113781147811578116781177811878119781207812178122781237812478125781267812778128781297813078131781327813378134781357813678137781387813978140781417814278143781447814578146781477814878149781507815178152781537815478155781567815778158781597816078161781627816378164781657816678167781687816978170781717817278173781747817578176781777817878179781807818178182781837818478185781867818778188781897819078191781927819378194781957819678197781987819978200782017820278203782047820578206782077820878209782107821178212782137821478215782167821778218782197822078221782227822378224782257822678227782287822978230782317823278233782347823578236782377823878239782407824178242782437824478245782467824778248782497825078251782527825378254782557825678257782587825978260782617826278263782647826578266782677826878269782707827178272782737827478275782767827778278782797828078281782827828378284782857828678287782887828978290782917829278293782947829578296782977829878299783007830178302783037830478305783067830778308783097831078311783127831378314783157831678317783187831978320783217832278323783247832578326783277832878329783307833178332783337833478335783367833778338783397834078341783427834378344783457834678347783487834978350783517835278353783547835578356783577835878359783607836178362783637836478365783667836778368783697837078371783727837378374783757837678377783787837978380783817838278383783847838578386783877838878389783907839178392783937839478395783967839778398783997840078401784027840378404784057840678407784087840978410784117841278413784147841578416784177841878419784207842178422784237842478425784267842778428784297843078431784327843378434784357843678437784387843978440784417844278443784447844578446784477844878449784507845178452784537845478455784567845778458784597846078461784627846378464784657846678467784687846978470784717847278473784747847578476784777847878479784807848178482784837848478485784867848778488784897849078491784927849378494784957849678497784987849978500785017850278503785047850578506785077850878509785107851178512785137851478515785167851778518785197852078521785227852378524785257852678527785287852978530785317853278533785347853578536785377853878539785407854178542785437854478545785467854778548785497855078551785527855378554785557855678557785587855978560785617856278563785647856578566785677856878569785707857178572785737857478575785767857778578785797858078581785827858378584785857858678587785887858978590785917859278593785947859578596785977859878599786007860178602786037860478605786067860778608786097861078611786127861378614786157861678617786187861978620786217862278623786247862578626786277862878629786307863178632786337863478635786367863778638786397864078641786427864378644786457864678647786487864978650786517865278653786547865578656786577865878659786607866178662786637866478665786667866778668786697867078671786727867378674786757867678677786787867978680786817868278683786847868578686786877868878689786907869178692786937869478695786967869778698786997870078701787027870378704787057870678707787087870978710787117871278713787147871578716787177871878719787207872178722787237872478725787267872778728787297873078731787327873378734787357873678737787387873978740787417874278743787447874578746787477874878749787507875178752787537875478755787567875778758787597876078761787627876378764787657876678767787687876978770787717877278773787747877578776787777877878779787807878178782787837878478785787867878778788787897879078791787927879378794787957879678797787987879978800788017880278803788047880578806788077880878809788107881178812788137881478815788167881778818788197882078821788227882378824788257882678827788287882978830788317883278833788347883578836788377883878839788407884178842788437884478845788467884778848788497885078851788527885378854788557885678857788587885978860788617886278863788647886578866788677886878869788707887178872788737887478875788767887778878788797888078881788827888378884788857888678887788887888978890788917889278893788947889578896788977889878899789007890178902789037890478905789067890778908789097891078911789127891378914789157891678917789187891978920789217892278923789247892578926789277892878929789307893178932789337893478935789367893778938789397894078941789427894378944789457894678947789487894978950789517895278953789547895578956789577895878959789607896178962789637896478965789667896778968789697897078971789727897378974789757897678977789787897978980789817898278983789847898578986789877898878989789907899178992789937899478995789967899778998789997900079001790027900379004790057900679007790087900979010790117901279013790147901579016790177901879019790207902179022790237902479025790267902779028790297903079031790327903379034790357903679037790387903979040790417904279043790447904579046790477904879049790507905179052790537905479055790567905779058790597906079061790627906379064790657906679067790687906979070790717907279073790747907579076790777907879079790807908179082790837908479085790867908779088790897909079091790927909379094790957909679097790987909979100791017910279103791047910579106791077910879109791107911179112791137911479115791167911779118791197912079121791227912379124791257912679127791287912979130791317913279133791347913579136791377913879139791407914179142791437914479145791467914779148791497915079151791527915379154791557915679157791587915979160791617916279163791647916579166791677916879169791707917179172791737917479175791767917779178791797918079181791827918379184791857918679187791887918979190791917919279193791947919579196791977919879199792007920179202792037920479205792067920779208792097921079211792127921379214792157921679217792187921979220792217922279223792247922579226792277922879229792307923179232792337923479235792367923779238792397924079241792427924379244792457924679247792487924979250792517925279253792547925579256792577925879259792607926179262792637926479265792667926779268792697927079271792727927379274792757927679277792787927979280792817928279283792847928579286792877928879289792907929179292792937929479295792967929779298792997930079301793027930379304793057930679307793087930979310793117931279313793147931579316793177931879319793207932179322793237932479325793267932779328793297933079331793327933379334793357933679337793387933979340793417934279343793447934579346793477934879349793507935179352793537935479355793567935779358793597936079361793627936379364793657936679367793687936979370793717937279373793747937579376793777937879379793807938179382793837938479385793867938779388793897939079391793927939379394793957939679397793987939979400794017940279403794047940579406794077940879409794107941179412794137941479415794167941779418794197942079421794227942379424794257942679427794287942979430794317943279433794347943579436794377943879439794407944179442794437944479445794467944779448794497945079451794527945379454794557945679457794587945979460794617946279463794647946579466794677946879469794707947179472794737947479475794767947779478794797948079481794827948379484794857948679487794887948979490794917949279493794947949579496794977949879499795007950179502795037950479505795067950779508795097951079511795127951379514795157951679517795187951979520795217952279523795247952579526795277952879529795307953179532795337953479535795367953779538795397954079541795427954379544795457954679547795487954979550795517955279553795547955579556795577955879559795607956179562795637956479565795667956779568795697957079571795727957379574795757957679577795787957979580795817958279583795847958579586795877958879589795907959179592795937959479595795967959779598795997960079601796027960379604796057960679607796087960979610796117961279613796147961579616796177961879619796207962179622796237962479625796267962779628796297963079631796327963379634796357963679637796387963979640796417964279643796447964579646796477964879649796507965179652796537965479655796567965779658796597966079661796627966379664796657966679667796687966979670796717967279673796747967579676796777967879679796807968179682796837968479685796867968779688796897969079691796927969379694796957969679697796987969979700797017970279703797047970579706797077970879709797107971179712797137971479715797167971779718797197972079721797227972379724797257972679727797287972979730797317973279733797347973579736797377973879739797407974179742797437974479745797467974779748797497975079751797527975379754797557975679757797587975979760797617976279763797647976579766797677976879769797707977179772797737977479775797767977779778797797978079781797827978379784797857978679787797887978979790797917979279793797947979579796797977979879799798007980179802798037980479805798067980779808798097981079811798127981379814798157981679817798187981979820798217982279823798247982579826798277982879829798307983179832798337983479835798367983779838798397984079841798427984379844798457984679847798487984979850798517985279853798547985579856798577985879859798607986179862798637986479865798667986779868798697987079871798727987379874798757987679877798787987979880798817988279883798847988579886798877988879889798907989179892798937989479895798967989779898798997990079901799027990379904799057990679907799087990979910799117991279913799147991579916799177991879919799207992179922799237992479925799267992779928799297993079931799327993379934799357993679937799387993979940799417994279943799447994579946799477994879949799507995179952799537995479955799567995779958799597996079961799627996379964799657996679967799687996979970799717997279973799747997579976799777997879979799807998179982799837998479985799867998779988799897999079991799927999379994799957999679997799987999980000800018000280003800048000580006800078000880009800108001180012800138001480015800168001780018800198002080021800228002380024800258002680027800288002980030800318003280033800348003580036800378003880039800408004180042800438004480045800468004780048800498005080051800528005380054800558005680057800588005980060800618006280063800648006580066800678006880069800708007180072800738007480075800768007780078800798008080081800828008380084800858008680087800888008980090800918009280093800948009580096800978009880099801008010180102801038010480105801068010780108801098011080111801128011380114801158011680117801188011980120801218012280123801248012580126801278012880129801308013180132801338013480135801368013780138801398014080141801428014380144801458014680147801488014980150801518015280153801548015580156801578015880159801608016180162801638016480165801668016780168801698017080171801728017380174801758017680177801788017980180801818018280183801848018580186801878018880189801908019180192801938019480195801968019780198801998020080201802028020380204802058020680207802088020980210802118021280213802148021580216802178021880219802208022180222802238022480225802268022780228802298023080231802328023380234802358023680237802388023980240802418024280243802448024580246802478024880249802508025180252802538025480255802568025780258802598026080261802628026380264802658026680267802688026980270802718027280273802748027580276802778027880279802808028180282802838028480285802868028780288802898029080291802928029380294802958029680297802988029980300803018030280303803048030580306803078030880309803108031180312803138031480315803168031780318803198032080321803228032380324803258032680327803288032980330803318033280333803348033580336803378033880339803408034180342803438034480345803468034780348803498035080351803528035380354803558035680357803588035980360803618036280363803648036580366803678036880369803708037180372803738037480375803768037780378803798038080381803828038380384803858038680387803888038980390803918039280393803948039580396803978039880399804008040180402804038040480405804068040780408804098041080411804128041380414804158041680417804188041980420804218042280423804248042580426804278042880429804308043180432804338043480435804368043780438804398044080441804428044380444804458044680447804488044980450804518045280453804548045580456804578045880459804608046180462804638046480465804668046780468804698047080471804728047380474804758047680477804788047980480804818048280483804848048580486804878048880489804908049180492804938049480495804968049780498804998050080501805028050380504805058050680507805088050980510805118051280513805148051580516805178051880519805208052180522805238052480525805268052780528805298053080531805328053380534805358053680537805388053980540805418054280543805448054580546805478054880549805508055180552805538055480555805568055780558805598056080561805628056380564805658056680567805688056980570805718057280573805748057580576805778057880579805808058180582805838058480585805868058780588805898059080591805928059380594805958059680597805988059980600806018060280603806048060580606806078060880609806108061180612806138061480615806168061780618806198062080621806228062380624806258062680627806288062980630806318063280633806348063580636806378063880639806408064180642806438064480645806468064780648806498065080651806528065380654806558065680657806588065980660806618066280663806648066580666806678066880669806708067180672806738067480675806768067780678806798068080681806828068380684806858068680687806888068980690806918069280693806948069580696806978069880699807008070180702807038070480705807068070780708807098071080711807128071380714807158071680717807188071980720807218072280723807248072580726807278072880729807308073180732807338073480735807368073780738807398074080741807428074380744807458074680747807488074980750807518075280753807548075580756807578075880759807608076180762807638076480765807668076780768807698077080771807728077380774807758077680777807788077980780807818078280783807848078580786807878078880789807908079180792807938079480795807968079780798807998080080801808028080380804808058080680807808088080980810808118081280813808148081580816808178081880819808208082180822808238082480825808268082780828808298083080831808328083380834808358083680837808388083980840808418084280843808448084580846808478084880849808508085180852808538085480855808568085780858808598086080861808628086380864808658086680867808688086980870808718087280873808748087580876808778087880879808808088180882808838088480885808868088780888808898089080891808928089380894808958089680897808988089980900809018090280903809048090580906809078090880909809108091180912809138091480915809168091780918809198092080921809228092380924809258092680927809288092980930809318093280933809348093580936809378093880939809408094180942809438094480945809468094780948809498095080951809528095380954809558095680957809588095980960809618096280963809648096580966809678096880969809708097180972809738097480975809768097780978809798098080981809828098380984809858098680987809888098980990809918099280993809948099580996809978099880999810008100181002810038100481005810068100781008810098101081011810128101381014810158101681017810188101981020810218102281023810248102581026810278102881029810308103181032810338103481035810368103781038810398104081041810428104381044810458104681047810488104981050810518105281053810548105581056810578105881059810608106181062810638106481065810668106781068810698107081071810728107381074810758107681077810788107981080810818108281083810848108581086810878108881089810908109181092810938109481095810968109781098810998110081101811028110381104811058110681107811088110981110811118111281113811148111581116811178111881119811208112181122811238112481125811268112781128811298113081131811328113381134811358113681137811388113981140811418114281143811448114581146811478114881149811508115181152811538115481155811568115781158811598116081161811628116381164811658116681167811688116981170811718117281173811748117581176811778117881179811808118181182811838118481185811868118781188811898119081191811928119381194811958119681197811988119981200812018120281203812048120581206812078120881209812108121181212812138121481215812168121781218812198122081221812228122381224812258122681227812288122981230812318123281233812348123581236812378123881239812408124181242812438124481245812468124781248812498125081251812528125381254812558125681257812588125981260812618126281263812648126581266812678126881269812708127181272812738127481275812768127781278812798128081281812828128381284812858128681287812888128981290812918129281293812948129581296812978129881299813008130181302813038130481305813068130781308813098131081311813128131381314813158131681317813188131981320813218132281323813248132581326813278132881329813308133181332813338133481335813368133781338813398134081341813428134381344813458134681347813488134981350813518135281353813548135581356813578135881359813608136181362813638136481365813668136781368813698137081371813728137381374813758137681377813788137981380813818138281383813848138581386813878138881389813908139181392813938139481395813968139781398813998140081401814028140381404814058140681407814088140981410814118141281413814148141581416814178141881419814208142181422814238142481425814268142781428814298143081431814328143381434814358143681437814388143981440814418144281443814448144581446814478144881449814508145181452814538145481455814568145781458814598146081461814628146381464814658146681467814688146981470814718147281473814748147581476814778147881479814808148181482814838148481485814868148781488814898149081491814928149381494814958149681497814988149981500815018150281503815048150581506815078150881509815108151181512815138151481515815168151781518815198152081521815228152381524815258152681527815288152981530815318153281533815348153581536815378153881539815408154181542815438154481545815468154781548815498155081551815528155381554815558155681557815588155981560815618156281563815648156581566815678156881569815708157181572815738157481575815768157781578815798158081581815828158381584815858158681587815888158981590815918159281593815948159581596815978159881599816008160181602816038160481605816068160781608816098161081611816128161381614816158161681617816188161981620816218162281623816248162581626816278162881629816308163181632816338163481635816368163781638816398164081641816428164381644816458164681647816488164981650816518165281653816548165581656816578165881659816608166181662816638166481665816668166781668816698167081671816728167381674816758167681677816788167981680816818168281683816848168581686816878168881689816908169181692816938169481695816968169781698816998170081701817028170381704817058170681707817088170981710817118171281713817148171581716817178171881719817208172181722817238172481725817268172781728817298173081731817328173381734817358173681737817388173981740817418174281743817448174581746817478174881749817508175181752817538175481755817568175781758817598176081761817628176381764817658176681767817688176981770817718177281773817748177581776817778177881779817808178181782817838178481785817868178781788817898179081791817928179381794817958179681797817988179981800818018180281803818048180581806818078180881809818108181181812818138181481815818168181781818818198182081821818228182381824818258182681827818288182981830818318183281833818348183581836818378183881839818408184181842818438184481845818468184781848818498185081851818528185381854818558185681857818588185981860818618186281863818648186581866818678186881869818708187181872818738187481875818768187781878818798188081881818828188381884818858188681887818888188981890818918189281893818948189581896818978189881899819008190181902819038190481905819068190781908819098191081911819128191381914819158191681917819188191981920819218192281923819248192581926819278192881929819308193181932819338193481935819368193781938819398194081941819428194381944819458194681947819488194981950819518195281953819548195581956819578195881959819608196181962819638196481965819668196781968819698197081971819728197381974819758197681977819788197981980819818198281983819848198581986819878198881989819908199181992819938199481995819968199781998819998200082001820028200382004820058200682007820088200982010820118201282013820148201582016820178201882019820208202182022820238202482025820268202782028820298203082031820328203382034820358203682037820388203982040820418204282043820448204582046820478204882049820508205182052820538205482055820568205782058820598206082061820628206382064820658206682067820688206982070820718207282073820748207582076820778207882079820808208182082820838208482085820868208782088820898209082091820928209382094820958209682097820988209982100821018210282103821048210582106821078210882109821108211182112821138211482115821168211782118821198212082121821228212382124821258212682127821288212982130821318213282133821348213582136821378213882139821408214182142821438214482145821468214782148821498215082151821528215382154821558215682157821588215982160821618216282163821648216582166821678216882169821708217182172821738217482175821768217782178821798218082181821828218382184821858218682187821888218982190821918219282193821948219582196821978219882199822008220182202822038220482205822068220782208822098221082211822128221382214822158221682217822188221982220822218222282223822248222582226822278222882229822308223182232822338223482235822368223782238822398224082241822428224382244822458224682247822488224982250822518225282253822548225582256822578225882259822608226182262822638226482265822668226782268822698227082271822728227382274822758227682277822788227982280822818228282283822848228582286822878228882289822908229182292822938229482295822968229782298822998230082301823028230382304823058230682307823088230982310823118231282313823148231582316823178231882319823208232182322823238232482325823268232782328823298233082331823328233382334823358233682337823388233982340823418234282343823448234582346823478234882349823508235182352823538235482355823568235782358823598236082361823628236382364823658236682367823688236982370823718237282373823748237582376823778237882379823808238182382823838238482385823868238782388823898239082391823928239382394823958239682397823988239982400824018240282403824048240582406824078240882409824108241182412824138241482415824168241782418824198242082421824228242382424824258242682427824288242982430824318243282433824348243582436824378243882439824408244182442824438244482445824468244782448824498245082451824528245382454824558245682457824588245982460824618246282463824648246582466824678246882469824708247182472824738247482475824768247782478824798248082481824828248382484824858248682487824888248982490824918249282493824948249582496824978249882499825008250182502825038250482505825068250782508825098251082511825128251382514825158251682517825188251982520825218252282523825248252582526825278252882529825308253182532825338253482535825368253782538825398254082541825428254382544825458254682547825488254982550825518255282553825548255582556825578255882559825608256182562825638256482565825668256782568825698257082571825728257382574825758257682577825788257982580825818258282583825848258582586825878258882589825908259182592825938259482595825968259782598825998260082601826028260382604826058260682607826088260982610826118261282613826148261582616826178261882619826208262182622826238262482625826268262782628826298263082631826328263382634826358263682637826388263982640826418264282643826448264582646826478264882649826508265182652826538265482655826568265782658826598266082661826628266382664826658266682667826688266982670826718267282673826748267582676826778267882679826808268182682826838268482685826868268782688826898269082691826928269382694826958269682697826988269982700827018270282703827048270582706827078270882709827108271182712827138271482715827168271782718827198272082721827228272382724827258272682727827288272982730827318273282733827348273582736827378273882739827408274182742827438274482745827468274782748827498275082751827528275382754827558275682757827588275982760827618276282763827648276582766827678276882769827708277182772827738277482775827768277782778827798278082781827828278382784827858278682787827888278982790827918279282793827948279582796827978279882799828008280182802828038280482805828068280782808828098281082811828128281382814828158281682817828188281982820828218282282823828248282582826828278282882829828308283182832828338283482835828368283782838828398284082841828428284382844828458284682847828488284982850828518285282853828548285582856828578285882859828608286182862828638286482865828668286782868828698287082871828728287382874828758287682877828788287982880828818288282883828848288582886828878288882889828908289182892828938289482895828968289782898828998290082901829028290382904829058290682907829088290982910829118291282913829148291582916829178291882919829208292182922829238292482925829268292782928829298293082931829328293382934829358293682937829388293982940829418294282943829448294582946829478294882949829508295182952829538295482955829568295782958829598296082961829628296382964829658296682967829688296982970829718297282973829748297582976829778297882979829808298182982829838298482985829868298782988829898299082991829928299382994829958299682997829988299983000830018300283003830048300583006830078300883009830108301183012830138301483015830168301783018830198302083021830228302383024830258302683027830288302983030830318303283033830348303583036830378303883039830408304183042830438304483045830468304783048830498305083051830528305383054830558305683057830588305983060830618306283063830648306583066830678306883069830708307183072830738307483075830768307783078830798308083081830828308383084830858308683087830888308983090830918309283093830948309583096830978309883099831008310183102831038310483105831068310783108831098311083111831128311383114831158311683117831188311983120831218312283123831248312583126831278312883129831308313183132831338313483135831368313783138831398314083141831428314383144831458314683147831488314983150831518315283153831548315583156831578315883159831608316183162831638316483165831668316783168831698317083171831728317383174831758317683177831788317983180831818318283183831848318583186831878318883189831908319183192831938319483195831968319783198831998320083201832028320383204832058320683207832088320983210832118321283213832148321583216832178321883219832208322183222832238322483225832268322783228832298323083231832328323383234832358323683237832388323983240832418324283243832448324583246832478324883249832508325183252832538325483255832568325783258832598326083261832628326383264832658326683267832688326983270832718327283273832748327583276832778327883279832808328183282832838328483285832868328783288832898329083291832928329383294832958329683297832988329983300833018330283303833048330583306833078330883309833108331183312833138331483315833168331783318833198332083321833228332383324833258332683327833288332983330833318333283333833348333583336833378333883339833408334183342833438334483345833468334783348833498335083351833528335383354833558335683357833588335983360833618336283363833648336583366833678336883369833708337183372833738337483375833768337783378833798338083381833828338383384833858338683387833888338983390833918339283393833948339583396833978339883399834008340183402834038340483405834068340783408834098341083411834128341383414834158341683417834188341983420834218342283423834248342583426834278342883429834308343183432834338343483435834368343783438834398344083441834428344383444834458344683447834488344983450834518345283453834548345583456834578345883459834608346183462834638346483465834668346783468834698347083471834728347383474834758347683477834788347983480834818348283483834848348583486834878348883489834908349183492834938349483495834968349783498834998350083501835028350383504835058350683507835088350983510835118351283513835148351583516835178351883519835208352183522835238352483525835268352783528835298353083531835328353383534835358353683537835388353983540835418354283543835448354583546835478354883549835508355183552835538355483555835568355783558835598356083561835628356383564835658356683567835688356983570835718357283573835748357583576835778357883579835808358183582835838358483585835868358783588835898359083591835928359383594835958359683597835988359983600836018360283603836048360583606836078360883609836108361183612836138361483615836168361783618836198362083621836228362383624836258362683627836288362983630836318363283633836348363583636836378363883639836408364183642836438364483645836468364783648836498365083651836528365383654836558365683657836588365983660836618366283663836648366583666836678366883669836708367183672836738367483675836768367783678836798368083681836828368383684836858368683687836888368983690836918369283693836948369583696836978369883699837008370183702837038370483705837068370783708837098371083711837128371383714837158371683717837188371983720837218372283723837248372583726837278372883729837308373183732837338373483735837368373783738837398374083741837428374383744837458374683747837488374983750837518375283753837548375583756837578375883759837608376183762837638376483765837668376783768837698377083771837728377383774837758377683777837788377983780837818378283783837848378583786837878378883789837908379183792837938379483795837968379783798837998380083801838028380383804838058380683807838088380983810838118381283813838148381583816838178381883819838208382183822838238382483825838268382783828838298383083831838328383383834838358383683837838388383983840838418384283843838448384583846838478384883849838508385183852838538385483855838568385783858838598386083861838628386383864838658386683867838688386983870838718387283873838748387583876838778387883879838808388183882838838388483885838868388783888838898389083891838928389383894838958389683897838988389983900839018390283903839048390583906839078390883909839108391183912839138391483915839168391783918839198392083921839228392383924839258392683927839288392983930839318393283933839348393583936839378393883939839408394183942839438394483945839468394783948839498395083951839528395383954839558395683957839588395983960839618396283963839648396583966839678396883969839708397183972839738397483975839768397783978839798398083981839828398383984839858398683987839888398983990839918399283993839948399583996839978399883999840008400184002840038400484005840068400784008840098401084011840128401384014840158401684017840188401984020840218402284023840248402584026840278402884029840308403184032840338403484035840368403784038840398404084041840428404384044840458404684047840488404984050840518405284053840548405584056840578405884059840608406184062840638406484065840668406784068840698407084071840728407384074840758407684077840788407984080840818408284083840848408584086840878408884089840908409184092840938409484095840968409784098840998410084101841028410384104841058410684107841088410984110841118411284113841148411584116841178411884119841208412184122841238412484125841268412784128841298413084131841328413384134841358413684137841388413984140841418414284143841448414584146841478414884149841508415184152841538415484155841568415784158841598416084161841628416384164841658416684167841688416984170841718417284173841748417584176841778417884179841808418184182841838418484185841868418784188841898419084191841928419384194841958419684197841988419984200842018420284203842048420584206842078420884209842108421184212842138421484215842168421784218842198422084221842228422384224842258422684227842288422984230842318423284233842348423584236842378423884239842408424184242842438424484245842468424784248842498425084251842528425384254842558425684257842588425984260842618426284263842648426584266842678426884269842708427184272842738427484275842768427784278842798428084281842828428384284842858428684287842888428984290842918429284293842948429584296842978429884299843008430184302843038430484305843068430784308843098431084311843128431384314843158431684317843188431984320843218432284323843248432584326843278432884329843308433184332843338433484335843368433784338843398434084341843428434384344843458434684347843488434984350843518435284353843548435584356843578435884359843608436184362843638436484365843668436784368843698437084371843728437384374843758437684377843788437984380843818438284383843848438584386843878438884389843908439184392843938439484395843968439784398843998440084401844028440384404844058440684407844088440984410844118441284413844148441584416844178441884419844208442184422844238442484425844268442784428844298443084431844328443384434844358443684437844388443984440844418444284443844448444584446844478444884449844508445184452844538445484455844568445784458844598446084461844628446384464844658446684467844688446984470844718447284473844748447584476844778447884479844808448184482844838448484485844868448784488844898449084491844928449384494844958449684497844988449984500845018450284503845048450584506845078450884509845108451184512845138451484515845168451784518845198452084521845228452384524845258452684527845288452984530845318453284533845348453584536845378453884539845408454184542845438454484545845468454784548845498455084551845528455384554845558455684557845588455984560845618456284563845648456584566845678456884569845708457184572845738457484575845768457784578845798458084581845828458384584845858458684587845888458984590845918459284593845948459584596845978459884599846008460184602846038460484605846068460784608846098461084611846128461384614846158461684617846188461984620846218462284623846248462584626846278462884629846308463184632846338463484635846368463784638846398464084641846428464384644846458464684647846488464984650846518465284653846548465584656846578465884659846608466184662846638466484665846668466784668846698467084671846728467384674846758467684677846788467984680846818468284683846848468584686846878468884689846908469184692846938469484695846968469784698846998470084701847028470384704847058470684707847088470984710847118471284713847148471584716847178471884719847208472184722847238472484725847268472784728847298473084731847328473384734847358473684737847388473984740847418474284743847448474584746847478474884749847508475184752847538475484755847568475784758847598476084761847628476384764847658476684767847688476984770847718477284773847748477584776847778477884779847808478184782847838478484785847868478784788847898479084791847928479384794847958479684797847988479984800848018480284803848048480584806848078480884809848108481184812848138481484815848168481784818848198482084821848228482384824848258482684827848288482984830848318483284833848348483584836848378483884839848408484184842848438484484845848468484784848848498485084851848528485384854848558485684857848588485984860848618486284863848648486584866848678486884869848708487184872848738487484875848768487784878848798488084881848828488384884848858488684887848888488984890848918489284893848948489584896848978489884899849008490184902849038490484905849068490784908849098491084911849128491384914849158491684917849188491984920849218492284923849248492584926849278492884929849308493184932849338493484935849368493784938849398494084941849428494384944849458494684947849488494984950849518495284953849548495584956849578495884959849608496184962849638496484965849668496784968849698497084971849728497384974849758497684977849788497984980849818498284983849848498584986849878498884989849908499184992849938499484995849968499784998849998500085001850028500385004850058500685007850088500985010850118501285013850148501585016850178501885019850208502185022850238502485025850268502785028850298503085031850328503385034850358503685037850388503985040850418504285043850448504585046850478504885049850508505185052850538505485055850568505785058850598506085061850628506385064850658506685067850688506985070850718507285073850748507585076850778507885079850808508185082850838508485085850868508785088850898509085091850928509385094850958509685097850988509985100851018510285103851048510585106851078510885109851108511185112851138511485115851168511785118851198512085121851228512385124851258512685127851288512985130851318513285133851348513585136851378513885139851408514185142851438514485145851468514785148851498515085151851528515385154851558515685157851588515985160851618516285163851648516585166851678516885169851708517185172851738517485175851768517785178851798518085181851828518385184851858518685187851888518985190851918519285193851948519585196851978519885199852008520185202852038520485205852068520785208852098521085211852128521385214852158521685217852188521985220852218522285223852248522585226852278522885229852308523185232852338523485235852368523785238852398524085241852428524385244852458524685247852488524985250852518525285253852548525585256852578525885259852608526185262852638526485265852668526785268852698527085271852728527385274852758527685277852788527985280852818528285283852848528585286852878528885289852908529185292852938529485295852968529785298852998530085301853028530385304853058530685307853088530985310853118531285313853148531585316853178531885319853208532185322853238532485325853268532785328853298533085331853328533385334853358533685337853388533985340853418534285343853448534585346853478534885349853508535185352853538535485355853568535785358853598536085361853628536385364853658536685367853688536985370853718537285373853748537585376853778537885379853808538185382853838538485385853868538785388853898539085391853928539385394853958539685397853988539985400854018540285403854048540585406854078540885409854108541185412854138541485415854168541785418854198542085421854228542385424854258542685427854288542985430854318543285433854348543585436854378543885439854408544185442854438544485445854468544785448854498545085451854528545385454854558545685457854588545985460854618546285463854648546585466854678546885469854708547185472854738547485475854768547785478854798548085481854828548385484854858548685487854888548985490854918549285493854948549585496854978549885499855008550185502855038550485505855068550785508855098551085511855128551385514855158551685517855188551985520855218552285523855248552585526855278552885529855308553185532855338553485535855368553785538855398554085541855428554385544855458554685547855488554985550855518555285553855548555585556855578555885559855608556185562855638556485565855668556785568855698557085571855728557385574855758557685577855788557985580855818558285583855848558585586855878558885589855908559185592855938559485595855968559785598855998560085601856028560385604856058560685607856088560985610856118561285613856148561585616856178561885619856208562185622856238562485625856268562785628856298563085631856328563385634856358563685637856388563985640856418564285643856448564585646856478564885649856508565185652856538565485655856568565785658856598566085661856628566385664856658566685667856688566985670856718567285673856748567585676856778567885679856808568185682856838568485685856868568785688856898569085691856928569385694856958569685697856988569985700857018570285703857048570585706857078570885709857108571185712857138571485715857168571785718857198572085721857228572385724857258572685727857288572985730857318573285733857348573585736857378573885739857408574185742857438574485745857468574785748857498575085751857528575385754857558575685757857588575985760857618576285763857648576585766857678576885769857708577185772857738577485775857768577785778857798578085781857828578385784857858578685787857888578985790857918579285793857948579585796857978579885799858008580185802858038580485805858068580785808858098581085811858128581385814858158581685817858188581985820858218582285823858248582585826858278582885829858308583185832858338583485835858368583785838858398584085841858428584385844858458584685847858488584985850858518585285853858548585585856858578585885859858608586185862858638586485865858668586785868858698587085871858728587385874858758587685877858788587985880858818588285883858848588585886858878588885889858908589185892858938589485895858968589785898858998590085901859028590385904859058590685907859088590985910859118591285913859148591585916859178591885919859208592185922859238592485925859268592785928859298593085931859328593385934859358593685937859388593985940859418594285943859448594585946859478594885949859508595185952859538595485955859568595785958859598596085961859628596385964859658596685967859688596985970859718597285973859748597585976859778597885979859808598185982859838598485985859868598785988859898599085991859928599385994859958599685997859988599986000860018600286003860048600586006860078600886009860108601186012860138601486015860168601786018860198602086021860228602386024860258602686027860288602986030860318603286033860348603586036860378603886039860408604186042860438604486045860468604786048860498605086051860528605386054860558605686057860588605986060860618606286063860648606586066860678606886069860708607186072860738607486075860768607786078860798608086081860828608386084860858608686087860888608986090860918609286093860948609586096860978609886099861008610186102861038610486105
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module BABYLON {
  51. /**
  52. * A class serves as a medium between the observable and its observers
  53. */
  54. export class EventState {
  55. /**
  56. * Create a new EventState
  57. * @param mask defines the mask associated with this state
  58. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  59. * @param target defines the original target of the state
  60. * @param currentTarget defines the current target of the state
  61. */
  62. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63. /**
  64. * Initialize the current event state
  65. * @param mask defines the mask associated with this state
  66. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  67. * @param target defines the original target of the state
  68. * @param currentTarget defines the current target of the state
  69. * @returns the current event state
  70. */
  71. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  72. /**
  73. * An Observer can set this property to true to prevent subsequent observers of being notified
  74. */
  75. skipNextObservers: boolean;
  76. /**
  77. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78. */
  79. mask: number;
  80. /**
  81. * The object that originally notified the event
  82. */
  83. target?: any;
  84. /**
  85. * The current object in the bubbling phase
  86. */
  87. currentTarget?: any;
  88. /**
  89. * This will be populated with the return value of the last function that was executed.
  90. * If it is the first function in the callback chain it will be the event data.
  91. */
  92. lastReturnValue?: any;
  93. }
  94. /**
  95. * Represent an Observer registered to a given Observable object.
  96. */
  97. export class Observer<T> {
  98. /**
  99. * Defines the callback to call when the observer is notified
  100. */
  101. callback: (eventData: T, eventState: EventState) => void;
  102. /**
  103. * Defines the mask of the observer (used to filter notifications)
  104. */
  105. mask: number;
  106. /**
  107. * Defines the current scope used to restore the JS context
  108. */
  109. scope: any;
  110. /** @hidden */
  111. _willBeUnregistered: boolean;
  112. /**
  113. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  114. */
  115. unregisterOnNextCall: boolean;
  116. /**
  117. * Creates a new observer
  118. * @param callback defines the callback to call when the observer is notified
  119. * @param mask defines the mask of the observer (used to filter notifications)
  120. * @param scope defines the current scope used to restore the JS context
  121. */
  122. constructor(
  123. /**
  124. * Defines the callback to call when the observer is notified
  125. */
  126. callback: (eventData: T, eventState: EventState) => void,
  127. /**
  128. * Defines the mask of the observer (used to filter notifications)
  129. */
  130. mask: number,
  131. /**
  132. * Defines the current scope used to restore the JS context
  133. */
  134. scope?: any);
  135. }
  136. /**
  137. * Represent a list of observers registered to multiple Observables object.
  138. */
  139. export class MultiObserver<T> {
  140. private _observers;
  141. private _observables;
  142. /**
  143. * Release associated resources
  144. */
  145. dispose(): void;
  146. /**
  147. * Raise a callback when one of the observable will notify
  148. * @param observables defines a list of observables to watch
  149. * @param callback defines the callback to call on notification
  150. * @param mask defines the mask used to filter notifications
  151. * @param scope defines the current scope used to restore the JS context
  152. * @returns the new MultiObserver
  153. */
  154. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  155. }
  156. /**
  157. * The Observable class is a simple implementation of the Observable pattern.
  158. *
  159. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  160. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  161. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  162. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  163. */
  164. export class Observable<T> {
  165. private _observers;
  166. private _eventState;
  167. private _onObserverAdded;
  168. /**
  169. * Gets the list of observers
  170. */
  171. get observers(): Array<Observer<T>>;
  172. /**
  173. * Creates a new observable
  174. * @param onObserverAdded defines a callback to call when a new observer is added
  175. */
  176. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  177. /**
  178. * Create a new Observer with the specified callback
  179. * @param callback the callback that will be executed for that Observer
  180. * @param mask the mask used to filter observers
  181. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  182. * @param scope optional scope for the callback to be called from
  183. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  184. * @returns the new observer created for the callback
  185. */
  186. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  187. /**
  188. * Create a new Observer with the specified callback and unregisters after the next notification
  189. * @param callback the callback that will be executed for that Observer
  190. * @returns the new observer created for the callback
  191. */
  192. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  193. /**
  194. * Remove an Observer from the Observable object
  195. * @param observer the instance of the Observer to remove
  196. * @returns false if it doesn't belong to this Observable
  197. */
  198. remove(observer: Nullable<Observer<T>>): boolean;
  199. /**
  200. * Remove a callback from the Observable object
  201. * @param callback the callback to remove
  202. * @param scope optional scope. If used only the callbacks with this scope will be removed
  203. * @returns false if it doesn't belong to this Observable
  204. */
  205. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  206. private _deferUnregister;
  207. private _remove;
  208. /**
  209. * Moves the observable to the top of the observer list making it get called first when notified
  210. * @param observer the observer to move
  211. */
  212. makeObserverTopPriority(observer: Observer<T>): void;
  213. /**
  214. * Moves the observable to the bottom of the observer list making it get called last when notified
  215. * @param observer the observer to move
  216. */
  217. makeObserverBottomPriority(observer: Observer<T>): void;
  218. /**
  219. * Notify all Observers by calling their respective callback with the given data
  220. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  221. * @param eventData defines the data to send to all observers
  222. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  223. * @param target defines the original target of the state
  224. * @param currentTarget defines the current target of the state
  225. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  226. */
  227. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  228. /**
  229. * Calling this will execute each callback, expecting it to be a promise or return a value.
  230. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  231. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  232. * and it is crucial that all callbacks will be executed.
  233. * The order of the callbacks is kept, callbacks are not executed parallel.
  234. *
  235. * @param eventData The data to be sent to each callback
  236. * @param mask is used to filter observers defaults to -1
  237. * @param target defines the callback target (see EventState)
  238. * @param currentTarget defines he current object in the bubbling phase
  239. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  240. */
  241. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  242. /**
  243. * Notify a specific observer
  244. * @param observer defines the observer to notify
  245. * @param eventData defines the data to be sent to each callback
  246. * @param mask is used to filter observers defaults to -1
  247. */
  248. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  249. /**
  250. * Gets a boolean indicating if the observable has at least one observer
  251. * @returns true is the Observable has at least one Observer registered
  252. */
  253. hasObservers(): boolean;
  254. /**
  255. * Clear the list of observers
  256. */
  257. clear(): void;
  258. /**
  259. * Clone the current observable
  260. * @returns a new observable
  261. */
  262. clone(): Observable<T>;
  263. /**
  264. * Does this observable handles observer registered with a given mask
  265. * @param mask defines the mask to be tested
  266. * @return whether or not one observer registered with the given mask is handeled
  267. **/
  268. hasSpecificMask(mask?: number): boolean;
  269. }
  270. }
  271. declare module BABYLON {
  272. /**
  273. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  274. * Babylon.js
  275. */
  276. export class DomManagement {
  277. /**
  278. * Checks if the window object exists
  279. * @returns true if the window object exists
  280. */
  281. static IsWindowObjectExist(): boolean;
  282. /**
  283. * Checks if the navigator object exists
  284. * @returns true if the navigator object exists
  285. */
  286. static IsNavigatorAvailable(): boolean;
  287. /**
  288. * Check if the document object exists
  289. * @returns true if the document object exists
  290. */
  291. static IsDocumentAvailable(): boolean;
  292. /**
  293. * Extracts text content from a DOM element hierarchy
  294. * @param element defines the root element
  295. * @returns a string
  296. */
  297. static GetDOMTextContent(element: HTMLElement): string;
  298. }
  299. }
  300. declare module BABYLON {
  301. /**
  302. * Logger used througouht the application to allow configuration of
  303. * the log level required for the messages.
  304. */
  305. export class Logger {
  306. /**
  307. * No log
  308. */
  309. static readonly NoneLogLevel: number;
  310. /**
  311. * Only message logs
  312. */
  313. static readonly MessageLogLevel: number;
  314. /**
  315. * Only warning logs
  316. */
  317. static readonly WarningLogLevel: number;
  318. /**
  319. * Only error logs
  320. */
  321. static readonly ErrorLogLevel: number;
  322. /**
  323. * All logs
  324. */
  325. static readonly AllLogLevel: number;
  326. private static _LogCache;
  327. /**
  328. * Gets a value indicating the number of loading errors
  329. * @ignorenaming
  330. */
  331. static errorsCount: number;
  332. /**
  333. * Callback called when a new log is added
  334. */
  335. static OnNewCacheEntry: (entry: string) => void;
  336. private static _AddLogEntry;
  337. private static _FormatMessage;
  338. private static _LogDisabled;
  339. private static _LogEnabled;
  340. private static _WarnDisabled;
  341. private static _WarnEnabled;
  342. private static _ErrorDisabled;
  343. private static _ErrorEnabled;
  344. /**
  345. * Log a message to the console
  346. */
  347. static Log: (message: string) => void;
  348. /**
  349. * Write a warning message to the console
  350. */
  351. static Warn: (message: string) => void;
  352. /**
  353. * Write an error message to the console
  354. */
  355. static Error: (message: string) => void;
  356. /**
  357. * Gets current log cache (list of logs)
  358. */
  359. static get LogCache(): string;
  360. /**
  361. * Clears the log cache
  362. */
  363. static ClearLogCache(): void;
  364. /**
  365. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  366. */
  367. static set LogLevels(level: number);
  368. }
  369. }
  370. declare module BABYLON {
  371. /** @hidden */
  372. export class _TypeStore {
  373. /** @hidden */
  374. static RegisteredTypes: {
  375. [key: string]: Object;
  376. };
  377. /** @hidden */
  378. static GetClass(fqdn: string): any;
  379. }
  380. }
  381. declare module BABYLON {
  382. /**
  383. * Helper to manipulate strings
  384. */
  385. export class StringTools {
  386. /**
  387. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  388. * @param str Source string
  389. * @param suffix Suffix to search for in the source string
  390. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  391. */
  392. static EndsWith(str: string, suffix: string): boolean;
  393. /**
  394. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  395. * @param str Source string
  396. * @param suffix Suffix to search for in the source string
  397. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  398. */
  399. static StartsWith(str: string, suffix: string): boolean;
  400. /**
  401. * Decodes a buffer into a string
  402. * @param buffer The buffer to decode
  403. * @returns The decoded string
  404. */
  405. static Decode(buffer: Uint8Array | Uint16Array): string;
  406. /**
  407. * Encode a buffer to a base64 string
  408. * @param buffer defines the buffer to encode
  409. * @returns the encoded string
  410. */
  411. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  412. /**
  413. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  414. * @param num the number to convert and pad
  415. * @param length the expected length of the string
  416. * @returns the padded string
  417. */
  418. static PadNumber(num: number, length: number): string;
  419. }
  420. }
  421. declare module BABYLON {
  422. /**
  423. * Class containing a set of static utilities functions for deep copy.
  424. */
  425. export class DeepCopier {
  426. /**
  427. * Tries to copy an object by duplicating every property
  428. * @param source defines the source object
  429. * @param destination defines the target object
  430. * @param doNotCopyList defines a list of properties to avoid
  431. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  432. */
  433. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  434. }
  435. }
  436. declare module BABYLON {
  437. /**
  438. * Class containing a set of static utilities functions for precision date
  439. */
  440. export class PrecisionDate {
  441. /**
  442. * Gets either window.performance.now() if supported or Date.now() else
  443. */
  444. static get Now(): number;
  445. }
  446. }
  447. declare module BABYLON {
  448. /** @hidden */
  449. export class _DevTools {
  450. static WarnImport(name: string): string;
  451. }
  452. }
  453. declare module BABYLON {
  454. /**
  455. * Interface used to define the mechanism to get data from the network
  456. */
  457. export interface IWebRequest {
  458. /**
  459. * Returns client's response url
  460. */
  461. responseURL: string;
  462. /**
  463. * Returns client's status
  464. */
  465. status: number;
  466. /**
  467. * Returns client's status as a text
  468. */
  469. statusText: string;
  470. }
  471. }
  472. declare module BABYLON {
  473. /**
  474. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  475. */
  476. export class WebRequest implements IWebRequest {
  477. private _xhr;
  478. /**
  479. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  480. * i.e. when loading files, where the server/service expects an Authorization header
  481. */
  482. static CustomRequestHeaders: {
  483. [key: string]: string;
  484. };
  485. /**
  486. * Add callback functions in this array to update all the requests before they get sent to the network
  487. */
  488. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  489. private _injectCustomRequestHeaders;
  490. /**
  491. * Gets or sets a function to be called when loading progress changes
  492. */
  493. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  494. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  495. /**
  496. * Returns client's state
  497. */
  498. get readyState(): number;
  499. /**
  500. * Returns client's status
  501. */
  502. get status(): number;
  503. /**
  504. * Returns client's status as a text
  505. */
  506. get statusText(): string;
  507. /**
  508. * Returns client's response
  509. */
  510. get response(): any;
  511. /**
  512. * Returns client's response url
  513. */
  514. get responseURL(): string;
  515. /**
  516. * Returns client's response as text
  517. */
  518. get responseText(): string;
  519. /**
  520. * Gets or sets the expected response type
  521. */
  522. get responseType(): XMLHttpRequestResponseType;
  523. set responseType(value: XMLHttpRequestResponseType);
  524. /** @hidden */
  525. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  526. /** @hidden */
  527. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  528. /**
  529. * Cancels any network activity
  530. */
  531. abort(): void;
  532. /**
  533. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  534. * @param body defines an optional request body
  535. */
  536. send(body?: Document | BodyInit | null): void;
  537. /**
  538. * Sets the request method, request URL
  539. * @param method defines the method to use (GET, POST, etc..)
  540. * @param url defines the url to connect with
  541. */
  542. open(method: string, url: string): void;
  543. /**
  544. * Sets the value of a request header.
  545. * @param name The name of the header whose value is to be set
  546. * @param value The value to set as the body of the header
  547. */
  548. setRequestHeader(name: string, value: string): void;
  549. /**
  550. * Get the string containing the text of a particular header's value.
  551. * @param name The name of the header
  552. * @returns The string containing the text of the given header name
  553. */
  554. getResponseHeader(name: string): Nullable<string>;
  555. }
  556. }
  557. declare module BABYLON {
  558. /**
  559. * File request interface
  560. */
  561. export interface IFileRequest {
  562. /**
  563. * Raised when the request is complete (success or error).
  564. */
  565. onCompleteObservable: Observable<IFileRequest>;
  566. /**
  567. * Aborts the request for a file.
  568. */
  569. abort: () => void;
  570. }
  571. }
  572. declare module BABYLON {
  573. /**
  574. * Define options used to create a render target texture
  575. */
  576. export class RenderTargetCreationOptions {
  577. /**
  578. * Specifies is mipmaps must be generated
  579. */
  580. generateMipMaps?: boolean;
  581. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  582. generateDepthBuffer?: boolean;
  583. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  584. generateStencilBuffer?: boolean;
  585. /** Defines texture type (int by default) */
  586. type?: number;
  587. /** Defines sampling mode (trilinear by default) */
  588. samplingMode?: number;
  589. /** Defines format (RGBA by default) */
  590. format?: number;
  591. }
  592. }
  593. declare module BABYLON {
  594. /** Defines the cross module used constants to avoid circular dependncies */
  595. export class Constants {
  596. /** Defines that alpha blending is disabled */
  597. static readonly ALPHA_DISABLE: number;
  598. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  599. static readonly ALPHA_ADD: number;
  600. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  601. static readonly ALPHA_COMBINE: number;
  602. /** Defines that alpha blending is DEST - SRC * DEST */
  603. static readonly ALPHA_SUBTRACT: number;
  604. /** Defines that alpha blending is SRC * DEST */
  605. static readonly ALPHA_MULTIPLY: number;
  606. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  607. static readonly ALPHA_MAXIMIZED: number;
  608. /** Defines that alpha blending is SRC + DEST */
  609. static readonly ALPHA_ONEONE: number;
  610. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  611. static readonly ALPHA_PREMULTIPLIED: number;
  612. /**
  613. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  614. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  615. */
  616. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  617. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  618. static readonly ALPHA_INTERPOLATE: number;
  619. /**
  620. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  621. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  622. */
  623. static readonly ALPHA_SCREENMODE: number;
  624. /**
  625. * Defines that alpha blending is SRC + DST
  626. * Alpha will be set to SRC ALPHA + DST ALPHA
  627. */
  628. static readonly ALPHA_ONEONE_ONEONE: number;
  629. /**
  630. * Defines that alpha blending is SRC * DST ALPHA + DST
  631. * Alpha will be set to 0
  632. */
  633. static readonly ALPHA_ALPHATOCOLOR: number;
  634. /**
  635. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  636. */
  637. static readonly ALPHA_REVERSEONEMINUS: number;
  638. /**
  639. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  640. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  641. */
  642. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  643. /**
  644. * Defines that alpha blending is SRC + DST
  645. * Alpha will be set to SRC ALPHA
  646. */
  647. static readonly ALPHA_ONEONE_ONEZERO: number;
  648. /**
  649. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  650. * Alpha will be set to DST ALPHA
  651. */
  652. static readonly ALPHA_EXCLUSION: number;
  653. /** Defines that alpha blending equation a SUM */
  654. static readonly ALPHA_EQUATION_ADD: number;
  655. /** Defines that alpha blending equation a SUBSTRACTION */
  656. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  657. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  658. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  659. /** Defines that alpha blending equation a MAX operation */
  660. static readonly ALPHA_EQUATION_MAX: number;
  661. /** Defines that alpha blending equation a MIN operation */
  662. static readonly ALPHA_EQUATION_MIN: number;
  663. /**
  664. * Defines that alpha blending equation a DARKEN operation:
  665. * It takes the min of the src and sums the alpha channels.
  666. */
  667. static readonly ALPHA_EQUATION_DARKEN: number;
  668. /** Defines that the ressource is not delayed*/
  669. static readonly DELAYLOADSTATE_NONE: number;
  670. /** Defines that the ressource was successfully delay loaded */
  671. static readonly DELAYLOADSTATE_LOADED: number;
  672. /** Defines that the ressource is currently delay loading */
  673. static readonly DELAYLOADSTATE_LOADING: number;
  674. /** Defines that the ressource is delayed and has not started loading */
  675. static readonly DELAYLOADSTATE_NOTLOADED: number;
  676. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  677. static readonly NEVER: number;
  678. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  679. static readonly ALWAYS: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  681. static readonly LESS: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  683. static readonly EQUAL: number;
  684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  685. static readonly LEQUAL: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  687. static readonly GREATER: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  689. static readonly GEQUAL: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  691. static readonly NOTEQUAL: number;
  692. /** Passed to stencilOperation to specify that stencil value must be kept */
  693. static readonly KEEP: number;
  694. /** Passed to stencilOperation to specify that stencil value must be replaced */
  695. static readonly REPLACE: number;
  696. /** Passed to stencilOperation to specify that stencil value must be incremented */
  697. static readonly INCR: number;
  698. /** Passed to stencilOperation to specify that stencil value must be decremented */
  699. static readonly DECR: number;
  700. /** Passed to stencilOperation to specify that stencil value must be inverted */
  701. static readonly INVERT: number;
  702. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  703. static readonly INCR_WRAP: number;
  704. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  705. static readonly DECR_WRAP: number;
  706. /** Texture is not repeating outside of 0..1 UVs */
  707. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  708. /** Texture is repeating outside of 0..1 UVs */
  709. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  710. /** Texture is repeating and mirrored */
  711. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  712. /** ALPHA */
  713. static readonly TEXTUREFORMAT_ALPHA: number;
  714. /** LUMINANCE */
  715. static readonly TEXTUREFORMAT_LUMINANCE: number;
  716. /** LUMINANCE_ALPHA */
  717. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  718. /** RGB */
  719. static readonly TEXTUREFORMAT_RGB: number;
  720. /** RGBA */
  721. static readonly TEXTUREFORMAT_RGBA: number;
  722. /** RED */
  723. static readonly TEXTUREFORMAT_RED: number;
  724. /** RED (2nd reference) */
  725. static readonly TEXTUREFORMAT_R: number;
  726. /** RG */
  727. static readonly TEXTUREFORMAT_RG: number;
  728. /** RED_INTEGER */
  729. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  730. /** RED_INTEGER (2nd reference) */
  731. static readonly TEXTUREFORMAT_R_INTEGER: number;
  732. /** RG_INTEGER */
  733. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  734. /** RGB_INTEGER */
  735. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  736. /** RGBA_INTEGER */
  737. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  738. /** UNSIGNED_BYTE */
  739. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  740. /** UNSIGNED_BYTE (2nd reference) */
  741. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  742. /** FLOAT */
  743. static readonly TEXTURETYPE_FLOAT: number;
  744. /** HALF_FLOAT */
  745. static readonly TEXTURETYPE_HALF_FLOAT: number;
  746. /** BYTE */
  747. static readonly TEXTURETYPE_BYTE: number;
  748. /** SHORT */
  749. static readonly TEXTURETYPE_SHORT: number;
  750. /** UNSIGNED_SHORT */
  751. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  752. /** INT */
  753. static readonly TEXTURETYPE_INT: number;
  754. /** UNSIGNED_INT */
  755. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  756. /** UNSIGNED_SHORT_4_4_4_4 */
  757. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  758. /** UNSIGNED_SHORT_5_5_5_1 */
  759. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  760. /** UNSIGNED_SHORT_5_6_5 */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  762. /** UNSIGNED_INT_2_10_10_10_REV */
  763. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  764. /** UNSIGNED_INT_24_8 */
  765. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  766. /** UNSIGNED_INT_10F_11F_11F_REV */
  767. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  768. /** UNSIGNED_INT_5_9_9_9_REV */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  770. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  771. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  772. /** nearest is mag = nearest and min = nearest and no mip */
  773. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  774. /** mag = nearest and min = nearest and mip = none */
  775. static readonly TEXTURE_NEAREST_NEAREST: number;
  776. /** Bilinear is mag = linear and min = linear and no mip */
  777. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  778. /** mag = linear and min = linear and mip = none */
  779. static readonly TEXTURE_LINEAR_LINEAR: number;
  780. /** Trilinear is mag = linear and min = linear and mip = linear */
  781. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  782. /** Trilinear is mag = linear and min = linear and mip = linear */
  783. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  784. /** mag = nearest and min = nearest and mip = nearest */
  785. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  786. /** mag = nearest and min = linear and mip = nearest */
  787. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  788. /** mag = nearest and min = linear and mip = linear */
  789. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  790. /** mag = nearest and min = linear and mip = none */
  791. static readonly TEXTURE_NEAREST_LINEAR: number;
  792. /** nearest is mag = nearest and min = nearest and mip = linear */
  793. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  794. /** mag = linear and min = nearest and mip = nearest */
  795. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  796. /** mag = linear and min = nearest and mip = linear */
  797. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  798. /** Bilinear is mag = linear and min = linear and mip = nearest */
  799. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  800. /** mag = linear and min = nearest and mip = none */
  801. static readonly TEXTURE_LINEAR_NEAREST: number;
  802. /** Explicit coordinates mode */
  803. static readonly TEXTURE_EXPLICIT_MODE: number;
  804. /** Spherical coordinates mode */
  805. static readonly TEXTURE_SPHERICAL_MODE: number;
  806. /** Planar coordinates mode */
  807. static readonly TEXTURE_PLANAR_MODE: number;
  808. /** Cubic coordinates mode */
  809. static readonly TEXTURE_CUBIC_MODE: number;
  810. /** Projection coordinates mode */
  811. static readonly TEXTURE_PROJECTION_MODE: number;
  812. /** Skybox coordinates mode */
  813. static readonly TEXTURE_SKYBOX_MODE: number;
  814. /** Inverse Cubic coordinates mode */
  815. static readonly TEXTURE_INVCUBIC_MODE: number;
  816. /** Equirectangular coordinates mode */
  817. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  818. /** Equirectangular Fixed coordinates mode */
  819. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  820. /** Equirectangular Fixed Mirrored coordinates mode */
  821. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  822. /** Offline (baking) quality for texture filtering */
  823. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  824. /** High quality for texture filtering */
  825. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  826. /** Medium quality for texture filtering */
  827. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  828. /** Low quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  830. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  831. static readonly SCALEMODE_FLOOR: number;
  832. /** Defines that texture rescaling will look for the nearest power of 2 size */
  833. static readonly SCALEMODE_NEAREST: number;
  834. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  835. static readonly SCALEMODE_CEILING: number;
  836. /**
  837. * The dirty texture flag value
  838. */
  839. static readonly MATERIAL_TextureDirtyFlag: number;
  840. /**
  841. * The dirty light flag value
  842. */
  843. static readonly MATERIAL_LightDirtyFlag: number;
  844. /**
  845. * The dirty fresnel flag value
  846. */
  847. static readonly MATERIAL_FresnelDirtyFlag: number;
  848. /**
  849. * The dirty attribute flag value
  850. */
  851. static readonly MATERIAL_AttributesDirtyFlag: number;
  852. /**
  853. * The dirty misc flag value
  854. */
  855. static readonly MATERIAL_MiscDirtyFlag: number;
  856. /**
  857. * The all dirty flag value
  858. */
  859. static readonly MATERIAL_AllDirtyFlag: number;
  860. /**
  861. * Returns the triangle fill mode
  862. */
  863. static readonly MATERIAL_TriangleFillMode: number;
  864. /**
  865. * Returns the wireframe mode
  866. */
  867. static readonly MATERIAL_WireFrameFillMode: number;
  868. /**
  869. * Returns the point fill mode
  870. */
  871. static readonly MATERIAL_PointFillMode: number;
  872. /**
  873. * Returns the point list draw mode
  874. */
  875. static readonly MATERIAL_PointListDrawMode: number;
  876. /**
  877. * Returns the line list draw mode
  878. */
  879. static readonly MATERIAL_LineListDrawMode: number;
  880. /**
  881. * Returns the line loop draw mode
  882. */
  883. static readonly MATERIAL_LineLoopDrawMode: number;
  884. /**
  885. * Returns the line strip draw mode
  886. */
  887. static readonly MATERIAL_LineStripDrawMode: number;
  888. /**
  889. * Returns the triangle strip draw mode
  890. */
  891. static readonly MATERIAL_TriangleStripDrawMode: number;
  892. /**
  893. * Returns the triangle fan draw mode
  894. */
  895. static readonly MATERIAL_TriangleFanDrawMode: number;
  896. /**
  897. * Stores the clock-wise side orientation
  898. */
  899. static readonly MATERIAL_ClockWiseSideOrientation: number;
  900. /**
  901. * Stores the counter clock-wise side orientation
  902. */
  903. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  904. /**
  905. * Nothing
  906. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  907. */
  908. static readonly ACTION_NothingTrigger: number;
  909. /**
  910. * On pick
  911. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  912. */
  913. static readonly ACTION_OnPickTrigger: number;
  914. /**
  915. * On left pick
  916. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  917. */
  918. static readonly ACTION_OnLeftPickTrigger: number;
  919. /**
  920. * On right pick
  921. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  922. */
  923. static readonly ACTION_OnRightPickTrigger: number;
  924. /**
  925. * On center pick
  926. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  927. */
  928. static readonly ACTION_OnCenterPickTrigger: number;
  929. /**
  930. * On pick down
  931. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnPickDownTrigger: number;
  934. /**
  935. * On double pick
  936. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnDoublePickTrigger: number;
  939. /**
  940. * On pick up
  941. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPickUpTrigger: number;
  944. /**
  945. * On pick out.
  946. * This trigger will only be raised if you also declared a OnPickDown
  947. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  948. */
  949. static readonly ACTION_OnPickOutTrigger: number;
  950. /**
  951. * On long press
  952. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  953. */
  954. static readonly ACTION_OnLongPressTrigger: number;
  955. /**
  956. * On pointer over
  957. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  958. */
  959. static readonly ACTION_OnPointerOverTrigger: number;
  960. /**
  961. * On pointer out
  962. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  963. */
  964. static readonly ACTION_OnPointerOutTrigger: number;
  965. /**
  966. * On every frame
  967. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  968. */
  969. static readonly ACTION_OnEveryFrameTrigger: number;
  970. /**
  971. * On intersection enter
  972. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  973. */
  974. static readonly ACTION_OnIntersectionEnterTrigger: number;
  975. /**
  976. * On intersection exit
  977. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  978. */
  979. static readonly ACTION_OnIntersectionExitTrigger: number;
  980. /**
  981. * On key down
  982. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  983. */
  984. static readonly ACTION_OnKeyDownTrigger: number;
  985. /**
  986. * On key up
  987. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  988. */
  989. static readonly ACTION_OnKeyUpTrigger: number;
  990. /**
  991. * Billboard mode will only apply to Y axis
  992. */
  993. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  994. /**
  995. * Billboard mode will apply to all axes
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  998. /**
  999. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1000. */
  1001. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1002. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1003. * Test order :
  1004. * Is the bounding sphere outside the frustum ?
  1005. * If not, are the bounding box vertices outside the frustum ?
  1006. * It not, then the cullable object is in the frustum.
  1007. */
  1008. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1009. /** Culling strategy : Bounding Sphere Only.
  1010. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1011. * It's also less accurate than the standard because some not visible objects can still be selected.
  1012. * Test : is the bounding sphere outside the frustum ?
  1013. * If not, then the cullable object is in the frustum.
  1014. */
  1015. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1016. /** Culling strategy : Optimistic Inclusion.
  1017. * This in an inclusion test first, then the standard exclusion test.
  1018. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1019. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1020. * Anyway, it's as accurate as the standard strategy.
  1021. * Test :
  1022. * Is the cullable object bounding sphere center in the frustum ?
  1023. * If not, apply the default culling strategy.
  1024. */
  1025. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1026. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1027. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1028. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1029. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1030. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1031. * Test :
  1032. * Is the cullable object bounding sphere center in the frustum ?
  1033. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1034. */
  1035. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1036. /**
  1037. * No logging while loading
  1038. */
  1039. static readonly SCENELOADER_NO_LOGGING: number;
  1040. /**
  1041. * Minimal logging while loading
  1042. */
  1043. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1044. /**
  1045. * Summary logging while loading
  1046. */
  1047. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1048. /**
  1049. * Detailled logging while loading
  1050. */
  1051. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1052. /**
  1053. * Prepass texture index for color
  1054. */
  1055. static readonly PREPASS_COLOR_INDEX: number;
  1056. /**
  1057. * Prepass texture index for irradiance
  1058. */
  1059. static readonly PREPASS_IRRADIANCE_INDEX: number;
  1060. /**
  1061. * Prepass texture index for depth + normal
  1062. */
  1063. static readonly PREPASS_DEPTHNORMAL_INDEX: number;
  1064. /**
  1065. * Prepass texture index for albedo
  1066. */
  1067. static readonly PREPASS_ALBEDO_INDEX: number;
  1068. }
  1069. }
  1070. declare module BABYLON {
  1071. /**
  1072. * This represents the required contract to create a new type of texture loader.
  1073. */
  1074. export interface IInternalTextureLoader {
  1075. /**
  1076. * Defines wether the loader supports cascade loading the different faces.
  1077. */
  1078. supportCascades: boolean;
  1079. /**
  1080. * This returns if the loader support the current file information.
  1081. * @param extension defines the file extension of the file being loaded
  1082. * @param mimeType defines the optional mime type of the file being loaded
  1083. * @returns true if the loader can load the specified file
  1084. */
  1085. canLoad(extension: string, mimeType?: string): boolean;
  1086. /**
  1087. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1088. * @param data contains the texture data
  1089. * @param texture defines the BabylonJS internal texture
  1090. * @param createPolynomials will be true if polynomials have been requested
  1091. * @param onLoad defines the callback to trigger once the texture is ready
  1092. * @param onError defines the callback to trigger in case of error
  1093. */
  1094. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1095. /**
  1096. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1097. * @param data contains the texture data
  1098. * @param texture defines the BabylonJS internal texture
  1099. * @param callback defines the method to call once ready to upload
  1100. */
  1101. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1102. }
  1103. }
  1104. declare module BABYLON {
  1105. /**
  1106. * Class used to store and describe the pipeline context associated with an effect
  1107. */
  1108. export interface IPipelineContext {
  1109. /**
  1110. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1111. */
  1112. isAsync: boolean;
  1113. /**
  1114. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1115. */
  1116. isReady: boolean;
  1117. /** @hidden */
  1118. _getVertexShaderCode(): string | null;
  1119. /** @hidden */
  1120. _getFragmentShaderCode(): string | null;
  1121. /** @hidden */
  1122. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1123. }
  1124. }
  1125. declare module BABYLON {
  1126. /**
  1127. * Class used to store gfx data (like WebGLBuffer)
  1128. */
  1129. export class DataBuffer {
  1130. /**
  1131. * Gets or sets the number of objects referencing this buffer
  1132. */
  1133. references: number;
  1134. /** Gets or sets the size of the underlying buffer */
  1135. capacity: number;
  1136. /**
  1137. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1138. */
  1139. is32Bits: boolean;
  1140. /**
  1141. * Gets the underlying buffer
  1142. */
  1143. get underlyingResource(): any;
  1144. }
  1145. }
  1146. declare module BABYLON {
  1147. /** @hidden */
  1148. export interface IShaderProcessor {
  1149. attributeProcessor?: (attribute: string) => string;
  1150. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1151. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1152. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1153. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1154. lineProcessor?: (line: string, isFragment: boolean) => string;
  1155. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1156. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1157. }
  1158. }
  1159. declare module BABYLON {
  1160. /** @hidden */
  1161. export interface ProcessingOptions {
  1162. defines: string[];
  1163. indexParameters: any;
  1164. isFragment: boolean;
  1165. shouldUseHighPrecisionShader: boolean;
  1166. supportsUniformBuffers: boolean;
  1167. shadersRepository: string;
  1168. includesShadersStore: {
  1169. [key: string]: string;
  1170. };
  1171. processor?: IShaderProcessor;
  1172. version: string;
  1173. platformName: string;
  1174. lookForClosingBracketForUniformBuffer?: boolean;
  1175. }
  1176. }
  1177. declare module BABYLON {
  1178. /** @hidden */
  1179. export class ShaderCodeNode {
  1180. line: string;
  1181. children: ShaderCodeNode[];
  1182. additionalDefineKey?: string;
  1183. additionalDefineValue?: string;
  1184. isValid(preprocessors: {
  1185. [key: string]: string;
  1186. }): boolean;
  1187. process(preprocessors: {
  1188. [key: string]: string;
  1189. }, options: ProcessingOptions): string;
  1190. }
  1191. }
  1192. declare module BABYLON {
  1193. /** @hidden */
  1194. export class ShaderCodeCursor {
  1195. private _lines;
  1196. lineIndex: number;
  1197. get currentLine(): string;
  1198. get canRead(): boolean;
  1199. set lines(value: string[]);
  1200. }
  1201. }
  1202. declare module BABYLON {
  1203. /** @hidden */
  1204. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1205. process(preprocessors: {
  1206. [key: string]: string;
  1207. }, options: ProcessingOptions): string;
  1208. }
  1209. }
  1210. declare module BABYLON {
  1211. /** @hidden */
  1212. export class ShaderDefineExpression {
  1213. isTrue(preprocessors: {
  1214. [key: string]: string;
  1215. }): boolean;
  1216. private static _OperatorPriority;
  1217. private static _Stack;
  1218. static postfixToInfix(postfix: string[]): string;
  1219. static infixToPostfix(infix: string): string[];
  1220. }
  1221. }
  1222. declare module BABYLON {
  1223. /** @hidden */
  1224. export class ShaderCodeTestNode extends ShaderCodeNode {
  1225. testExpression: ShaderDefineExpression;
  1226. isValid(preprocessors: {
  1227. [key: string]: string;
  1228. }): boolean;
  1229. }
  1230. }
  1231. declare module BABYLON {
  1232. /** @hidden */
  1233. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1234. define: string;
  1235. not: boolean;
  1236. constructor(define: string, not?: boolean);
  1237. isTrue(preprocessors: {
  1238. [key: string]: string;
  1239. }): boolean;
  1240. }
  1241. }
  1242. declare module BABYLON {
  1243. /** @hidden */
  1244. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1245. leftOperand: ShaderDefineExpression;
  1246. rightOperand: ShaderDefineExpression;
  1247. isTrue(preprocessors: {
  1248. [key: string]: string;
  1249. }): boolean;
  1250. }
  1251. }
  1252. declare module BABYLON {
  1253. /** @hidden */
  1254. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1255. leftOperand: ShaderDefineExpression;
  1256. rightOperand: ShaderDefineExpression;
  1257. isTrue(preprocessors: {
  1258. [key: string]: string;
  1259. }): boolean;
  1260. }
  1261. }
  1262. declare module BABYLON {
  1263. /** @hidden */
  1264. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1265. define: string;
  1266. operand: string;
  1267. testValue: string;
  1268. constructor(define: string, operand: string, testValue: string);
  1269. isTrue(preprocessors: {
  1270. [key: string]: string;
  1271. }): boolean;
  1272. }
  1273. }
  1274. declare module BABYLON {
  1275. /**
  1276. * Class used to enable access to offline support
  1277. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1278. */
  1279. export interface IOfflineProvider {
  1280. /**
  1281. * Gets a boolean indicating if scene must be saved in the database
  1282. */
  1283. enableSceneOffline: boolean;
  1284. /**
  1285. * Gets a boolean indicating if textures must be saved in the database
  1286. */
  1287. enableTexturesOffline: boolean;
  1288. /**
  1289. * Open the offline support and make it available
  1290. * @param successCallback defines the callback to call on success
  1291. * @param errorCallback defines the callback to call on error
  1292. */
  1293. open(successCallback: () => void, errorCallback: () => void): void;
  1294. /**
  1295. * Loads an image from the offline support
  1296. * @param url defines the url to load from
  1297. * @param image defines the target DOM image
  1298. */
  1299. loadImage(url: string, image: HTMLImageElement): void;
  1300. /**
  1301. * Loads a file from offline support
  1302. * @param url defines the URL to load from
  1303. * @param sceneLoaded defines a callback to call on success
  1304. * @param progressCallBack defines a callback to call when progress changed
  1305. * @param errorCallback defines a callback to call on error
  1306. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1307. */
  1308. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1309. }
  1310. }
  1311. declare module BABYLON {
  1312. /**
  1313. * Class used to help managing file picking and drag'n'drop
  1314. * File Storage
  1315. */
  1316. export class FilesInputStore {
  1317. /**
  1318. * List of files ready to be loaded
  1319. */
  1320. static FilesToLoad: {
  1321. [key: string]: File;
  1322. };
  1323. }
  1324. }
  1325. declare module BABYLON {
  1326. /**
  1327. * Class used to define a retry strategy when error happens while loading assets
  1328. */
  1329. export class RetryStrategy {
  1330. /**
  1331. * Function used to defines an exponential back off strategy
  1332. * @param maxRetries defines the maximum number of retries (3 by default)
  1333. * @param baseInterval defines the interval between retries
  1334. * @returns the strategy function to use
  1335. */
  1336. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1337. }
  1338. }
  1339. declare module BABYLON {
  1340. /**
  1341. * @ignore
  1342. * Application error to support additional information when loading a file
  1343. */
  1344. export abstract class BaseError extends Error {
  1345. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1346. }
  1347. }
  1348. declare module BABYLON {
  1349. /** @ignore */
  1350. export class LoadFileError extends BaseError {
  1351. request?: WebRequest;
  1352. file?: File;
  1353. /**
  1354. * Creates a new LoadFileError
  1355. * @param message defines the message of the error
  1356. * @param request defines the optional web request
  1357. * @param file defines the optional file
  1358. */
  1359. constructor(message: string, object?: WebRequest | File);
  1360. }
  1361. /** @ignore */
  1362. export class RequestFileError extends BaseError {
  1363. request: WebRequest;
  1364. /**
  1365. * Creates a new LoadFileError
  1366. * @param message defines the message of the error
  1367. * @param request defines the optional web request
  1368. */
  1369. constructor(message: string, request: WebRequest);
  1370. }
  1371. /** @ignore */
  1372. export class ReadFileError extends BaseError {
  1373. file: File;
  1374. /**
  1375. * Creates a new ReadFileError
  1376. * @param message defines the message of the error
  1377. * @param file defines the optional file
  1378. */
  1379. constructor(message: string, file: File);
  1380. }
  1381. /**
  1382. * @hidden
  1383. */
  1384. export class FileTools {
  1385. /**
  1386. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1387. */
  1388. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1389. /**
  1390. * Gets or sets the base URL to use to load assets
  1391. */
  1392. static BaseUrl: string;
  1393. /**
  1394. * Default behaviour for cors in the application.
  1395. * It can be a string if the expected behavior is identical in the entire app.
  1396. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1397. */
  1398. static CorsBehavior: string | ((url: string | string[]) => string);
  1399. /**
  1400. * Gets or sets a function used to pre-process url before using them to load assets
  1401. */
  1402. static PreprocessUrl: (url: string) => string;
  1403. /**
  1404. * Removes unwanted characters from an url
  1405. * @param url defines the url to clean
  1406. * @returns the cleaned url
  1407. */
  1408. private static _CleanUrl;
  1409. /**
  1410. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1411. * @param url define the url we are trying
  1412. * @param element define the dom element where to configure the cors policy
  1413. */
  1414. static SetCorsBehavior(url: string | string[], element: {
  1415. crossOrigin: string | null;
  1416. }): void;
  1417. /**
  1418. * Loads an image as an HTMLImageElement.
  1419. * @param input url string, ArrayBuffer, or Blob to load
  1420. * @param onLoad callback called when the image successfully loads
  1421. * @param onError callback called when the image fails to load
  1422. * @param offlineProvider offline provider for caching
  1423. * @param mimeType optional mime type
  1424. * @returns the HTMLImageElement of the loaded image
  1425. */
  1426. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1427. /**
  1428. * Reads a file from a File object
  1429. * @param file defines the file to load
  1430. * @param onSuccess defines the callback to call when data is loaded
  1431. * @param onProgress defines the callback to call during loading process
  1432. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1433. * @param onError defines the callback to call when an error occurs
  1434. * @returns a file request object
  1435. */
  1436. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1437. /**
  1438. * Loads a file from a url
  1439. * @param url url to load
  1440. * @param onSuccess callback called when the file successfully loads
  1441. * @param onProgress callback called while file is loading (if the server supports this mode)
  1442. * @param offlineProvider defines the offline provider for caching
  1443. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1444. * @param onError callback called when the file fails to load
  1445. * @returns a file request object
  1446. */
  1447. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1448. /**
  1449. * Loads a file
  1450. * @param url url to load
  1451. * @param onSuccess callback called when the file successfully loads
  1452. * @param onProgress callback called while file is loading (if the server supports this mode)
  1453. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1454. * @param onError callback called when the file fails to load
  1455. * @param onOpened callback called when the web request is opened
  1456. * @returns a file request object
  1457. */
  1458. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1459. /**
  1460. * Checks if the loaded document was accessed via `file:`-Protocol.
  1461. * @returns boolean
  1462. */
  1463. static IsFileURL(): boolean;
  1464. }
  1465. }
  1466. declare module BABYLON {
  1467. /** @hidden */
  1468. export class ShaderProcessor {
  1469. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1470. private static _ProcessPrecision;
  1471. private static _ExtractOperation;
  1472. private static _BuildSubExpression;
  1473. private static _BuildExpression;
  1474. private static _MoveCursorWithinIf;
  1475. private static _MoveCursor;
  1476. private static _EvaluatePreProcessors;
  1477. private static _PreparePreProcessors;
  1478. private static _ProcessShaderConversion;
  1479. private static _ProcessIncludes;
  1480. /**
  1481. * Loads a file from a url
  1482. * @param url url to load
  1483. * @param onSuccess callback called when the file successfully loads
  1484. * @param onProgress callback called while file is loading (if the server supports this mode)
  1485. * @param offlineProvider defines the offline provider for caching
  1486. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1487. * @param onError callback called when the file fails to load
  1488. * @returns a file request object
  1489. * @hidden
  1490. */
  1491. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1492. }
  1493. }
  1494. declare module BABYLON {
  1495. /**
  1496. * @hidden
  1497. */
  1498. export interface IColor4Like {
  1499. r: float;
  1500. g: float;
  1501. b: float;
  1502. a: float;
  1503. }
  1504. /**
  1505. * @hidden
  1506. */
  1507. export interface IColor3Like {
  1508. r: float;
  1509. g: float;
  1510. b: float;
  1511. }
  1512. /**
  1513. * @hidden
  1514. */
  1515. export interface IVector4Like {
  1516. x: float;
  1517. y: float;
  1518. z: float;
  1519. w: float;
  1520. }
  1521. /**
  1522. * @hidden
  1523. */
  1524. export interface IVector3Like {
  1525. x: float;
  1526. y: float;
  1527. z: float;
  1528. }
  1529. /**
  1530. * @hidden
  1531. */
  1532. export interface IVector2Like {
  1533. x: float;
  1534. y: float;
  1535. }
  1536. /**
  1537. * @hidden
  1538. */
  1539. export interface IMatrixLike {
  1540. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1541. updateFlag: int;
  1542. }
  1543. /**
  1544. * @hidden
  1545. */
  1546. export interface IViewportLike {
  1547. x: float;
  1548. y: float;
  1549. width: float;
  1550. height: float;
  1551. }
  1552. /**
  1553. * @hidden
  1554. */
  1555. export interface IPlaneLike {
  1556. normal: IVector3Like;
  1557. d: float;
  1558. normalize(): void;
  1559. }
  1560. }
  1561. declare module BABYLON {
  1562. /**
  1563. * Interface used to define common properties for effect fallbacks
  1564. */
  1565. export interface IEffectFallbacks {
  1566. /**
  1567. * Removes the defines that should be removed when falling back.
  1568. * @param currentDefines defines the current define statements for the shader.
  1569. * @param effect defines the current effect we try to compile
  1570. * @returns The resulting defines with defines of the current rank removed.
  1571. */
  1572. reduce(currentDefines: string, effect: Effect): string;
  1573. /**
  1574. * Removes the fallback from the bound mesh.
  1575. */
  1576. unBindMesh(): void;
  1577. /**
  1578. * Checks to see if more fallbacks are still availible.
  1579. */
  1580. hasMoreFallbacks: boolean;
  1581. }
  1582. }
  1583. declare module BABYLON {
  1584. /**
  1585. * Class used to evalaute queries containing `and` and `or` operators
  1586. */
  1587. export class AndOrNotEvaluator {
  1588. /**
  1589. * Evaluate a query
  1590. * @param query defines the query to evaluate
  1591. * @param evaluateCallback defines the callback used to filter result
  1592. * @returns true if the query matches
  1593. */
  1594. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1595. private static _HandleParenthesisContent;
  1596. private static _SimplifyNegation;
  1597. }
  1598. }
  1599. declare module BABYLON {
  1600. /**
  1601. * Class used to store custom tags
  1602. */
  1603. export class Tags {
  1604. /**
  1605. * Adds support for tags on the given object
  1606. * @param obj defines the object to use
  1607. */
  1608. static EnableFor(obj: any): void;
  1609. /**
  1610. * Removes tags support
  1611. * @param obj defines the object to use
  1612. */
  1613. static DisableFor(obj: any): void;
  1614. /**
  1615. * Gets a boolean indicating if the given object has tags
  1616. * @param obj defines the object to use
  1617. * @returns a boolean
  1618. */
  1619. static HasTags(obj: any): boolean;
  1620. /**
  1621. * Gets the tags available on a given object
  1622. * @param obj defines the object to use
  1623. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1624. * @returns the tags
  1625. */
  1626. static GetTags(obj: any, asString?: boolean): any;
  1627. /**
  1628. * Adds tags to an object
  1629. * @param obj defines the object to use
  1630. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1631. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1632. */
  1633. static AddTagsTo(obj: any, tagsString: string): void;
  1634. /**
  1635. * @hidden
  1636. */
  1637. static _AddTagTo(obj: any, tag: string): void;
  1638. /**
  1639. * Removes specific tags from a specific object
  1640. * @param obj defines the object to use
  1641. * @param tagsString defines the tags to remove
  1642. */
  1643. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1644. /**
  1645. * @hidden
  1646. */
  1647. static _RemoveTagFrom(obj: any, tag: string): void;
  1648. /**
  1649. * Defines if tags hosted on an object match a given query
  1650. * @param obj defines the object to use
  1651. * @param tagsQuery defines the tag query
  1652. * @returns a boolean
  1653. */
  1654. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1655. }
  1656. }
  1657. declare module BABYLON {
  1658. /**
  1659. * Scalar computation library
  1660. */
  1661. export class Scalar {
  1662. /**
  1663. * Two pi constants convenient for computation.
  1664. */
  1665. static TwoPi: number;
  1666. /**
  1667. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1668. * @param a number
  1669. * @param b number
  1670. * @param epsilon (default = 1.401298E-45)
  1671. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1672. */
  1673. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1674. /**
  1675. * Returns a string : the upper case translation of the number i to hexadecimal.
  1676. * @param i number
  1677. * @returns the upper case translation of the number i to hexadecimal.
  1678. */
  1679. static ToHex(i: number): string;
  1680. /**
  1681. * Returns -1 if value is negative and +1 is value is positive.
  1682. * @param value the value
  1683. * @returns the value itself if it's equal to zero.
  1684. */
  1685. static Sign(value: number): number;
  1686. /**
  1687. * Returns the value itself if it's between min and max.
  1688. * Returns min if the value is lower than min.
  1689. * Returns max if the value is greater than max.
  1690. * @param value the value to clmap
  1691. * @param min the min value to clamp to (default: 0)
  1692. * @param max the max value to clamp to (default: 1)
  1693. * @returns the clamped value
  1694. */
  1695. static Clamp(value: number, min?: number, max?: number): number;
  1696. /**
  1697. * the log2 of value.
  1698. * @param value the value to compute log2 of
  1699. * @returns the log2 of value.
  1700. */
  1701. static Log2(value: number): number;
  1702. /**
  1703. * Loops the value, so that it is never larger than length and never smaller than 0.
  1704. *
  1705. * This is similar to the modulo operator but it works with floating point numbers.
  1706. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1707. * With t = 5 and length = 2.5, the result would be 0.0.
  1708. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1709. * @param value the value
  1710. * @param length the length
  1711. * @returns the looped value
  1712. */
  1713. static Repeat(value: number, length: number): number;
  1714. /**
  1715. * Normalize the value between 0.0 and 1.0 using min and max values
  1716. * @param value value to normalize
  1717. * @param min max to normalize between
  1718. * @param max min to normalize between
  1719. * @returns the normalized value
  1720. */
  1721. static Normalize(value: number, min: number, max: number): number;
  1722. /**
  1723. * Denormalize the value from 0.0 and 1.0 using min and max values
  1724. * @param normalized value to denormalize
  1725. * @param min max to denormalize between
  1726. * @param max min to denormalize between
  1727. * @returns the denormalized value
  1728. */
  1729. static Denormalize(normalized: number, min: number, max: number): number;
  1730. /**
  1731. * Calculates the shortest difference between two given angles given in degrees.
  1732. * @param current current angle in degrees
  1733. * @param target target angle in degrees
  1734. * @returns the delta
  1735. */
  1736. static DeltaAngle(current: number, target: number): number;
  1737. /**
  1738. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1739. * @param tx value
  1740. * @param length length
  1741. * @returns The returned value will move back and forth between 0 and length
  1742. */
  1743. static PingPong(tx: number, length: number): number;
  1744. /**
  1745. * Interpolates between min and max with smoothing at the limits.
  1746. *
  1747. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1748. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1749. * @param from from
  1750. * @param to to
  1751. * @param tx value
  1752. * @returns the smooth stepped value
  1753. */
  1754. static SmoothStep(from: number, to: number, tx: number): number;
  1755. /**
  1756. * Moves a value current towards target.
  1757. *
  1758. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1759. * Negative values of maxDelta pushes the value away from target.
  1760. * @param current current value
  1761. * @param target target value
  1762. * @param maxDelta max distance to move
  1763. * @returns resulting value
  1764. */
  1765. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1766. /**
  1767. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1768. *
  1769. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1770. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1771. * @param current current value
  1772. * @param target target value
  1773. * @param maxDelta max distance to move
  1774. * @returns resulting angle
  1775. */
  1776. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1777. /**
  1778. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1779. * @param start start value
  1780. * @param end target value
  1781. * @param amount amount to lerp between
  1782. * @returns the lerped value
  1783. */
  1784. static Lerp(start: number, end: number, amount: number): number;
  1785. /**
  1786. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1787. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1788. * @param start start value
  1789. * @param end target value
  1790. * @param amount amount to lerp between
  1791. * @returns the lerped value
  1792. */
  1793. static LerpAngle(start: number, end: number, amount: number): number;
  1794. /**
  1795. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1796. * @param a start value
  1797. * @param b target value
  1798. * @param value value between a and b
  1799. * @returns the inverseLerp value
  1800. */
  1801. static InverseLerp(a: number, b: number, value: number): number;
  1802. /**
  1803. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1804. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1805. * @param value1 spline value
  1806. * @param tangent1 spline value
  1807. * @param value2 spline value
  1808. * @param tangent2 spline value
  1809. * @param amount input value
  1810. * @returns hermite result
  1811. */
  1812. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1813. /**
  1814. * Returns a random float number between and min and max values
  1815. * @param min min value of random
  1816. * @param max max value of random
  1817. * @returns random value
  1818. */
  1819. static RandomRange(min: number, max: number): number;
  1820. /**
  1821. * This function returns percentage of a number in a given range.
  1822. *
  1823. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1824. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1825. * @param number to convert to percentage
  1826. * @param min min range
  1827. * @param max max range
  1828. * @returns the percentage
  1829. */
  1830. static RangeToPercent(number: number, min: number, max: number): number;
  1831. /**
  1832. * This function returns number that corresponds to the percentage in a given range.
  1833. *
  1834. * PercentToRange(0.34,0,100) will return 34.
  1835. * @param percent to convert to number
  1836. * @param min min range
  1837. * @param max max range
  1838. * @returns the number
  1839. */
  1840. static PercentToRange(percent: number, min: number, max: number): number;
  1841. /**
  1842. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1843. * @param angle The angle to normalize in radian.
  1844. * @return The converted angle.
  1845. */
  1846. static NormalizeRadians(angle: number): number;
  1847. }
  1848. }
  1849. declare module BABYLON {
  1850. /**
  1851. * Constant used to convert a value to gamma space
  1852. * @ignorenaming
  1853. */
  1854. export const ToGammaSpace: number;
  1855. /**
  1856. * Constant used to convert a value to linear space
  1857. * @ignorenaming
  1858. */
  1859. export const ToLinearSpace = 2.2;
  1860. /**
  1861. * Constant used to define the minimal number value in Babylon.js
  1862. * @ignorenaming
  1863. */
  1864. let Epsilon: number;
  1865. }
  1866. declare module BABYLON {
  1867. /**
  1868. * Class used to represent a viewport on screen
  1869. */
  1870. export class Viewport {
  1871. /** viewport left coordinate */
  1872. x: number;
  1873. /** viewport top coordinate */
  1874. y: number;
  1875. /**viewport width */
  1876. width: number;
  1877. /** viewport height */
  1878. height: number;
  1879. /**
  1880. * Creates a Viewport object located at (x, y) and sized (width, height)
  1881. * @param x defines viewport left coordinate
  1882. * @param y defines viewport top coordinate
  1883. * @param width defines the viewport width
  1884. * @param height defines the viewport height
  1885. */
  1886. constructor(
  1887. /** viewport left coordinate */
  1888. x: number,
  1889. /** viewport top coordinate */
  1890. y: number,
  1891. /**viewport width */
  1892. width: number,
  1893. /** viewport height */
  1894. height: number);
  1895. /**
  1896. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1897. * @param renderWidth defines the rendering width
  1898. * @param renderHeight defines the rendering height
  1899. * @returns a new Viewport
  1900. */
  1901. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1902. /**
  1903. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1904. * @param renderWidth defines the rendering width
  1905. * @param renderHeight defines the rendering height
  1906. * @param ref defines the target viewport
  1907. * @returns the current viewport
  1908. */
  1909. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1910. /**
  1911. * Returns a new Viewport copied from the current one
  1912. * @returns a new Viewport
  1913. */
  1914. clone(): Viewport;
  1915. }
  1916. }
  1917. declare module BABYLON {
  1918. /**
  1919. * Class containing a set of static utilities functions for arrays.
  1920. */
  1921. export class ArrayTools {
  1922. /**
  1923. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1924. * @param size the number of element to construct and put in the array
  1925. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1926. * @returns a new array filled with new objects
  1927. */
  1928. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1929. }
  1930. }
  1931. declare module BABYLON {
  1932. /**
  1933. * Represents a plane by the equation ax + by + cz + d = 0
  1934. */
  1935. export class Plane {
  1936. private static _TmpMatrix;
  1937. /**
  1938. * Normal of the plane (a,b,c)
  1939. */
  1940. normal: Vector3;
  1941. /**
  1942. * d component of the plane
  1943. */
  1944. d: number;
  1945. /**
  1946. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1947. * @param a a component of the plane
  1948. * @param b b component of the plane
  1949. * @param c c component of the plane
  1950. * @param d d component of the plane
  1951. */
  1952. constructor(a: number, b: number, c: number, d: number);
  1953. /**
  1954. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1955. */
  1956. asArray(): number[];
  1957. /**
  1958. * @returns a new plane copied from the current Plane.
  1959. */
  1960. clone(): Plane;
  1961. /**
  1962. * @returns the string "Plane".
  1963. */
  1964. getClassName(): string;
  1965. /**
  1966. * @returns the Plane hash code.
  1967. */
  1968. getHashCode(): number;
  1969. /**
  1970. * Normalize the current Plane in place.
  1971. * @returns the updated Plane.
  1972. */
  1973. normalize(): Plane;
  1974. /**
  1975. * Applies a transformation the plane and returns the result
  1976. * @param transformation the transformation matrix to be applied to the plane
  1977. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  1978. */
  1979. transform(transformation: DeepImmutable<Matrix>): Plane;
  1980. /**
  1981. * Compute the dot product between the point and the plane normal
  1982. * @param point point to calculate the dot product with
  1983. * @returns the dot product (float) of the point coordinates and the plane normal.
  1984. */
  1985. dotCoordinate(point: DeepImmutable<Vector3>): number;
  1986. /**
  1987. * Updates the current Plane from the plane defined by the three given points.
  1988. * @param point1 one of the points used to contruct the plane
  1989. * @param point2 one of the points used to contruct the plane
  1990. * @param point3 one of the points used to contruct the plane
  1991. * @returns the updated Plane.
  1992. */
  1993. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  1994. /**
  1995. * Checks if the plane is facing a given direction
  1996. * @param direction the direction to check if the plane is facing
  1997. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  1998. * @returns True is the vector "direction" is the same side than the plane normal.
  1999. */
  2000. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2001. /**
  2002. * Calculates the distance to a point
  2003. * @param point point to calculate distance to
  2004. * @returns the signed distance (float) from the given point to the Plane.
  2005. */
  2006. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2007. /**
  2008. * Creates a plane from an array
  2009. * @param array the array to create a plane from
  2010. * @returns a new Plane from the given array.
  2011. */
  2012. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2013. /**
  2014. * Creates a plane from three points
  2015. * @param point1 point used to create the plane
  2016. * @param point2 point used to create the plane
  2017. * @param point3 point used to create the plane
  2018. * @returns a new Plane defined by the three given points.
  2019. */
  2020. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2021. /**
  2022. * Creates a plane from an origin point and a normal
  2023. * @param origin origin of the plane to be constructed
  2024. * @param normal normal of the plane to be constructed
  2025. * @returns a new Plane the normal vector to this plane at the given origin point.
  2026. * Note : the vector "normal" is updated because normalized.
  2027. */
  2028. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2029. /**
  2030. * Calculates the distance from a plane and a point
  2031. * @param origin origin of the plane to be constructed
  2032. * @param normal normal of the plane to be constructed
  2033. * @param point point to calculate distance to
  2034. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2035. */
  2036. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2037. }
  2038. }
  2039. declare module BABYLON {
  2040. /** @hidden */
  2041. export class PerformanceConfigurator {
  2042. /** @hidden */
  2043. static MatrixUse64Bits: boolean;
  2044. /** @hidden */
  2045. static MatrixTrackPrecisionChange: boolean;
  2046. /** @hidden */
  2047. static MatrixCurrentType: any;
  2048. /** @hidden */
  2049. static MatrixTrackedMatrices: Array<any> | null;
  2050. /** @hidden */
  2051. static SetMatrixPrecision(use64bits: boolean): void;
  2052. }
  2053. }
  2054. declare module BABYLON {
  2055. /**
  2056. * Class representing a vector containing 2 coordinates
  2057. */
  2058. export class Vector2 {
  2059. /** defines the first coordinate */
  2060. x: number;
  2061. /** defines the second coordinate */
  2062. y: number;
  2063. /**
  2064. * Creates a new Vector2 from the given x and y coordinates
  2065. * @param x defines the first coordinate
  2066. * @param y defines the second coordinate
  2067. */
  2068. constructor(
  2069. /** defines the first coordinate */
  2070. x?: number,
  2071. /** defines the second coordinate */
  2072. y?: number);
  2073. /**
  2074. * Gets a string with the Vector2 coordinates
  2075. * @returns a string with the Vector2 coordinates
  2076. */
  2077. toString(): string;
  2078. /**
  2079. * Gets class name
  2080. * @returns the string "Vector2"
  2081. */
  2082. getClassName(): string;
  2083. /**
  2084. * Gets current vector hash code
  2085. * @returns the Vector2 hash code as a number
  2086. */
  2087. getHashCode(): number;
  2088. /**
  2089. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2090. * @param array defines the source array
  2091. * @param index defines the offset in source array
  2092. * @returns the current Vector2
  2093. */
  2094. toArray(array: FloatArray, index?: number): Vector2;
  2095. /**
  2096. * Update the current vector from an array
  2097. * @param array defines the destination array
  2098. * @param index defines the offset in the destination array
  2099. * @returns the current Vector3
  2100. */
  2101. fromArray(array: FloatArray, index?: number): Vector2;
  2102. /**
  2103. * Copy the current vector to an array
  2104. * @returns a new array with 2 elements: the Vector2 coordinates.
  2105. */
  2106. asArray(): number[];
  2107. /**
  2108. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2109. * @param source defines the source Vector2
  2110. * @returns the current updated Vector2
  2111. */
  2112. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2113. /**
  2114. * Sets the Vector2 coordinates with the given floats
  2115. * @param x defines the first coordinate
  2116. * @param y defines the second coordinate
  2117. * @returns the current updated Vector2
  2118. */
  2119. copyFromFloats(x: number, y: number): Vector2;
  2120. /**
  2121. * Sets the Vector2 coordinates with the given floats
  2122. * @param x defines the first coordinate
  2123. * @param y defines the second coordinate
  2124. * @returns the current updated Vector2
  2125. */
  2126. set(x: number, y: number): Vector2;
  2127. /**
  2128. * Add another vector with the current one
  2129. * @param otherVector defines the other vector
  2130. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2131. */
  2132. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2133. /**
  2134. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2135. * @param otherVector defines the other vector
  2136. * @param result defines the target vector
  2137. * @returns the unmodified current Vector2
  2138. */
  2139. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2140. /**
  2141. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2142. * @param otherVector defines the other vector
  2143. * @returns the current updated Vector2
  2144. */
  2145. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2146. /**
  2147. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2148. * @param otherVector defines the other vector
  2149. * @returns a new Vector2
  2150. */
  2151. addVector3(otherVector: Vector3): Vector2;
  2152. /**
  2153. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2154. * @param otherVector defines the other vector
  2155. * @returns a new Vector2
  2156. */
  2157. subtract(otherVector: Vector2): Vector2;
  2158. /**
  2159. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2160. * @param otherVector defines the other vector
  2161. * @param result defines the target vector
  2162. * @returns the unmodified current Vector2
  2163. */
  2164. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2165. /**
  2166. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2167. * @param otherVector defines the other vector
  2168. * @returns the current updated Vector2
  2169. */
  2170. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2171. /**
  2172. * Multiplies in place the current Vector2 coordinates by the given ones
  2173. * @param otherVector defines the other vector
  2174. * @returns the current updated Vector2
  2175. */
  2176. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2177. /**
  2178. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2179. * @param otherVector defines the other vector
  2180. * @returns a new Vector2
  2181. */
  2182. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2183. /**
  2184. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2185. * @param otherVector defines the other vector
  2186. * @param result defines the target vector
  2187. * @returns the unmodified current Vector2
  2188. */
  2189. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2190. /**
  2191. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2192. * @param x defines the first coordinate
  2193. * @param y defines the second coordinate
  2194. * @returns a new Vector2
  2195. */
  2196. multiplyByFloats(x: number, y: number): Vector2;
  2197. /**
  2198. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2199. * @param otherVector defines the other vector
  2200. * @returns a new Vector2
  2201. */
  2202. divide(otherVector: Vector2): Vector2;
  2203. /**
  2204. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2205. * @param otherVector defines the other vector
  2206. * @param result defines the target vector
  2207. * @returns the unmodified current Vector2
  2208. */
  2209. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2210. /**
  2211. * Divides the current Vector2 coordinates by the given ones
  2212. * @param otherVector defines the other vector
  2213. * @returns the current updated Vector2
  2214. */
  2215. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2216. /**
  2217. * Gets a new Vector2 with current Vector2 negated coordinates
  2218. * @returns a new Vector2
  2219. */
  2220. negate(): Vector2;
  2221. /**
  2222. * Negate this vector in place
  2223. * @returns this
  2224. */
  2225. negateInPlace(): Vector2;
  2226. /**
  2227. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2228. * @param result defines the Vector3 object where to store the result
  2229. * @returns the current Vector2
  2230. */
  2231. negateToRef(result: Vector2): Vector2;
  2232. /**
  2233. * Multiply the Vector2 coordinates by scale
  2234. * @param scale defines the scaling factor
  2235. * @returns the current updated Vector2
  2236. */
  2237. scaleInPlace(scale: number): Vector2;
  2238. /**
  2239. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2240. * @param scale defines the scaling factor
  2241. * @returns a new Vector2
  2242. */
  2243. scale(scale: number): Vector2;
  2244. /**
  2245. * Scale the current Vector2 values by a factor to a given Vector2
  2246. * @param scale defines the scale factor
  2247. * @param result defines the Vector2 object where to store the result
  2248. * @returns the unmodified current Vector2
  2249. */
  2250. scaleToRef(scale: number, result: Vector2): Vector2;
  2251. /**
  2252. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2253. * @param scale defines the scale factor
  2254. * @param result defines the Vector2 object where to store the result
  2255. * @returns the unmodified current Vector2
  2256. */
  2257. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2258. /**
  2259. * Gets a boolean if two vectors are equals
  2260. * @param otherVector defines the other vector
  2261. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2262. */
  2263. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2264. /**
  2265. * Gets a boolean if two vectors are equals (using an epsilon value)
  2266. * @param otherVector defines the other vector
  2267. * @param epsilon defines the minimal distance to consider equality
  2268. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2269. */
  2270. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2271. /**
  2272. * Gets a new Vector2 from current Vector2 floored values
  2273. * @returns a new Vector2
  2274. */
  2275. floor(): Vector2;
  2276. /**
  2277. * Gets a new Vector2 from current Vector2 floored values
  2278. * @returns a new Vector2
  2279. */
  2280. fract(): Vector2;
  2281. /**
  2282. * Gets the length of the vector
  2283. * @returns the vector length (float)
  2284. */
  2285. length(): number;
  2286. /**
  2287. * Gets the vector squared length
  2288. * @returns the vector squared length (float)
  2289. */
  2290. lengthSquared(): number;
  2291. /**
  2292. * Normalize the vector
  2293. * @returns the current updated Vector2
  2294. */
  2295. normalize(): Vector2;
  2296. /**
  2297. * Gets a new Vector2 copied from the Vector2
  2298. * @returns a new Vector2
  2299. */
  2300. clone(): Vector2;
  2301. /**
  2302. * Gets a new Vector2(0, 0)
  2303. * @returns a new Vector2
  2304. */
  2305. static Zero(): Vector2;
  2306. /**
  2307. * Gets a new Vector2(1, 1)
  2308. * @returns a new Vector2
  2309. */
  2310. static One(): Vector2;
  2311. /**
  2312. * Gets a new Vector2 set from the given index element of the given array
  2313. * @param array defines the data source
  2314. * @param offset defines the offset in the data source
  2315. * @returns a new Vector2
  2316. */
  2317. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2318. /**
  2319. * Sets "result" from the given index element of the given array
  2320. * @param array defines the data source
  2321. * @param offset defines the offset in the data source
  2322. * @param result defines the target vector
  2323. */
  2324. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2325. /**
  2326. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2327. * @param value1 defines 1st point of control
  2328. * @param value2 defines 2nd point of control
  2329. * @param value3 defines 3rd point of control
  2330. * @param value4 defines 4th point of control
  2331. * @param amount defines the interpolation factor
  2332. * @returns a new Vector2
  2333. */
  2334. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2335. /**
  2336. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2337. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2338. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2339. * @param value defines the value to clamp
  2340. * @param min defines the lower limit
  2341. * @param max defines the upper limit
  2342. * @returns a new Vector2
  2343. */
  2344. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2345. /**
  2346. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2347. * @param value1 defines the 1st control point
  2348. * @param tangent1 defines the outgoing tangent
  2349. * @param value2 defines the 2nd control point
  2350. * @param tangent2 defines the incoming tangent
  2351. * @param amount defines the interpolation factor
  2352. * @returns a new Vector2
  2353. */
  2354. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2355. /**
  2356. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2357. * @param start defines the start vector
  2358. * @param end defines the end vector
  2359. * @param amount defines the interpolation factor
  2360. * @returns a new Vector2
  2361. */
  2362. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2363. /**
  2364. * Gets the dot product of the vector "left" and the vector "right"
  2365. * @param left defines first vector
  2366. * @param right defines second vector
  2367. * @returns the dot product (float)
  2368. */
  2369. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2370. /**
  2371. * Returns a new Vector2 equal to the normalized given vector
  2372. * @param vector defines the vector to normalize
  2373. * @returns a new Vector2
  2374. */
  2375. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2376. /**
  2377. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2378. * @param left defines 1st vector
  2379. * @param right defines 2nd vector
  2380. * @returns a new Vector2
  2381. */
  2382. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2383. /**
  2384. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2385. * @param left defines 1st vector
  2386. * @param right defines 2nd vector
  2387. * @returns a new Vector2
  2388. */
  2389. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2390. /**
  2391. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2392. * @param vector defines the vector to transform
  2393. * @param transformation defines the matrix to apply
  2394. * @returns a new Vector2
  2395. */
  2396. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2397. /**
  2398. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2399. * @param vector defines the vector to transform
  2400. * @param transformation defines the matrix to apply
  2401. * @param result defines the target vector
  2402. */
  2403. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2404. /**
  2405. * Determines if a given vector is included in a triangle
  2406. * @param p defines the vector to test
  2407. * @param p0 defines 1st triangle point
  2408. * @param p1 defines 2nd triangle point
  2409. * @param p2 defines 3rd triangle point
  2410. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2411. */
  2412. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2413. /**
  2414. * Gets the distance between the vectors "value1" and "value2"
  2415. * @param value1 defines first vector
  2416. * @param value2 defines second vector
  2417. * @returns the distance between vectors
  2418. */
  2419. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2420. /**
  2421. * Returns the squared distance between the vectors "value1" and "value2"
  2422. * @param value1 defines first vector
  2423. * @param value2 defines second vector
  2424. * @returns the squared distance between vectors
  2425. */
  2426. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2427. /**
  2428. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2429. * @param value1 defines first vector
  2430. * @param value2 defines second vector
  2431. * @returns a new Vector2
  2432. */
  2433. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2434. /**
  2435. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2436. * @param p defines the middle point
  2437. * @param segA defines one point of the segment
  2438. * @param segB defines the other point of the segment
  2439. * @returns the shortest distance
  2440. */
  2441. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2442. }
  2443. /**
  2444. * Class used to store (x,y,z) vector representation
  2445. * A Vector3 is the main object used in 3D geometry
  2446. * It can represent etiher the coordinates of a point the space, either a direction
  2447. * Reminder: js uses a left handed forward facing system
  2448. */
  2449. export class Vector3 {
  2450. private static _UpReadOnly;
  2451. private static _ZeroReadOnly;
  2452. /** @hidden */
  2453. _x: number;
  2454. /** @hidden */
  2455. _y: number;
  2456. /** @hidden */
  2457. _z: number;
  2458. /** @hidden */
  2459. _isDirty: boolean;
  2460. /** Gets or sets the x coordinate */
  2461. get x(): number;
  2462. set x(value: number);
  2463. /** Gets or sets the y coordinate */
  2464. get y(): number;
  2465. set y(value: number);
  2466. /** Gets or sets the z coordinate */
  2467. get z(): number;
  2468. set z(value: number);
  2469. /**
  2470. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2471. * @param x defines the first coordinates (on X axis)
  2472. * @param y defines the second coordinates (on Y axis)
  2473. * @param z defines the third coordinates (on Z axis)
  2474. */
  2475. constructor(x?: number, y?: number, z?: number);
  2476. /**
  2477. * Creates a string representation of the Vector3
  2478. * @returns a string with the Vector3 coordinates.
  2479. */
  2480. toString(): string;
  2481. /**
  2482. * Gets the class name
  2483. * @returns the string "Vector3"
  2484. */
  2485. getClassName(): string;
  2486. /**
  2487. * Creates the Vector3 hash code
  2488. * @returns a number which tends to be unique between Vector3 instances
  2489. */
  2490. getHashCode(): number;
  2491. /**
  2492. * Creates an array containing three elements : the coordinates of the Vector3
  2493. * @returns a new array of numbers
  2494. */
  2495. asArray(): number[];
  2496. /**
  2497. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2498. * @param array defines the destination array
  2499. * @param index defines the offset in the destination array
  2500. * @returns the current Vector3
  2501. */
  2502. toArray(array: FloatArray, index?: number): Vector3;
  2503. /**
  2504. * Update the current vector from an array
  2505. * @param array defines the destination array
  2506. * @param index defines the offset in the destination array
  2507. * @returns the current Vector3
  2508. */
  2509. fromArray(array: FloatArray, index?: number): Vector3;
  2510. /**
  2511. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2512. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2513. */
  2514. toQuaternion(): Quaternion;
  2515. /**
  2516. * Adds the given vector to the current Vector3
  2517. * @param otherVector defines the second operand
  2518. * @returns the current updated Vector3
  2519. */
  2520. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2521. /**
  2522. * Adds the given coordinates to the current Vector3
  2523. * @param x defines the x coordinate of the operand
  2524. * @param y defines the y coordinate of the operand
  2525. * @param z defines the z coordinate of the operand
  2526. * @returns the current updated Vector3
  2527. */
  2528. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2529. /**
  2530. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2531. * @param otherVector defines the second operand
  2532. * @returns the resulting Vector3
  2533. */
  2534. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2535. /**
  2536. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2537. * @param otherVector defines the second operand
  2538. * @param result defines the Vector3 object where to store the result
  2539. * @returns the current Vector3
  2540. */
  2541. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2542. /**
  2543. * Subtract the given vector from the current Vector3
  2544. * @param otherVector defines the second operand
  2545. * @returns the current updated Vector3
  2546. */
  2547. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2548. /**
  2549. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2550. * @param otherVector defines the second operand
  2551. * @returns the resulting Vector3
  2552. */
  2553. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2554. /**
  2555. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2556. * @param otherVector defines the second operand
  2557. * @param result defines the Vector3 object where to store the result
  2558. * @returns the current Vector3
  2559. */
  2560. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2561. /**
  2562. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2563. * @param x defines the x coordinate of the operand
  2564. * @param y defines the y coordinate of the operand
  2565. * @param z defines the z coordinate of the operand
  2566. * @returns the resulting Vector3
  2567. */
  2568. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2569. /**
  2570. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2571. * @param x defines the x coordinate of the operand
  2572. * @param y defines the y coordinate of the operand
  2573. * @param z defines the z coordinate of the operand
  2574. * @param result defines the Vector3 object where to store the result
  2575. * @returns the current Vector3
  2576. */
  2577. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2578. /**
  2579. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2580. * @returns a new Vector3
  2581. */
  2582. negate(): Vector3;
  2583. /**
  2584. * Negate this vector in place
  2585. * @returns this
  2586. */
  2587. negateInPlace(): Vector3;
  2588. /**
  2589. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2590. * @param result defines the Vector3 object where to store the result
  2591. * @returns the current Vector3
  2592. */
  2593. negateToRef(result: Vector3): Vector3;
  2594. /**
  2595. * Multiplies the Vector3 coordinates by the float "scale"
  2596. * @param scale defines the multiplier factor
  2597. * @returns the current updated Vector3
  2598. */
  2599. scaleInPlace(scale: number): Vector3;
  2600. /**
  2601. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2602. * @param scale defines the multiplier factor
  2603. * @returns a new Vector3
  2604. */
  2605. scale(scale: number): Vector3;
  2606. /**
  2607. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2608. * @param scale defines the multiplier factor
  2609. * @param result defines the Vector3 object where to store the result
  2610. * @returns the current Vector3
  2611. */
  2612. scaleToRef(scale: number, result: Vector3): Vector3;
  2613. /**
  2614. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2615. * @param scale defines the scale factor
  2616. * @param result defines the Vector3 object where to store the result
  2617. * @returns the unmodified current Vector3
  2618. */
  2619. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2620. /**
  2621. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2622. * @param origin defines the origin of the projection ray
  2623. * @param plane defines the plane to project to
  2624. * @returns the projected vector3
  2625. */
  2626. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2627. /**
  2628. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2629. * @param origin defines the origin of the projection ray
  2630. * @param plane defines the plane to project to
  2631. * @param result defines the Vector3 where to store the result
  2632. */
  2633. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2634. /**
  2635. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2636. * @param otherVector defines the second operand
  2637. * @returns true if both vectors are equals
  2638. */
  2639. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2640. /**
  2641. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2642. * @param otherVector defines the second operand
  2643. * @param epsilon defines the minimal distance to define values as equals
  2644. * @returns true if both vectors are distant less than epsilon
  2645. */
  2646. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2647. /**
  2648. * Returns true if the current Vector3 coordinates equals the given floats
  2649. * @param x defines the x coordinate of the operand
  2650. * @param y defines the y coordinate of the operand
  2651. * @param z defines the z coordinate of the operand
  2652. * @returns true if both vectors are equals
  2653. */
  2654. equalsToFloats(x: number, y: number, z: number): boolean;
  2655. /**
  2656. * Multiplies the current Vector3 coordinates by the given ones
  2657. * @param otherVector defines the second operand
  2658. * @returns the current updated Vector3
  2659. */
  2660. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2661. /**
  2662. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2663. * @param otherVector defines the second operand
  2664. * @returns the new Vector3
  2665. */
  2666. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2667. /**
  2668. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2669. * @param otherVector defines the second operand
  2670. * @param result defines the Vector3 object where to store the result
  2671. * @returns the current Vector3
  2672. */
  2673. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2674. /**
  2675. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2676. * @param x defines the x coordinate of the operand
  2677. * @param y defines the y coordinate of the operand
  2678. * @param z defines the z coordinate of the operand
  2679. * @returns the new Vector3
  2680. */
  2681. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2682. /**
  2683. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2684. * @param otherVector defines the second operand
  2685. * @returns the new Vector3
  2686. */
  2687. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2688. /**
  2689. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2690. * @param otherVector defines the second operand
  2691. * @param result defines the Vector3 object where to store the result
  2692. * @returns the current Vector3
  2693. */
  2694. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2695. /**
  2696. * Divides the current Vector3 coordinates by the given ones.
  2697. * @param otherVector defines the second operand
  2698. * @returns the current updated Vector3
  2699. */
  2700. divideInPlace(otherVector: Vector3): Vector3;
  2701. /**
  2702. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2703. * @param other defines the second operand
  2704. * @returns the current updated Vector3
  2705. */
  2706. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2707. /**
  2708. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2709. * @param other defines the second operand
  2710. * @returns the current updated Vector3
  2711. */
  2712. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2713. /**
  2714. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2715. * @param x defines the x coordinate of the operand
  2716. * @param y defines the y coordinate of the operand
  2717. * @param z defines the z coordinate of the operand
  2718. * @returns the current updated Vector3
  2719. */
  2720. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2721. /**
  2722. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2723. * @param x defines the x coordinate of the operand
  2724. * @param y defines the y coordinate of the operand
  2725. * @param z defines the z coordinate of the operand
  2726. * @returns the current updated Vector3
  2727. */
  2728. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2729. /**
  2730. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2731. * Check if is non uniform within a certain amount of decimal places to account for this
  2732. * @param epsilon the amount the values can differ
  2733. * @returns if the the vector is non uniform to a certain number of decimal places
  2734. */
  2735. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2736. /**
  2737. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2738. */
  2739. get isNonUniform(): boolean;
  2740. /**
  2741. * Gets a new Vector3 from current Vector3 floored values
  2742. * @returns a new Vector3
  2743. */
  2744. floor(): Vector3;
  2745. /**
  2746. * Gets a new Vector3 from current Vector3 floored values
  2747. * @returns a new Vector3
  2748. */
  2749. fract(): Vector3;
  2750. /**
  2751. * Gets the length of the Vector3
  2752. * @returns the length of the Vector3
  2753. */
  2754. length(): number;
  2755. /**
  2756. * Gets the squared length of the Vector3
  2757. * @returns squared length of the Vector3
  2758. */
  2759. lengthSquared(): number;
  2760. /**
  2761. * Normalize the current Vector3.
  2762. * Please note that this is an in place operation.
  2763. * @returns the current updated Vector3
  2764. */
  2765. normalize(): Vector3;
  2766. /**
  2767. * Reorders the x y z properties of the vector in place
  2768. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2769. * @returns the current updated vector
  2770. */
  2771. reorderInPlace(order: string): this;
  2772. /**
  2773. * Rotates the vector around 0,0,0 by a quaternion
  2774. * @param quaternion the rotation quaternion
  2775. * @param result vector to store the result
  2776. * @returns the resulting vector
  2777. */
  2778. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2779. /**
  2780. * Rotates a vector around a given point
  2781. * @param quaternion the rotation quaternion
  2782. * @param point the point to rotate around
  2783. * @param result vector to store the result
  2784. * @returns the resulting vector
  2785. */
  2786. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2787. /**
  2788. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2789. * The cross product is then orthogonal to both current and "other"
  2790. * @param other defines the right operand
  2791. * @returns the cross product
  2792. */
  2793. cross(other: Vector3): Vector3;
  2794. /**
  2795. * Normalize the current Vector3 with the given input length.
  2796. * Please note that this is an in place operation.
  2797. * @param len the length of the vector
  2798. * @returns the current updated Vector3
  2799. */
  2800. normalizeFromLength(len: number): Vector3;
  2801. /**
  2802. * Normalize the current Vector3 to a new vector
  2803. * @returns the new Vector3
  2804. */
  2805. normalizeToNew(): Vector3;
  2806. /**
  2807. * Normalize the current Vector3 to the reference
  2808. * @param reference define the Vector3 to update
  2809. * @returns the updated Vector3
  2810. */
  2811. normalizeToRef(reference: Vector3): Vector3;
  2812. /**
  2813. * Creates a new Vector3 copied from the current Vector3
  2814. * @returns the new Vector3
  2815. */
  2816. clone(): Vector3;
  2817. /**
  2818. * Copies the given vector coordinates to the current Vector3 ones
  2819. * @param source defines the source Vector3
  2820. * @returns the current updated Vector3
  2821. */
  2822. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2823. /**
  2824. * Copies the given floats to the current Vector3 coordinates
  2825. * @param x defines the x coordinate of the operand
  2826. * @param y defines the y coordinate of the operand
  2827. * @param z defines the z coordinate of the operand
  2828. * @returns the current updated Vector3
  2829. */
  2830. copyFromFloats(x: number, y: number, z: number): Vector3;
  2831. /**
  2832. * Copies the given floats to the current Vector3 coordinates
  2833. * @param x defines the x coordinate of the operand
  2834. * @param y defines the y coordinate of the operand
  2835. * @param z defines the z coordinate of the operand
  2836. * @returns the current updated Vector3
  2837. */
  2838. set(x: number, y: number, z: number): Vector3;
  2839. /**
  2840. * Copies the given float to the current Vector3 coordinates
  2841. * @param v defines the x, y and z coordinates of the operand
  2842. * @returns the current updated Vector3
  2843. */
  2844. setAll(v: number): Vector3;
  2845. /**
  2846. * Get the clip factor between two vectors
  2847. * @param vector0 defines the first operand
  2848. * @param vector1 defines the second operand
  2849. * @param axis defines the axis to use
  2850. * @param size defines the size along the axis
  2851. * @returns the clip factor
  2852. */
  2853. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2854. /**
  2855. * Get angle between two vectors
  2856. * @param vector0 angle between vector0 and vector1
  2857. * @param vector1 angle between vector0 and vector1
  2858. * @param normal direction of the normal
  2859. * @return the angle between vector0 and vector1
  2860. */
  2861. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2862. /**
  2863. * Returns a new Vector3 set from the index "offset" of the given array
  2864. * @param array defines the source array
  2865. * @param offset defines the offset in the source array
  2866. * @returns the new Vector3
  2867. */
  2868. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2869. /**
  2870. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2871. * @param array defines the source array
  2872. * @param offset defines the offset in the source array
  2873. * @returns the new Vector3
  2874. * @deprecated Please use FromArray instead.
  2875. */
  2876. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2877. /**
  2878. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2879. * @param array defines the source array
  2880. * @param offset defines the offset in the source array
  2881. * @param result defines the Vector3 where to store the result
  2882. */
  2883. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2884. /**
  2885. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2886. * @param array defines the source array
  2887. * @param offset defines the offset in the source array
  2888. * @param result defines the Vector3 where to store the result
  2889. * @deprecated Please use FromArrayToRef instead.
  2890. */
  2891. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2892. /**
  2893. * Sets the given vector "result" with the given floats.
  2894. * @param x defines the x coordinate of the source
  2895. * @param y defines the y coordinate of the source
  2896. * @param z defines the z coordinate of the source
  2897. * @param result defines the Vector3 where to store the result
  2898. */
  2899. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2900. /**
  2901. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2902. * @returns a new empty Vector3
  2903. */
  2904. static Zero(): Vector3;
  2905. /**
  2906. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2907. * @returns a new unit Vector3
  2908. */
  2909. static One(): Vector3;
  2910. /**
  2911. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2912. * @returns a new up Vector3
  2913. */
  2914. static Up(): Vector3;
  2915. /**
  2916. * Gets a up Vector3 that must not be updated
  2917. */
  2918. static get UpReadOnly(): DeepImmutable<Vector3>;
  2919. /**
  2920. * Gets a zero Vector3 that must not be updated
  2921. */
  2922. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2923. /**
  2924. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2925. * @returns a new down Vector3
  2926. */
  2927. static Down(): Vector3;
  2928. /**
  2929. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2930. * @param rightHandedSystem is the scene right-handed (negative z)
  2931. * @returns a new forward Vector3
  2932. */
  2933. static Forward(rightHandedSystem?: boolean): Vector3;
  2934. /**
  2935. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2936. * @param rightHandedSystem is the scene right-handed (negative-z)
  2937. * @returns a new forward Vector3
  2938. */
  2939. static Backward(rightHandedSystem?: boolean): Vector3;
  2940. /**
  2941. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2942. * @returns a new right Vector3
  2943. */
  2944. static Right(): Vector3;
  2945. /**
  2946. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2947. * @returns a new left Vector3
  2948. */
  2949. static Left(): Vector3;
  2950. /**
  2951. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2952. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2953. * @param vector defines the Vector3 to transform
  2954. * @param transformation defines the transformation matrix
  2955. * @returns the transformed Vector3
  2956. */
  2957. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2958. /**
  2959. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2960. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2961. * @param vector defines the Vector3 to transform
  2962. * @param transformation defines the transformation matrix
  2963. * @param result defines the Vector3 where to store the result
  2964. */
  2965. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2966. /**
  2967. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2968. * This method computes tranformed coordinates only, not transformed direction vectors
  2969. * @param x define the x coordinate of the source vector
  2970. * @param y define the y coordinate of the source vector
  2971. * @param z define the z coordinate of the source vector
  2972. * @param transformation defines the transformation matrix
  2973. * @param result defines the Vector3 where to store the result
  2974. */
  2975. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2976. /**
  2977. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2978. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2979. * @param vector defines the Vector3 to transform
  2980. * @param transformation defines the transformation matrix
  2981. * @returns the new Vector3
  2982. */
  2983. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2984. /**
  2985. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2986. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2987. * @param vector defines the Vector3 to transform
  2988. * @param transformation defines the transformation matrix
  2989. * @param result defines the Vector3 where to store the result
  2990. */
  2991. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2992. /**
  2993. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2994. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2995. * @param x define the x coordinate of the source vector
  2996. * @param y define the y coordinate of the source vector
  2997. * @param z define the z coordinate of the source vector
  2998. * @param transformation defines the transformation matrix
  2999. * @param result defines the Vector3 where to store the result
  3000. */
  3001. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3002. /**
  3003. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3004. * @param value1 defines the first control point
  3005. * @param value2 defines the second control point
  3006. * @param value3 defines the third control point
  3007. * @param value4 defines the fourth control point
  3008. * @param amount defines the amount on the spline to use
  3009. * @returns the new Vector3
  3010. */
  3011. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3012. /**
  3013. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3014. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3015. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3016. * @param value defines the current value
  3017. * @param min defines the lower range value
  3018. * @param max defines the upper range value
  3019. * @returns the new Vector3
  3020. */
  3021. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3022. /**
  3023. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  3024. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3025. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3026. * @param value defines the current value
  3027. * @param min defines the lower range value
  3028. * @param max defines the upper range value
  3029. * @param result defines the Vector3 where to store the result
  3030. */
  3031. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3032. /**
  3033. * Checks if a given vector is inside a specific range
  3034. * @param v defines the vector to test
  3035. * @param min defines the minimum range
  3036. * @param max defines the maximum range
  3037. */
  3038. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3039. /**
  3040. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3041. * @param value1 defines the first control point
  3042. * @param tangent1 defines the first tangent vector
  3043. * @param value2 defines the second control point
  3044. * @param tangent2 defines the second tangent vector
  3045. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3046. * @returns the new Vector3
  3047. */
  3048. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3049. /**
  3050. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3051. * @param start defines the start value
  3052. * @param end defines the end value
  3053. * @param amount max defines amount between both (between 0 and 1)
  3054. * @returns the new Vector3
  3055. */
  3056. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3057. /**
  3058. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3059. * @param start defines the start value
  3060. * @param end defines the end value
  3061. * @param amount max defines amount between both (between 0 and 1)
  3062. * @param result defines the Vector3 where to store the result
  3063. */
  3064. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3065. /**
  3066. * Returns the dot product (float) between the vectors "left" and "right"
  3067. * @param left defines the left operand
  3068. * @param right defines the right operand
  3069. * @returns the dot product
  3070. */
  3071. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3072. /**
  3073. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3074. * The cross product is then orthogonal to both "left" and "right"
  3075. * @param left defines the left operand
  3076. * @param right defines the right operand
  3077. * @returns the cross product
  3078. */
  3079. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3080. /**
  3081. * Sets the given vector "result" with the cross product of "left" and "right"
  3082. * The cross product is then orthogonal to both "left" and "right"
  3083. * @param left defines the left operand
  3084. * @param right defines the right operand
  3085. * @param result defines the Vector3 where to store the result
  3086. */
  3087. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3088. /**
  3089. * Returns a new Vector3 as the normalization of the given vector
  3090. * @param vector defines the Vector3 to normalize
  3091. * @returns the new Vector3
  3092. */
  3093. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3094. /**
  3095. * Sets the given vector "result" with the normalization of the given first vector
  3096. * @param vector defines the Vector3 to normalize
  3097. * @param result defines the Vector3 where to store the result
  3098. */
  3099. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3100. /**
  3101. * Project a Vector3 onto screen space
  3102. * @param vector defines the Vector3 to project
  3103. * @param world defines the world matrix to use
  3104. * @param transform defines the transform (view x projection) matrix to use
  3105. * @param viewport defines the screen viewport to use
  3106. * @returns the new Vector3
  3107. */
  3108. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3109. /** @hidden */
  3110. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3111. /**
  3112. * Unproject from screen space to object space
  3113. * @param source defines the screen space Vector3 to use
  3114. * @param viewportWidth defines the current width of the viewport
  3115. * @param viewportHeight defines the current height of the viewport
  3116. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3117. * @param transform defines the transform (view x projection) matrix to use
  3118. * @returns the new Vector3
  3119. */
  3120. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3121. /**
  3122. * Unproject from screen space to object space
  3123. * @param source defines the screen space Vector3 to use
  3124. * @param viewportWidth defines the current width of the viewport
  3125. * @param viewportHeight defines the current height of the viewport
  3126. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3127. * @param view defines the view matrix to use
  3128. * @param projection defines the projection matrix to use
  3129. * @returns the new Vector3
  3130. */
  3131. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3132. /**
  3133. * Unproject from screen space to object space
  3134. * @param source defines the screen space Vector3 to use
  3135. * @param viewportWidth defines the current width of the viewport
  3136. * @param viewportHeight defines the current height of the viewport
  3137. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3138. * @param view defines the view matrix to use
  3139. * @param projection defines the projection matrix to use
  3140. * @param result defines the Vector3 where to store the result
  3141. */
  3142. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3143. /**
  3144. * Unproject from screen space to object space
  3145. * @param sourceX defines the screen space x coordinate to use
  3146. * @param sourceY defines the screen space y coordinate to use
  3147. * @param sourceZ defines the screen space z coordinate to use
  3148. * @param viewportWidth defines the current width of the viewport
  3149. * @param viewportHeight defines the current height of the viewport
  3150. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3151. * @param view defines the view matrix to use
  3152. * @param projection defines the projection matrix to use
  3153. * @param result defines the Vector3 where to store the result
  3154. */
  3155. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3156. /**
  3157. * Gets the minimal coordinate values between two Vector3
  3158. * @param left defines the first operand
  3159. * @param right defines the second operand
  3160. * @returns the new Vector3
  3161. */
  3162. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3163. /**
  3164. * Gets the maximal coordinate values between two Vector3
  3165. * @param left defines the first operand
  3166. * @param right defines the second operand
  3167. * @returns the new Vector3
  3168. */
  3169. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3170. /**
  3171. * Returns the distance between the vectors "value1" and "value2"
  3172. * @param value1 defines the first operand
  3173. * @param value2 defines the second operand
  3174. * @returns the distance
  3175. */
  3176. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3177. /**
  3178. * Returns the squared distance between the vectors "value1" and "value2"
  3179. * @param value1 defines the first operand
  3180. * @param value2 defines the second operand
  3181. * @returns the squared distance
  3182. */
  3183. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3184. /**
  3185. * Returns a new Vector3 located at the center between "value1" and "value2"
  3186. * @param value1 defines the first operand
  3187. * @param value2 defines the second operand
  3188. * @returns the new Vector3
  3189. */
  3190. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3191. /**
  3192. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3193. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3194. * to something in order to rotate it from its local system to the given target system
  3195. * Note: axis1, axis2 and axis3 are normalized during this operation
  3196. * @param axis1 defines the first axis
  3197. * @param axis2 defines the second axis
  3198. * @param axis3 defines the third axis
  3199. * @returns a new Vector3
  3200. */
  3201. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3202. /**
  3203. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3204. * @param axis1 defines the first axis
  3205. * @param axis2 defines the second axis
  3206. * @param axis3 defines the third axis
  3207. * @param ref defines the Vector3 where to store the result
  3208. */
  3209. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3210. }
  3211. /**
  3212. * Vector4 class created for EulerAngle class conversion to Quaternion
  3213. */
  3214. export class Vector4 {
  3215. /** x value of the vector */
  3216. x: number;
  3217. /** y value of the vector */
  3218. y: number;
  3219. /** z value of the vector */
  3220. z: number;
  3221. /** w value of the vector */
  3222. w: number;
  3223. /**
  3224. * Creates a Vector4 object from the given floats.
  3225. * @param x x value of the vector
  3226. * @param y y value of the vector
  3227. * @param z z value of the vector
  3228. * @param w w value of the vector
  3229. */
  3230. constructor(
  3231. /** x value of the vector */
  3232. x: number,
  3233. /** y value of the vector */
  3234. y: number,
  3235. /** z value of the vector */
  3236. z: number,
  3237. /** w value of the vector */
  3238. w: number);
  3239. /**
  3240. * Returns the string with the Vector4 coordinates.
  3241. * @returns a string containing all the vector values
  3242. */
  3243. toString(): string;
  3244. /**
  3245. * Returns the string "Vector4".
  3246. * @returns "Vector4"
  3247. */
  3248. getClassName(): string;
  3249. /**
  3250. * Returns the Vector4 hash code.
  3251. * @returns a unique hash code
  3252. */
  3253. getHashCode(): number;
  3254. /**
  3255. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3256. * @returns the resulting array
  3257. */
  3258. asArray(): number[];
  3259. /**
  3260. * Populates the given array from the given index with the Vector4 coordinates.
  3261. * @param array array to populate
  3262. * @param index index of the array to start at (default: 0)
  3263. * @returns the Vector4.
  3264. */
  3265. toArray(array: FloatArray, index?: number): Vector4;
  3266. /**
  3267. * Update the current vector from an array
  3268. * @param array defines the destination array
  3269. * @param index defines the offset in the destination array
  3270. * @returns the current Vector3
  3271. */
  3272. fromArray(array: FloatArray, index?: number): Vector4;
  3273. /**
  3274. * Adds the given vector to the current Vector4.
  3275. * @param otherVector the vector to add
  3276. * @returns the updated Vector4.
  3277. */
  3278. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3279. /**
  3280. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3281. * @param otherVector the vector to add
  3282. * @returns the resulting vector
  3283. */
  3284. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3285. /**
  3286. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3287. * @param otherVector the vector to add
  3288. * @param result the vector to store the result
  3289. * @returns the current Vector4.
  3290. */
  3291. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3292. /**
  3293. * Subtract in place the given vector from the current Vector4.
  3294. * @param otherVector the vector to subtract
  3295. * @returns the updated Vector4.
  3296. */
  3297. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3298. /**
  3299. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3300. * @param otherVector the vector to add
  3301. * @returns the new vector with the result
  3302. */
  3303. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3304. /**
  3305. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3306. * @param otherVector the vector to subtract
  3307. * @param result the vector to store the result
  3308. * @returns the current Vector4.
  3309. */
  3310. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3311. /**
  3312. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3313. */
  3314. /**
  3315. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3316. * @param x value to subtract
  3317. * @param y value to subtract
  3318. * @param z value to subtract
  3319. * @param w value to subtract
  3320. * @returns new vector containing the result
  3321. */
  3322. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3323. /**
  3324. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3325. * @param x value to subtract
  3326. * @param y value to subtract
  3327. * @param z value to subtract
  3328. * @param w value to subtract
  3329. * @param result the vector to store the result in
  3330. * @returns the current Vector4.
  3331. */
  3332. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3333. /**
  3334. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3335. * @returns a new vector with the negated values
  3336. */
  3337. negate(): Vector4;
  3338. /**
  3339. * Negate this vector in place
  3340. * @returns this
  3341. */
  3342. negateInPlace(): Vector4;
  3343. /**
  3344. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3345. * @param result defines the Vector3 object where to store the result
  3346. * @returns the current Vector4
  3347. */
  3348. negateToRef(result: Vector4): Vector4;
  3349. /**
  3350. * Multiplies the current Vector4 coordinates by scale (float).
  3351. * @param scale the number to scale with
  3352. * @returns the updated Vector4.
  3353. */
  3354. scaleInPlace(scale: number): Vector4;
  3355. /**
  3356. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3357. * @param scale the number to scale with
  3358. * @returns a new vector with the result
  3359. */
  3360. scale(scale: number): Vector4;
  3361. /**
  3362. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3363. * @param scale the number to scale with
  3364. * @param result a vector to store the result in
  3365. * @returns the current Vector4.
  3366. */
  3367. scaleToRef(scale: number, result: Vector4): Vector4;
  3368. /**
  3369. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3370. * @param scale defines the scale factor
  3371. * @param result defines the Vector4 object where to store the result
  3372. * @returns the unmodified current Vector4
  3373. */
  3374. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3375. /**
  3376. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3377. * @param otherVector the vector to compare against
  3378. * @returns true if they are equal
  3379. */
  3380. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3381. /**
  3382. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3383. * @param otherVector vector to compare against
  3384. * @param epsilon (Default: very small number)
  3385. * @returns true if they are equal
  3386. */
  3387. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3388. /**
  3389. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3390. * @param x x value to compare against
  3391. * @param y y value to compare against
  3392. * @param z z value to compare against
  3393. * @param w w value to compare against
  3394. * @returns true if equal
  3395. */
  3396. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3397. /**
  3398. * Multiplies in place the current Vector4 by the given one.
  3399. * @param otherVector vector to multiple with
  3400. * @returns the updated Vector4.
  3401. */
  3402. multiplyInPlace(otherVector: Vector4): Vector4;
  3403. /**
  3404. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3405. * @param otherVector vector to multiple with
  3406. * @returns resulting new vector
  3407. */
  3408. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3409. /**
  3410. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3411. * @param otherVector vector to multiple with
  3412. * @param result vector to store the result
  3413. * @returns the current Vector4.
  3414. */
  3415. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3416. /**
  3417. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3418. * @param x x value multiply with
  3419. * @param y y value multiply with
  3420. * @param z z value multiply with
  3421. * @param w w value multiply with
  3422. * @returns resulting new vector
  3423. */
  3424. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3425. /**
  3426. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3427. * @param otherVector vector to devide with
  3428. * @returns resulting new vector
  3429. */
  3430. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3431. /**
  3432. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3433. * @param otherVector vector to devide with
  3434. * @param result vector to store the result
  3435. * @returns the current Vector4.
  3436. */
  3437. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3438. /**
  3439. * Divides the current Vector3 coordinates by the given ones.
  3440. * @param otherVector vector to devide with
  3441. * @returns the updated Vector3.
  3442. */
  3443. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3444. /**
  3445. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3446. * @param other defines the second operand
  3447. * @returns the current updated Vector4
  3448. */
  3449. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3450. /**
  3451. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3452. * @param other defines the second operand
  3453. * @returns the current updated Vector4
  3454. */
  3455. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3456. /**
  3457. * Gets a new Vector4 from current Vector4 floored values
  3458. * @returns a new Vector4
  3459. */
  3460. floor(): Vector4;
  3461. /**
  3462. * Gets a new Vector4 from current Vector3 floored values
  3463. * @returns a new Vector4
  3464. */
  3465. fract(): Vector4;
  3466. /**
  3467. * Returns the Vector4 length (float).
  3468. * @returns the length
  3469. */
  3470. length(): number;
  3471. /**
  3472. * Returns the Vector4 squared length (float).
  3473. * @returns the length squared
  3474. */
  3475. lengthSquared(): number;
  3476. /**
  3477. * Normalizes in place the Vector4.
  3478. * @returns the updated Vector4.
  3479. */
  3480. normalize(): Vector4;
  3481. /**
  3482. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3483. * @returns this converted to a new vector3
  3484. */
  3485. toVector3(): Vector3;
  3486. /**
  3487. * Returns a new Vector4 copied from the current one.
  3488. * @returns the new cloned vector
  3489. */
  3490. clone(): Vector4;
  3491. /**
  3492. * Updates the current Vector4 with the given one coordinates.
  3493. * @param source the source vector to copy from
  3494. * @returns the updated Vector4.
  3495. */
  3496. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3497. /**
  3498. * Updates the current Vector4 coordinates with the given floats.
  3499. * @param x float to copy from
  3500. * @param y float to copy from
  3501. * @param z float to copy from
  3502. * @param w float to copy from
  3503. * @returns the updated Vector4.
  3504. */
  3505. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3506. /**
  3507. * Updates the current Vector4 coordinates with the given floats.
  3508. * @param x float to set from
  3509. * @param y float to set from
  3510. * @param z float to set from
  3511. * @param w float to set from
  3512. * @returns the updated Vector4.
  3513. */
  3514. set(x: number, y: number, z: number, w: number): Vector4;
  3515. /**
  3516. * Copies the given float to the current Vector3 coordinates
  3517. * @param v defines the x, y, z and w coordinates of the operand
  3518. * @returns the current updated Vector3
  3519. */
  3520. setAll(v: number): Vector4;
  3521. /**
  3522. * Returns a new Vector4 set from the starting index of the given array.
  3523. * @param array the array to pull values from
  3524. * @param offset the offset into the array to start at
  3525. * @returns the new vector
  3526. */
  3527. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3528. /**
  3529. * Updates the given vector "result" from the starting index of the given array.
  3530. * @param array the array to pull values from
  3531. * @param offset the offset into the array to start at
  3532. * @param result the vector to store the result in
  3533. */
  3534. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3535. /**
  3536. * Updates the given vector "result" from the starting index of the given Float32Array.
  3537. * @param array the array to pull values from
  3538. * @param offset the offset into the array to start at
  3539. * @param result the vector to store the result in
  3540. */
  3541. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3542. /**
  3543. * Updates the given vector "result" coordinates from the given floats.
  3544. * @param x float to set from
  3545. * @param y float to set from
  3546. * @param z float to set from
  3547. * @param w float to set from
  3548. * @param result the vector to the floats in
  3549. */
  3550. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3551. /**
  3552. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3553. * @returns the new vector
  3554. */
  3555. static Zero(): Vector4;
  3556. /**
  3557. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3558. * @returns the new vector
  3559. */
  3560. static One(): Vector4;
  3561. /**
  3562. * Returns a new normalized Vector4 from the given one.
  3563. * @param vector the vector to normalize
  3564. * @returns the vector
  3565. */
  3566. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3567. /**
  3568. * Updates the given vector "result" from the normalization of the given one.
  3569. * @param vector the vector to normalize
  3570. * @param result the vector to store the result in
  3571. */
  3572. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3573. /**
  3574. * Returns a vector with the minimum values from the left and right vectors
  3575. * @param left left vector to minimize
  3576. * @param right right vector to minimize
  3577. * @returns a new vector with the minimum of the left and right vector values
  3578. */
  3579. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3580. /**
  3581. * Returns a vector with the maximum values from the left and right vectors
  3582. * @param left left vector to maximize
  3583. * @param right right vector to maximize
  3584. * @returns a new vector with the maximum of the left and right vector values
  3585. */
  3586. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3587. /**
  3588. * Returns the distance (float) between the vectors "value1" and "value2".
  3589. * @param value1 value to calulate the distance between
  3590. * @param value2 value to calulate the distance between
  3591. * @return the distance between the two vectors
  3592. */
  3593. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3594. /**
  3595. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3596. * @param value1 value to calulate the distance between
  3597. * @param value2 value to calulate the distance between
  3598. * @return the distance between the two vectors squared
  3599. */
  3600. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3601. /**
  3602. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3603. * @param value1 value to calulate the center between
  3604. * @param value2 value to calulate the center between
  3605. * @return the center between the two vectors
  3606. */
  3607. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3608. /**
  3609. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3610. * This methods computes transformed normalized direction vectors only.
  3611. * @param vector the vector to transform
  3612. * @param transformation the transformation matrix to apply
  3613. * @returns the new vector
  3614. */
  3615. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3616. /**
  3617. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3618. * This methods computes transformed normalized direction vectors only.
  3619. * @param vector the vector to transform
  3620. * @param transformation the transformation matrix to apply
  3621. * @param result the vector to store the result in
  3622. */
  3623. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3624. /**
  3625. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3626. * This methods computes transformed normalized direction vectors only.
  3627. * @param x value to transform
  3628. * @param y value to transform
  3629. * @param z value to transform
  3630. * @param w value to transform
  3631. * @param transformation the transformation matrix to apply
  3632. * @param result the vector to store the results in
  3633. */
  3634. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3635. /**
  3636. * Creates a new Vector4 from a Vector3
  3637. * @param source defines the source data
  3638. * @param w defines the 4th component (default is 0)
  3639. * @returns a new Vector4
  3640. */
  3641. static FromVector3(source: Vector3, w?: number): Vector4;
  3642. }
  3643. /**
  3644. * Class used to store quaternion data
  3645. * @see https://en.wikipedia.org/wiki/Quaternion
  3646. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3647. */
  3648. export class Quaternion {
  3649. /** @hidden */
  3650. _x: number;
  3651. /** @hidden */
  3652. _y: number;
  3653. /** @hidden */
  3654. _z: number;
  3655. /** @hidden */
  3656. _w: number;
  3657. /** @hidden */
  3658. _isDirty: boolean;
  3659. /** Gets or sets the x coordinate */
  3660. get x(): number;
  3661. set x(value: number);
  3662. /** Gets or sets the y coordinate */
  3663. get y(): number;
  3664. set y(value: number);
  3665. /** Gets or sets the z coordinate */
  3666. get z(): number;
  3667. set z(value: number);
  3668. /** Gets or sets the w coordinate */
  3669. get w(): number;
  3670. set w(value: number);
  3671. /**
  3672. * Creates a new Quaternion from the given floats
  3673. * @param x defines the first component (0 by default)
  3674. * @param y defines the second component (0 by default)
  3675. * @param z defines the third component (0 by default)
  3676. * @param w defines the fourth component (1.0 by default)
  3677. */
  3678. constructor(x?: number, y?: number, z?: number, w?: number);
  3679. /**
  3680. * Gets a string representation for the current quaternion
  3681. * @returns a string with the Quaternion coordinates
  3682. */
  3683. toString(): string;
  3684. /**
  3685. * Gets the class name of the quaternion
  3686. * @returns the string "Quaternion"
  3687. */
  3688. getClassName(): string;
  3689. /**
  3690. * Gets a hash code for this quaternion
  3691. * @returns the quaternion hash code
  3692. */
  3693. getHashCode(): number;
  3694. /**
  3695. * Copy the quaternion to an array
  3696. * @returns a new array populated with 4 elements from the quaternion coordinates
  3697. */
  3698. asArray(): number[];
  3699. /**
  3700. * Check if two quaternions are equals
  3701. * @param otherQuaternion defines the second operand
  3702. * @return true if the current quaternion and the given one coordinates are strictly equals
  3703. */
  3704. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3705. /**
  3706. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3707. * @param otherQuaternion defines the other quaternion
  3708. * @param epsilon defines the minimal distance to consider equality
  3709. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3710. */
  3711. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3712. /**
  3713. * Clone the current quaternion
  3714. * @returns a new quaternion copied from the current one
  3715. */
  3716. clone(): Quaternion;
  3717. /**
  3718. * Copy a quaternion to the current one
  3719. * @param other defines the other quaternion
  3720. * @returns the updated current quaternion
  3721. */
  3722. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3723. /**
  3724. * Updates the current quaternion with the given float coordinates
  3725. * @param x defines the x coordinate
  3726. * @param y defines the y coordinate
  3727. * @param z defines the z coordinate
  3728. * @param w defines the w coordinate
  3729. * @returns the updated current quaternion
  3730. */
  3731. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3732. /**
  3733. * Updates the current quaternion from the given float coordinates
  3734. * @param x defines the x coordinate
  3735. * @param y defines the y coordinate
  3736. * @param z defines the z coordinate
  3737. * @param w defines the w coordinate
  3738. * @returns the updated current quaternion
  3739. */
  3740. set(x: number, y: number, z: number, w: number): Quaternion;
  3741. /**
  3742. * Adds two quaternions
  3743. * @param other defines the second operand
  3744. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3745. */
  3746. add(other: DeepImmutable<Quaternion>): Quaternion;
  3747. /**
  3748. * Add a quaternion to the current one
  3749. * @param other defines the quaternion to add
  3750. * @returns the current quaternion
  3751. */
  3752. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3753. /**
  3754. * Subtract two quaternions
  3755. * @param other defines the second operand
  3756. * @returns a new quaternion as the subtraction result of the given one from the current one
  3757. */
  3758. subtract(other: Quaternion): Quaternion;
  3759. /**
  3760. * Multiplies the current quaternion by a scale factor
  3761. * @param value defines the scale factor
  3762. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3763. */
  3764. scale(value: number): Quaternion;
  3765. /**
  3766. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3767. * @param scale defines the scale factor
  3768. * @param result defines the Quaternion object where to store the result
  3769. * @returns the unmodified current quaternion
  3770. */
  3771. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3772. /**
  3773. * Multiplies in place the current quaternion by a scale factor
  3774. * @param value defines the scale factor
  3775. * @returns the current modified quaternion
  3776. */
  3777. scaleInPlace(value: number): Quaternion;
  3778. /**
  3779. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3780. * @param scale defines the scale factor
  3781. * @param result defines the Quaternion object where to store the result
  3782. * @returns the unmodified current quaternion
  3783. */
  3784. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3785. /**
  3786. * Multiplies two quaternions
  3787. * @param q1 defines the second operand
  3788. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3789. */
  3790. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3791. /**
  3792. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3793. * @param q1 defines the second operand
  3794. * @param result defines the target quaternion
  3795. * @returns the current quaternion
  3796. */
  3797. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3798. /**
  3799. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3800. * @param q1 defines the second operand
  3801. * @returns the currentupdated quaternion
  3802. */
  3803. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3804. /**
  3805. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3806. * @param ref defines the target quaternion
  3807. * @returns the current quaternion
  3808. */
  3809. conjugateToRef(ref: Quaternion): Quaternion;
  3810. /**
  3811. * Conjugates in place (1-q) the current quaternion
  3812. * @returns the current updated quaternion
  3813. */
  3814. conjugateInPlace(): Quaternion;
  3815. /**
  3816. * Conjugates in place (1-q) the current quaternion
  3817. * @returns a new quaternion
  3818. */
  3819. conjugate(): Quaternion;
  3820. /**
  3821. * Gets length of current quaternion
  3822. * @returns the quaternion length (float)
  3823. */
  3824. length(): number;
  3825. /**
  3826. * Normalize in place the current quaternion
  3827. * @returns the current updated quaternion
  3828. */
  3829. normalize(): Quaternion;
  3830. /**
  3831. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3832. * @param order is a reserved parameter and is ignore for now
  3833. * @returns a new Vector3 containing the Euler angles
  3834. */
  3835. toEulerAngles(order?: string): Vector3;
  3836. /**
  3837. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3838. * @param result defines the vector which will be filled with the Euler angles
  3839. * @param order is a reserved parameter and is ignore for now
  3840. * @returns the current unchanged quaternion
  3841. */
  3842. toEulerAnglesToRef(result: Vector3): Quaternion;
  3843. /**
  3844. * Updates the given rotation matrix with the current quaternion values
  3845. * @param result defines the target matrix
  3846. * @returns the current unchanged quaternion
  3847. */
  3848. toRotationMatrix(result: Matrix): Quaternion;
  3849. /**
  3850. * Updates the current quaternion from the given rotation matrix values
  3851. * @param matrix defines the source matrix
  3852. * @returns the current updated quaternion
  3853. */
  3854. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3855. /**
  3856. * Creates a new quaternion from a rotation matrix
  3857. * @param matrix defines the source matrix
  3858. * @returns a new quaternion created from the given rotation matrix values
  3859. */
  3860. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3861. /**
  3862. * Updates the given quaternion with the given rotation matrix values
  3863. * @param matrix defines the source matrix
  3864. * @param result defines the target quaternion
  3865. */
  3866. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3867. /**
  3868. * Returns the dot product (float) between the quaternions "left" and "right"
  3869. * @param left defines the left operand
  3870. * @param right defines the right operand
  3871. * @returns the dot product
  3872. */
  3873. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3874. /**
  3875. * Checks if the two quaternions are close to each other
  3876. * @param quat0 defines the first quaternion to check
  3877. * @param quat1 defines the second quaternion to check
  3878. * @returns true if the two quaternions are close to each other
  3879. */
  3880. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3881. /**
  3882. * Creates an empty quaternion
  3883. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3884. */
  3885. static Zero(): Quaternion;
  3886. /**
  3887. * Inverse a given quaternion
  3888. * @param q defines the source quaternion
  3889. * @returns a new quaternion as the inverted current quaternion
  3890. */
  3891. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3892. /**
  3893. * Inverse a given quaternion
  3894. * @param q defines the source quaternion
  3895. * @param result the quaternion the result will be stored in
  3896. * @returns the result quaternion
  3897. */
  3898. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3899. /**
  3900. * Creates an identity quaternion
  3901. * @returns the identity quaternion
  3902. */
  3903. static Identity(): Quaternion;
  3904. /**
  3905. * Gets a boolean indicating if the given quaternion is identity
  3906. * @param quaternion defines the quaternion to check
  3907. * @returns true if the quaternion is identity
  3908. */
  3909. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3910. /**
  3911. * Creates a quaternion from a rotation around an axis
  3912. * @param axis defines the axis to use
  3913. * @param angle defines the angle to use
  3914. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3915. */
  3916. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3917. /**
  3918. * Creates a rotation around an axis and stores it into the given quaternion
  3919. * @param axis defines the axis to use
  3920. * @param angle defines the angle to use
  3921. * @param result defines the target quaternion
  3922. * @returns the target quaternion
  3923. */
  3924. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3925. /**
  3926. * Creates a new quaternion from data stored into an array
  3927. * @param array defines the data source
  3928. * @param offset defines the offset in the source array where the data starts
  3929. * @returns a new quaternion
  3930. */
  3931. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3932. /**
  3933. * Updates the given quaternion "result" from the starting index of the given array.
  3934. * @param array the array to pull values from
  3935. * @param offset the offset into the array to start at
  3936. * @param result the quaternion to store the result in
  3937. */
  3938. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3939. /**
  3940. * Create a quaternion from Euler rotation angles
  3941. * @param x Pitch
  3942. * @param y Yaw
  3943. * @param z Roll
  3944. * @returns the new Quaternion
  3945. */
  3946. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3947. /**
  3948. * Updates a quaternion from Euler rotation angles
  3949. * @param x Pitch
  3950. * @param y Yaw
  3951. * @param z Roll
  3952. * @param result the quaternion to store the result
  3953. * @returns the updated quaternion
  3954. */
  3955. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3956. /**
  3957. * Create a quaternion from Euler rotation vector
  3958. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3959. * @returns the new Quaternion
  3960. */
  3961. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3962. /**
  3963. * Updates a quaternion from Euler rotation vector
  3964. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3965. * @param result the quaternion to store the result
  3966. * @returns the updated quaternion
  3967. */
  3968. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3969. /**
  3970. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3971. * @param yaw defines the rotation around Y axis
  3972. * @param pitch defines the rotation around X axis
  3973. * @param roll defines the rotation around Z axis
  3974. * @returns the new quaternion
  3975. */
  3976. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3977. /**
  3978. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3979. * @param yaw defines the rotation around Y axis
  3980. * @param pitch defines the rotation around X axis
  3981. * @param roll defines the rotation around Z axis
  3982. * @param result defines the target quaternion
  3983. */
  3984. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3985. /**
  3986. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3987. * @param alpha defines the rotation around first axis
  3988. * @param beta defines the rotation around second axis
  3989. * @param gamma defines the rotation around third axis
  3990. * @returns the new quaternion
  3991. */
  3992. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3993. /**
  3994. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3995. * @param alpha defines the rotation around first axis
  3996. * @param beta defines the rotation around second axis
  3997. * @param gamma defines the rotation around third axis
  3998. * @param result defines the target quaternion
  3999. */
  4000. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4001. /**
  4002. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  4003. * @param axis1 defines the first axis
  4004. * @param axis2 defines the second axis
  4005. * @param axis3 defines the third axis
  4006. * @returns the new quaternion
  4007. */
  4008. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4009. /**
  4010. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  4011. * @param axis1 defines the first axis
  4012. * @param axis2 defines the second axis
  4013. * @param axis3 defines the third axis
  4014. * @param ref defines the target quaternion
  4015. */
  4016. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4017. /**
  4018. * Interpolates between two quaternions
  4019. * @param left defines first quaternion
  4020. * @param right defines second quaternion
  4021. * @param amount defines the gradient to use
  4022. * @returns the new interpolated quaternion
  4023. */
  4024. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4025. /**
  4026. * Interpolates between two quaternions and stores it into a target quaternion
  4027. * @param left defines first quaternion
  4028. * @param right defines second quaternion
  4029. * @param amount defines the gradient to use
  4030. * @param result defines the target quaternion
  4031. */
  4032. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4033. /**
  4034. * Interpolate between two quaternions using Hermite interpolation
  4035. * @param value1 defines first quaternion
  4036. * @param tangent1 defines the incoming tangent
  4037. * @param value2 defines second quaternion
  4038. * @param tangent2 defines the outgoing tangent
  4039. * @param amount defines the target quaternion
  4040. * @returns the new interpolated quaternion
  4041. */
  4042. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4043. }
  4044. /**
  4045. * Class used to store matrix data (4x4)
  4046. */
  4047. export class Matrix {
  4048. /**
  4049. * Gets the precision of matrix computations
  4050. */
  4051. static get Use64Bits(): boolean;
  4052. private static _updateFlagSeed;
  4053. private static _identityReadOnly;
  4054. private _isIdentity;
  4055. private _isIdentityDirty;
  4056. private _isIdentity3x2;
  4057. private _isIdentity3x2Dirty;
  4058. /**
  4059. * Gets the update flag of the matrix which is an unique number for the matrix.
  4060. * It will be incremented every time the matrix data change.
  4061. * You can use it to speed the comparison between two versions of the same matrix.
  4062. */
  4063. updateFlag: number;
  4064. private readonly _m;
  4065. /**
  4066. * Gets the internal data of the matrix
  4067. */
  4068. get m(): DeepImmutable<Float32Array | Array<number>>;
  4069. /** @hidden */
  4070. _markAsUpdated(): void;
  4071. /** @hidden */
  4072. private _updateIdentityStatus;
  4073. /**
  4074. * Creates an empty matrix (filled with zeros)
  4075. */
  4076. constructor();
  4077. /**
  4078. * Check if the current matrix is identity
  4079. * @returns true is the matrix is the identity matrix
  4080. */
  4081. isIdentity(): boolean;
  4082. /**
  4083. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4084. * @returns true is the matrix is the identity matrix
  4085. */
  4086. isIdentityAs3x2(): boolean;
  4087. /**
  4088. * Gets the determinant of the matrix
  4089. * @returns the matrix determinant
  4090. */
  4091. determinant(): number;
  4092. /**
  4093. * Returns the matrix as a Float32Array or Array<number>
  4094. * @returns the matrix underlying array
  4095. */
  4096. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4097. /**
  4098. * Returns the matrix as a Float32Array or Array<number>
  4099. * @returns the matrix underlying array.
  4100. */
  4101. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4102. /**
  4103. * Inverts the current matrix in place
  4104. * @returns the current inverted matrix
  4105. */
  4106. invert(): Matrix;
  4107. /**
  4108. * Sets all the matrix elements to zero
  4109. * @returns the current matrix
  4110. */
  4111. reset(): Matrix;
  4112. /**
  4113. * Adds the current matrix with a second one
  4114. * @param other defines the matrix to add
  4115. * @returns a new matrix as the addition of the current matrix and the given one
  4116. */
  4117. add(other: DeepImmutable<Matrix>): Matrix;
  4118. /**
  4119. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4120. * @param other defines the matrix to add
  4121. * @param result defines the target matrix
  4122. * @returns the current matrix
  4123. */
  4124. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4125. /**
  4126. * Adds in place the given matrix to the current matrix
  4127. * @param other defines the second operand
  4128. * @returns the current updated matrix
  4129. */
  4130. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4131. /**
  4132. * Sets the given matrix to the current inverted Matrix
  4133. * @param other defines the target matrix
  4134. * @returns the unmodified current matrix
  4135. */
  4136. invertToRef(other: Matrix): Matrix;
  4137. /**
  4138. * add a value at the specified position in the current Matrix
  4139. * @param index the index of the value within the matrix. between 0 and 15.
  4140. * @param value the value to be added
  4141. * @returns the current updated matrix
  4142. */
  4143. addAtIndex(index: number, value: number): Matrix;
  4144. /**
  4145. * mutiply the specified position in the current Matrix by a value
  4146. * @param index the index of the value within the matrix. between 0 and 15.
  4147. * @param value the value to be added
  4148. * @returns the current updated matrix
  4149. */
  4150. multiplyAtIndex(index: number, value: number): Matrix;
  4151. /**
  4152. * Inserts the translation vector (using 3 floats) in the current matrix
  4153. * @param x defines the 1st component of the translation
  4154. * @param y defines the 2nd component of the translation
  4155. * @param z defines the 3rd component of the translation
  4156. * @returns the current updated matrix
  4157. */
  4158. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4159. /**
  4160. * Adds the translation vector (using 3 floats) in the current matrix
  4161. * @param x defines the 1st component of the translation
  4162. * @param y defines the 2nd component of the translation
  4163. * @param z defines the 3rd component of the translation
  4164. * @returns the current updated matrix
  4165. */
  4166. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4167. /**
  4168. * Inserts the translation vector in the current matrix
  4169. * @param vector3 defines the translation to insert
  4170. * @returns the current updated matrix
  4171. */
  4172. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4173. /**
  4174. * Gets the translation value of the current matrix
  4175. * @returns a new Vector3 as the extracted translation from the matrix
  4176. */
  4177. getTranslation(): Vector3;
  4178. /**
  4179. * Fill a Vector3 with the extracted translation from the matrix
  4180. * @param result defines the Vector3 where to store the translation
  4181. * @returns the current matrix
  4182. */
  4183. getTranslationToRef(result: Vector3): Matrix;
  4184. /**
  4185. * Remove rotation and scaling part from the matrix
  4186. * @returns the updated matrix
  4187. */
  4188. removeRotationAndScaling(): Matrix;
  4189. /**
  4190. * Multiply two matrices
  4191. * @param other defines the second operand
  4192. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4193. */
  4194. multiply(other: DeepImmutable<Matrix>): Matrix;
  4195. /**
  4196. * Copy the current matrix from the given one
  4197. * @param other defines the source matrix
  4198. * @returns the current updated matrix
  4199. */
  4200. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4201. /**
  4202. * Populates the given array from the starting index with the current matrix values
  4203. * @param array defines the target array
  4204. * @param offset defines the offset in the target array where to start storing values
  4205. * @returns the current matrix
  4206. */
  4207. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4208. /**
  4209. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4210. * @param other defines the second operand
  4211. * @param result defines the matrix where to store the multiplication
  4212. * @returns the current matrix
  4213. */
  4214. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4215. /**
  4216. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4217. * @param other defines the second operand
  4218. * @param result defines the array where to store the multiplication
  4219. * @param offset defines the offset in the target array where to start storing values
  4220. * @returns the current matrix
  4221. */
  4222. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4223. /**
  4224. * Check equality between this matrix and a second one
  4225. * @param value defines the second matrix to compare
  4226. * @returns true is the current matrix and the given one values are strictly equal
  4227. */
  4228. equals(value: DeepImmutable<Matrix>): boolean;
  4229. /**
  4230. * Clone the current matrix
  4231. * @returns a new matrix from the current matrix
  4232. */
  4233. clone(): Matrix;
  4234. /**
  4235. * Returns the name of the current matrix class
  4236. * @returns the string "Matrix"
  4237. */
  4238. getClassName(): string;
  4239. /**
  4240. * Gets the hash code of the current matrix
  4241. * @returns the hash code
  4242. */
  4243. getHashCode(): number;
  4244. /**
  4245. * Decomposes the current Matrix into a translation, rotation and scaling components
  4246. * @param scale defines the scale vector3 given as a reference to update
  4247. * @param rotation defines the rotation quaternion given as a reference to update
  4248. * @param translation defines the translation vector3 given as a reference to update
  4249. * @returns true if operation was successful
  4250. */
  4251. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4252. /**
  4253. * Gets specific row of the matrix
  4254. * @param index defines the number of the row to get
  4255. * @returns the index-th row of the current matrix as a new Vector4
  4256. */
  4257. getRow(index: number): Nullable<Vector4>;
  4258. /**
  4259. * Sets the index-th row of the current matrix to the vector4 values
  4260. * @param index defines the number of the row to set
  4261. * @param row defines the target vector4
  4262. * @returns the updated current matrix
  4263. */
  4264. setRow(index: number, row: Vector4): Matrix;
  4265. /**
  4266. * Compute the transpose of the matrix
  4267. * @returns the new transposed matrix
  4268. */
  4269. transpose(): Matrix;
  4270. /**
  4271. * Compute the transpose of the matrix and store it in a given matrix
  4272. * @param result defines the target matrix
  4273. * @returns the current matrix
  4274. */
  4275. transposeToRef(result: Matrix): Matrix;
  4276. /**
  4277. * Sets the index-th row of the current matrix with the given 4 x float values
  4278. * @param index defines the row index
  4279. * @param x defines the x component to set
  4280. * @param y defines the y component to set
  4281. * @param z defines the z component to set
  4282. * @param w defines the w component to set
  4283. * @returns the updated current matrix
  4284. */
  4285. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4286. /**
  4287. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4288. * @param scale defines the scale factor
  4289. * @returns a new matrix
  4290. */
  4291. scale(scale: number): Matrix;
  4292. /**
  4293. * Scale the current matrix values by a factor to a given result matrix
  4294. * @param scale defines the scale factor
  4295. * @param result defines the matrix to store the result
  4296. * @returns the current matrix
  4297. */
  4298. scaleToRef(scale: number, result: Matrix): Matrix;
  4299. /**
  4300. * Scale the current matrix values by a factor and add the result to a given matrix
  4301. * @param scale defines the scale factor
  4302. * @param result defines the Matrix to store the result
  4303. * @returns the current matrix
  4304. */
  4305. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4306. /**
  4307. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4308. * @param ref matrix to store the result
  4309. */
  4310. toNormalMatrix(ref: Matrix): void;
  4311. /**
  4312. * Gets only rotation part of the current matrix
  4313. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4314. */
  4315. getRotationMatrix(): Matrix;
  4316. /**
  4317. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4318. * @param result defines the target matrix to store data to
  4319. * @returns the current matrix
  4320. */
  4321. getRotationMatrixToRef(result: Matrix): Matrix;
  4322. /**
  4323. * Toggles model matrix from being right handed to left handed in place and vice versa
  4324. */
  4325. toggleModelMatrixHandInPlace(): void;
  4326. /**
  4327. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4328. */
  4329. toggleProjectionMatrixHandInPlace(): void;
  4330. /**
  4331. * Creates a matrix from an array
  4332. * @param array defines the source array
  4333. * @param offset defines an offset in the source array
  4334. * @returns a new Matrix set from the starting index of the given array
  4335. */
  4336. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4337. /**
  4338. * Copy the content of an array into a given matrix
  4339. * @param array defines the source array
  4340. * @param offset defines an offset in the source array
  4341. * @param result defines the target matrix
  4342. */
  4343. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4344. /**
  4345. * Stores an array into a matrix after having multiplied each component by a given factor
  4346. * @param array defines the source array
  4347. * @param offset defines the offset in the source array
  4348. * @param scale defines the scaling factor
  4349. * @param result defines the target matrix
  4350. */
  4351. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4352. /**
  4353. * Gets an identity matrix that must not be updated
  4354. */
  4355. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4356. /**
  4357. * Stores a list of values (16) inside a given matrix
  4358. * @param initialM11 defines 1st value of 1st row
  4359. * @param initialM12 defines 2nd value of 1st row
  4360. * @param initialM13 defines 3rd value of 1st row
  4361. * @param initialM14 defines 4th value of 1st row
  4362. * @param initialM21 defines 1st value of 2nd row
  4363. * @param initialM22 defines 2nd value of 2nd row
  4364. * @param initialM23 defines 3rd value of 2nd row
  4365. * @param initialM24 defines 4th value of 2nd row
  4366. * @param initialM31 defines 1st value of 3rd row
  4367. * @param initialM32 defines 2nd value of 3rd row
  4368. * @param initialM33 defines 3rd value of 3rd row
  4369. * @param initialM34 defines 4th value of 3rd row
  4370. * @param initialM41 defines 1st value of 4th row
  4371. * @param initialM42 defines 2nd value of 4th row
  4372. * @param initialM43 defines 3rd value of 4th row
  4373. * @param initialM44 defines 4th value of 4th row
  4374. * @param result defines the target matrix
  4375. */
  4376. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4377. /**
  4378. * Creates new matrix from a list of values (16)
  4379. * @param initialM11 defines 1st value of 1st row
  4380. * @param initialM12 defines 2nd value of 1st row
  4381. * @param initialM13 defines 3rd value of 1st row
  4382. * @param initialM14 defines 4th value of 1st row
  4383. * @param initialM21 defines 1st value of 2nd row
  4384. * @param initialM22 defines 2nd value of 2nd row
  4385. * @param initialM23 defines 3rd value of 2nd row
  4386. * @param initialM24 defines 4th value of 2nd row
  4387. * @param initialM31 defines 1st value of 3rd row
  4388. * @param initialM32 defines 2nd value of 3rd row
  4389. * @param initialM33 defines 3rd value of 3rd row
  4390. * @param initialM34 defines 4th value of 3rd row
  4391. * @param initialM41 defines 1st value of 4th row
  4392. * @param initialM42 defines 2nd value of 4th row
  4393. * @param initialM43 defines 3rd value of 4th row
  4394. * @param initialM44 defines 4th value of 4th row
  4395. * @returns the new matrix
  4396. */
  4397. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4398. /**
  4399. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4400. * @param scale defines the scale vector3
  4401. * @param rotation defines the rotation quaternion
  4402. * @param translation defines the translation vector3
  4403. * @returns a new matrix
  4404. */
  4405. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4406. /**
  4407. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4408. * @param scale defines the scale vector3
  4409. * @param rotation defines the rotation quaternion
  4410. * @param translation defines the translation vector3
  4411. * @param result defines the target matrix
  4412. */
  4413. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4414. /**
  4415. * Creates a new identity matrix
  4416. * @returns a new identity matrix
  4417. */
  4418. static Identity(): Matrix;
  4419. /**
  4420. * Creates a new identity matrix and stores the result in a given matrix
  4421. * @param result defines the target matrix
  4422. */
  4423. static IdentityToRef(result: Matrix): void;
  4424. /**
  4425. * Creates a new zero matrix
  4426. * @returns a new zero matrix
  4427. */
  4428. static Zero(): Matrix;
  4429. /**
  4430. * Creates a new rotation matrix for "angle" radians around the X axis
  4431. * @param angle defines the angle (in radians) to use
  4432. * @return the new matrix
  4433. */
  4434. static RotationX(angle: number): Matrix;
  4435. /**
  4436. * Creates a new matrix as the invert of a given matrix
  4437. * @param source defines the source matrix
  4438. * @returns the new matrix
  4439. */
  4440. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4441. /**
  4442. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4443. * @param angle defines the angle (in radians) to use
  4444. * @param result defines the target matrix
  4445. */
  4446. static RotationXToRef(angle: number, result: Matrix): void;
  4447. /**
  4448. * Creates a new rotation matrix for "angle" radians around the Y axis
  4449. * @param angle defines the angle (in radians) to use
  4450. * @return the new matrix
  4451. */
  4452. static RotationY(angle: number): Matrix;
  4453. /**
  4454. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4455. * @param angle defines the angle (in radians) to use
  4456. * @param result defines the target matrix
  4457. */
  4458. static RotationYToRef(angle: number, result: Matrix): void;
  4459. /**
  4460. * Creates a new rotation matrix for "angle" radians around the Z axis
  4461. * @param angle defines the angle (in radians) to use
  4462. * @return the new matrix
  4463. */
  4464. static RotationZ(angle: number): Matrix;
  4465. /**
  4466. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4467. * @param angle defines the angle (in radians) to use
  4468. * @param result defines the target matrix
  4469. */
  4470. static RotationZToRef(angle: number, result: Matrix): void;
  4471. /**
  4472. * Creates a new rotation matrix for "angle" radians around the given axis
  4473. * @param axis defines the axis to use
  4474. * @param angle defines the angle (in radians) to use
  4475. * @return the new matrix
  4476. */
  4477. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4478. /**
  4479. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4480. * @param axis defines the axis to use
  4481. * @param angle defines the angle (in radians) to use
  4482. * @param result defines the target matrix
  4483. */
  4484. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4485. /**
  4486. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4487. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4488. * @param from defines the vector to align
  4489. * @param to defines the vector to align to
  4490. * @param result defines the target matrix
  4491. */
  4492. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4493. /**
  4494. * Creates a rotation matrix
  4495. * @param yaw defines the yaw angle in radians (Y axis)
  4496. * @param pitch defines the pitch angle in radians (X axis)
  4497. * @param roll defines the roll angle in radians (Z axis)
  4498. * @returns the new rotation matrix
  4499. */
  4500. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4501. /**
  4502. * Creates a rotation matrix and stores it in a given matrix
  4503. * @param yaw defines the yaw angle in radians (Y axis)
  4504. * @param pitch defines the pitch angle in radians (X axis)
  4505. * @param roll defines the roll angle in radians (Z axis)
  4506. * @param result defines the target matrix
  4507. */
  4508. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4509. /**
  4510. * Creates a scaling matrix
  4511. * @param x defines the scale factor on X axis
  4512. * @param y defines the scale factor on Y axis
  4513. * @param z defines the scale factor on Z axis
  4514. * @returns the new matrix
  4515. */
  4516. static Scaling(x: number, y: number, z: number): Matrix;
  4517. /**
  4518. * Creates a scaling matrix and stores it in a given matrix
  4519. * @param x defines the scale factor on X axis
  4520. * @param y defines the scale factor on Y axis
  4521. * @param z defines the scale factor on Z axis
  4522. * @param result defines the target matrix
  4523. */
  4524. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4525. /**
  4526. * Creates a translation matrix
  4527. * @param x defines the translation on X axis
  4528. * @param y defines the translation on Y axis
  4529. * @param z defines the translationon Z axis
  4530. * @returns the new matrix
  4531. */
  4532. static Translation(x: number, y: number, z: number): Matrix;
  4533. /**
  4534. * Creates a translation matrix and stores it in a given matrix
  4535. * @param x defines the translation on X axis
  4536. * @param y defines the translation on Y axis
  4537. * @param z defines the translationon Z axis
  4538. * @param result defines the target matrix
  4539. */
  4540. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4541. /**
  4542. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4543. * @param startValue defines the start value
  4544. * @param endValue defines the end value
  4545. * @param gradient defines the gradient factor
  4546. * @returns the new matrix
  4547. */
  4548. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4549. /**
  4550. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4551. * @param startValue defines the start value
  4552. * @param endValue defines the end value
  4553. * @param gradient defines the gradient factor
  4554. * @param result defines the Matrix object where to store data
  4555. */
  4556. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4557. /**
  4558. * Builds a new matrix whose values are computed by:
  4559. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4560. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4561. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4562. * @param startValue defines the first matrix
  4563. * @param endValue defines the second matrix
  4564. * @param gradient defines the gradient between the two matrices
  4565. * @returns the new matrix
  4566. */
  4567. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4568. /**
  4569. * Update a matrix to values which are computed by:
  4570. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4571. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4572. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4573. * @param startValue defines the first matrix
  4574. * @param endValue defines the second matrix
  4575. * @param gradient defines the gradient between the two matrices
  4576. * @param result defines the target matrix
  4577. */
  4578. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4579. /**
  4580. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4581. * This function works in left handed mode
  4582. * @param eye defines the final position of the entity
  4583. * @param target defines where the entity should look at
  4584. * @param up defines the up vector for the entity
  4585. * @returns the new matrix
  4586. */
  4587. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4588. /**
  4589. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4590. * This function works in left handed mode
  4591. * @param eye defines the final position of the entity
  4592. * @param target defines where the entity should look at
  4593. * @param up defines the up vector for the entity
  4594. * @param result defines the target matrix
  4595. */
  4596. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4597. /**
  4598. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4599. * This function works in right handed mode
  4600. * @param eye defines the final position of the entity
  4601. * @param target defines where the entity should look at
  4602. * @param up defines the up vector for the entity
  4603. * @returns the new matrix
  4604. */
  4605. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4606. /**
  4607. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4608. * This function works in right handed mode
  4609. * @param eye defines the final position of the entity
  4610. * @param target defines where the entity should look at
  4611. * @param up defines the up vector for the entity
  4612. * @param result defines the target matrix
  4613. */
  4614. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4615. /**
  4616. * Create a left-handed orthographic projection matrix
  4617. * @param width defines the viewport width
  4618. * @param height defines the viewport height
  4619. * @param znear defines the near clip plane
  4620. * @param zfar defines the far clip plane
  4621. * @returns a new matrix as a left-handed orthographic projection matrix
  4622. */
  4623. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4624. /**
  4625. * Store a left-handed orthographic projection to a given matrix
  4626. * @param width defines the viewport width
  4627. * @param height defines the viewport height
  4628. * @param znear defines the near clip plane
  4629. * @param zfar defines the far clip plane
  4630. * @param result defines the target matrix
  4631. */
  4632. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4633. /**
  4634. * Create a left-handed orthographic projection matrix
  4635. * @param left defines the viewport left coordinate
  4636. * @param right defines the viewport right coordinate
  4637. * @param bottom defines the viewport bottom coordinate
  4638. * @param top defines the viewport top coordinate
  4639. * @param znear defines the near clip plane
  4640. * @param zfar defines the far clip plane
  4641. * @returns a new matrix as a left-handed orthographic projection matrix
  4642. */
  4643. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4644. /**
  4645. * Stores a left-handed orthographic projection into a given matrix
  4646. * @param left defines the viewport left coordinate
  4647. * @param right defines the viewport right coordinate
  4648. * @param bottom defines the viewport bottom coordinate
  4649. * @param top defines the viewport top coordinate
  4650. * @param znear defines the near clip plane
  4651. * @param zfar defines the far clip plane
  4652. * @param result defines the target matrix
  4653. */
  4654. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4655. /**
  4656. * Creates a right-handed orthographic projection matrix
  4657. * @param left defines the viewport left coordinate
  4658. * @param right defines the viewport right coordinate
  4659. * @param bottom defines the viewport bottom coordinate
  4660. * @param top defines the viewport top coordinate
  4661. * @param znear defines the near clip plane
  4662. * @param zfar defines the far clip plane
  4663. * @returns a new matrix as a right-handed orthographic projection matrix
  4664. */
  4665. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4666. /**
  4667. * Stores a right-handed orthographic projection into a given matrix
  4668. * @param left defines the viewport left coordinate
  4669. * @param right defines the viewport right coordinate
  4670. * @param bottom defines the viewport bottom coordinate
  4671. * @param top defines the viewport top coordinate
  4672. * @param znear defines the near clip plane
  4673. * @param zfar defines the far clip plane
  4674. * @param result defines the target matrix
  4675. */
  4676. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4677. /**
  4678. * Creates a left-handed perspective projection matrix
  4679. * @param width defines the viewport width
  4680. * @param height defines the viewport height
  4681. * @param znear defines the near clip plane
  4682. * @param zfar defines the far clip plane
  4683. * @returns a new matrix as a left-handed perspective projection matrix
  4684. */
  4685. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4686. /**
  4687. * Creates a left-handed perspective projection matrix
  4688. * @param fov defines the horizontal field of view
  4689. * @param aspect defines the aspect ratio
  4690. * @param znear defines the near clip plane
  4691. * @param zfar defines the far clip plane
  4692. * @returns a new matrix as a left-handed perspective projection matrix
  4693. */
  4694. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4695. /**
  4696. * Stores a left-handed perspective projection into a given matrix
  4697. * @param fov defines the horizontal field of view
  4698. * @param aspect defines the aspect ratio
  4699. * @param znear defines the near clip plane
  4700. * @param zfar defines the far clip plane
  4701. * @param result defines the target matrix
  4702. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4703. */
  4704. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4705. /**
  4706. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4707. * @param fov defines the horizontal field of view
  4708. * @param aspect defines the aspect ratio
  4709. * @param znear defines the near clip plane
  4710. * @param zfar not used as infinity is used as far clip
  4711. * @param result defines the target matrix
  4712. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4713. */
  4714. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4715. /**
  4716. * Creates a right-handed perspective projection matrix
  4717. * @param fov defines the horizontal field of view
  4718. * @param aspect defines the aspect ratio
  4719. * @param znear defines the near clip plane
  4720. * @param zfar defines the far clip plane
  4721. * @returns a new matrix as a right-handed perspective projection matrix
  4722. */
  4723. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4724. /**
  4725. * Stores a right-handed perspective projection into a given matrix
  4726. * @param fov defines the horizontal field of view
  4727. * @param aspect defines the aspect ratio
  4728. * @param znear defines the near clip plane
  4729. * @param zfar defines the far clip plane
  4730. * @param result defines the target matrix
  4731. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4732. */
  4733. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4734. /**
  4735. * Stores a right-handed perspective projection into a given matrix
  4736. * @param fov defines the horizontal field of view
  4737. * @param aspect defines the aspect ratio
  4738. * @param znear defines the near clip plane
  4739. * @param zfar not used as infinity is used as far clip
  4740. * @param result defines the target matrix
  4741. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4742. */
  4743. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4744. /**
  4745. * Stores a perspective projection for WebVR info a given matrix
  4746. * @param fov defines the field of view
  4747. * @param znear defines the near clip plane
  4748. * @param zfar defines the far clip plane
  4749. * @param result defines the target matrix
  4750. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4751. */
  4752. static PerspectiveFovWebVRToRef(fov: {
  4753. upDegrees: number;
  4754. downDegrees: number;
  4755. leftDegrees: number;
  4756. rightDegrees: number;
  4757. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4758. /**
  4759. * Computes a complete transformation matrix
  4760. * @param viewport defines the viewport to use
  4761. * @param world defines the world matrix
  4762. * @param view defines the view matrix
  4763. * @param projection defines the projection matrix
  4764. * @param zmin defines the near clip plane
  4765. * @param zmax defines the far clip plane
  4766. * @returns the transformation matrix
  4767. */
  4768. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4769. /**
  4770. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4771. * @param matrix defines the matrix to use
  4772. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4773. */
  4774. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4775. /**
  4776. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4777. * @param matrix defines the matrix to use
  4778. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4779. */
  4780. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4781. /**
  4782. * Compute the transpose of a given matrix
  4783. * @param matrix defines the matrix to transpose
  4784. * @returns the new matrix
  4785. */
  4786. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4787. /**
  4788. * Compute the transpose of a matrix and store it in a target matrix
  4789. * @param matrix defines the matrix to transpose
  4790. * @param result defines the target matrix
  4791. */
  4792. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4793. /**
  4794. * Computes a reflection matrix from a plane
  4795. * @param plane defines the reflection plane
  4796. * @returns a new matrix
  4797. */
  4798. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4799. /**
  4800. * Computes a reflection matrix from a plane
  4801. * @param plane defines the reflection plane
  4802. * @param result defines the target matrix
  4803. */
  4804. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4805. /**
  4806. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4807. * @param xaxis defines the value of the 1st axis
  4808. * @param yaxis defines the value of the 2nd axis
  4809. * @param zaxis defines the value of the 3rd axis
  4810. * @param result defines the target matrix
  4811. */
  4812. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4813. /**
  4814. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4815. * @param quat defines the quaternion to use
  4816. * @param result defines the target matrix
  4817. */
  4818. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4819. }
  4820. /**
  4821. * @hidden
  4822. */
  4823. export class TmpVectors {
  4824. static Vector2: Vector2[];
  4825. static Vector3: Vector3[];
  4826. static Vector4: Vector4[];
  4827. static Quaternion: Quaternion[];
  4828. static Matrix: Matrix[];
  4829. }
  4830. }
  4831. declare module BABYLON {
  4832. /**
  4833. * Defines potential orientation for back face culling
  4834. */
  4835. export enum Orientation {
  4836. /**
  4837. * Clockwise
  4838. */
  4839. CW = 0,
  4840. /** Counter clockwise */
  4841. CCW = 1
  4842. }
  4843. /** Class used to represent a Bezier curve */
  4844. export class BezierCurve {
  4845. /**
  4846. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4847. * @param t defines the time
  4848. * @param x1 defines the left coordinate on X axis
  4849. * @param y1 defines the left coordinate on Y axis
  4850. * @param x2 defines the right coordinate on X axis
  4851. * @param y2 defines the right coordinate on Y axis
  4852. * @returns the interpolated value
  4853. */
  4854. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4855. }
  4856. /**
  4857. * Defines angle representation
  4858. */
  4859. export class Angle {
  4860. private _radians;
  4861. /**
  4862. * Creates an Angle object of "radians" radians (float).
  4863. * @param radians the angle in radians
  4864. */
  4865. constructor(radians: number);
  4866. /**
  4867. * Get value in degrees
  4868. * @returns the Angle value in degrees (float)
  4869. */
  4870. degrees(): number;
  4871. /**
  4872. * Get value in radians
  4873. * @returns the Angle value in radians (float)
  4874. */
  4875. radians(): number;
  4876. /**
  4877. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4878. * @param a defines first point as the origin
  4879. * @param b defines point
  4880. * @returns a new Angle
  4881. */
  4882. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4883. /**
  4884. * Gets a new Angle object from the given float in radians
  4885. * @param radians defines the angle value in radians
  4886. * @returns a new Angle
  4887. */
  4888. static FromRadians(radians: number): Angle;
  4889. /**
  4890. * Gets a new Angle object from the given float in degrees
  4891. * @param degrees defines the angle value in degrees
  4892. * @returns a new Angle
  4893. */
  4894. static FromDegrees(degrees: number): Angle;
  4895. }
  4896. /**
  4897. * This represents an arc in a 2d space.
  4898. */
  4899. export class Arc2 {
  4900. /** Defines the start point of the arc */
  4901. startPoint: Vector2;
  4902. /** Defines the mid point of the arc */
  4903. midPoint: Vector2;
  4904. /** Defines the end point of the arc */
  4905. endPoint: Vector2;
  4906. /**
  4907. * Defines the center point of the arc.
  4908. */
  4909. centerPoint: Vector2;
  4910. /**
  4911. * Defines the radius of the arc.
  4912. */
  4913. radius: number;
  4914. /**
  4915. * Defines the angle of the arc (from mid point to end point).
  4916. */
  4917. angle: Angle;
  4918. /**
  4919. * Defines the start angle of the arc (from start point to middle point).
  4920. */
  4921. startAngle: Angle;
  4922. /**
  4923. * Defines the orientation of the arc (clock wise/counter clock wise).
  4924. */
  4925. orientation: Orientation;
  4926. /**
  4927. * Creates an Arc object from the three given points : start, middle and end.
  4928. * @param startPoint Defines the start point of the arc
  4929. * @param midPoint Defines the midlle point of the arc
  4930. * @param endPoint Defines the end point of the arc
  4931. */
  4932. constructor(
  4933. /** Defines the start point of the arc */
  4934. startPoint: Vector2,
  4935. /** Defines the mid point of the arc */
  4936. midPoint: Vector2,
  4937. /** Defines the end point of the arc */
  4938. endPoint: Vector2);
  4939. }
  4940. /**
  4941. * Represents a 2D path made up of multiple 2D points
  4942. */
  4943. export class Path2 {
  4944. private _points;
  4945. private _length;
  4946. /**
  4947. * If the path start and end point are the same
  4948. */
  4949. closed: boolean;
  4950. /**
  4951. * Creates a Path2 object from the starting 2D coordinates x and y.
  4952. * @param x the starting points x value
  4953. * @param y the starting points y value
  4954. */
  4955. constructor(x: number, y: number);
  4956. /**
  4957. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4958. * @param x the added points x value
  4959. * @param y the added points y value
  4960. * @returns the updated Path2.
  4961. */
  4962. addLineTo(x: number, y: number): Path2;
  4963. /**
  4964. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  4965. * @param midX middle point x value
  4966. * @param midY middle point y value
  4967. * @param endX end point x value
  4968. * @param endY end point y value
  4969. * @param numberOfSegments (default: 36)
  4970. * @returns the updated Path2.
  4971. */
  4972. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4973. /**
  4974. * Closes the Path2.
  4975. * @returns the Path2.
  4976. */
  4977. close(): Path2;
  4978. /**
  4979. * Gets the sum of the distance between each sequential point in the path
  4980. * @returns the Path2 total length (float).
  4981. */
  4982. length(): number;
  4983. /**
  4984. * Gets the points which construct the path
  4985. * @returns the Path2 internal array of points.
  4986. */
  4987. getPoints(): Vector2[];
  4988. /**
  4989. * Retreives the point at the distance aways from the starting point
  4990. * @param normalizedLengthPosition the length along the path to retreive the point from
  4991. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4992. */
  4993. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4994. /**
  4995. * Creates a new path starting from an x and y position
  4996. * @param x starting x value
  4997. * @param y starting y value
  4998. * @returns a new Path2 starting at the coordinates (x, y).
  4999. */
  5000. static StartingAt(x: number, y: number): Path2;
  5001. }
  5002. /**
  5003. * Represents a 3D path made up of multiple 3D points
  5004. */
  5005. export class Path3D {
  5006. /**
  5007. * an array of Vector3, the curve axis of the Path3D
  5008. */
  5009. path: Vector3[];
  5010. private _curve;
  5011. private _distances;
  5012. private _tangents;
  5013. private _normals;
  5014. private _binormals;
  5015. private _raw;
  5016. private _alignTangentsWithPath;
  5017. private readonly _pointAtData;
  5018. /**
  5019. * new Path3D(path, normal, raw)
  5020. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5021. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5022. * @param path an array of Vector3, the curve axis of the Path3D
  5023. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5024. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5025. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5026. */
  5027. constructor(
  5028. /**
  5029. * an array of Vector3, the curve axis of the Path3D
  5030. */
  5031. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5032. /**
  5033. * Returns the Path3D array of successive Vector3 designing its curve.
  5034. * @returns the Path3D array of successive Vector3 designing its curve.
  5035. */
  5036. getCurve(): Vector3[];
  5037. /**
  5038. * Returns the Path3D array of successive Vector3 designing its curve.
  5039. * @returns the Path3D array of successive Vector3 designing its curve.
  5040. */
  5041. getPoints(): Vector3[];
  5042. /**
  5043. * @returns the computed length (float) of the path.
  5044. */
  5045. length(): number;
  5046. /**
  5047. * Returns an array populated with tangent vectors on each Path3D curve point.
  5048. * @returns an array populated with tangent vectors on each Path3D curve point.
  5049. */
  5050. getTangents(): Vector3[];
  5051. /**
  5052. * Returns an array populated with normal vectors on each Path3D curve point.
  5053. * @returns an array populated with normal vectors on each Path3D curve point.
  5054. */
  5055. getNormals(): Vector3[];
  5056. /**
  5057. * Returns an array populated with binormal vectors on each Path3D curve point.
  5058. * @returns an array populated with binormal vectors on each Path3D curve point.
  5059. */
  5060. getBinormals(): Vector3[];
  5061. /**
  5062. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5063. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5064. */
  5065. getDistances(): number[];
  5066. /**
  5067. * Returns an interpolated point along this path
  5068. * @param position the position of the point along this path, from 0.0 to 1.0
  5069. * @returns a new Vector3 as the point
  5070. */
  5071. getPointAt(position: number): Vector3;
  5072. /**
  5073. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5074. * @param position the position of the point along this path, from 0.0 to 1.0
  5075. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5076. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5077. */
  5078. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5079. /**
  5080. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5081. * @param position the position of the point along this path, from 0.0 to 1.0
  5082. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5083. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5084. */
  5085. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5086. /**
  5087. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5088. * @param position the position of the point along this path, from 0.0 to 1.0
  5089. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5090. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5091. */
  5092. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5093. /**
  5094. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5095. * @param position the position of the point along this path, from 0.0 to 1.0
  5096. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5097. */
  5098. getDistanceAt(position: number): number;
  5099. /**
  5100. * Returns the array index of the previous point of an interpolated point along this path
  5101. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5102. * @returns the array index
  5103. */
  5104. getPreviousPointIndexAt(position: number): number;
  5105. /**
  5106. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  5107. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5108. * @returns the sub position
  5109. */
  5110. getSubPositionAt(position: number): number;
  5111. /**
  5112. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5113. * @param target the vector of which to get the closest position to
  5114. * @returns the position of the closest virtual point on this path to the target vector
  5115. */
  5116. getClosestPositionTo(target: Vector3): number;
  5117. /**
  5118. * Returns a sub path (slice) of this path
  5119. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5120. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  5121. * @returns a sub path (slice) of this path
  5122. */
  5123. slice(start?: number, end?: number): Path3D;
  5124. /**
  5125. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5126. * @param path path which all values are copied into the curves points
  5127. * @param firstNormal which should be projected onto the curve
  5128. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5129. * @returns the same object updated.
  5130. */
  5131. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5132. private _compute;
  5133. private _getFirstNonNullVector;
  5134. private _getLastNonNullVector;
  5135. private _normalVector;
  5136. /**
  5137. * Updates the point at data for an interpolated point along this curve
  5138. * @param position the position of the point along this curve, from 0.0 to 1.0
  5139. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5140. * @returns the (updated) point at data
  5141. */
  5142. private _updatePointAtData;
  5143. /**
  5144. * Updates the point at data from the specified parameters
  5145. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5146. * @param point the interpolated point
  5147. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5148. */
  5149. private _setPointAtData;
  5150. /**
  5151. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5152. */
  5153. private _updateInterpolationMatrix;
  5154. }
  5155. /**
  5156. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5157. * A Curve3 is designed from a series of successive Vector3.
  5158. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5159. */
  5160. export class Curve3 {
  5161. private _points;
  5162. private _length;
  5163. /**
  5164. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5165. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5166. * @param v1 (Vector3) the control point
  5167. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5168. * @param nbPoints (integer) the wanted number of points in the curve
  5169. * @returns the created Curve3
  5170. */
  5171. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5172. /**
  5173. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5174. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5175. * @param v1 (Vector3) the first control point
  5176. * @param v2 (Vector3) the second control point
  5177. * @param v3 (Vector3) the end point of the Cubic Bezier
  5178. * @param nbPoints (integer) the wanted number of points in the curve
  5179. * @returns the created Curve3
  5180. */
  5181. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5182. /**
  5183. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5184. * @param p1 (Vector3) the origin point of the Hermite Spline
  5185. * @param t1 (Vector3) the tangent vector at the origin point
  5186. * @param p2 (Vector3) the end point of the Hermite Spline
  5187. * @param t2 (Vector3) the tangent vector at the end point
  5188. * @param nbPoints (integer) the wanted number of points in the curve
  5189. * @returns the created Curve3
  5190. */
  5191. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5192. /**
  5193. * Returns a Curve3 object along a CatmullRom Spline curve :
  5194. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5195. * @param nbPoints (integer) the wanted number of points between each curve control points
  5196. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5197. * @returns the created Curve3
  5198. */
  5199. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5200. /**
  5201. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5202. * A Curve3 is designed from a series of successive Vector3.
  5203. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5204. * @param points points which make up the curve
  5205. */
  5206. constructor(points: Vector3[]);
  5207. /**
  5208. * @returns the Curve3 stored array of successive Vector3
  5209. */
  5210. getPoints(): Vector3[];
  5211. /**
  5212. * @returns the computed length (float) of the curve.
  5213. */
  5214. length(): number;
  5215. /**
  5216. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5217. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5218. * curveA and curveB keep unchanged.
  5219. * @param curve the curve to continue from this curve
  5220. * @returns the newly constructed curve
  5221. */
  5222. continue(curve: DeepImmutable<Curve3>): Curve3;
  5223. private _computeLength;
  5224. }
  5225. }
  5226. declare module BABYLON {
  5227. /**
  5228. * This represents the main contract an easing function should follow.
  5229. * Easing functions are used throughout the animation system.
  5230. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5231. */
  5232. export interface IEasingFunction {
  5233. /**
  5234. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5235. * of the easing function.
  5236. * The link below provides some of the most common examples of easing functions.
  5237. * @see https://easings.net/
  5238. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5239. * @returns the corresponding value on the curve defined by the easing function
  5240. */
  5241. ease(gradient: number): number;
  5242. }
  5243. /**
  5244. * Base class used for every default easing function.
  5245. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5246. */
  5247. export class EasingFunction implements IEasingFunction {
  5248. /**
  5249. * Interpolation follows the mathematical formula associated with the easing function.
  5250. */
  5251. static readonly EASINGMODE_EASEIN: number;
  5252. /**
  5253. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5254. */
  5255. static readonly EASINGMODE_EASEOUT: number;
  5256. /**
  5257. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5258. */
  5259. static readonly EASINGMODE_EASEINOUT: number;
  5260. private _easingMode;
  5261. /**
  5262. * Sets the easing mode of the current function.
  5263. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5264. */
  5265. setEasingMode(easingMode: number): void;
  5266. /**
  5267. * Gets the current easing mode.
  5268. * @returns the easing mode
  5269. */
  5270. getEasingMode(): number;
  5271. /**
  5272. * @hidden
  5273. */
  5274. easeInCore(gradient: number): number;
  5275. /**
  5276. * Given an input gradient between 0 and 1, this returns the corresponding value
  5277. * of the easing function.
  5278. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5279. * @returns the corresponding value on the curve defined by the easing function
  5280. */
  5281. ease(gradient: number): number;
  5282. }
  5283. /**
  5284. * Easing function with a circle shape (see link below).
  5285. * @see https://easings.net/#easeInCirc
  5286. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5287. */
  5288. export class CircleEase extends EasingFunction implements IEasingFunction {
  5289. /** @hidden */
  5290. easeInCore(gradient: number): number;
  5291. }
  5292. /**
  5293. * Easing function with a ease back shape (see link below).
  5294. * @see https://easings.net/#easeInBack
  5295. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5296. */
  5297. export class BackEase extends EasingFunction implements IEasingFunction {
  5298. /** Defines the amplitude of the function */
  5299. amplitude: number;
  5300. /**
  5301. * Instantiates a back ease easing
  5302. * @see https://easings.net/#easeInBack
  5303. * @param amplitude Defines the amplitude of the function
  5304. */
  5305. constructor(
  5306. /** Defines the amplitude of the function */
  5307. amplitude?: number);
  5308. /** @hidden */
  5309. easeInCore(gradient: number): number;
  5310. }
  5311. /**
  5312. * Easing function with a bouncing shape (see link below).
  5313. * @see https://easings.net/#easeInBounce
  5314. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5315. */
  5316. export class BounceEase extends EasingFunction implements IEasingFunction {
  5317. /** Defines the number of bounces */
  5318. bounces: number;
  5319. /** Defines the amplitude of the bounce */
  5320. bounciness: number;
  5321. /**
  5322. * Instantiates a bounce easing
  5323. * @see https://easings.net/#easeInBounce
  5324. * @param bounces Defines the number of bounces
  5325. * @param bounciness Defines the amplitude of the bounce
  5326. */
  5327. constructor(
  5328. /** Defines the number of bounces */
  5329. bounces?: number,
  5330. /** Defines the amplitude of the bounce */
  5331. bounciness?: number);
  5332. /** @hidden */
  5333. easeInCore(gradient: number): number;
  5334. }
  5335. /**
  5336. * Easing function with a power of 3 shape (see link below).
  5337. * @see https://easings.net/#easeInCubic
  5338. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5339. */
  5340. export class CubicEase extends EasingFunction implements IEasingFunction {
  5341. /** @hidden */
  5342. easeInCore(gradient: number): number;
  5343. }
  5344. /**
  5345. * Easing function with an elastic shape (see link below).
  5346. * @see https://easings.net/#easeInElastic
  5347. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5348. */
  5349. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5350. /** Defines the number of oscillations*/
  5351. oscillations: number;
  5352. /** Defines the amplitude of the oscillations*/
  5353. springiness: number;
  5354. /**
  5355. * Instantiates an elastic easing function
  5356. * @see https://easings.net/#easeInElastic
  5357. * @param oscillations Defines the number of oscillations
  5358. * @param springiness Defines the amplitude of the oscillations
  5359. */
  5360. constructor(
  5361. /** Defines the number of oscillations*/
  5362. oscillations?: number,
  5363. /** Defines the amplitude of the oscillations*/
  5364. springiness?: number);
  5365. /** @hidden */
  5366. easeInCore(gradient: number): number;
  5367. }
  5368. /**
  5369. * Easing function with an exponential shape (see link below).
  5370. * @see https://easings.net/#easeInExpo
  5371. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5372. */
  5373. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5374. /** Defines the exponent of the function */
  5375. exponent: number;
  5376. /**
  5377. * Instantiates an exponential easing function
  5378. * @see https://easings.net/#easeInExpo
  5379. * @param exponent Defines the exponent of the function
  5380. */
  5381. constructor(
  5382. /** Defines the exponent of the function */
  5383. exponent?: number);
  5384. /** @hidden */
  5385. easeInCore(gradient: number): number;
  5386. }
  5387. /**
  5388. * Easing function with a power shape (see link below).
  5389. * @see https://easings.net/#easeInQuad
  5390. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5391. */
  5392. export class PowerEase extends EasingFunction implements IEasingFunction {
  5393. /** Defines the power of the function */
  5394. power: number;
  5395. /**
  5396. * Instantiates an power base easing function
  5397. * @see https://easings.net/#easeInQuad
  5398. * @param power Defines the power of the function
  5399. */
  5400. constructor(
  5401. /** Defines the power of the function */
  5402. power?: number);
  5403. /** @hidden */
  5404. easeInCore(gradient: number): number;
  5405. }
  5406. /**
  5407. * Easing function with a power of 2 shape (see link below).
  5408. * @see https://easings.net/#easeInQuad
  5409. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5410. */
  5411. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5412. /** @hidden */
  5413. easeInCore(gradient: number): number;
  5414. }
  5415. /**
  5416. * Easing function with a power of 4 shape (see link below).
  5417. * @see https://easings.net/#easeInQuart
  5418. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5419. */
  5420. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5421. /** @hidden */
  5422. easeInCore(gradient: number): number;
  5423. }
  5424. /**
  5425. * Easing function with a power of 5 shape (see link below).
  5426. * @see https://easings.net/#easeInQuint
  5427. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5428. */
  5429. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5430. /** @hidden */
  5431. easeInCore(gradient: number): number;
  5432. }
  5433. /**
  5434. * Easing function with a sin shape (see link below).
  5435. * @see https://easings.net/#easeInSine
  5436. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5437. */
  5438. export class SineEase extends EasingFunction implements IEasingFunction {
  5439. /** @hidden */
  5440. easeInCore(gradient: number): number;
  5441. }
  5442. /**
  5443. * Easing function with a bezier shape (see link below).
  5444. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5445. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5446. */
  5447. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5448. /** Defines the x component of the start tangent in the bezier curve */
  5449. x1: number;
  5450. /** Defines the y component of the start tangent in the bezier curve */
  5451. y1: number;
  5452. /** Defines the x component of the end tangent in the bezier curve */
  5453. x2: number;
  5454. /** Defines the y component of the end tangent in the bezier curve */
  5455. y2: number;
  5456. /**
  5457. * Instantiates a bezier function
  5458. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5459. * @param x1 Defines the x component of the start tangent in the bezier curve
  5460. * @param y1 Defines the y component of the start tangent in the bezier curve
  5461. * @param x2 Defines the x component of the end tangent in the bezier curve
  5462. * @param y2 Defines the y component of the end tangent in the bezier curve
  5463. */
  5464. constructor(
  5465. /** Defines the x component of the start tangent in the bezier curve */
  5466. x1?: number,
  5467. /** Defines the y component of the start tangent in the bezier curve */
  5468. y1?: number,
  5469. /** Defines the x component of the end tangent in the bezier curve */
  5470. x2?: number,
  5471. /** Defines the y component of the end tangent in the bezier curve */
  5472. y2?: number);
  5473. /** @hidden */
  5474. easeInCore(gradient: number): number;
  5475. }
  5476. }
  5477. declare module BABYLON {
  5478. /**
  5479. * Class used to hold a RBG color
  5480. */
  5481. export class Color3 {
  5482. /**
  5483. * Defines the red component (between 0 and 1, default is 0)
  5484. */
  5485. r: number;
  5486. /**
  5487. * Defines the green component (between 0 and 1, default is 0)
  5488. */
  5489. g: number;
  5490. /**
  5491. * Defines the blue component (between 0 and 1, default is 0)
  5492. */
  5493. b: number;
  5494. /**
  5495. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5496. * @param r defines the red component (between 0 and 1, default is 0)
  5497. * @param g defines the green component (between 0 and 1, default is 0)
  5498. * @param b defines the blue component (between 0 and 1, default is 0)
  5499. */
  5500. constructor(
  5501. /**
  5502. * Defines the red component (between 0 and 1, default is 0)
  5503. */
  5504. r?: number,
  5505. /**
  5506. * Defines the green component (between 0 and 1, default is 0)
  5507. */
  5508. g?: number,
  5509. /**
  5510. * Defines the blue component (between 0 and 1, default is 0)
  5511. */
  5512. b?: number);
  5513. /**
  5514. * Creates a string with the Color3 current values
  5515. * @returns the string representation of the Color3 object
  5516. */
  5517. toString(): string;
  5518. /**
  5519. * Returns the string "Color3"
  5520. * @returns "Color3"
  5521. */
  5522. getClassName(): string;
  5523. /**
  5524. * Compute the Color3 hash code
  5525. * @returns an unique number that can be used to hash Color3 objects
  5526. */
  5527. getHashCode(): number;
  5528. /**
  5529. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5530. * @param array defines the array where to store the r,g,b components
  5531. * @param index defines an optional index in the target array to define where to start storing values
  5532. * @returns the current Color3 object
  5533. */
  5534. toArray(array: FloatArray, index?: number): Color3;
  5535. /**
  5536. * Update the current color with values stored in an array from the starting index of the given array
  5537. * @param array defines the source array
  5538. * @param offset defines an offset in the source array
  5539. * @returns the current Color3 object
  5540. */
  5541. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5542. /**
  5543. * Returns a new Color4 object from the current Color3 and the given alpha
  5544. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5545. * @returns a new Color4 object
  5546. */
  5547. toColor4(alpha?: number): Color4;
  5548. /**
  5549. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5550. * @returns the new array
  5551. */
  5552. asArray(): number[];
  5553. /**
  5554. * Returns the luminance value
  5555. * @returns a float value
  5556. */
  5557. toLuminance(): number;
  5558. /**
  5559. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5560. * @param otherColor defines the second operand
  5561. * @returns the new Color3 object
  5562. */
  5563. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5564. /**
  5565. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5566. * @param otherColor defines the second operand
  5567. * @param result defines the Color3 object where to store the result
  5568. * @returns the current Color3
  5569. */
  5570. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5571. /**
  5572. * Determines equality between Color3 objects
  5573. * @param otherColor defines the second operand
  5574. * @returns true if the rgb values are equal to the given ones
  5575. */
  5576. equals(otherColor: DeepImmutable<Color3>): boolean;
  5577. /**
  5578. * Determines equality between the current Color3 object and a set of r,b,g values
  5579. * @param r defines the red component to check
  5580. * @param g defines the green component to check
  5581. * @param b defines the blue component to check
  5582. * @returns true if the rgb values are equal to the given ones
  5583. */
  5584. equalsFloats(r: number, g: number, b: number): boolean;
  5585. /**
  5586. * Multiplies in place each rgb value by scale
  5587. * @param scale defines the scaling factor
  5588. * @returns the updated Color3
  5589. */
  5590. scale(scale: number): Color3;
  5591. /**
  5592. * Multiplies the rgb values by scale and stores the result into "result"
  5593. * @param scale defines the scaling factor
  5594. * @param result defines the Color3 object where to store the result
  5595. * @returns the unmodified current Color3
  5596. */
  5597. scaleToRef(scale: number, result: Color3): Color3;
  5598. /**
  5599. * Scale the current Color3 values by a factor and add the result to a given Color3
  5600. * @param scale defines the scale factor
  5601. * @param result defines color to store the result into
  5602. * @returns the unmodified current Color3
  5603. */
  5604. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5605. /**
  5606. * Clamps the rgb values by the min and max values and stores the result into "result"
  5607. * @param min defines minimum clamping value (default is 0)
  5608. * @param max defines maximum clamping value (default is 1)
  5609. * @param result defines color to store the result into
  5610. * @returns the original Color3
  5611. */
  5612. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5613. /**
  5614. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5615. * @param otherColor defines the second operand
  5616. * @returns the new Color3
  5617. */
  5618. add(otherColor: DeepImmutable<Color3>): Color3;
  5619. /**
  5620. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5621. * @param otherColor defines the second operand
  5622. * @param result defines Color3 object to store the result into
  5623. * @returns the unmodified current Color3
  5624. */
  5625. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5626. /**
  5627. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5628. * @param otherColor defines the second operand
  5629. * @returns the new Color3
  5630. */
  5631. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5632. /**
  5633. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5634. * @param otherColor defines the second operand
  5635. * @param result defines Color3 object to store the result into
  5636. * @returns the unmodified current Color3
  5637. */
  5638. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5639. /**
  5640. * Copy the current object
  5641. * @returns a new Color3 copied the current one
  5642. */
  5643. clone(): Color3;
  5644. /**
  5645. * Copies the rgb values from the source in the current Color3
  5646. * @param source defines the source Color3 object
  5647. * @returns the updated Color3 object
  5648. */
  5649. copyFrom(source: DeepImmutable<Color3>): Color3;
  5650. /**
  5651. * Updates the Color3 rgb values from the given floats
  5652. * @param r defines the red component to read from
  5653. * @param g defines the green component to read from
  5654. * @param b defines the blue component to read from
  5655. * @returns the current Color3 object
  5656. */
  5657. copyFromFloats(r: number, g: number, b: number): Color3;
  5658. /**
  5659. * Updates the Color3 rgb values from the given floats
  5660. * @param r defines the red component to read from
  5661. * @param g defines the green component to read from
  5662. * @param b defines the blue component to read from
  5663. * @returns the current Color3 object
  5664. */
  5665. set(r: number, g: number, b: number): Color3;
  5666. /**
  5667. * Compute the Color3 hexadecimal code as a string
  5668. * @returns a string containing the hexadecimal representation of the Color3 object
  5669. */
  5670. toHexString(): string;
  5671. /**
  5672. * Computes a new Color3 converted from the current one to linear space
  5673. * @returns a new Color3 object
  5674. */
  5675. toLinearSpace(): Color3;
  5676. /**
  5677. * Converts current color in rgb space to HSV values
  5678. * @returns a new color3 representing the HSV values
  5679. */
  5680. toHSV(): Color3;
  5681. /**
  5682. * Converts current color in rgb space to HSV values
  5683. * @param result defines the Color3 where to store the HSV values
  5684. */
  5685. toHSVToRef(result: Color3): void;
  5686. /**
  5687. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5688. * @param convertedColor defines the Color3 object where to store the linear space version
  5689. * @returns the unmodified Color3
  5690. */
  5691. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5692. /**
  5693. * Computes a new Color3 converted from the current one to gamma space
  5694. * @returns a new Color3 object
  5695. */
  5696. toGammaSpace(): Color3;
  5697. /**
  5698. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5699. * @param convertedColor defines the Color3 object where to store the gamma space version
  5700. * @returns the unmodified Color3
  5701. */
  5702. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5703. private static _BlackReadOnly;
  5704. /**
  5705. * Convert Hue, saturation and value to a Color3 (RGB)
  5706. * @param hue defines the hue
  5707. * @param saturation defines the saturation
  5708. * @param value defines the value
  5709. * @param result defines the Color3 where to store the RGB values
  5710. */
  5711. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5712. /**
  5713. * Creates a new Color3 from the string containing valid hexadecimal values
  5714. * @param hex defines a string containing valid hexadecimal values
  5715. * @returns a new Color3 object
  5716. */
  5717. static FromHexString(hex: string): Color3;
  5718. /**
  5719. * Creates a new Color3 from the starting index of the given array
  5720. * @param array defines the source array
  5721. * @param offset defines an offset in the source array
  5722. * @returns a new Color3 object
  5723. */
  5724. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5725. /**
  5726. * Creates a new Color3 from the starting index element of the given array
  5727. * @param array defines the source array to read from
  5728. * @param offset defines the offset in the source array
  5729. * @param result defines the target Color3 object
  5730. */
  5731. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5732. /**
  5733. * Creates a new Color3 from integer values (< 256)
  5734. * @param r defines the red component to read from (value between 0 and 255)
  5735. * @param g defines the green component to read from (value between 0 and 255)
  5736. * @param b defines the blue component to read from (value between 0 and 255)
  5737. * @returns a new Color3 object
  5738. */
  5739. static FromInts(r: number, g: number, b: number): Color3;
  5740. /**
  5741. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5742. * @param start defines the start Color3 value
  5743. * @param end defines the end Color3 value
  5744. * @param amount defines the gradient value between start and end
  5745. * @returns a new Color3 object
  5746. */
  5747. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5748. /**
  5749. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5750. * @param left defines the start value
  5751. * @param right defines the end value
  5752. * @param amount defines the gradient factor
  5753. * @param result defines the Color3 object where to store the result
  5754. */
  5755. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5756. /**
  5757. * Returns a Color3 value containing a red color
  5758. * @returns a new Color3 object
  5759. */
  5760. static Red(): Color3;
  5761. /**
  5762. * Returns a Color3 value containing a green color
  5763. * @returns a new Color3 object
  5764. */
  5765. static Green(): Color3;
  5766. /**
  5767. * Returns a Color3 value containing a blue color
  5768. * @returns a new Color3 object
  5769. */
  5770. static Blue(): Color3;
  5771. /**
  5772. * Returns a Color3 value containing a black color
  5773. * @returns a new Color3 object
  5774. */
  5775. static Black(): Color3;
  5776. /**
  5777. * Gets a Color3 value containing a black color that must not be updated
  5778. */
  5779. static get BlackReadOnly(): DeepImmutable<Color3>;
  5780. /**
  5781. * Returns a Color3 value containing a white color
  5782. * @returns a new Color3 object
  5783. */
  5784. static White(): Color3;
  5785. /**
  5786. * Returns a Color3 value containing a purple color
  5787. * @returns a new Color3 object
  5788. */
  5789. static Purple(): Color3;
  5790. /**
  5791. * Returns a Color3 value containing a magenta color
  5792. * @returns a new Color3 object
  5793. */
  5794. static Magenta(): Color3;
  5795. /**
  5796. * Returns a Color3 value containing a yellow color
  5797. * @returns a new Color3 object
  5798. */
  5799. static Yellow(): Color3;
  5800. /**
  5801. * Returns a Color3 value containing a gray color
  5802. * @returns a new Color3 object
  5803. */
  5804. static Gray(): Color3;
  5805. /**
  5806. * Returns a Color3 value containing a teal color
  5807. * @returns a new Color3 object
  5808. */
  5809. static Teal(): Color3;
  5810. /**
  5811. * Returns a Color3 value containing a random color
  5812. * @returns a new Color3 object
  5813. */
  5814. static Random(): Color3;
  5815. }
  5816. /**
  5817. * Class used to hold a RBGA color
  5818. */
  5819. export class Color4 {
  5820. /**
  5821. * Defines the red component (between 0 and 1, default is 0)
  5822. */
  5823. r: number;
  5824. /**
  5825. * Defines the green component (between 0 and 1, default is 0)
  5826. */
  5827. g: number;
  5828. /**
  5829. * Defines the blue component (between 0 and 1, default is 0)
  5830. */
  5831. b: number;
  5832. /**
  5833. * Defines the alpha component (between 0 and 1, default is 1)
  5834. */
  5835. a: number;
  5836. /**
  5837. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5838. * @param r defines the red component (between 0 and 1, default is 0)
  5839. * @param g defines the green component (between 0 and 1, default is 0)
  5840. * @param b defines the blue component (between 0 and 1, default is 0)
  5841. * @param a defines the alpha component (between 0 and 1, default is 1)
  5842. */
  5843. constructor(
  5844. /**
  5845. * Defines the red component (between 0 and 1, default is 0)
  5846. */
  5847. r?: number,
  5848. /**
  5849. * Defines the green component (between 0 and 1, default is 0)
  5850. */
  5851. g?: number,
  5852. /**
  5853. * Defines the blue component (between 0 and 1, default is 0)
  5854. */
  5855. b?: number,
  5856. /**
  5857. * Defines the alpha component (between 0 and 1, default is 1)
  5858. */
  5859. a?: number);
  5860. /**
  5861. * Adds in place the given Color4 values to the current Color4 object
  5862. * @param right defines the second operand
  5863. * @returns the current updated Color4 object
  5864. */
  5865. addInPlace(right: DeepImmutable<Color4>): Color4;
  5866. /**
  5867. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5868. * @returns the new array
  5869. */
  5870. asArray(): number[];
  5871. /**
  5872. * Stores from the starting index in the given array the Color4 successive values
  5873. * @param array defines the array where to store the r,g,b components
  5874. * @param index defines an optional index in the target array to define where to start storing values
  5875. * @returns the current Color4 object
  5876. */
  5877. toArray(array: number[], index?: number): Color4;
  5878. /**
  5879. * Update the current color with values stored in an array from the starting index of the given array
  5880. * @param array defines the source array
  5881. * @param offset defines an offset in the source array
  5882. * @returns the current Color4 object
  5883. */
  5884. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5885. /**
  5886. * Determines equality between Color4 objects
  5887. * @param otherColor defines the second operand
  5888. * @returns true if the rgba values are equal to the given ones
  5889. */
  5890. equals(otherColor: DeepImmutable<Color4>): boolean;
  5891. /**
  5892. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5893. * @param right defines the second operand
  5894. * @returns a new Color4 object
  5895. */
  5896. add(right: DeepImmutable<Color4>): Color4;
  5897. /**
  5898. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5899. * @param right defines the second operand
  5900. * @returns a new Color4 object
  5901. */
  5902. subtract(right: DeepImmutable<Color4>): Color4;
  5903. /**
  5904. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5905. * @param right defines the second operand
  5906. * @param result defines the Color4 object where to store the result
  5907. * @returns the current Color4 object
  5908. */
  5909. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5910. /**
  5911. * Creates a new Color4 with the current Color4 values multiplied by scale
  5912. * @param scale defines the scaling factor to apply
  5913. * @returns a new Color4 object
  5914. */
  5915. scale(scale: number): Color4;
  5916. /**
  5917. * Multiplies the current Color4 values by scale and stores the result in "result"
  5918. * @param scale defines the scaling factor to apply
  5919. * @param result defines the Color4 object where to store the result
  5920. * @returns the current unmodified Color4
  5921. */
  5922. scaleToRef(scale: number, result: Color4): Color4;
  5923. /**
  5924. * Scale the current Color4 values by a factor and add the result to a given Color4
  5925. * @param scale defines the scale factor
  5926. * @param result defines the Color4 object where to store the result
  5927. * @returns the unmodified current Color4
  5928. */
  5929. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5930. /**
  5931. * Clamps the rgb values by the min and max values and stores the result into "result"
  5932. * @param min defines minimum clamping value (default is 0)
  5933. * @param max defines maximum clamping value (default is 1)
  5934. * @param result defines color to store the result into.
  5935. * @returns the cuurent Color4
  5936. */
  5937. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5938. /**
  5939. * Multipy an Color4 value by another and return a new Color4 object
  5940. * @param color defines the Color4 value to multiply by
  5941. * @returns a new Color4 object
  5942. */
  5943. multiply(color: Color4): Color4;
  5944. /**
  5945. * Multipy a Color4 value by another and push the result in a reference value
  5946. * @param color defines the Color4 value to multiply by
  5947. * @param result defines the Color4 to fill the result in
  5948. * @returns the result Color4
  5949. */
  5950. multiplyToRef(color: Color4, result: Color4): Color4;
  5951. /**
  5952. * Creates a string with the Color4 current values
  5953. * @returns the string representation of the Color4 object
  5954. */
  5955. toString(): string;
  5956. /**
  5957. * Returns the string "Color4"
  5958. * @returns "Color4"
  5959. */
  5960. getClassName(): string;
  5961. /**
  5962. * Compute the Color4 hash code
  5963. * @returns an unique number that can be used to hash Color4 objects
  5964. */
  5965. getHashCode(): number;
  5966. /**
  5967. * Creates a new Color4 copied from the current one
  5968. * @returns a new Color4 object
  5969. */
  5970. clone(): Color4;
  5971. /**
  5972. * Copies the given Color4 values into the current one
  5973. * @param source defines the source Color4 object
  5974. * @returns the current updated Color4 object
  5975. */
  5976. copyFrom(source: Color4): Color4;
  5977. /**
  5978. * Copies the given float values into the current one
  5979. * @param r defines the red component to read from
  5980. * @param g defines the green component to read from
  5981. * @param b defines the blue component to read from
  5982. * @param a defines the alpha component to read from
  5983. * @returns the current updated Color4 object
  5984. */
  5985. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5986. /**
  5987. * Copies the given float values into the current one
  5988. * @param r defines the red component to read from
  5989. * @param g defines the green component to read from
  5990. * @param b defines the blue component to read from
  5991. * @param a defines the alpha component to read from
  5992. * @returns the current updated Color4 object
  5993. */
  5994. set(r: number, g: number, b: number, a: number): Color4;
  5995. /**
  5996. * Compute the Color4 hexadecimal code as a string
  5997. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5998. * @returns a string containing the hexadecimal representation of the Color4 object
  5999. */
  6000. toHexString(returnAsColor3?: boolean): string;
  6001. /**
  6002. * Computes a new Color4 converted from the current one to linear space
  6003. * @returns a new Color4 object
  6004. */
  6005. toLinearSpace(): Color4;
  6006. /**
  6007. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6008. * @param convertedColor defines the Color4 object where to store the linear space version
  6009. * @returns the unmodified Color4
  6010. */
  6011. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6012. /**
  6013. * Computes a new Color4 converted from the current one to gamma space
  6014. * @returns a new Color4 object
  6015. */
  6016. toGammaSpace(): Color4;
  6017. /**
  6018. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6019. * @param convertedColor defines the Color4 object where to store the gamma space version
  6020. * @returns the unmodified Color4
  6021. */
  6022. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6023. /**
  6024. * Creates a new Color4 from the string containing valid hexadecimal values
  6025. * @param hex defines a string containing valid hexadecimal values
  6026. * @returns a new Color4 object
  6027. */
  6028. static FromHexString(hex: string): Color4;
  6029. /**
  6030. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6031. * @param left defines the start value
  6032. * @param right defines the end value
  6033. * @param amount defines the gradient factor
  6034. * @returns a new Color4 object
  6035. */
  6036. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6037. /**
  6038. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6039. * @param left defines the start value
  6040. * @param right defines the end value
  6041. * @param amount defines the gradient factor
  6042. * @param result defines the Color4 object where to store data
  6043. */
  6044. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6045. /**
  6046. * Creates a new Color4 from a Color3 and an alpha value
  6047. * @param color3 defines the source Color3 to read from
  6048. * @param alpha defines the alpha component (1.0 by default)
  6049. * @returns a new Color4 object
  6050. */
  6051. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6052. /**
  6053. * Creates a new Color4 from the starting index element of the given array
  6054. * @param array defines the source array to read from
  6055. * @param offset defines the offset in the source array
  6056. * @returns a new Color4 object
  6057. */
  6058. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6059. /**
  6060. * Creates a new Color4 from the starting index element of the given array
  6061. * @param array defines the source array to read from
  6062. * @param offset defines the offset in the source array
  6063. * @param result defines the target Color4 object
  6064. */
  6065. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6066. /**
  6067. * Creates a new Color3 from integer values (< 256)
  6068. * @param r defines the red component to read from (value between 0 and 255)
  6069. * @param g defines the green component to read from (value between 0 and 255)
  6070. * @param b defines the blue component to read from (value between 0 and 255)
  6071. * @param a defines the alpha component to read from (value between 0 and 255)
  6072. * @returns a new Color3 object
  6073. */
  6074. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6075. /**
  6076. * Check the content of a given array and convert it to an array containing RGBA data
  6077. * If the original array was already containing count * 4 values then it is returned directly
  6078. * @param colors defines the array to check
  6079. * @param count defines the number of RGBA data to expect
  6080. * @returns an array containing count * 4 values (RGBA)
  6081. */
  6082. static CheckColors4(colors: number[], count: number): number[];
  6083. }
  6084. /**
  6085. * @hidden
  6086. */
  6087. export class TmpColors {
  6088. static Color3: Color3[];
  6089. static Color4: Color4[];
  6090. }
  6091. }
  6092. declare module BABYLON {
  6093. /**
  6094. * Defines an interface which represents an animation key frame
  6095. */
  6096. export interface IAnimationKey {
  6097. /**
  6098. * Frame of the key frame
  6099. */
  6100. frame: number;
  6101. /**
  6102. * Value at the specifies key frame
  6103. */
  6104. value: any;
  6105. /**
  6106. * The input tangent for the cubic hermite spline
  6107. */
  6108. inTangent?: any;
  6109. /**
  6110. * The output tangent for the cubic hermite spline
  6111. */
  6112. outTangent?: any;
  6113. /**
  6114. * The animation interpolation type
  6115. */
  6116. interpolation?: AnimationKeyInterpolation;
  6117. }
  6118. /**
  6119. * Enum for the animation key frame interpolation type
  6120. */
  6121. export enum AnimationKeyInterpolation {
  6122. /**
  6123. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6124. */
  6125. STEP = 1
  6126. }
  6127. }
  6128. declare module BABYLON {
  6129. /**
  6130. * Represents the range of an animation
  6131. */
  6132. export class AnimationRange {
  6133. /**The name of the animation range**/
  6134. name: string;
  6135. /**The starting frame of the animation */
  6136. from: number;
  6137. /**The ending frame of the animation*/
  6138. to: number;
  6139. /**
  6140. * Initializes the range of an animation
  6141. * @param name The name of the animation range
  6142. * @param from The starting frame of the animation
  6143. * @param to The ending frame of the animation
  6144. */
  6145. constructor(
  6146. /**The name of the animation range**/
  6147. name: string,
  6148. /**The starting frame of the animation */
  6149. from: number,
  6150. /**The ending frame of the animation*/
  6151. to: number);
  6152. /**
  6153. * Makes a copy of the animation range
  6154. * @returns A copy of the animation range
  6155. */
  6156. clone(): AnimationRange;
  6157. }
  6158. }
  6159. declare module BABYLON {
  6160. /**
  6161. * Composed of a frame, and an action function
  6162. */
  6163. export class AnimationEvent {
  6164. /** The frame for which the event is triggered **/
  6165. frame: number;
  6166. /** The event to perform when triggered **/
  6167. action: (currentFrame: number) => void;
  6168. /** Specifies if the event should be triggered only once**/
  6169. onlyOnce?: boolean | undefined;
  6170. /**
  6171. * Specifies if the animation event is done
  6172. */
  6173. isDone: boolean;
  6174. /**
  6175. * Initializes the animation event
  6176. * @param frame The frame for which the event is triggered
  6177. * @param action The event to perform when triggered
  6178. * @param onlyOnce Specifies if the event should be triggered only once
  6179. */
  6180. constructor(
  6181. /** The frame for which the event is triggered **/
  6182. frame: number,
  6183. /** The event to perform when triggered **/
  6184. action: (currentFrame: number) => void,
  6185. /** Specifies if the event should be triggered only once**/
  6186. onlyOnce?: boolean | undefined);
  6187. /** @hidden */
  6188. _clone(): AnimationEvent;
  6189. }
  6190. }
  6191. declare module BABYLON {
  6192. /**
  6193. * Interface used to define a behavior
  6194. */
  6195. export interface Behavior<T> {
  6196. /** gets or sets behavior's name */
  6197. name: string;
  6198. /**
  6199. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6200. */
  6201. init(): void;
  6202. /**
  6203. * Called when the behavior is attached to a target
  6204. * @param target defines the target where the behavior is attached to
  6205. */
  6206. attach(target: T): void;
  6207. /**
  6208. * Called when the behavior is detached from its target
  6209. */
  6210. detach(): void;
  6211. }
  6212. /**
  6213. * Interface implemented by classes supporting behaviors
  6214. */
  6215. export interface IBehaviorAware<T> {
  6216. /**
  6217. * Attach a behavior
  6218. * @param behavior defines the behavior to attach
  6219. * @returns the current host
  6220. */
  6221. addBehavior(behavior: Behavior<T>): T;
  6222. /**
  6223. * Remove a behavior from the current object
  6224. * @param behavior defines the behavior to detach
  6225. * @returns the current host
  6226. */
  6227. removeBehavior(behavior: Behavior<T>): T;
  6228. /**
  6229. * Gets a behavior using its name to search
  6230. * @param name defines the name to search
  6231. * @returns the behavior or null if not found
  6232. */
  6233. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6234. }
  6235. }
  6236. declare module BABYLON {
  6237. /**
  6238. * Defines an array and its length.
  6239. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6240. */
  6241. export interface ISmartArrayLike<T> {
  6242. /**
  6243. * The data of the array.
  6244. */
  6245. data: Array<T>;
  6246. /**
  6247. * The active length of the array.
  6248. */
  6249. length: number;
  6250. }
  6251. /**
  6252. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6253. */
  6254. export class SmartArray<T> implements ISmartArrayLike<T> {
  6255. /**
  6256. * The full set of data from the array.
  6257. */
  6258. data: Array<T>;
  6259. /**
  6260. * The active length of the array.
  6261. */
  6262. length: number;
  6263. protected _id: number;
  6264. /**
  6265. * Instantiates a Smart Array.
  6266. * @param capacity defines the default capacity of the array.
  6267. */
  6268. constructor(capacity: number);
  6269. /**
  6270. * Pushes a value at the end of the active data.
  6271. * @param value defines the object to push in the array.
  6272. */
  6273. push(value: T): void;
  6274. /**
  6275. * Iterates over the active data and apply the lambda to them.
  6276. * @param func defines the action to apply on each value.
  6277. */
  6278. forEach(func: (content: T) => void): void;
  6279. /**
  6280. * Sorts the full sets of data.
  6281. * @param compareFn defines the comparison function to apply.
  6282. */
  6283. sort(compareFn: (a: T, b: T) => number): void;
  6284. /**
  6285. * Resets the active data to an empty array.
  6286. */
  6287. reset(): void;
  6288. /**
  6289. * Releases all the data from the array as well as the array.
  6290. */
  6291. dispose(): void;
  6292. /**
  6293. * Concats the active data with a given array.
  6294. * @param array defines the data to concatenate with.
  6295. */
  6296. concat(array: any): void;
  6297. /**
  6298. * Returns the position of a value in the active data.
  6299. * @param value defines the value to find the index for
  6300. * @returns the index if found in the active data otherwise -1
  6301. */
  6302. indexOf(value: T): number;
  6303. /**
  6304. * Returns whether an element is part of the active data.
  6305. * @param value defines the value to look for
  6306. * @returns true if found in the active data otherwise false
  6307. */
  6308. contains(value: T): boolean;
  6309. private static _GlobalId;
  6310. }
  6311. /**
  6312. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6313. * The data in this array can only be present once
  6314. */
  6315. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6316. private _duplicateId;
  6317. /**
  6318. * Pushes a value at the end of the active data.
  6319. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6320. * @param value defines the object to push in the array.
  6321. */
  6322. push(value: T): void;
  6323. /**
  6324. * Pushes a value at the end of the active data.
  6325. * If the data is already present, it won t be added again
  6326. * @param value defines the object to push in the array.
  6327. * @returns true if added false if it was already present
  6328. */
  6329. pushNoDuplicate(value: T): boolean;
  6330. /**
  6331. * Resets the active data to an empty array.
  6332. */
  6333. reset(): void;
  6334. /**
  6335. * Concats the active data with a given array.
  6336. * This ensures no dupplicate will be present in the result.
  6337. * @param array defines the data to concatenate with.
  6338. */
  6339. concatWithNoDuplicate(array: any): void;
  6340. }
  6341. }
  6342. declare module BABYLON {
  6343. /**
  6344. * @ignore
  6345. * This is a list of all the different input types that are available in the application.
  6346. * Fo instance: ArcRotateCameraGamepadInput...
  6347. */
  6348. export var CameraInputTypes: {};
  6349. /**
  6350. * This is the contract to implement in order to create a new input class.
  6351. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6352. */
  6353. export interface ICameraInput<TCamera extends Camera> {
  6354. /**
  6355. * Defines the camera the input is attached to.
  6356. */
  6357. camera: Nullable<TCamera>;
  6358. /**
  6359. * Gets the class name of the current intput.
  6360. * @returns the class name
  6361. */
  6362. getClassName(): string;
  6363. /**
  6364. * Get the friendly name associated with the input class.
  6365. * @returns the input friendly name
  6366. */
  6367. getSimpleName(): string;
  6368. /**
  6369. * Attach the input controls to a specific dom element to get the input from.
  6370. * @param element Defines the element the controls should be listened from
  6371. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6372. */
  6373. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6374. /**
  6375. * Detach the current controls from the specified dom element.
  6376. * @param element Defines the element to stop listening the inputs from
  6377. */
  6378. detachControl(element: Nullable<HTMLElement>): void;
  6379. /**
  6380. * Update the current camera state depending on the inputs that have been used this frame.
  6381. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6382. */
  6383. checkInputs?: () => void;
  6384. }
  6385. /**
  6386. * Represents a map of input types to input instance or input index to input instance.
  6387. */
  6388. export interface CameraInputsMap<TCamera extends Camera> {
  6389. /**
  6390. * Accessor to the input by input type.
  6391. */
  6392. [name: string]: ICameraInput<TCamera>;
  6393. /**
  6394. * Accessor to the input by input index.
  6395. */
  6396. [idx: number]: ICameraInput<TCamera>;
  6397. }
  6398. /**
  6399. * This represents the input manager used within a camera.
  6400. * It helps dealing with all the different kind of input attached to a camera.
  6401. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6402. */
  6403. export class CameraInputsManager<TCamera extends Camera> {
  6404. /**
  6405. * Defines the list of inputs attahed to the camera.
  6406. */
  6407. attached: CameraInputsMap<TCamera>;
  6408. /**
  6409. * Defines the dom element the camera is collecting inputs from.
  6410. * This is null if the controls have not been attached.
  6411. */
  6412. attachedElement: Nullable<HTMLElement>;
  6413. /**
  6414. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6415. */
  6416. noPreventDefault: boolean;
  6417. /**
  6418. * Defined the camera the input manager belongs to.
  6419. */
  6420. camera: TCamera;
  6421. /**
  6422. * Update the current camera state depending on the inputs that have been used this frame.
  6423. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6424. */
  6425. checkInputs: () => void;
  6426. /**
  6427. * Instantiate a new Camera Input Manager.
  6428. * @param camera Defines the camera the input manager blongs to
  6429. */
  6430. constructor(camera: TCamera);
  6431. /**
  6432. * Add an input method to a camera
  6433. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6434. * @param input camera input method
  6435. */
  6436. add(input: ICameraInput<TCamera>): void;
  6437. /**
  6438. * Remove a specific input method from a camera
  6439. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6440. * @param inputToRemove camera input method
  6441. */
  6442. remove(inputToRemove: ICameraInput<TCamera>): void;
  6443. /**
  6444. * Remove a specific input type from a camera
  6445. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6446. * @param inputType the type of the input to remove
  6447. */
  6448. removeByType(inputType: string): void;
  6449. private _addCheckInputs;
  6450. /**
  6451. * Attach the input controls to the currently attached dom element to listen the events from.
  6452. * @param input Defines the input to attach
  6453. */
  6454. attachInput(input: ICameraInput<TCamera>): void;
  6455. /**
  6456. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6457. * @param element Defines the dom element to collect the events from
  6458. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6459. */
  6460. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6461. /**
  6462. * Detach the current manager inputs controls from a specific dom element.
  6463. * @param element Defines the dom element to collect the events from
  6464. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6465. */
  6466. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6467. /**
  6468. * Rebuild the dynamic inputCheck function from the current list of
  6469. * defined inputs in the manager.
  6470. */
  6471. rebuildInputCheck(): void;
  6472. /**
  6473. * Remove all attached input methods from a camera
  6474. */
  6475. clear(): void;
  6476. /**
  6477. * Serialize the current input manager attached to a camera.
  6478. * This ensures than once parsed,
  6479. * the input associated to the camera will be identical to the current ones
  6480. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6481. */
  6482. serialize(serializedCamera: any): void;
  6483. /**
  6484. * Parses an input manager serialized JSON to restore the previous list of inputs
  6485. * and states associated to a camera.
  6486. * @param parsedCamera Defines the JSON to parse
  6487. */
  6488. parse(parsedCamera: any): void;
  6489. }
  6490. }
  6491. declare module BABYLON {
  6492. /**
  6493. * Class used to store data that will be store in GPU memory
  6494. */
  6495. export class Buffer {
  6496. private _engine;
  6497. private _buffer;
  6498. /** @hidden */
  6499. _data: Nullable<DataArray>;
  6500. private _updatable;
  6501. private _instanced;
  6502. private _divisor;
  6503. /**
  6504. * Gets the byte stride.
  6505. */
  6506. readonly byteStride: number;
  6507. /**
  6508. * Constructor
  6509. * @param engine the engine
  6510. * @param data the data to use for this buffer
  6511. * @param updatable whether the data is updatable
  6512. * @param stride the stride (optional)
  6513. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6514. * @param instanced whether the buffer is instanced (optional)
  6515. * @param useBytes set to true if the stride in in bytes (optional)
  6516. * @param divisor sets an optional divisor for instances (1 by default)
  6517. */
  6518. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6519. /**
  6520. * Create a new VertexBuffer based on the current buffer
  6521. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6522. * @param offset defines offset in the buffer (0 by default)
  6523. * @param size defines the size in floats of attributes (position is 3 for instance)
  6524. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6525. * @param instanced defines if the vertex buffer contains indexed data
  6526. * @param useBytes defines if the offset and stride are in bytes *
  6527. * @param divisor sets an optional divisor for instances (1 by default)
  6528. * @returns the new vertex buffer
  6529. */
  6530. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6531. /**
  6532. * Gets a boolean indicating if the Buffer is updatable?
  6533. * @returns true if the buffer is updatable
  6534. */
  6535. isUpdatable(): boolean;
  6536. /**
  6537. * Gets current buffer's data
  6538. * @returns a DataArray or null
  6539. */
  6540. getData(): Nullable<DataArray>;
  6541. /**
  6542. * Gets underlying native buffer
  6543. * @returns underlying native buffer
  6544. */
  6545. getBuffer(): Nullable<DataBuffer>;
  6546. /**
  6547. * Gets the stride in float32 units (i.e. byte stride / 4).
  6548. * May not be an integer if the byte stride is not divisible by 4.
  6549. * @returns the stride in float32 units
  6550. * @deprecated Please use byteStride instead.
  6551. */
  6552. getStrideSize(): number;
  6553. /**
  6554. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6555. * @param data defines the data to store
  6556. */
  6557. create(data?: Nullable<DataArray>): void;
  6558. /** @hidden */
  6559. _rebuild(): void;
  6560. /**
  6561. * Update current buffer data
  6562. * @param data defines the data to store
  6563. */
  6564. update(data: DataArray): void;
  6565. /**
  6566. * Updates the data directly.
  6567. * @param data the new data
  6568. * @param offset the new offset
  6569. * @param vertexCount the vertex count (optional)
  6570. * @param useBytes set to true if the offset is in bytes
  6571. */
  6572. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6573. /**
  6574. * Release all resources
  6575. */
  6576. dispose(): void;
  6577. }
  6578. /**
  6579. * Specialized buffer used to store vertex data
  6580. */
  6581. export class VertexBuffer {
  6582. /** @hidden */
  6583. _buffer: Buffer;
  6584. private _kind;
  6585. private _size;
  6586. private _ownsBuffer;
  6587. private _instanced;
  6588. private _instanceDivisor;
  6589. /**
  6590. * The byte type.
  6591. */
  6592. static readonly BYTE: number;
  6593. /**
  6594. * The unsigned byte type.
  6595. */
  6596. static readonly UNSIGNED_BYTE: number;
  6597. /**
  6598. * The short type.
  6599. */
  6600. static readonly SHORT: number;
  6601. /**
  6602. * The unsigned short type.
  6603. */
  6604. static readonly UNSIGNED_SHORT: number;
  6605. /**
  6606. * The integer type.
  6607. */
  6608. static readonly INT: number;
  6609. /**
  6610. * The unsigned integer type.
  6611. */
  6612. static readonly UNSIGNED_INT: number;
  6613. /**
  6614. * The float type.
  6615. */
  6616. static readonly FLOAT: number;
  6617. /**
  6618. * Gets or sets the instance divisor when in instanced mode
  6619. */
  6620. get instanceDivisor(): number;
  6621. set instanceDivisor(value: number);
  6622. /**
  6623. * Gets the byte stride.
  6624. */
  6625. readonly byteStride: number;
  6626. /**
  6627. * Gets the byte offset.
  6628. */
  6629. readonly byteOffset: number;
  6630. /**
  6631. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6632. */
  6633. readonly normalized: boolean;
  6634. /**
  6635. * Gets the data type of each component in the array.
  6636. */
  6637. readonly type: number;
  6638. /**
  6639. * Constructor
  6640. * @param engine the engine
  6641. * @param data the data to use for this vertex buffer
  6642. * @param kind the vertex buffer kind
  6643. * @param updatable whether the data is updatable
  6644. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6645. * @param stride the stride (optional)
  6646. * @param instanced whether the buffer is instanced (optional)
  6647. * @param offset the offset of the data (optional)
  6648. * @param size the number of components (optional)
  6649. * @param type the type of the component (optional)
  6650. * @param normalized whether the data contains normalized data (optional)
  6651. * @param useBytes set to true if stride and offset are in bytes (optional)
  6652. * @param divisor defines the instance divisor to use (1 by default)
  6653. */
  6654. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6655. /** @hidden */
  6656. _rebuild(): void;
  6657. /**
  6658. * Returns the kind of the VertexBuffer (string)
  6659. * @returns a string
  6660. */
  6661. getKind(): string;
  6662. /**
  6663. * Gets a boolean indicating if the VertexBuffer is updatable?
  6664. * @returns true if the buffer is updatable
  6665. */
  6666. isUpdatable(): boolean;
  6667. /**
  6668. * Gets current buffer's data
  6669. * @returns a DataArray or null
  6670. */
  6671. getData(): Nullable<DataArray>;
  6672. /**
  6673. * Gets underlying native buffer
  6674. * @returns underlying native buffer
  6675. */
  6676. getBuffer(): Nullable<DataBuffer>;
  6677. /**
  6678. * Gets the stride in float32 units (i.e. byte stride / 4).
  6679. * May not be an integer if the byte stride is not divisible by 4.
  6680. * @returns the stride in float32 units
  6681. * @deprecated Please use byteStride instead.
  6682. */
  6683. getStrideSize(): number;
  6684. /**
  6685. * Returns the offset as a multiple of the type byte length.
  6686. * @returns the offset in bytes
  6687. * @deprecated Please use byteOffset instead.
  6688. */
  6689. getOffset(): number;
  6690. /**
  6691. * Returns the number of components per vertex attribute (integer)
  6692. * @returns the size in float
  6693. */
  6694. getSize(): number;
  6695. /**
  6696. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6697. * @returns true if this buffer is instanced
  6698. */
  6699. getIsInstanced(): boolean;
  6700. /**
  6701. * Returns the instancing divisor, zero for non-instanced (integer).
  6702. * @returns a number
  6703. */
  6704. getInstanceDivisor(): number;
  6705. /**
  6706. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6707. * @param data defines the data to store
  6708. */
  6709. create(data?: DataArray): void;
  6710. /**
  6711. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6712. * This function will create a new buffer if the current one is not updatable
  6713. * @param data defines the data to store
  6714. */
  6715. update(data: DataArray): void;
  6716. /**
  6717. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6718. * Returns the directly updated WebGLBuffer.
  6719. * @param data the new data
  6720. * @param offset the new offset
  6721. * @param useBytes set to true if the offset is in bytes
  6722. */
  6723. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6724. /**
  6725. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6726. */
  6727. dispose(): void;
  6728. /**
  6729. * Enumerates each value of this vertex buffer as numbers.
  6730. * @param count the number of values to enumerate
  6731. * @param callback the callback function called for each value
  6732. */
  6733. forEach(count: number, callback: (value: number, index: number) => void): void;
  6734. /**
  6735. * Positions
  6736. */
  6737. static readonly PositionKind: string;
  6738. /**
  6739. * Normals
  6740. */
  6741. static readonly NormalKind: string;
  6742. /**
  6743. * Tangents
  6744. */
  6745. static readonly TangentKind: string;
  6746. /**
  6747. * Texture coordinates
  6748. */
  6749. static readonly UVKind: string;
  6750. /**
  6751. * Texture coordinates 2
  6752. */
  6753. static readonly UV2Kind: string;
  6754. /**
  6755. * Texture coordinates 3
  6756. */
  6757. static readonly UV3Kind: string;
  6758. /**
  6759. * Texture coordinates 4
  6760. */
  6761. static readonly UV4Kind: string;
  6762. /**
  6763. * Texture coordinates 5
  6764. */
  6765. static readonly UV5Kind: string;
  6766. /**
  6767. * Texture coordinates 6
  6768. */
  6769. static readonly UV6Kind: string;
  6770. /**
  6771. * Colors
  6772. */
  6773. static readonly ColorKind: string;
  6774. /**
  6775. * Matrix indices (for bones)
  6776. */
  6777. static readonly MatricesIndicesKind: string;
  6778. /**
  6779. * Matrix weights (for bones)
  6780. */
  6781. static readonly MatricesWeightsKind: string;
  6782. /**
  6783. * Additional matrix indices (for bones)
  6784. */
  6785. static readonly MatricesIndicesExtraKind: string;
  6786. /**
  6787. * Additional matrix weights (for bones)
  6788. */
  6789. static readonly MatricesWeightsExtraKind: string;
  6790. /**
  6791. * Deduces the stride given a kind.
  6792. * @param kind The kind string to deduce
  6793. * @returns The deduced stride
  6794. */
  6795. static DeduceStride(kind: string): number;
  6796. /**
  6797. * Gets the byte length of the given type.
  6798. * @param type the type
  6799. * @returns the number of bytes
  6800. */
  6801. static GetTypeByteLength(type: number): number;
  6802. /**
  6803. * Enumerates each value of the given parameters as numbers.
  6804. * @param data the data to enumerate
  6805. * @param byteOffset the byte offset of the data
  6806. * @param byteStride the byte stride of the data
  6807. * @param componentCount the number of components per element
  6808. * @param componentType the type of the component
  6809. * @param count the number of values to enumerate
  6810. * @param normalized whether the data is normalized
  6811. * @param callback the callback function called for each value
  6812. */
  6813. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6814. private static _GetFloatValue;
  6815. }
  6816. }
  6817. declare module BABYLON {
  6818. /**
  6819. * @hidden
  6820. */
  6821. export class IntersectionInfo {
  6822. bu: Nullable<number>;
  6823. bv: Nullable<number>;
  6824. distance: number;
  6825. faceId: number;
  6826. subMeshId: number;
  6827. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6828. }
  6829. }
  6830. declare module BABYLON {
  6831. /**
  6832. * Class used to store bounding sphere information
  6833. */
  6834. export class BoundingSphere {
  6835. /**
  6836. * Gets the center of the bounding sphere in local space
  6837. */
  6838. readonly center: Vector3;
  6839. /**
  6840. * Radius of the bounding sphere in local space
  6841. */
  6842. radius: number;
  6843. /**
  6844. * Gets the center of the bounding sphere in world space
  6845. */
  6846. readonly centerWorld: Vector3;
  6847. /**
  6848. * Radius of the bounding sphere in world space
  6849. */
  6850. radiusWorld: number;
  6851. /**
  6852. * Gets the minimum vector in local space
  6853. */
  6854. readonly minimum: Vector3;
  6855. /**
  6856. * Gets the maximum vector in local space
  6857. */
  6858. readonly maximum: Vector3;
  6859. private _worldMatrix;
  6860. private static readonly TmpVector3;
  6861. /**
  6862. * Creates a new bounding sphere
  6863. * @param min defines the minimum vector (in local space)
  6864. * @param max defines the maximum vector (in local space)
  6865. * @param worldMatrix defines the new world matrix
  6866. */
  6867. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6868. /**
  6869. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6870. * @param min defines the new minimum vector (in local space)
  6871. * @param max defines the new maximum vector (in local space)
  6872. * @param worldMatrix defines the new world matrix
  6873. */
  6874. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6875. /**
  6876. * Scale the current bounding sphere by applying a scale factor
  6877. * @param factor defines the scale factor to apply
  6878. * @returns the current bounding box
  6879. */
  6880. scale(factor: number): BoundingSphere;
  6881. /**
  6882. * Gets the world matrix of the bounding box
  6883. * @returns a matrix
  6884. */
  6885. getWorldMatrix(): DeepImmutable<Matrix>;
  6886. /** @hidden */
  6887. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6888. /**
  6889. * Tests if the bounding sphere is intersecting the frustum planes
  6890. * @param frustumPlanes defines the frustum planes to test
  6891. * @returns true if there is an intersection
  6892. */
  6893. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6894. /**
  6895. * Tests if the bounding sphere center is in between the frustum planes.
  6896. * Used for optimistic fast inclusion.
  6897. * @param frustumPlanes defines the frustum planes to test
  6898. * @returns true if the sphere center is in between the frustum planes
  6899. */
  6900. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6901. /**
  6902. * Tests if a point is inside the bounding sphere
  6903. * @param point defines the point to test
  6904. * @returns true if the point is inside the bounding sphere
  6905. */
  6906. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6907. /**
  6908. * Checks if two sphere intersct
  6909. * @param sphere0 sphere 0
  6910. * @param sphere1 sphere 1
  6911. * @returns true if the speres intersect
  6912. */
  6913. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6914. }
  6915. }
  6916. declare module BABYLON {
  6917. /**
  6918. * Class used to store bounding box information
  6919. */
  6920. export class BoundingBox implements ICullable {
  6921. /**
  6922. * Gets the 8 vectors representing the bounding box in local space
  6923. */
  6924. readonly vectors: Vector3[];
  6925. /**
  6926. * Gets the center of the bounding box in local space
  6927. */
  6928. readonly center: Vector3;
  6929. /**
  6930. * Gets the center of the bounding box in world space
  6931. */
  6932. readonly centerWorld: Vector3;
  6933. /**
  6934. * Gets the extend size in local space
  6935. */
  6936. readonly extendSize: Vector3;
  6937. /**
  6938. * Gets the extend size in world space
  6939. */
  6940. readonly extendSizeWorld: Vector3;
  6941. /**
  6942. * Gets the OBB (object bounding box) directions
  6943. */
  6944. readonly directions: Vector3[];
  6945. /**
  6946. * Gets the 8 vectors representing the bounding box in world space
  6947. */
  6948. readonly vectorsWorld: Vector3[];
  6949. /**
  6950. * Gets the minimum vector in world space
  6951. */
  6952. readonly minimumWorld: Vector3;
  6953. /**
  6954. * Gets the maximum vector in world space
  6955. */
  6956. readonly maximumWorld: Vector3;
  6957. /**
  6958. * Gets the minimum vector in local space
  6959. */
  6960. readonly minimum: Vector3;
  6961. /**
  6962. * Gets the maximum vector in local space
  6963. */
  6964. readonly maximum: Vector3;
  6965. private _worldMatrix;
  6966. private static readonly TmpVector3;
  6967. /**
  6968. * @hidden
  6969. */
  6970. _tag: number;
  6971. /**
  6972. * Creates a new bounding box
  6973. * @param min defines the minimum vector (in local space)
  6974. * @param max defines the maximum vector (in local space)
  6975. * @param worldMatrix defines the new world matrix
  6976. */
  6977. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6978. /**
  6979. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6980. * @param min defines the new minimum vector (in local space)
  6981. * @param max defines the new maximum vector (in local space)
  6982. * @param worldMatrix defines the new world matrix
  6983. */
  6984. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6985. /**
  6986. * Scale the current bounding box by applying a scale factor
  6987. * @param factor defines the scale factor to apply
  6988. * @returns the current bounding box
  6989. */
  6990. scale(factor: number): BoundingBox;
  6991. /**
  6992. * Gets the world matrix of the bounding box
  6993. * @returns a matrix
  6994. */
  6995. getWorldMatrix(): DeepImmutable<Matrix>;
  6996. /** @hidden */
  6997. _update(world: DeepImmutable<Matrix>): void;
  6998. /**
  6999. * Tests if the bounding box is intersecting the frustum planes
  7000. * @param frustumPlanes defines the frustum planes to test
  7001. * @returns true if there is an intersection
  7002. */
  7003. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7004. /**
  7005. * Tests if the bounding box is entirely inside the frustum planes
  7006. * @param frustumPlanes defines the frustum planes to test
  7007. * @returns true if there is an inclusion
  7008. */
  7009. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7010. /**
  7011. * Tests if a point is inside the bounding box
  7012. * @param point defines the point to test
  7013. * @returns true if the point is inside the bounding box
  7014. */
  7015. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7016. /**
  7017. * Tests if the bounding box intersects with a bounding sphere
  7018. * @param sphere defines the sphere to test
  7019. * @returns true if there is an intersection
  7020. */
  7021. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7022. /**
  7023. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7024. * @param min defines the min vector to use
  7025. * @param max defines the max vector to use
  7026. * @returns true if there is an intersection
  7027. */
  7028. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7029. /**
  7030. * Tests if two bounding boxes are intersections
  7031. * @param box0 defines the first box to test
  7032. * @param box1 defines the second box to test
  7033. * @returns true if there is an intersection
  7034. */
  7035. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7036. /**
  7037. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7038. * @param minPoint defines the minimum vector of the bounding box
  7039. * @param maxPoint defines the maximum vector of the bounding box
  7040. * @param sphereCenter defines the sphere center
  7041. * @param sphereRadius defines the sphere radius
  7042. * @returns true if there is an intersection
  7043. */
  7044. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7045. /**
  7046. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7047. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7048. * @param frustumPlanes defines the frustum planes to test
  7049. * @return true if there is an inclusion
  7050. */
  7051. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7052. /**
  7053. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7054. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7055. * @param frustumPlanes defines the frustum planes to test
  7056. * @return true if there is an intersection
  7057. */
  7058. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7059. }
  7060. }
  7061. declare module BABYLON {
  7062. /** @hidden */
  7063. export class Collider {
  7064. /** Define if a collision was found */
  7065. collisionFound: boolean;
  7066. /**
  7067. * Define last intersection point in local space
  7068. */
  7069. intersectionPoint: Vector3;
  7070. /**
  7071. * Define last collided mesh
  7072. */
  7073. collidedMesh: Nullable<AbstractMesh>;
  7074. private _collisionPoint;
  7075. private _planeIntersectionPoint;
  7076. private _tempVector;
  7077. private _tempVector2;
  7078. private _tempVector3;
  7079. private _tempVector4;
  7080. private _edge;
  7081. private _baseToVertex;
  7082. private _destinationPoint;
  7083. private _slidePlaneNormal;
  7084. private _displacementVector;
  7085. /** @hidden */
  7086. _radius: Vector3;
  7087. /** @hidden */
  7088. _retry: number;
  7089. private _velocity;
  7090. private _basePoint;
  7091. private _epsilon;
  7092. /** @hidden */
  7093. _velocityWorldLength: number;
  7094. /** @hidden */
  7095. _basePointWorld: Vector3;
  7096. private _velocityWorld;
  7097. private _normalizedVelocity;
  7098. /** @hidden */
  7099. _initialVelocity: Vector3;
  7100. /** @hidden */
  7101. _initialPosition: Vector3;
  7102. private _nearestDistance;
  7103. private _collisionMask;
  7104. get collisionMask(): number;
  7105. set collisionMask(mask: number);
  7106. /**
  7107. * Gets the plane normal used to compute the sliding response (in local space)
  7108. */
  7109. get slidePlaneNormal(): Vector3;
  7110. /** @hidden */
  7111. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7112. /** @hidden */
  7113. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7114. /** @hidden */
  7115. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7116. /** @hidden */
  7117. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7118. /** @hidden */
  7119. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7120. /** @hidden */
  7121. _getResponse(pos: Vector3, vel: Vector3): void;
  7122. }
  7123. }
  7124. declare module BABYLON {
  7125. /**
  7126. * Interface for cullable objects
  7127. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7128. */
  7129. export interface ICullable {
  7130. /**
  7131. * Checks if the object or part of the object is in the frustum
  7132. * @param frustumPlanes Camera near/planes
  7133. * @returns true if the object is in frustum otherwise false
  7134. */
  7135. isInFrustum(frustumPlanes: Plane[]): boolean;
  7136. /**
  7137. * Checks if a cullable object (mesh...) is in the camera frustum
  7138. * Unlike isInFrustum this cheks the full bounding box
  7139. * @param frustumPlanes Camera near/planes
  7140. * @returns true if the object is in frustum otherwise false
  7141. */
  7142. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7143. }
  7144. /**
  7145. * Info for a bounding data of a mesh
  7146. */
  7147. export class BoundingInfo implements ICullable {
  7148. /**
  7149. * Bounding box for the mesh
  7150. */
  7151. readonly boundingBox: BoundingBox;
  7152. /**
  7153. * Bounding sphere for the mesh
  7154. */
  7155. readonly boundingSphere: BoundingSphere;
  7156. private _isLocked;
  7157. private static readonly TmpVector3;
  7158. /**
  7159. * Constructs bounding info
  7160. * @param minimum min vector of the bounding box/sphere
  7161. * @param maximum max vector of the bounding box/sphere
  7162. * @param worldMatrix defines the new world matrix
  7163. */
  7164. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7165. /**
  7166. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7167. * @param min defines the new minimum vector (in local space)
  7168. * @param max defines the new maximum vector (in local space)
  7169. * @param worldMatrix defines the new world matrix
  7170. */
  7171. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7172. /**
  7173. * min vector of the bounding box/sphere
  7174. */
  7175. get minimum(): Vector3;
  7176. /**
  7177. * max vector of the bounding box/sphere
  7178. */
  7179. get maximum(): Vector3;
  7180. /**
  7181. * If the info is locked and won't be updated to avoid perf overhead
  7182. */
  7183. get isLocked(): boolean;
  7184. set isLocked(value: boolean);
  7185. /**
  7186. * Updates the bounding sphere and box
  7187. * @param world world matrix to be used to update
  7188. */
  7189. update(world: DeepImmutable<Matrix>): void;
  7190. /**
  7191. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7192. * @param center New center of the bounding info
  7193. * @param extend New extend of the bounding info
  7194. * @returns the current bounding info
  7195. */
  7196. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7197. /**
  7198. * Scale the current bounding info by applying a scale factor
  7199. * @param factor defines the scale factor to apply
  7200. * @returns the current bounding info
  7201. */
  7202. scale(factor: number): BoundingInfo;
  7203. /**
  7204. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7205. * @param frustumPlanes defines the frustum to test
  7206. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7207. * @returns true if the bounding info is in the frustum planes
  7208. */
  7209. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7210. /**
  7211. * Gets the world distance between the min and max points of the bounding box
  7212. */
  7213. get diagonalLength(): number;
  7214. /**
  7215. * Checks if a cullable object (mesh...) is in the camera frustum
  7216. * Unlike isInFrustum this cheks the full bounding box
  7217. * @param frustumPlanes Camera near/planes
  7218. * @returns true if the object is in frustum otherwise false
  7219. */
  7220. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7221. /** @hidden */
  7222. _checkCollision(collider: Collider): boolean;
  7223. /**
  7224. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7225. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7226. * @param point the point to check intersection with
  7227. * @returns if the point intersects
  7228. */
  7229. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7230. /**
  7231. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7232. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7233. * @param boundingInfo the bounding info to check intersection with
  7234. * @param precise if the intersection should be done using OBB
  7235. * @returns if the bounding info intersects
  7236. */
  7237. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7238. }
  7239. }
  7240. declare module BABYLON {
  7241. /**
  7242. * Extracts minimum and maximum values from a list of indexed positions
  7243. * @param positions defines the positions to use
  7244. * @param indices defines the indices to the positions
  7245. * @param indexStart defines the start index
  7246. * @param indexCount defines the end index
  7247. * @param bias defines bias value to add to the result
  7248. * @return minimum and maximum values
  7249. */
  7250. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7251. minimum: Vector3;
  7252. maximum: Vector3;
  7253. };
  7254. /**
  7255. * Extracts minimum and maximum values from a list of positions
  7256. * @param positions defines the positions to use
  7257. * @param start defines the start index in the positions array
  7258. * @param count defines the number of positions to handle
  7259. * @param bias defines bias value to add to the result
  7260. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7261. * @return minimum and maximum values
  7262. */
  7263. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7264. minimum: Vector3;
  7265. maximum: Vector3;
  7266. };
  7267. }
  7268. declare module BABYLON {
  7269. /** @hidden */
  7270. export class WebGLDataBuffer extends DataBuffer {
  7271. private _buffer;
  7272. constructor(resource: WebGLBuffer);
  7273. get underlyingResource(): any;
  7274. }
  7275. }
  7276. declare module BABYLON {
  7277. /** @hidden */
  7278. export class WebGLPipelineContext implements IPipelineContext {
  7279. engine: ThinEngine;
  7280. program: Nullable<WebGLProgram>;
  7281. context?: WebGLRenderingContext;
  7282. vertexShader?: WebGLShader;
  7283. fragmentShader?: WebGLShader;
  7284. isParallelCompiled: boolean;
  7285. onCompiled?: () => void;
  7286. transformFeedback?: WebGLTransformFeedback | null;
  7287. vertexCompilationError: Nullable<string>;
  7288. fragmentCompilationError: Nullable<string>;
  7289. programLinkError: Nullable<string>;
  7290. programValidationError: Nullable<string>;
  7291. get isAsync(): boolean;
  7292. get isReady(): boolean;
  7293. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7294. _getVertexShaderCode(): string | null;
  7295. _getFragmentShaderCode(): string | null;
  7296. }
  7297. }
  7298. declare module BABYLON {
  7299. interface ThinEngine {
  7300. /**
  7301. * Create an uniform buffer
  7302. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7303. * @param elements defines the content of the uniform buffer
  7304. * @returns the webGL uniform buffer
  7305. */
  7306. createUniformBuffer(elements: FloatArray): DataBuffer;
  7307. /**
  7308. * Create a dynamic uniform buffer
  7309. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7310. * @param elements defines the content of the uniform buffer
  7311. * @returns the webGL uniform buffer
  7312. */
  7313. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7314. /**
  7315. * Update an existing uniform buffer
  7316. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7317. * @param uniformBuffer defines the target uniform buffer
  7318. * @param elements defines the content to update
  7319. * @param offset defines the offset in the uniform buffer where update should start
  7320. * @param count defines the size of the data to update
  7321. */
  7322. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7323. /**
  7324. * Bind an uniform buffer to the current webGL context
  7325. * @param buffer defines the buffer to bind
  7326. */
  7327. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7328. /**
  7329. * Bind a buffer to the current webGL context at a given location
  7330. * @param buffer defines the buffer to bind
  7331. * @param location defines the index where to bind the buffer
  7332. */
  7333. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7334. /**
  7335. * Bind a specific block at a given index in a specific shader program
  7336. * @param pipelineContext defines the pipeline context to use
  7337. * @param blockName defines the block name
  7338. * @param index defines the index where to bind the block
  7339. */
  7340. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7341. }
  7342. }
  7343. declare module BABYLON {
  7344. /**
  7345. * Uniform buffer objects.
  7346. *
  7347. * Handles blocks of uniform on the GPU.
  7348. *
  7349. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7350. *
  7351. * For more information, please refer to :
  7352. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7353. */
  7354. export class UniformBuffer {
  7355. private _engine;
  7356. private _buffer;
  7357. private _data;
  7358. private _bufferData;
  7359. private _dynamic?;
  7360. private _uniformLocations;
  7361. private _uniformSizes;
  7362. private _uniformLocationPointer;
  7363. private _needSync;
  7364. private _noUBO;
  7365. private _currentEffect;
  7366. /** @hidden */
  7367. _alreadyBound: boolean;
  7368. private static _MAX_UNIFORM_SIZE;
  7369. private static _tempBuffer;
  7370. /**
  7371. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7372. * This is dynamic to allow compat with webgl 1 and 2.
  7373. * You will need to pass the name of the uniform as well as the value.
  7374. */
  7375. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7376. /**
  7377. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7378. * This is dynamic to allow compat with webgl 1 and 2.
  7379. * You will need to pass the name of the uniform as well as the value.
  7380. */
  7381. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7382. /**
  7383. * Lambda to Update a single float in a uniform buffer.
  7384. * This is dynamic to allow compat with webgl 1 and 2.
  7385. * You will need to pass the name of the uniform as well as the value.
  7386. */
  7387. updateFloat: (name: string, x: number) => void;
  7388. /**
  7389. * Lambda to Update a vec2 of float in a uniform buffer.
  7390. * This is dynamic to allow compat with webgl 1 and 2.
  7391. * You will need to pass the name of the uniform as well as the value.
  7392. */
  7393. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7394. /**
  7395. * Lambda to Update a vec3 of float in a uniform buffer.
  7396. * This is dynamic to allow compat with webgl 1 and 2.
  7397. * You will need to pass the name of the uniform as well as the value.
  7398. */
  7399. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7400. /**
  7401. * Lambda to Update a vec4 of float in a uniform buffer.
  7402. * This is dynamic to allow compat with webgl 1 and 2.
  7403. * You will need to pass the name of the uniform as well as the value.
  7404. */
  7405. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7406. /**
  7407. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7408. * This is dynamic to allow compat with webgl 1 and 2.
  7409. * You will need to pass the name of the uniform as well as the value.
  7410. */
  7411. updateMatrix: (name: string, mat: Matrix) => void;
  7412. /**
  7413. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7414. * This is dynamic to allow compat with webgl 1 and 2.
  7415. * You will need to pass the name of the uniform as well as the value.
  7416. */
  7417. updateVector3: (name: string, vector: Vector3) => void;
  7418. /**
  7419. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7420. * This is dynamic to allow compat with webgl 1 and 2.
  7421. * You will need to pass the name of the uniform as well as the value.
  7422. */
  7423. updateVector4: (name: string, vector: Vector4) => void;
  7424. /**
  7425. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7426. * This is dynamic to allow compat with webgl 1 and 2.
  7427. * You will need to pass the name of the uniform as well as the value.
  7428. */
  7429. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7430. /**
  7431. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7432. * This is dynamic to allow compat with webgl 1 and 2.
  7433. * You will need to pass the name of the uniform as well as the value.
  7434. */
  7435. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7436. /**
  7437. * Instantiates a new Uniform buffer objects.
  7438. *
  7439. * Handles blocks of uniform on the GPU.
  7440. *
  7441. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7442. *
  7443. * For more information, please refer to :
  7444. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7445. * @param engine Define the engine the buffer is associated with
  7446. * @param data Define the data contained in the buffer
  7447. * @param dynamic Define if the buffer is updatable
  7448. */
  7449. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7450. /**
  7451. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7452. * or just falling back on setUniformXXX calls.
  7453. */
  7454. get useUbo(): boolean;
  7455. /**
  7456. * Indicates if the WebGL underlying uniform buffer is in sync
  7457. * with the javascript cache data.
  7458. */
  7459. get isSync(): boolean;
  7460. /**
  7461. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7462. * Also, a dynamic UniformBuffer will disable cache verification and always
  7463. * update the underlying WebGL uniform buffer to the GPU.
  7464. * @returns if Dynamic, otherwise false
  7465. */
  7466. isDynamic(): boolean;
  7467. /**
  7468. * The data cache on JS side.
  7469. * @returns the underlying data as a float array
  7470. */
  7471. getData(): Float32Array;
  7472. /**
  7473. * The underlying WebGL Uniform buffer.
  7474. * @returns the webgl buffer
  7475. */
  7476. getBuffer(): Nullable<DataBuffer>;
  7477. /**
  7478. * std140 layout specifies how to align data within an UBO structure.
  7479. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7480. * for specs.
  7481. */
  7482. private _fillAlignment;
  7483. /**
  7484. * Adds an uniform in the buffer.
  7485. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7486. * for the layout to be correct !
  7487. * @param name Name of the uniform, as used in the uniform block in the shader.
  7488. * @param size Data size, or data directly.
  7489. */
  7490. addUniform(name: string, size: number | number[]): void;
  7491. /**
  7492. * Adds a Matrix 4x4 to the uniform buffer.
  7493. * @param name Name of the uniform, as used in the uniform block in the shader.
  7494. * @param mat A 4x4 matrix.
  7495. */
  7496. addMatrix(name: string, mat: Matrix): void;
  7497. /**
  7498. * Adds a vec2 to the uniform buffer.
  7499. * @param name Name of the uniform, as used in the uniform block in the shader.
  7500. * @param x Define the x component value of the vec2
  7501. * @param y Define the y component value of the vec2
  7502. */
  7503. addFloat2(name: string, x: number, y: number): void;
  7504. /**
  7505. * Adds a vec3 to the uniform buffer.
  7506. * @param name Name of the uniform, as used in the uniform block in the shader.
  7507. * @param x Define the x component value of the vec3
  7508. * @param y Define the y component value of the vec3
  7509. * @param z Define the z component value of the vec3
  7510. */
  7511. addFloat3(name: string, x: number, y: number, z: number): void;
  7512. /**
  7513. * Adds a vec3 to the uniform buffer.
  7514. * @param name Name of the uniform, as used in the uniform block in the shader.
  7515. * @param color Define the vec3 from a Color
  7516. */
  7517. addColor3(name: string, color: Color3): void;
  7518. /**
  7519. * Adds a vec4 to the uniform buffer.
  7520. * @param name Name of the uniform, as used in the uniform block in the shader.
  7521. * @param color Define the rgb components from a Color
  7522. * @param alpha Define the a component of the vec4
  7523. */
  7524. addColor4(name: string, color: Color3, alpha: number): void;
  7525. /**
  7526. * Adds a vec3 to the uniform buffer.
  7527. * @param name Name of the uniform, as used in the uniform block in the shader.
  7528. * @param vector Define the vec3 components from a Vector
  7529. */
  7530. addVector3(name: string, vector: Vector3): void;
  7531. /**
  7532. * Adds a Matrix 3x3 to the uniform buffer.
  7533. * @param name Name of the uniform, as used in the uniform block in the shader.
  7534. */
  7535. addMatrix3x3(name: string): void;
  7536. /**
  7537. * Adds a Matrix 2x2 to the uniform buffer.
  7538. * @param name Name of the uniform, as used in the uniform block in the shader.
  7539. */
  7540. addMatrix2x2(name: string): void;
  7541. /**
  7542. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7543. */
  7544. create(): void;
  7545. /** @hidden */
  7546. _rebuild(): void;
  7547. /**
  7548. * Updates the WebGL Uniform Buffer on the GPU.
  7549. * If the `dynamic` flag is set to true, no cache comparison is done.
  7550. * Otherwise, the buffer will be updated only if the cache differs.
  7551. */
  7552. update(): void;
  7553. /**
  7554. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7555. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7556. * @param data Define the flattened data
  7557. * @param size Define the size of the data.
  7558. */
  7559. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7560. private _valueCache;
  7561. private _cacheMatrix;
  7562. private _updateMatrix3x3ForUniform;
  7563. private _updateMatrix3x3ForEffect;
  7564. private _updateMatrix2x2ForEffect;
  7565. private _updateMatrix2x2ForUniform;
  7566. private _updateFloatForEffect;
  7567. private _updateFloatForUniform;
  7568. private _updateFloat2ForEffect;
  7569. private _updateFloat2ForUniform;
  7570. private _updateFloat3ForEffect;
  7571. private _updateFloat3ForUniform;
  7572. private _updateFloat4ForEffect;
  7573. private _updateFloat4ForUniform;
  7574. private _updateMatrixForEffect;
  7575. private _updateMatrixForUniform;
  7576. private _updateVector3ForEffect;
  7577. private _updateVector3ForUniform;
  7578. private _updateVector4ForEffect;
  7579. private _updateVector4ForUniform;
  7580. private _updateColor3ForEffect;
  7581. private _updateColor3ForUniform;
  7582. private _updateColor4ForEffect;
  7583. private _updateColor4ForUniform;
  7584. /**
  7585. * Sets a sampler uniform on the effect.
  7586. * @param name Define the name of the sampler.
  7587. * @param texture Define the texture to set in the sampler
  7588. */
  7589. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7590. /**
  7591. * Directly updates the value of the uniform in the cache AND on the GPU.
  7592. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7593. * @param data Define the flattened data
  7594. */
  7595. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7596. /**
  7597. * Binds this uniform buffer to an effect.
  7598. * @param effect Define the effect to bind the buffer to
  7599. * @param name Name of the uniform block in the shader.
  7600. */
  7601. bindToEffect(effect: Effect, name: string): void;
  7602. /**
  7603. * Disposes the uniform buffer.
  7604. */
  7605. dispose(): void;
  7606. }
  7607. }
  7608. declare module BABYLON {
  7609. /**
  7610. * Enum that determines the text-wrapping mode to use.
  7611. */
  7612. export enum InspectableType {
  7613. /**
  7614. * Checkbox for booleans
  7615. */
  7616. Checkbox = 0,
  7617. /**
  7618. * Sliders for numbers
  7619. */
  7620. Slider = 1,
  7621. /**
  7622. * Vector3
  7623. */
  7624. Vector3 = 2,
  7625. /**
  7626. * Quaternions
  7627. */
  7628. Quaternion = 3,
  7629. /**
  7630. * Color3
  7631. */
  7632. Color3 = 4,
  7633. /**
  7634. * String
  7635. */
  7636. String = 5
  7637. }
  7638. /**
  7639. * Interface used to define custom inspectable properties.
  7640. * This interface is used by the inspector to display custom property grids
  7641. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7642. */
  7643. export interface IInspectable {
  7644. /**
  7645. * Gets the label to display
  7646. */
  7647. label: string;
  7648. /**
  7649. * Gets the name of the property to edit
  7650. */
  7651. propertyName: string;
  7652. /**
  7653. * Gets the type of the editor to use
  7654. */
  7655. type: InspectableType;
  7656. /**
  7657. * Gets the minimum value of the property when using in "slider" mode
  7658. */
  7659. min?: number;
  7660. /**
  7661. * Gets the maximum value of the property when using in "slider" mode
  7662. */
  7663. max?: number;
  7664. /**
  7665. * Gets the setp to use when using in "slider" mode
  7666. */
  7667. step?: number;
  7668. }
  7669. }
  7670. declare module BABYLON {
  7671. /**
  7672. * Class used to provide helper for timing
  7673. */
  7674. export class TimingTools {
  7675. /**
  7676. * Polyfill for setImmediate
  7677. * @param action defines the action to execute after the current execution block
  7678. */
  7679. static SetImmediate(action: () => void): void;
  7680. }
  7681. }
  7682. declare module BABYLON {
  7683. /**
  7684. * Class used to enable instatition of objects by class name
  7685. */
  7686. export class InstantiationTools {
  7687. /**
  7688. * Use this object to register external classes like custom textures or material
  7689. * to allow the laoders to instantiate them
  7690. */
  7691. static RegisteredExternalClasses: {
  7692. [key: string]: Object;
  7693. };
  7694. /**
  7695. * Tries to instantiate a new object from a given class name
  7696. * @param className defines the class name to instantiate
  7697. * @returns the new object or null if the system was not able to do the instantiation
  7698. */
  7699. static Instantiate(className: string): any;
  7700. }
  7701. }
  7702. declare module BABYLON {
  7703. /**
  7704. * Define options used to create a depth texture
  7705. */
  7706. export class DepthTextureCreationOptions {
  7707. /** Specifies whether or not a stencil should be allocated in the texture */
  7708. generateStencil?: boolean;
  7709. /** Specifies whether or not bilinear filtering is enable on the texture */
  7710. bilinearFiltering?: boolean;
  7711. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7712. comparisonFunction?: number;
  7713. /** Specifies if the created texture is a cube texture */
  7714. isCube?: boolean;
  7715. }
  7716. }
  7717. declare module BABYLON {
  7718. interface ThinEngine {
  7719. /**
  7720. * Creates a depth stencil cube texture.
  7721. * This is only available in WebGL 2.
  7722. * @param size The size of face edge in the cube texture.
  7723. * @param options The options defining the cube texture.
  7724. * @returns The cube texture
  7725. */
  7726. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7727. /**
  7728. * Creates a cube texture
  7729. * @param rootUrl defines the url where the files to load is located
  7730. * @param scene defines the current scene
  7731. * @param files defines the list of files to load (1 per face)
  7732. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7733. * @param onLoad defines an optional callback raised when the texture is loaded
  7734. * @param onError defines an optional callback raised if there is an issue to load the texture
  7735. * @param format defines the format of the data
  7736. * @param forcedExtension defines the extension to use to pick the right loader
  7737. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7738. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7739. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7740. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7741. * @returns the cube texture as an InternalTexture
  7742. */
  7743. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  7744. /**
  7745. * Creates a cube texture
  7746. * @param rootUrl defines the url where the files to load is located
  7747. * @param scene defines the current scene
  7748. * @param files defines the list of files to load (1 per face)
  7749. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7750. * @param onLoad defines an optional callback raised when the texture is loaded
  7751. * @param onError defines an optional callback raised if there is an issue to load the texture
  7752. * @param format defines the format of the data
  7753. * @param forcedExtension defines the extension to use to pick the right loader
  7754. * @returns the cube texture as an InternalTexture
  7755. */
  7756. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7757. /**
  7758. * Creates a cube texture
  7759. * @param rootUrl defines the url where the files to load is located
  7760. * @param scene defines the current scene
  7761. * @param files defines the list of files to load (1 per face)
  7762. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7763. * @param onLoad defines an optional callback raised when the texture is loaded
  7764. * @param onError defines an optional callback raised if there is an issue to load the texture
  7765. * @param format defines the format of the data
  7766. * @param forcedExtension defines the extension to use to pick the right loader
  7767. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7768. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7769. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7770. * @returns the cube texture as an InternalTexture
  7771. */
  7772. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7773. /** @hidden */
  7774. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7775. /** @hidden */
  7776. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7777. /** @hidden */
  7778. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7779. /** @hidden */
  7780. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7781. /**
  7782. * @hidden
  7783. */
  7784. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7785. }
  7786. }
  7787. declare module BABYLON {
  7788. /**
  7789. * Class for creating a cube texture
  7790. */
  7791. export class CubeTexture extends BaseTexture {
  7792. private _delayedOnLoad;
  7793. /**
  7794. * Observable triggered once the texture has been loaded.
  7795. */
  7796. onLoadObservable: Observable<CubeTexture>;
  7797. /**
  7798. * The url of the texture
  7799. */
  7800. url: string;
  7801. /**
  7802. * Gets or sets the center of the bounding box associated with the cube texture.
  7803. * It must define where the camera used to render the texture was set
  7804. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7805. */
  7806. boundingBoxPosition: Vector3;
  7807. private _boundingBoxSize;
  7808. /**
  7809. * Gets or sets the size of the bounding box associated with the cube texture
  7810. * When defined, the cubemap will switch to local mode
  7811. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7812. * @example https://www.babylonjs-playground.com/#RNASML
  7813. */
  7814. set boundingBoxSize(value: Vector3);
  7815. /**
  7816. * Returns the bounding box size
  7817. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7818. */
  7819. get boundingBoxSize(): Vector3;
  7820. protected _rotationY: number;
  7821. /**
  7822. * Sets texture matrix rotation angle around Y axis in radians.
  7823. */
  7824. set rotationY(value: number);
  7825. /**
  7826. * Gets texture matrix rotation angle around Y axis radians.
  7827. */
  7828. get rotationY(): number;
  7829. /**
  7830. * Are mip maps generated for this texture or not.
  7831. */
  7832. get noMipmap(): boolean;
  7833. private _noMipmap;
  7834. private _files;
  7835. protected _forcedExtension: Nullable<string>;
  7836. private _extensions;
  7837. private _textureMatrix;
  7838. private _format;
  7839. private _createPolynomials;
  7840. /**
  7841. * Creates a cube texture from an array of image urls
  7842. * @param files defines an array of image urls
  7843. * @param scene defines the hosting scene
  7844. * @param noMipmap specifies if mip maps are not used
  7845. * @returns a cube texture
  7846. */
  7847. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7848. /**
  7849. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7850. * @param url defines the url of the prefiltered texture
  7851. * @param scene defines the scene the texture is attached to
  7852. * @param forcedExtension defines the extension of the file if different from the url
  7853. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7854. * @return the prefiltered texture
  7855. */
  7856. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7857. /**
  7858. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7859. * as prefiltered data.
  7860. * @param rootUrl defines the url of the texture or the root name of the six images
  7861. * @param null defines the scene or engine the texture is attached to
  7862. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7863. * @param noMipmap defines if mipmaps should be created or not
  7864. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7865. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7866. * @param onError defines a callback triggered in case of error during load
  7867. * @param format defines the internal format to use for the texture once loaded
  7868. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7869. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7870. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7871. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7872. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7873. * @return the cube texture
  7874. */
  7875. constructor(rootUrl: string, sceneOrEngine: Scene | ThinEngine, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7876. /**
  7877. * Get the current class name of the texture useful for serialization or dynamic coding.
  7878. * @returns "CubeTexture"
  7879. */
  7880. getClassName(): string;
  7881. /**
  7882. * Update the url (and optional buffer) of this texture if url was null during construction.
  7883. * @param url the url of the texture
  7884. * @param forcedExtension defines the extension to use
  7885. * @param onLoad callback called when the texture is loaded (defaults to null)
  7886. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7887. */
  7888. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7889. /**
  7890. * Delays loading of the cube texture
  7891. * @param forcedExtension defines the extension to use
  7892. */
  7893. delayLoad(forcedExtension?: string): void;
  7894. /**
  7895. * Returns the reflection texture matrix
  7896. * @returns the reflection texture matrix
  7897. */
  7898. getReflectionTextureMatrix(): Matrix;
  7899. /**
  7900. * Sets the reflection texture matrix
  7901. * @param value Reflection texture matrix
  7902. */
  7903. setReflectionTextureMatrix(value: Matrix): void;
  7904. /**
  7905. * Parses text to create a cube texture
  7906. * @param parsedTexture define the serialized text to read from
  7907. * @param scene defines the hosting scene
  7908. * @param rootUrl defines the root url of the cube texture
  7909. * @returns a cube texture
  7910. */
  7911. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7912. /**
  7913. * Makes a clone, or deep copy, of the cube texture
  7914. * @returns a new cube texture
  7915. */
  7916. clone(): CubeTexture;
  7917. }
  7918. }
  7919. declare module BABYLON {
  7920. /**
  7921. * Manages the defines for the Material
  7922. */
  7923. export class MaterialDefines {
  7924. /** @hidden */
  7925. protected _keys: string[];
  7926. private _isDirty;
  7927. /** @hidden */
  7928. _renderId: number;
  7929. /** @hidden */
  7930. _areLightsDirty: boolean;
  7931. /** @hidden */
  7932. _areLightsDisposed: boolean;
  7933. /** @hidden */
  7934. _areAttributesDirty: boolean;
  7935. /** @hidden */
  7936. _areTexturesDirty: boolean;
  7937. /** @hidden */
  7938. _areFresnelDirty: boolean;
  7939. /** @hidden */
  7940. _areMiscDirty: boolean;
  7941. /** @hidden */
  7942. _areImageProcessingDirty: boolean;
  7943. /** @hidden */
  7944. _normals: boolean;
  7945. /** @hidden */
  7946. _uvs: boolean;
  7947. /** @hidden */
  7948. _needNormals: boolean;
  7949. /** @hidden */
  7950. _needUVs: boolean;
  7951. [id: string]: any;
  7952. /**
  7953. * Specifies if the material needs to be re-calculated
  7954. */
  7955. get isDirty(): boolean;
  7956. /**
  7957. * Marks the material to indicate that it has been re-calculated
  7958. */
  7959. markAsProcessed(): void;
  7960. /**
  7961. * Marks the material to indicate that it needs to be re-calculated
  7962. */
  7963. markAsUnprocessed(): void;
  7964. /**
  7965. * Marks the material to indicate all of its defines need to be re-calculated
  7966. */
  7967. markAllAsDirty(): void;
  7968. /**
  7969. * Marks the material to indicate that image processing needs to be re-calculated
  7970. */
  7971. markAsImageProcessingDirty(): void;
  7972. /**
  7973. * Marks the material to indicate the lights need to be re-calculated
  7974. * @param disposed Defines whether the light is dirty due to dispose or not
  7975. */
  7976. markAsLightDirty(disposed?: boolean): void;
  7977. /**
  7978. * Marks the attribute state as changed
  7979. */
  7980. markAsAttributesDirty(): void;
  7981. /**
  7982. * Marks the texture state as changed
  7983. */
  7984. markAsTexturesDirty(): void;
  7985. /**
  7986. * Marks the fresnel state as changed
  7987. */
  7988. markAsFresnelDirty(): void;
  7989. /**
  7990. * Marks the misc state as changed
  7991. */
  7992. markAsMiscDirty(): void;
  7993. /**
  7994. * Rebuilds the material defines
  7995. */
  7996. rebuild(): void;
  7997. /**
  7998. * Specifies if two material defines are equal
  7999. * @param other - A material define instance to compare to
  8000. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8001. */
  8002. isEqual(other: MaterialDefines): boolean;
  8003. /**
  8004. * Clones this instance's defines to another instance
  8005. * @param other - material defines to clone values to
  8006. */
  8007. cloneTo(other: MaterialDefines): void;
  8008. /**
  8009. * Resets the material define values
  8010. */
  8011. reset(): void;
  8012. /**
  8013. * Converts the material define values to a string
  8014. * @returns - String of material define information
  8015. */
  8016. toString(): string;
  8017. }
  8018. }
  8019. declare module BABYLON {
  8020. /**
  8021. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8022. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8023. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  8024. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8025. */
  8026. export class ColorCurves {
  8027. private _dirty;
  8028. private _tempColor;
  8029. private _globalCurve;
  8030. private _highlightsCurve;
  8031. private _midtonesCurve;
  8032. private _shadowsCurve;
  8033. private _positiveCurve;
  8034. private _negativeCurve;
  8035. private _globalHue;
  8036. private _globalDensity;
  8037. private _globalSaturation;
  8038. private _globalExposure;
  8039. /**
  8040. * Gets the global Hue value.
  8041. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8042. */
  8043. get globalHue(): number;
  8044. /**
  8045. * Sets the global Hue value.
  8046. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8047. */
  8048. set globalHue(value: number);
  8049. /**
  8050. * Gets the global Density value.
  8051. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8052. * Values less than zero provide a filter of opposite hue.
  8053. */
  8054. get globalDensity(): number;
  8055. /**
  8056. * Sets the global Density value.
  8057. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8058. * Values less than zero provide a filter of opposite hue.
  8059. */
  8060. set globalDensity(value: number);
  8061. /**
  8062. * Gets the global Saturation value.
  8063. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8064. */
  8065. get globalSaturation(): number;
  8066. /**
  8067. * Sets the global Saturation value.
  8068. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8069. */
  8070. set globalSaturation(value: number);
  8071. /**
  8072. * Gets the global Exposure value.
  8073. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8074. */
  8075. get globalExposure(): number;
  8076. /**
  8077. * Sets the global Exposure value.
  8078. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8079. */
  8080. set globalExposure(value: number);
  8081. private _highlightsHue;
  8082. private _highlightsDensity;
  8083. private _highlightsSaturation;
  8084. private _highlightsExposure;
  8085. /**
  8086. * Gets the highlights Hue value.
  8087. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8088. */
  8089. get highlightsHue(): number;
  8090. /**
  8091. * Sets the highlights Hue value.
  8092. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8093. */
  8094. set highlightsHue(value: number);
  8095. /**
  8096. * Gets the highlights Density value.
  8097. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8098. * Values less than zero provide a filter of opposite hue.
  8099. */
  8100. get highlightsDensity(): number;
  8101. /**
  8102. * Sets the highlights Density value.
  8103. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8104. * Values less than zero provide a filter of opposite hue.
  8105. */
  8106. set highlightsDensity(value: number);
  8107. /**
  8108. * Gets the highlights Saturation value.
  8109. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8110. */
  8111. get highlightsSaturation(): number;
  8112. /**
  8113. * Sets the highlights Saturation value.
  8114. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8115. */
  8116. set highlightsSaturation(value: number);
  8117. /**
  8118. * Gets the highlights Exposure value.
  8119. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8120. */
  8121. get highlightsExposure(): number;
  8122. /**
  8123. * Sets the highlights Exposure value.
  8124. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8125. */
  8126. set highlightsExposure(value: number);
  8127. private _midtonesHue;
  8128. private _midtonesDensity;
  8129. private _midtonesSaturation;
  8130. private _midtonesExposure;
  8131. /**
  8132. * Gets the midtones Hue value.
  8133. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8134. */
  8135. get midtonesHue(): number;
  8136. /**
  8137. * Sets the midtones Hue value.
  8138. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8139. */
  8140. set midtonesHue(value: number);
  8141. /**
  8142. * Gets the midtones Density value.
  8143. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8144. * Values less than zero provide a filter of opposite hue.
  8145. */
  8146. get midtonesDensity(): number;
  8147. /**
  8148. * Sets the midtones Density value.
  8149. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8150. * Values less than zero provide a filter of opposite hue.
  8151. */
  8152. set midtonesDensity(value: number);
  8153. /**
  8154. * Gets the midtones Saturation value.
  8155. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8156. */
  8157. get midtonesSaturation(): number;
  8158. /**
  8159. * Sets the midtones Saturation value.
  8160. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8161. */
  8162. set midtonesSaturation(value: number);
  8163. /**
  8164. * Gets the midtones Exposure value.
  8165. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8166. */
  8167. get midtonesExposure(): number;
  8168. /**
  8169. * Sets the midtones Exposure value.
  8170. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8171. */
  8172. set midtonesExposure(value: number);
  8173. private _shadowsHue;
  8174. private _shadowsDensity;
  8175. private _shadowsSaturation;
  8176. private _shadowsExposure;
  8177. /**
  8178. * Gets the shadows Hue value.
  8179. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8180. */
  8181. get shadowsHue(): number;
  8182. /**
  8183. * Sets the shadows Hue value.
  8184. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8185. */
  8186. set shadowsHue(value: number);
  8187. /**
  8188. * Gets the shadows Density value.
  8189. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8190. * Values less than zero provide a filter of opposite hue.
  8191. */
  8192. get shadowsDensity(): number;
  8193. /**
  8194. * Sets the shadows Density value.
  8195. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8196. * Values less than zero provide a filter of opposite hue.
  8197. */
  8198. set shadowsDensity(value: number);
  8199. /**
  8200. * Gets the shadows Saturation value.
  8201. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8202. */
  8203. get shadowsSaturation(): number;
  8204. /**
  8205. * Sets the shadows Saturation value.
  8206. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8207. */
  8208. set shadowsSaturation(value: number);
  8209. /**
  8210. * Gets the shadows Exposure value.
  8211. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8212. */
  8213. get shadowsExposure(): number;
  8214. /**
  8215. * Sets the shadows Exposure value.
  8216. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8217. */
  8218. set shadowsExposure(value: number);
  8219. /**
  8220. * Returns the class name
  8221. * @returns The class name
  8222. */
  8223. getClassName(): string;
  8224. /**
  8225. * Binds the color curves to the shader.
  8226. * @param colorCurves The color curve to bind
  8227. * @param effect The effect to bind to
  8228. * @param positiveUniform The positive uniform shader parameter
  8229. * @param neutralUniform The neutral uniform shader parameter
  8230. * @param negativeUniform The negative uniform shader parameter
  8231. */
  8232. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8233. /**
  8234. * Prepare the list of uniforms associated with the ColorCurves effects.
  8235. * @param uniformsList The list of uniforms used in the effect
  8236. */
  8237. static PrepareUniforms(uniformsList: string[]): void;
  8238. /**
  8239. * Returns color grading data based on a hue, density, saturation and exposure value.
  8240. * @param filterHue The hue of the color filter.
  8241. * @param filterDensity The density of the color filter.
  8242. * @param saturation The saturation.
  8243. * @param exposure The exposure.
  8244. * @param result The result data container.
  8245. */
  8246. private getColorGradingDataToRef;
  8247. /**
  8248. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8249. * @param value The input slider value in range [-100,100].
  8250. * @returns Adjusted value.
  8251. */
  8252. private static applyColorGradingSliderNonlinear;
  8253. /**
  8254. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8255. * @param hue The hue (H) input.
  8256. * @param saturation The saturation (S) input.
  8257. * @param brightness The brightness (B) input.
  8258. * @result An RGBA color represented as Vector4.
  8259. */
  8260. private static fromHSBToRef;
  8261. /**
  8262. * Returns a value clamped between min and max
  8263. * @param value The value to clamp
  8264. * @param min The minimum of value
  8265. * @param max The maximum of value
  8266. * @returns The clamped value.
  8267. */
  8268. private static clamp;
  8269. /**
  8270. * Clones the current color curve instance.
  8271. * @return The cloned curves
  8272. */
  8273. clone(): ColorCurves;
  8274. /**
  8275. * Serializes the current color curve instance to a json representation.
  8276. * @return a JSON representation
  8277. */
  8278. serialize(): any;
  8279. /**
  8280. * Parses the color curve from a json representation.
  8281. * @param source the JSON source to parse
  8282. * @return The parsed curves
  8283. */
  8284. static Parse(source: any): ColorCurves;
  8285. }
  8286. }
  8287. declare module BABYLON {
  8288. /**
  8289. * Interface to follow in your material defines to integrate easily the
  8290. * Image proccessing functions.
  8291. * @hidden
  8292. */
  8293. export interface IImageProcessingConfigurationDefines {
  8294. IMAGEPROCESSING: boolean;
  8295. VIGNETTE: boolean;
  8296. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8297. VIGNETTEBLENDMODEOPAQUE: boolean;
  8298. TONEMAPPING: boolean;
  8299. TONEMAPPING_ACES: boolean;
  8300. CONTRAST: boolean;
  8301. EXPOSURE: boolean;
  8302. COLORCURVES: boolean;
  8303. COLORGRADING: boolean;
  8304. COLORGRADING3D: boolean;
  8305. SAMPLER3DGREENDEPTH: boolean;
  8306. SAMPLER3DBGRMAP: boolean;
  8307. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8308. }
  8309. /**
  8310. * @hidden
  8311. */
  8312. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8313. IMAGEPROCESSING: boolean;
  8314. VIGNETTE: boolean;
  8315. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8316. VIGNETTEBLENDMODEOPAQUE: boolean;
  8317. TONEMAPPING: boolean;
  8318. TONEMAPPING_ACES: boolean;
  8319. CONTRAST: boolean;
  8320. COLORCURVES: boolean;
  8321. COLORGRADING: boolean;
  8322. COLORGRADING3D: boolean;
  8323. SAMPLER3DGREENDEPTH: boolean;
  8324. SAMPLER3DBGRMAP: boolean;
  8325. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8326. EXPOSURE: boolean;
  8327. constructor();
  8328. }
  8329. /**
  8330. * This groups together the common properties used for image processing either in direct forward pass
  8331. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8332. * or not.
  8333. */
  8334. export class ImageProcessingConfiguration {
  8335. /**
  8336. * Default tone mapping applied in BabylonJS.
  8337. */
  8338. static readonly TONEMAPPING_STANDARD: number;
  8339. /**
  8340. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8341. * to other engines rendering to increase portability.
  8342. */
  8343. static readonly TONEMAPPING_ACES: number;
  8344. /**
  8345. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8346. */
  8347. colorCurves: Nullable<ColorCurves>;
  8348. private _colorCurvesEnabled;
  8349. /**
  8350. * Gets wether the color curves effect is enabled.
  8351. */
  8352. get colorCurvesEnabled(): boolean;
  8353. /**
  8354. * Sets wether the color curves effect is enabled.
  8355. */
  8356. set colorCurvesEnabled(value: boolean);
  8357. private _colorGradingTexture;
  8358. /**
  8359. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8360. */
  8361. get colorGradingTexture(): Nullable<BaseTexture>;
  8362. /**
  8363. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8364. */
  8365. set colorGradingTexture(value: Nullable<BaseTexture>);
  8366. private _colorGradingEnabled;
  8367. /**
  8368. * Gets wether the color grading effect is enabled.
  8369. */
  8370. get colorGradingEnabled(): boolean;
  8371. /**
  8372. * Sets wether the color grading effect is enabled.
  8373. */
  8374. set colorGradingEnabled(value: boolean);
  8375. private _colorGradingWithGreenDepth;
  8376. /**
  8377. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8378. */
  8379. get colorGradingWithGreenDepth(): boolean;
  8380. /**
  8381. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8382. */
  8383. set colorGradingWithGreenDepth(value: boolean);
  8384. private _colorGradingBGR;
  8385. /**
  8386. * Gets wether the color grading texture contains BGR values.
  8387. */
  8388. get colorGradingBGR(): boolean;
  8389. /**
  8390. * Sets wether the color grading texture contains BGR values.
  8391. */
  8392. set colorGradingBGR(value: boolean);
  8393. /** @hidden */
  8394. _exposure: number;
  8395. /**
  8396. * Gets the Exposure used in the effect.
  8397. */
  8398. get exposure(): number;
  8399. /**
  8400. * Sets the Exposure used in the effect.
  8401. */
  8402. set exposure(value: number);
  8403. private _toneMappingEnabled;
  8404. /**
  8405. * Gets wether the tone mapping effect is enabled.
  8406. */
  8407. get toneMappingEnabled(): boolean;
  8408. /**
  8409. * Sets wether the tone mapping effect is enabled.
  8410. */
  8411. set toneMappingEnabled(value: boolean);
  8412. private _toneMappingType;
  8413. /**
  8414. * Gets the type of tone mapping effect.
  8415. */
  8416. get toneMappingType(): number;
  8417. /**
  8418. * Sets the type of tone mapping effect used in BabylonJS.
  8419. */
  8420. set toneMappingType(value: number);
  8421. protected _contrast: number;
  8422. /**
  8423. * Gets the contrast used in the effect.
  8424. */
  8425. get contrast(): number;
  8426. /**
  8427. * Sets the contrast used in the effect.
  8428. */
  8429. set contrast(value: number);
  8430. /**
  8431. * Vignette stretch size.
  8432. */
  8433. vignetteStretch: number;
  8434. /**
  8435. * Vignette centre X Offset.
  8436. */
  8437. vignetteCentreX: number;
  8438. /**
  8439. * Vignette centre Y Offset.
  8440. */
  8441. vignetteCentreY: number;
  8442. /**
  8443. * Vignette weight or intensity of the vignette effect.
  8444. */
  8445. vignetteWeight: number;
  8446. /**
  8447. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8448. * if vignetteEnabled is set to true.
  8449. */
  8450. vignetteColor: Color4;
  8451. /**
  8452. * Camera field of view used by the Vignette effect.
  8453. */
  8454. vignetteCameraFov: number;
  8455. private _vignetteBlendMode;
  8456. /**
  8457. * Gets the vignette blend mode allowing different kind of effect.
  8458. */
  8459. get vignetteBlendMode(): number;
  8460. /**
  8461. * Sets the vignette blend mode allowing different kind of effect.
  8462. */
  8463. set vignetteBlendMode(value: number);
  8464. private _vignetteEnabled;
  8465. /**
  8466. * Gets wether the vignette effect is enabled.
  8467. */
  8468. get vignetteEnabled(): boolean;
  8469. /**
  8470. * Sets wether the vignette effect is enabled.
  8471. */
  8472. set vignetteEnabled(value: boolean);
  8473. private _applyByPostProcess;
  8474. /**
  8475. * Gets wether the image processing is applied through a post process or not.
  8476. */
  8477. get applyByPostProcess(): boolean;
  8478. /**
  8479. * Sets wether the image processing is applied through a post process or not.
  8480. */
  8481. set applyByPostProcess(value: boolean);
  8482. private _isEnabled;
  8483. /**
  8484. * Gets wether the image processing is enabled or not.
  8485. */
  8486. get isEnabled(): boolean;
  8487. /**
  8488. * Sets wether the image processing is enabled or not.
  8489. */
  8490. set isEnabled(value: boolean);
  8491. /**
  8492. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8493. */
  8494. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8495. /**
  8496. * Method called each time the image processing information changes requires to recompile the effect.
  8497. */
  8498. protected _updateParameters(): void;
  8499. /**
  8500. * Gets the current class name.
  8501. * @return "ImageProcessingConfiguration"
  8502. */
  8503. getClassName(): string;
  8504. /**
  8505. * Prepare the list of uniforms associated with the Image Processing effects.
  8506. * @param uniforms The list of uniforms used in the effect
  8507. * @param defines the list of defines currently in use
  8508. */
  8509. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8510. /**
  8511. * Prepare the list of samplers associated with the Image Processing effects.
  8512. * @param samplersList The list of uniforms used in the effect
  8513. * @param defines the list of defines currently in use
  8514. */
  8515. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8516. /**
  8517. * Prepare the list of defines associated to the shader.
  8518. * @param defines the list of defines to complete
  8519. * @param forPostProcess Define if we are currently in post process mode or not
  8520. */
  8521. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8522. /**
  8523. * Returns true if all the image processing information are ready.
  8524. * @returns True if ready, otherwise, false
  8525. */
  8526. isReady(): boolean;
  8527. /**
  8528. * Binds the image processing to the shader.
  8529. * @param effect The effect to bind to
  8530. * @param overrideAspectRatio Override the aspect ratio of the effect
  8531. */
  8532. bind(effect: Effect, overrideAspectRatio?: number): void;
  8533. /**
  8534. * Clones the current image processing instance.
  8535. * @return The cloned image processing
  8536. */
  8537. clone(): ImageProcessingConfiguration;
  8538. /**
  8539. * Serializes the current image processing instance to a json representation.
  8540. * @return a JSON representation
  8541. */
  8542. serialize(): any;
  8543. /**
  8544. * Parses the image processing from a json representation.
  8545. * @param source the JSON source to parse
  8546. * @return The parsed image processing
  8547. */
  8548. static Parse(source: any): ImageProcessingConfiguration;
  8549. private static _VIGNETTEMODE_MULTIPLY;
  8550. private static _VIGNETTEMODE_OPAQUE;
  8551. /**
  8552. * Used to apply the vignette as a mix with the pixel color.
  8553. */
  8554. static get VIGNETTEMODE_MULTIPLY(): number;
  8555. /**
  8556. * Used to apply the vignette as a replacement of the pixel color.
  8557. */
  8558. static get VIGNETTEMODE_OPAQUE(): number;
  8559. }
  8560. }
  8561. declare module BABYLON {
  8562. /** @hidden */
  8563. export var postprocessVertexShader: {
  8564. name: string;
  8565. shader: string;
  8566. };
  8567. }
  8568. declare module BABYLON {
  8569. interface ThinEngine {
  8570. /**
  8571. * Creates a new render target texture
  8572. * @param size defines the size of the texture
  8573. * @param options defines the options used to create the texture
  8574. * @returns a new render target texture stored in an InternalTexture
  8575. */
  8576. createRenderTargetTexture(size: number | {
  8577. width: number;
  8578. height: number;
  8579. layers?: number;
  8580. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8581. /**
  8582. * Creates a depth stencil texture.
  8583. * This is only available in WebGL 2 or with the depth texture extension available.
  8584. * @param size The size of face edge in the texture.
  8585. * @param options The options defining the texture.
  8586. * @returns The texture
  8587. */
  8588. createDepthStencilTexture(size: number | {
  8589. width: number;
  8590. height: number;
  8591. layers?: number;
  8592. }, options: DepthTextureCreationOptions): InternalTexture;
  8593. /** @hidden */
  8594. _createDepthStencilTexture(size: number | {
  8595. width: number;
  8596. height: number;
  8597. layers?: number;
  8598. }, options: DepthTextureCreationOptions): InternalTexture;
  8599. }
  8600. }
  8601. declare module BABYLON {
  8602. /**
  8603. * Defines the kind of connection point for node based material
  8604. */
  8605. export enum NodeMaterialBlockConnectionPointTypes {
  8606. /** Float */
  8607. Float = 1,
  8608. /** Int */
  8609. Int = 2,
  8610. /** Vector2 */
  8611. Vector2 = 4,
  8612. /** Vector3 */
  8613. Vector3 = 8,
  8614. /** Vector4 */
  8615. Vector4 = 16,
  8616. /** Color3 */
  8617. Color3 = 32,
  8618. /** Color4 */
  8619. Color4 = 64,
  8620. /** Matrix */
  8621. Matrix = 128,
  8622. /** Custom object */
  8623. Object = 256,
  8624. /** Detect type based on connection */
  8625. AutoDetect = 1024,
  8626. /** Output type that will be defined by input type */
  8627. BasedOnInput = 2048
  8628. }
  8629. }
  8630. declare module BABYLON {
  8631. /**
  8632. * Enum used to define the target of a block
  8633. */
  8634. export enum NodeMaterialBlockTargets {
  8635. /** Vertex shader */
  8636. Vertex = 1,
  8637. /** Fragment shader */
  8638. Fragment = 2,
  8639. /** Neutral */
  8640. Neutral = 4,
  8641. /** Vertex and Fragment */
  8642. VertexAndFragment = 3
  8643. }
  8644. }
  8645. declare module BABYLON {
  8646. /**
  8647. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8648. */
  8649. export enum NodeMaterialBlockConnectionPointMode {
  8650. /** Value is an uniform */
  8651. Uniform = 0,
  8652. /** Value is a mesh attribute */
  8653. Attribute = 1,
  8654. /** Value is a varying between vertex and fragment shaders */
  8655. Varying = 2,
  8656. /** Mode is undefined */
  8657. Undefined = 3
  8658. }
  8659. }
  8660. declare module BABYLON {
  8661. /**
  8662. * Enum used to define system values e.g. values automatically provided by the system
  8663. */
  8664. export enum NodeMaterialSystemValues {
  8665. /** World */
  8666. World = 1,
  8667. /** View */
  8668. View = 2,
  8669. /** Projection */
  8670. Projection = 3,
  8671. /** ViewProjection */
  8672. ViewProjection = 4,
  8673. /** WorldView */
  8674. WorldView = 5,
  8675. /** WorldViewProjection */
  8676. WorldViewProjection = 6,
  8677. /** CameraPosition */
  8678. CameraPosition = 7,
  8679. /** Fog Color */
  8680. FogColor = 8,
  8681. /** Delta time */
  8682. DeltaTime = 9
  8683. }
  8684. }
  8685. declare module BABYLON {
  8686. /** Defines supported spaces */
  8687. export enum Space {
  8688. /** Local (object) space */
  8689. LOCAL = 0,
  8690. /** World space */
  8691. WORLD = 1,
  8692. /** Bone space */
  8693. BONE = 2
  8694. }
  8695. /** Defines the 3 main axes */
  8696. export class Axis {
  8697. /** X axis */
  8698. static X: Vector3;
  8699. /** Y axis */
  8700. static Y: Vector3;
  8701. /** Z axis */
  8702. static Z: Vector3;
  8703. }
  8704. }
  8705. declare module BABYLON {
  8706. /**
  8707. * Represents a camera frustum
  8708. */
  8709. export class Frustum {
  8710. /**
  8711. * Gets the planes representing the frustum
  8712. * @param transform matrix to be applied to the returned planes
  8713. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8714. */
  8715. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8716. /**
  8717. * Gets the near frustum plane transformed by the transform matrix
  8718. * @param transform transformation matrix to be applied to the resulting frustum plane
  8719. * @param frustumPlane the resuling frustum plane
  8720. */
  8721. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8722. /**
  8723. * Gets the far frustum plane transformed by the transform matrix
  8724. * @param transform transformation matrix to be applied to the resulting frustum plane
  8725. * @param frustumPlane the resuling frustum plane
  8726. */
  8727. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8728. /**
  8729. * Gets the left frustum plane transformed by the transform matrix
  8730. * @param transform transformation matrix to be applied to the resulting frustum plane
  8731. * @param frustumPlane the resuling frustum plane
  8732. */
  8733. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8734. /**
  8735. * Gets the right frustum plane transformed by the transform matrix
  8736. * @param transform transformation matrix to be applied to the resulting frustum plane
  8737. * @param frustumPlane the resuling frustum plane
  8738. */
  8739. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8740. /**
  8741. * Gets the top frustum plane transformed by the transform matrix
  8742. * @param transform transformation matrix to be applied to the resulting frustum plane
  8743. * @param frustumPlane the resuling frustum plane
  8744. */
  8745. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8746. /**
  8747. * Gets the bottom frustum plane transformed by the transform matrix
  8748. * @param transform transformation matrix to be applied to the resulting frustum plane
  8749. * @param frustumPlane the resuling frustum plane
  8750. */
  8751. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8752. /**
  8753. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8754. * @param transform transformation matrix to be applied to the resulting frustum planes
  8755. * @param frustumPlanes the resuling frustum planes
  8756. */
  8757. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8758. }
  8759. }
  8760. declare module BABYLON {
  8761. /**
  8762. * Interface for the size containing width and height
  8763. */
  8764. export interface ISize {
  8765. /**
  8766. * Width
  8767. */
  8768. width: number;
  8769. /**
  8770. * Heighht
  8771. */
  8772. height: number;
  8773. }
  8774. /**
  8775. * Size containing widht and height
  8776. */
  8777. export class Size implements ISize {
  8778. /**
  8779. * Width
  8780. */
  8781. width: number;
  8782. /**
  8783. * Height
  8784. */
  8785. height: number;
  8786. /**
  8787. * Creates a Size object from the given width and height (floats).
  8788. * @param width width of the new size
  8789. * @param height height of the new size
  8790. */
  8791. constructor(width: number, height: number);
  8792. /**
  8793. * Returns a string with the Size width and height
  8794. * @returns a string with the Size width and height
  8795. */
  8796. toString(): string;
  8797. /**
  8798. * "Size"
  8799. * @returns the string "Size"
  8800. */
  8801. getClassName(): string;
  8802. /**
  8803. * Returns the Size hash code.
  8804. * @returns a hash code for a unique width and height
  8805. */
  8806. getHashCode(): number;
  8807. /**
  8808. * Updates the current size from the given one.
  8809. * @param src the given size
  8810. */
  8811. copyFrom(src: Size): void;
  8812. /**
  8813. * Updates in place the current Size from the given floats.
  8814. * @param width width of the new size
  8815. * @param height height of the new size
  8816. * @returns the updated Size.
  8817. */
  8818. copyFromFloats(width: number, height: number): Size;
  8819. /**
  8820. * Updates in place the current Size from the given floats.
  8821. * @param width width to set
  8822. * @param height height to set
  8823. * @returns the updated Size.
  8824. */
  8825. set(width: number, height: number): Size;
  8826. /**
  8827. * Multiplies the width and height by numbers
  8828. * @param w factor to multiple the width by
  8829. * @param h factor to multiple the height by
  8830. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8831. */
  8832. multiplyByFloats(w: number, h: number): Size;
  8833. /**
  8834. * Clones the size
  8835. * @returns a new Size copied from the given one.
  8836. */
  8837. clone(): Size;
  8838. /**
  8839. * True if the current Size and the given one width and height are strictly equal.
  8840. * @param other the other size to compare against
  8841. * @returns True if the current Size and the given one width and height are strictly equal.
  8842. */
  8843. equals(other: Size): boolean;
  8844. /**
  8845. * The surface of the Size : width * height (float).
  8846. */
  8847. get surface(): number;
  8848. /**
  8849. * Create a new size of zero
  8850. * @returns a new Size set to (0.0, 0.0)
  8851. */
  8852. static Zero(): Size;
  8853. /**
  8854. * Sums the width and height of two sizes
  8855. * @param otherSize size to add to this size
  8856. * @returns a new Size set as the addition result of the current Size and the given one.
  8857. */
  8858. add(otherSize: Size): Size;
  8859. /**
  8860. * Subtracts the width and height of two
  8861. * @param otherSize size to subtract to this size
  8862. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8863. */
  8864. subtract(otherSize: Size): Size;
  8865. /**
  8866. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8867. * @param start starting size to lerp between
  8868. * @param end end size to lerp between
  8869. * @param amount amount to lerp between the start and end values
  8870. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8871. */
  8872. static Lerp(start: Size, end: Size, amount: number): Size;
  8873. }
  8874. }
  8875. declare module BABYLON {
  8876. /**
  8877. * Contains position and normal vectors for a vertex
  8878. */
  8879. export class PositionNormalVertex {
  8880. /** the position of the vertex (defaut: 0,0,0) */
  8881. position: Vector3;
  8882. /** the normal of the vertex (defaut: 0,1,0) */
  8883. normal: Vector3;
  8884. /**
  8885. * Creates a PositionNormalVertex
  8886. * @param position the position of the vertex (defaut: 0,0,0)
  8887. * @param normal the normal of the vertex (defaut: 0,1,0)
  8888. */
  8889. constructor(
  8890. /** the position of the vertex (defaut: 0,0,0) */
  8891. position?: Vector3,
  8892. /** the normal of the vertex (defaut: 0,1,0) */
  8893. normal?: Vector3);
  8894. /**
  8895. * Clones the PositionNormalVertex
  8896. * @returns the cloned PositionNormalVertex
  8897. */
  8898. clone(): PositionNormalVertex;
  8899. }
  8900. /**
  8901. * Contains position, normal and uv vectors for a vertex
  8902. */
  8903. export class PositionNormalTextureVertex {
  8904. /** the position of the vertex (defaut: 0,0,0) */
  8905. position: Vector3;
  8906. /** the normal of the vertex (defaut: 0,1,0) */
  8907. normal: Vector3;
  8908. /** the uv of the vertex (default: 0,0) */
  8909. uv: Vector2;
  8910. /**
  8911. * Creates a PositionNormalTextureVertex
  8912. * @param position the position of the vertex (defaut: 0,0,0)
  8913. * @param normal the normal of the vertex (defaut: 0,1,0)
  8914. * @param uv the uv of the vertex (default: 0,0)
  8915. */
  8916. constructor(
  8917. /** the position of the vertex (defaut: 0,0,0) */
  8918. position?: Vector3,
  8919. /** the normal of the vertex (defaut: 0,1,0) */
  8920. normal?: Vector3,
  8921. /** the uv of the vertex (default: 0,0) */
  8922. uv?: Vector2);
  8923. /**
  8924. * Clones the PositionNormalTextureVertex
  8925. * @returns the cloned PositionNormalTextureVertex
  8926. */
  8927. clone(): PositionNormalTextureVertex;
  8928. }
  8929. }
  8930. declare module BABYLON {
  8931. /**
  8932. * Enum defining the type of animations supported by InputBlock
  8933. */
  8934. export enum AnimatedInputBlockTypes {
  8935. /** No animation */
  8936. None = 0,
  8937. /** Time based animation. Will only work for floats */
  8938. Time = 1
  8939. }
  8940. }
  8941. declare module BABYLON {
  8942. /**
  8943. * Interface describing all the common properties and methods a shadow light needs to implement.
  8944. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8945. * as well as binding the different shadow properties to the effects.
  8946. */
  8947. export interface IShadowLight extends Light {
  8948. /**
  8949. * The light id in the scene (used in scene.findLighById for instance)
  8950. */
  8951. id: string;
  8952. /**
  8953. * The position the shdow will be casted from.
  8954. */
  8955. position: Vector3;
  8956. /**
  8957. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8958. */
  8959. direction: Vector3;
  8960. /**
  8961. * The transformed position. Position of the light in world space taking parenting in account.
  8962. */
  8963. transformedPosition: Vector3;
  8964. /**
  8965. * The transformed direction. Direction of the light in world space taking parenting in account.
  8966. */
  8967. transformedDirection: Vector3;
  8968. /**
  8969. * The friendly name of the light in the scene.
  8970. */
  8971. name: string;
  8972. /**
  8973. * Defines the shadow projection clipping minimum z value.
  8974. */
  8975. shadowMinZ: number;
  8976. /**
  8977. * Defines the shadow projection clipping maximum z value.
  8978. */
  8979. shadowMaxZ: number;
  8980. /**
  8981. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8982. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8983. */
  8984. computeTransformedInformation(): boolean;
  8985. /**
  8986. * Gets the scene the light belongs to.
  8987. * @returns The scene
  8988. */
  8989. getScene(): Scene;
  8990. /**
  8991. * Callback defining a custom Projection Matrix Builder.
  8992. * This can be used to override the default projection matrix computation.
  8993. */
  8994. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8995. /**
  8996. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8997. * @param matrix The materix to updated with the projection information
  8998. * @param viewMatrix The transform matrix of the light
  8999. * @param renderList The list of mesh to render in the map
  9000. * @returns The current light
  9001. */
  9002. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9003. /**
  9004. * Gets the current depth scale used in ESM.
  9005. * @returns The scale
  9006. */
  9007. getDepthScale(): number;
  9008. /**
  9009. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9010. * @returns true if a cube texture needs to be use
  9011. */
  9012. needCube(): boolean;
  9013. /**
  9014. * Detects if the projection matrix requires to be recomputed this frame.
  9015. * @returns true if it requires to be recomputed otherwise, false.
  9016. */
  9017. needProjectionMatrixCompute(): boolean;
  9018. /**
  9019. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9020. */
  9021. forceProjectionMatrixCompute(): void;
  9022. /**
  9023. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9024. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9025. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9026. */
  9027. getShadowDirection(faceIndex?: number): Vector3;
  9028. /**
  9029. * Gets the minZ used for shadow according to both the scene and the light.
  9030. * @param activeCamera The camera we are returning the min for
  9031. * @returns the depth min z
  9032. */
  9033. getDepthMinZ(activeCamera: Camera): number;
  9034. /**
  9035. * Gets the maxZ used for shadow according to both the scene and the light.
  9036. * @param activeCamera The camera we are returning the max for
  9037. * @returns the depth max z
  9038. */
  9039. getDepthMaxZ(activeCamera: Camera): number;
  9040. }
  9041. /**
  9042. * Base implementation IShadowLight
  9043. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9044. */
  9045. export abstract class ShadowLight extends Light implements IShadowLight {
  9046. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9047. protected _position: Vector3;
  9048. protected _setPosition(value: Vector3): void;
  9049. /**
  9050. * Sets the position the shadow will be casted from. Also use as the light position for both
  9051. * point and spot lights.
  9052. */
  9053. get position(): Vector3;
  9054. /**
  9055. * Sets the position the shadow will be casted from. Also use as the light position for both
  9056. * point and spot lights.
  9057. */
  9058. set position(value: Vector3);
  9059. protected _direction: Vector3;
  9060. protected _setDirection(value: Vector3): void;
  9061. /**
  9062. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9063. * Also use as the light direction on spot and directional lights.
  9064. */
  9065. get direction(): Vector3;
  9066. /**
  9067. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9068. * Also use as the light direction on spot and directional lights.
  9069. */
  9070. set direction(value: Vector3);
  9071. protected _shadowMinZ: number;
  9072. /**
  9073. * Gets the shadow projection clipping minimum z value.
  9074. */
  9075. get shadowMinZ(): number;
  9076. /**
  9077. * Sets the shadow projection clipping minimum z value.
  9078. */
  9079. set shadowMinZ(value: number);
  9080. protected _shadowMaxZ: number;
  9081. /**
  9082. * Sets the shadow projection clipping maximum z value.
  9083. */
  9084. get shadowMaxZ(): number;
  9085. /**
  9086. * Gets the shadow projection clipping maximum z value.
  9087. */
  9088. set shadowMaxZ(value: number);
  9089. /**
  9090. * Callback defining a custom Projection Matrix Builder.
  9091. * This can be used to override the default projection matrix computation.
  9092. */
  9093. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9094. /**
  9095. * The transformed position. Position of the light in world space taking parenting in account.
  9096. */
  9097. transformedPosition: Vector3;
  9098. /**
  9099. * The transformed direction. Direction of the light in world space taking parenting in account.
  9100. */
  9101. transformedDirection: Vector3;
  9102. private _needProjectionMatrixCompute;
  9103. /**
  9104. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9105. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9106. */
  9107. computeTransformedInformation(): boolean;
  9108. /**
  9109. * Return the depth scale used for the shadow map.
  9110. * @returns the depth scale.
  9111. */
  9112. getDepthScale(): number;
  9113. /**
  9114. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9115. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9116. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9117. */
  9118. getShadowDirection(faceIndex?: number): Vector3;
  9119. /**
  9120. * Returns the ShadowLight absolute position in the World.
  9121. * @returns the position vector in world space
  9122. */
  9123. getAbsolutePosition(): Vector3;
  9124. /**
  9125. * Sets the ShadowLight direction toward the passed target.
  9126. * @param target The point to target in local space
  9127. * @returns the updated ShadowLight direction
  9128. */
  9129. setDirectionToTarget(target: Vector3): Vector3;
  9130. /**
  9131. * Returns the light rotation in euler definition.
  9132. * @returns the x y z rotation in local space.
  9133. */
  9134. getRotation(): Vector3;
  9135. /**
  9136. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9137. * @returns true if a cube texture needs to be use
  9138. */
  9139. needCube(): boolean;
  9140. /**
  9141. * Detects if the projection matrix requires to be recomputed this frame.
  9142. * @returns true if it requires to be recomputed otherwise, false.
  9143. */
  9144. needProjectionMatrixCompute(): boolean;
  9145. /**
  9146. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9147. */
  9148. forceProjectionMatrixCompute(): void;
  9149. /** @hidden */
  9150. _initCache(): void;
  9151. /** @hidden */
  9152. _isSynchronized(): boolean;
  9153. /**
  9154. * Computes the world matrix of the node
  9155. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9156. * @returns the world matrix
  9157. */
  9158. computeWorldMatrix(force?: boolean): Matrix;
  9159. /**
  9160. * Gets the minZ used for shadow according to both the scene and the light.
  9161. * @param activeCamera The camera we are returning the min for
  9162. * @returns the depth min z
  9163. */
  9164. getDepthMinZ(activeCamera: Camera): number;
  9165. /**
  9166. * Gets the maxZ used for shadow according to both the scene and the light.
  9167. * @param activeCamera The camera we are returning the max for
  9168. * @returns the depth max z
  9169. */
  9170. getDepthMaxZ(activeCamera: Camera): number;
  9171. /**
  9172. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9173. * @param matrix The materix to updated with the projection information
  9174. * @param viewMatrix The transform matrix of the light
  9175. * @param renderList The list of mesh to render in the map
  9176. * @returns The current light
  9177. */
  9178. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9179. }
  9180. }
  9181. declare module BABYLON {
  9182. /** @hidden */
  9183. export var packingFunctions: {
  9184. name: string;
  9185. shader: string;
  9186. };
  9187. }
  9188. declare module BABYLON {
  9189. /** @hidden */
  9190. export var bayerDitherFunctions: {
  9191. name: string;
  9192. shader: string;
  9193. };
  9194. }
  9195. declare module BABYLON {
  9196. /** @hidden */
  9197. export var shadowMapFragmentDeclaration: {
  9198. name: string;
  9199. shader: string;
  9200. };
  9201. }
  9202. declare module BABYLON {
  9203. /** @hidden */
  9204. export var clipPlaneFragmentDeclaration: {
  9205. name: string;
  9206. shader: string;
  9207. };
  9208. }
  9209. declare module BABYLON {
  9210. /** @hidden */
  9211. export var clipPlaneFragment: {
  9212. name: string;
  9213. shader: string;
  9214. };
  9215. }
  9216. declare module BABYLON {
  9217. /** @hidden */
  9218. export var shadowMapFragment: {
  9219. name: string;
  9220. shader: string;
  9221. };
  9222. }
  9223. declare module BABYLON {
  9224. /** @hidden */
  9225. export var shadowMapPixelShader: {
  9226. name: string;
  9227. shader: string;
  9228. };
  9229. }
  9230. declare module BABYLON {
  9231. /** @hidden */
  9232. export var bonesDeclaration: {
  9233. name: string;
  9234. shader: string;
  9235. };
  9236. }
  9237. declare module BABYLON {
  9238. /** @hidden */
  9239. export var morphTargetsVertexGlobalDeclaration: {
  9240. name: string;
  9241. shader: string;
  9242. };
  9243. }
  9244. declare module BABYLON {
  9245. /** @hidden */
  9246. export var morphTargetsVertexDeclaration: {
  9247. name: string;
  9248. shader: string;
  9249. };
  9250. }
  9251. declare module BABYLON {
  9252. /** @hidden */
  9253. export var instancesDeclaration: {
  9254. name: string;
  9255. shader: string;
  9256. };
  9257. }
  9258. declare module BABYLON {
  9259. /** @hidden */
  9260. export var helperFunctions: {
  9261. name: string;
  9262. shader: string;
  9263. };
  9264. }
  9265. declare module BABYLON {
  9266. /** @hidden */
  9267. export var shadowMapVertexDeclaration: {
  9268. name: string;
  9269. shader: string;
  9270. };
  9271. }
  9272. declare module BABYLON {
  9273. /** @hidden */
  9274. export var clipPlaneVertexDeclaration: {
  9275. name: string;
  9276. shader: string;
  9277. };
  9278. }
  9279. declare module BABYLON {
  9280. /** @hidden */
  9281. export var morphTargetsVertex: {
  9282. name: string;
  9283. shader: string;
  9284. };
  9285. }
  9286. declare module BABYLON {
  9287. /** @hidden */
  9288. export var instancesVertex: {
  9289. name: string;
  9290. shader: string;
  9291. };
  9292. }
  9293. declare module BABYLON {
  9294. /** @hidden */
  9295. export var bonesVertex: {
  9296. name: string;
  9297. shader: string;
  9298. };
  9299. }
  9300. declare module BABYLON {
  9301. /** @hidden */
  9302. export var shadowMapVertexNormalBias: {
  9303. name: string;
  9304. shader: string;
  9305. };
  9306. }
  9307. declare module BABYLON {
  9308. /** @hidden */
  9309. export var shadowMapVertexMetric: {
  9310. name: string;
  9311. shader: string;
  9312. };
  9313. }
  9314. declare module BABYLON {
  9315. /** @hidden */
  9316. export var clipPlaneVertex: {
  9317. name: string;
  9318. shader: string;
  9319. };
  9320. }
  9321. declare module BABYLON {
  9322. /** @hidden */
  9323. export var shadowMapVertexShader: {
  9324. name: string;
  9325. shader: string;
  9326. };
  9327. }
  9328. declare module BABYLON {
  9329. /** @hidden */
  9330. export var depthBoxBlurPixelShader: {
  9331. name: string;
  9332. shader: string;
  9333. };
  9334. }
  9335. declare module BABYLON {
  9336. /** @hidden */
  9337. export var shadowMapFragmentSoftTransparentShadow: {
  9338. name: string;
  9339. shader: string;
  9340. };
  9341. }
  9342. declare module BABYLON {
  9343. /**
  9344. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9345. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9346. */
  9347. export class EffectFallbacks implements IEffectFallbacks {
  9348. private _defines;
  9349. private _currentRank;
  9350. private _maxRank;
  9351. private _mesh;
  9352. /**
  9353. * Removes the fallback from the bound mesh.
  9354. */
  9355. unBindMesh(): void;
  9356. /**
  9357. * Adds a fallback on the specified property.
  9358. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9359. * @param define The name of the define in the shader
  9360. */
  9361. addFallback(rank: number, define: string): void;
  9362. /**
  9363. * Sets the mesh to use CPU skinning when needing to fallback.
  9364. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9365. * @param mesh The mesh to use the fallbacks.
  9366. */
  9367. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9368. /**
  9369. * Checks to see if more fallbacks are still availible.
  9370. */
  9371. get hasMoreFallbacks(): boolean;
  9372. /**
  9373. * Removes the defines that should be removed when falling back.
  9374. * @param currentDefines defines the current define statements for the shader.
  9375. * @param effect defines the current effect we try to compile
  9376. * @returns The resulting defines with defines of the current rank removed.
  9377. */
  9378. reduce(currentDefines: string, effect: Effect): string;
  9379. }
  9380. }
  9381. declare module BABYLON {
  9382. /**
  9383. * Interface used to define Action
  9384. */
  9385. export interface IAction {
  9386. /**
  9387. * Trigger for the action
  9388. */
  9389. trigger: number;
  9390. /** Options of the trigger */
  9391. triggerOptions: any;
  9392. /**
  9393. * Gets the trigger parameters
  9394. * @returns the trigger parameters
  9395. */
  9396. getTriggerParameter(): any;
  9397. /**
  9398. * Internal only - executes current action event
  9399. * @hidden
  9400. */
  9401. _executeCurrent(evt?: ActionEvent): void;
  9402. /**
  9403. * Serialize placeholder for child classes
  9404. * @param parent of child
  9405. * @returns the serialized object
  9406. */
  9407. serialize(parent: any): any;
  9408. /**
  9409. * Internal only
  9410. * @hidden
  9411. */
  9412. _prepare(): void;
  9413. /**
  9414. * Internal only - manager for action
  9415. * @hidden
  9416. */
  9417. _actionManager: AbstractActionManager;
  9418. /**
  9419. * Adds action to chain of actions, may be a DoNothingAction
  9420. * @param action defines the next action to execute
  9421. * @returns The action passed in
  9422. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9423. */
  9424. then(action: IAction): IAction;
  9425. }
  9426. /**
  9427. * The action to be carried out following a trigger
  9428. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9429. */
  9430. export class Action implements IAction {
  9431. /** the trigger, with or without parameters, for the action */
  9432. triggerOptions: any;
  9433. /**
  9434. * Trigger for the action
  9435. */
  9436. trigger: number;
  9437. /**
  9438. * Internal only - manager for action
  9439. * @hidden
  9440. */
  9441. _actionManager: ActionManager;
  9442. private _nextActiveAction;
  9443. private _child;
  9444. private _condition?;
  9445. private _triggerParameter;
  9446. /**
  9447. * An event triggered prior to action being executed.
  9448. */
  9449. onBeforeExecuteObservable: Observable<Action>;
  9450. /**
  9451. * Creates a new Action
  9452. * @param triggerOptions the trigger, with or without parameters, for the action
  9453. * @param condition an optional determinant of action
  9454. */
  9455. constructor(
  9456. /** the trigger, with or without parameters, for the action */
  9457. triggerOptions: any, condition?: Condition);
  9458. /**
  9459. * Internal only
  9460. * @hidden
  9461. */
  9462. _prepare(): void;
  9463. /**
  9464. * Gets the trigger parameters
  9465. * @returns the trigger parameters
  9466. */
  9467. getTriggerParameter(): any;
  9468. /**
  9469. * Internal only - executes current action event
  9470. * @hidden
  9471. */
  9472. _executeCurrent(evt?: ActionEvent): void;
  9473. /**
  9474. * Execute placeholder for child classes
  9475. * @param evt optional action event
  9476. */
  9477. execute(evt?: ActionEvent): void;
  9478. /**
  9479. * Skips to next active action
  9480. */
  9481. skipToNextActiveAction(): void;
  9482. /**
  9483. * Adds action to chain of actions, may be a DoNothingAction
  9484. * @param action defines the next action to execute
  9485. * @returns The action passed in
  9486. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9487. */
  9488. then(action: Action): Action;
  9489. /**
  9490. * Internal only
  9491. * @hidden
  9492. */
  9493. _getProperty(propertyPath: string): string;
  9494. /**
  9495. * Internal only
  9496. * @hidden
  9497. */
  9498. _getEffectiveTarget(target: any, propertyPath: string): any;
  9499. /**
  9500. * Serialize placeholder for child classes
  9501. * @param parent of child
  9502. * @returns the serialized object
  9503. */
  9504. serialize(parent: any): any;
  9505. /**
  9506. * Internal only called by serialize
  9507. * @hidden
  9508. */
  9509. protected _serialize(serializedAction: any, parent?: any): any;
  9510. /**
  9511. * Internal only
  9512. * @hidden
  9513. */
  9514. static _SerializeValueAsString: (value: any) => string;
  9515. /**
  9516. * Internal only
  9517. * @hidden
  9518. */
  9519. static _GetTargetProperty: (target: Scene | Node) => {
  9520. name: string;
  9521. targetType: string;
  9522. value: string;
  9523. };
  9524. }
  9525. }
  9526. declare module BABYLON {
  9527. /**
  9528. * A Condition applied to an Action
  9529. */
  9530. export class Condition {
  9531. /**
  9532. * Internal only - manager for action
  9533. * @hidden
  9534. */
  9535. _actionManager: ActionManager;
  9536. /**
  9537. * Internal only
  9538. * @hidden
  9539. */
  9540. _evaluationId: number;
  9541. /**
  9542. * Internal only
  9543. * @hidden
  9544. */
  9545. _currentResult: boolean;
  9546. /**
  9547. * Creates a new Condition
  9548. * @param actionManager the manager of the action the condition is applied to
  9549. */
  9550. constructor(actionManager: ActionManager);
  9551. /**
  9552. * Check if the current condition is valid
  9553. * @returns a boolean
  9554. */
  9555. isValid(): boolean;
  9556. /**
  9557. * Internal only
  9558. * @hidden
  9559. */
  9560. _getProperty(propertyPath: string): string;
  9561. /**
  9562. * Internal only
  9563. * @hidden
  9564. */
  9565. _getEffectiveTarget(target: any, propertyPath: string): any;
  9566. /**
  9567. * Serialize placeholder for child classes
  9568. * @returns the serialized object
  9569. */
  9570. serialize(): any;
  9571. /**
  9572. * Internal only
  9573. * @hidden
  9574. */
  9575. protected _serialize(serializedCondition: any): any;
  9576. }
  9577. /**
  9578. * Defines specific conditional operators as extensions of Condition
  9579. */
  9580. export class ValueCondition extends Condition {
  9581. /** path to specify the property of the target the conditional operator uses */
  9582. propertyPath: string;
  9583. /** the value compared by the conditional operator against the current value of the property */
  9584. value: any;
  9585. /** the conditional operator, default ValueCondition.IsEqual */
  9586. operator: number;
  9587. /**
  9588. * Internal only
  9589. * @hidden
  9590. */
  9591. private static _IsEqual;
  9592. /**
  9593. * Internal only
  9594. * @hidden
  9595. */
  9596. private static _IsDifferent;
  9597. /**
  9598. * Internal only
  9599. * @hidden
  9600. */
  9601. private static _IsGreater;
  9602. /**
  9603. * Internal only
  9604. * @hidden
  9605. */
  9606. private static _IsLesser;
  9607. /**
  9608. * returns the number for IsEqual
  9609. */
  9610. static get IsEqual(): number;
  9611. /**
  9612. * Returns the number for IsDifferent
  9613. */
  9614. static get IsDifferent(): number;
  9615. /**
  9616. * Returns the number for IsGreater
  9617. */
  9618. static get IsGreater(): number;
  9619. /**
  9620. * Returns the number for IsLesser
  9621. */
  9622. static get IsLesser(): number;
  9623. /**
  9624. * Internal only The action manager for the condition
  9625. * @hidden
  9626. */
  9627. _actionManager: ActionManager;
  9628. /**
  9629. * Internal only
  9630. * @hidden
  9631. */
  9632. private _target;
  9633. /**
  9634. * Internal only
  9635. * @hidden
  9636. */
  9637. private _effectiveTarget;
  9638. /**
  9639. * Internal only
  9640. * @hidden
  9641. */
  9642. private _property;
  9643. /**
  9644. * Creates a new ValueCondition
  9645. * @param actionManager manager for the action the condition applies to
  9646. * @param target for the action
  9647. * @param propertyPath path to specify the property of the target the conditional operator uses
  9648. * @param value the value compared by the conditional operator against the current value of the property
  9649. * @param operator the conditional operator, default ValueCondition.IsEqual
  9650. */
  9651. constructor(actionManager: ActionManager, target: any,
  9652. /** path to specify the property of the target the conditional operator uses */
  9653. propertyPath: string,
  9654. /** the value compared by the conditional operator against the current value of the property */
  9655. value: any,
  9656. /** the conditional operator, default ValueCondition.IsEqual */
  9657. operator?: number);
  9658. /**
  9659. * Compares the given value with the property value for the specified conditional operator
  9660. * @returns the result of the comparison
  9661. */
  9662. isValid(): boolean;
  9663. /**
  9664. * Serialize the ValueCondition into a JSON compatible object
  9665. * @returns serialization object
  9666. */
  9667. serialize(): any;
  9668. /**
  9669. * Gets the name of the conditional operator for the ValueCondition
  9670. * @param operator the conditional operator
  9671. * @returns the name
  9672. */
  9673. static GetOperatorName(operator: number): string;
  9674. }
  9675. /**
  9676. * Defines a predicate condition as an extension of Condition
  9677. */
  9678. export class PredicateCondition extends Condition {
  9679. /** defines the predicate function used to validate the condition */
  9680. predicate: () => boolean;
  9681. /**
  9682. * Internal only - manager for action
  9683. * @hidden
  9684. */
  9685. _actionManager: ActionManager;
  9686. /**
  9687. * Creates a new PredicateCondition
  9688. * @param actionManager manager for the action the condition applies to
  9689. * @param predicate defines the predicate function used to validate the condition
  9690. */
  9691. constructor(actionManager: ActionManager,
  9692. /** defines the predicate function used to validate the condition */
  9693. predicate: () => boolean);
  9694. /**
  9695. * @returns the validity of the predicate condition
  9696. */
  9697. isValid(): boolean;
  9698. }
  9699. /**
  9700. * Defines a state condition as an extension of Condition
  9701. */
  9702. export class StateCondition extends Condition {
  9703. /** Value to compare with target state */
  9704. value: string;
  9705. /**
  9706. * Internal only - manager for action
  9707. * @hidden
  9708. */
  9709. _actionManager: ActionManager;
  9710. /**
  9711. * Internal only
  9712. * @hidden
  9713. */
  9714. private _target;
  9715. /**
  9716. * Creates a new StateCondition
  9717. * @param actionManager manager for the action the condition applies to
  9718. * @param target of the condition
  9719. * @param value to compare with target state
  9720. */
  9721. constructor(actionManager: ActionManager, target: any,
  9722. /** Value to compare with target state */
  9723. value: string);
  9724. /**
  9725. * Gets a boolean indicating if the current condition is met
  9726. * @returns the validity of the state
  9727. */
  9728. isValid(): boolean;
  9729. /**
  9730. * Serialize the StateCondition into a JSON compatible object
  9731. * @returns serialization object
  9732. */
  9733. serialize(): any;
  9734. }
  9735. }
  9736. declare module BABYLON {
  9737. /**
  9738. * This defines an action responsible to toggle a boolean once triggered.
  9739. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9740. */
  9741. export class SwitchBooleanAction extends Action {
  9742. /**
  9743. * The path to the boolean property in the target object
  9744. */
  9745. propertyPath: string;
  9746. private _target;
  9747. private _effectiveTarget;
  9748. private _property;
  9749. /**
  9750. * Instantiate the action
  9751. * @param triggerOptions defines the trigger options
  9752. * @param target defines the object containing the boolean
  9753. * @param propertyPath defines the path to the boolean property in the target object
  9754. * @param condition defines the trigger related conditions
  9755. */
  9756. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9757. /** @hidden */
  9758. _prepare(): void;
  9759. /**
  9760. * Execute the action toggle the boolean value.
  9761. */
  9762. execute(): void;
  9763. /**
  9764. * Serializes the actions and its related information.
  9765. * @param parent defines the object to serialize in
  9766. * @returns the serialized object
  9767. */
  9768. serialize(parent: any): any;
  9769. }
  9770. /**
  9771. * This defines an action responsible to set a the state field of the target
  9772. * to a desired value once triggered.
  9773. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9774. */
  9775. export class SetStateAction extends Action {
  9776. /**
  9777. * The value to store in the state field.
  9778. */
  9779. value: string;
  9780. private _target;
  9781. /**
  9782. * Instantiate the action
  9783. * @param triggerOptions defines the trigger options
  9784. * @param target defines the object containing the state property
  9785. * @param value defines the value to store in the state field
  9786. * @param condition defines the trigger related conditions
  9787. */
  9788. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9789. /**
  9790. * Execute the action and store the value on the target state property.
  9791. */
  9792. execute(): void;
  9793. /**
  9794. * Serializes the actions and its related information.
  9795. * @param parent defines the object to serialize in
  9796. * @returns the serialized object
  9797. */
  9798. serialize(parent: any): any;
  9799. }
  9800. /**
  9801. * This defines an action responsible to set a property of the target
  9802. * to a desired value once triggered.
  9803. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9804. */
  9805. export class SetValueAction extends Action {
  9806. /**
  9807. * The path of the property to set in the target.
  9808. */
  9809. propertyPath: string;
  9810. /**
  9811. * The value to set in the property
  9812. */
  9813. value: any;
  9814. private _target;
  9815. private _effectiveTarget;
  9816. private _property;
  9817. /**
  9818. * Instantiate the action
  9819. * @param triggerOptions defines the trigger options
  9820. * @param target defines the object containing the property
  9821. * @param propertyPath defines the path of the property to set in the target
  9822. * @param value defines the value to set in the property
  9823. * @param condition defines the trigger related conditions
  9824. */
  9825. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9826. /** @hidden */
  9827. _prepare(): void;
  9828. /**
  9829. * Execute the action and set the targetted property to the desired value.
  9830. */
  9831. execute(): void;
  9832. /**
  9833. * Serializes the actions and its related information.
  9834. * @param parent defines the object to serialize in
  9835. * @returns the serialized object
  9836. */
  9837. serialize(parent: any): any;
  9838. }
  9839. /**
  9840. * This defines an action responsible to increment the target value
  9841. * to a desired value once triggered.
  9842. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9843. */
  9844. export class IncrementValueAction extends Action {
  9845. /**
  9846. * The path of the property to increment in the target.
  9847. */
  9848. propertyPath: string;
  9849. /**
  9850. * The value we should increment the property by.
  9851. */
  9852. value: any;
  9853. private _target;
  9854. private _effectiveTarget;
  9855. private _property;
  9856. /**
  9857. * Instantiate the action
  9858. * @param triggerOptions defines the trigger options
  9859. * @param target defines the object containing the property
  9860. * @param propertyPath defines the path of the property to increment in the target
  9861. * @param value defines the value value we should increment the property by
  9862. * @param condition defines the trigger related conditions
  9863. */
  9864. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9865. /** @hidden */
  9866. _prepare(): void;
  9867. /**
  9868. * Execute the action and increment the target of the value amount.
  9869. */
  9870. execute(): void;
  9871. /**
  9872. * Serializes the actions and its related information.
  9873. * @param parent defines the object to serialize in
  9874. * @returns the serialized object
  9875. */
  9876. serialize(parent: any): any;
  9877. }
  9878. /**
  9879. * This defines an action responsible to start an animation once triggered.
  9880. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9881. */
  9882. export class PlayAnimationAction extends Action {
  9883. /**
  9884. * Where the animation should start (animation frame)
  9885. */
  9886. from: number;
  9887. /**
  9888. * Where the animation should stop (animation frame)
  9889. */
  9890. to: number;
  9891. /**
  9892. * Define if the animation should loop or stop after the first play.
  9893. */
  9894. loop?: boolean;
  9895. private _target;
  9896. /**
  9897. * Instantiate the action
  9898. * @param triggerOptions defines the trigger options
  9899. * @param target defines the target animation or animation name
  9900. * @param from defines from where the animation should start (animation frame)
  9901. * @param end defines where the animation should stop (animation frame)
  9902. * @param loop defines if the animation should loop or stop after the first play
  9903. * @param condition defines the trigger related conditions
  9904. */
  9905. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9906. /** @hidden */
  9907. _prepare(): void;
  9908. /**
  9909. * Execute the action and play the animation.
  9910. */
  9911. execute(): void;
  9912. /**
  9913. * Serializes the actions and its related information.
  9914. * @param parent defines the object to serialize in
  9915. * @returns the serialized object
  9916. */
  9917. serialize(parent: any): any;
  9918. }
  9919. /**
  9920. * This defines an action responsible to stop an animation once triggered.
  9921. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9922. */
  9923. export class StopAnimationAction extends Action {
  9924. private _target;
  9925. /**
  9926. * Instantiate the action
  9927. * @param triggerOptions defines the trigger options
  9928. * @param target defines the target animation or animation name
  9929. * @param condition defines the trigger related conditions
  9930. */
  9931. constructor(triggerOptions: any, target: any, condition?: Condition);
  9932. /** @hidden */
  9933. _prepare(): void;
  9934. /**
  9935. * Execute the action and stop the animation.
  9936. */
  9937. execute(): void;
  9938. /**
  9939. * Serializes the actions and its related information.
  9940. * @param parent defines the object to serialize in
  9941. * @returns the serialized object
  9942. */
  9943. serialize(parent: any): any;
  9944. }
  9945. /**
  9946. * This defines an action responsible that does nothing once triggered.
  9947. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9948. */
  9949. export class DoNothingAction extends Action {
  9950. /**
  9951. * Instantiate the action
  9952. * @param triggerOptions defines the trigger options
  9953. * @param condition defines the trigger related conditions
  9954. */
  9955. constructor(triggerOptions?: any, condition?: Condition);
  9956. /**
  9957. * Execute the action and do nothing.
  9958. */
  9959. execute(): void;
  9960. /**
  9961. * Serializes the actions and its related information.
  9962. * @param parent defines the object to serialize in
  9963. * @returns the serialized object
  9964. */
  9965. serialize(parent: any): any;
  9966. }
  9967. /**
  9968. * This defines an action responsible to trigger several actions once triggered.
  9969. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9970. */
  9971. export class CombineAction extends Action {
  9972. /**
  9973. * The list of aggregated animations to run.
  9974. */
  9975. children: Action[];
  9976. /**
  9977. * Instantiate the action
  9978. * @param triggerOptions defines the trigger options
  9979. * @param children defines the list of aggregated animations to run
  9980. * @param condition defines the trigger related conditions
  9981. */
  9982. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  9983. /** @hidden */
  9984. _prepare(): void;
  9985. /**
  9986. * Execute the action and executes all the aggregated actions.
  9987. */
  9988. execute(evt: ActionEvent): void;
  9989. /**
  9990. * Serializes the actions and its related information.
  9991. * @param parent defines the object to serialize in
  9992. * @returns the serialized object
  9993. */
  9994. serialize(parent: any): any;
  9995. }
  9996. /**
  9997. * This defines an action responsible to run code (external event) once triggered.
  9998. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9999. */
  10000. export class ExecuteCodeAction extends Action {
  10001. /**
  10002. * The callback function to run.
  10003. */
  10004. func: (evt: ActionEvent) => void;
  10005. /**
  10006. * Instantiate the action
  10007. * @param triggerOptions defines the trigger options
  10008. * @param func defines the callback function to run
  10009. * @param condition defines the trigger related conditions
  10010. */
  10011. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10012. /**
  10013. * Execute the action and run the attached code.
  10014. */
  10015. execute(evt: ActionEvent): void;
  10016. }
  10017. /**
  10018. * This defines an action responsible to set the parent property of the target once triggered.
  10019. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10020. */
  10021. export class SetParentAction extends Action {
  10022. private _parent;
  10023. private _target;
  10024. /**
  10025. * Instantiate the action
  10026. * @param triggerOptions defines the trigger options
  10027. * @param target defines the target containing the parent property
  10028. * @param parent defines from where the animation should start (animation frame)
  10029. * @param condition defines the trigger related conditions
  10030. */
  10031. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10032. /** @hidden */
  10033. _prepare(): void;
  10034. /**
  10035. * Execute the action and set the parent property.
  10036. */
  10037. execute(): void;
  10038. /**
  10039. * Serializes the actions and its related information.
  10040. * @param parent defines the object to serialize in
  10041. * @returns the serialized object
  10042. */
  10043. serialize(parent: any): any;
  10044. }
  10045. }
  10046. declare module BABYLON {
  10047. /**
  10048. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10049. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10050. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10051. */
  10052. export class ActionManager extends AbstractActionManager {
  10053. /**
  10054. * Nothing
  10055. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10056. */
  10057. static readonly NothingTrigger: number;
  10058. /**
  10059. * On pick
  10060. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10061. */
  10062. static readonly OnPickTrigger: number;
  10063. /**
  10064. * On left pick
  10065. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10066. */
  10067. static readonly OnLeftPickTrigger: number;
  10068. /**
  10069. * On right pick
  10070. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10071. */
  10072. static readonly OnRightPickTrigger: number;
  10073. /**
  10074. * On center pick
  10075. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10076. */
  10077. static readonly OnCenterPickTrigger: number;
  10078. /**
  10079. * On pick down
  10080. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10081. */
  10082. static readonly OnPickDownTrigger: number;
  10083. /**
  10084. * On double pick
  10085. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10086. */
  10087. static readonly OnDoublePickTrigger: number;
  10088. /**
  10089. * On pick up
  10090. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10091. */
  10092. static readonly OnPickUpTrigger: number;
  10093. /**
  10094. * On pick out.
  10095. * This trigger will only be raised if you also declared a OnPickDown
  10096. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10097. */
  10098. static readonly OnPickOutTrigger: number;
  10099. /**
  10100. * On long press
  10101. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10102. */
  10103. static readonly OnLongPressTrigger: number;
  10104. /**
  10105. * On pointer over
  10106. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10107. */
  10108. static readonly OnPointerOverTrigger: number;
  10109. /**
  10110. * On pointer out
  10111. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10112. */
  10113. static readonly OnPointerOutTrigger: number;
  10114. /**
  10115. * On every frame
  10116. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10117. */
  10118. static readonly OnEveryFrameTrigger: number;
  10119. /**
  10120. * On intersection enter
  10121. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10122. */
  10123. static readonly OnIntersectionEnterTrigger: number;
  10124. /**
  10125. * On intersection exit
  10126. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10127. */
  10128. static readonly OnIntersectionExitTrigger: number;
  10129. /**
  10130. * On key down
  10131. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10132. */
  10133. static readonly OnKeyDownTrigger: number;
  10134. /**
  10135. * On key up
  10136. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10137. */
  10138. static readonly OnKeyUpTrigger: number;
  10139. private _scene;
  10140. /**
  10141. * Creates a new action manager
  10142. * @param scene defines the hosting scene
  10143. */
  10144. constructor(scene: Scene);
  10145. /**
  10146. * Releases all associated resources
  10147. */
  10148. dispose(): void;
  10149. /**
  10150. * Gets hosting scene
  10151. * @returns the hosting scene
  10152. */
  10153. getScene(): Scene;
  10154. /**
  10155. * Does this action manager handles actions of any of the given triggers
  10156. * @param triggers defines the triggers to be tested
  10157. * @return a boolean indicating whether one (or more) of the triggers is handled
  10158. */
  10159. hasSpecificTriggers(triggers: number[]): boolean;
  10160. /**
  10161. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10162. * speed.
  10163. * @param triggerA defines the trigger to be tested
  10164. * @param triggerB defines the trigger to be tested
  10165. * @return a boolean indicating whether one (or more) of the triggers is handled
  10166. */
  10167. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10168. /**
  10169. * Does this action manager handles actions of a given trigger
  10170. * @param trigger defines the trigger to be tested
  10171. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10172. * @return whether the trigger is handled
  10173. */
  10174. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10175. /**
  10176. * Does this action manager has pointer triggers
  10177. */
  10178. get hasPointerTriggers(): boolean;
  10179. /**
  10180. * Does this action manager has pick triggers
  10181. */
  10182. get hasPickTriggers(): boolean;
  10183. /**
  10184. * Registers an action to this action manager
  10185. * @param action defines the action to be registered
  10186. * @return the action amended (prepared) after registration
  10187. */
  10188. registerAction(action: IAction): Nullable<IAction>;
  10189. /**
  10190. * Unregisters an action to this action manager
  10191. * @param action defines the action to be unregistered
  10192. * @return a boolean indicating whether the action has been unregistered
  10193. */
  10194. unregisterAction(action: IAction): Boolean;
  10195. /**
  10196. * Process a specific trigger
  10197. * @param trigger defines the trigger to process
  10198. * @param evt defines the event details to be processed
  10199. */
  10200. processTrigger(trigger: number, evt?: IActionEvent): void;
  10201. /** @hidden */
  10202. _getEffectiveTarget(target: any, propertyPath: string): any;
  10203. /** @hidden */
  10204. _getProperty(propertyPath: string): string;
  10205. /**
  10206. * Serialize this manager to a JSON object
  10207. * @param name defines the property name to store this manager
  10208. * @returns a JSON representation of this manager
  10209. */
  10210. serialize(name: string): any;
  10211. /**
  10212. * Creates a new ActionManager from a JSON data
  10213. * @param parsedActions defines the JSON data to read from
  10214. * @param object defines the hosting mesh
  10215. * @param scene defines the hosting scene
  10216. */
  10217. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10218. /**
  10219. * Get a trigger name by index
  10220. * @param trigger defines the trigger index
  10221. * @returns a trigger name
  10222. */
  10223. static GetTriggerName(trigger: number): string;
  10224. }
  10225. }
  10226. declare module BABYLON {
  10227. /**
  10228. * Class used to represent a sprite
  10229. * @see https://doc.babylonjs.com/babylon101/sprites
  10230. */
  10231. export class Sprite implements IAnimatable {
  10232. /** defines the name */
  10233. name: string;
  10234. /** Gets or sets the current world position */
  10235. position: Vector3;
  10236. /** Gets or sets the main color */
  10237. color: Color4;
  10238. /** Gets or sets the width */
  10239. width: number;
  10240. /** Gets or sets the height */
  10241. height: number;
  10242. /** Gets or sets rotation angle */
  10243. angle: number;
  10244. /** Gets or sets the cell index in the sprite sheet */
  10245. cellIndex: number;
  10246. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10247. cellRef: string;
  10248. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10249. invertU: boolean;
  10250. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10251. invertV: boolean;
  10252. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10253. disposeWhenFinishedAnimating: boolean;
  10254. /** Gets the list of attached animations */
  10255. animations: Nullable<Array<Animation>>;
  10256. /** Gets or sets a boolean indicating if the sprite can be picked */
  10257. isPickable: boolean;
  10258. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10259. useAlphaForPicking: boolean;
  10260. /** @hidden */
  10261. _xOffset: number;
  10262. /** @hidden */
  10263. _yOffset: number;
  10264. /** @hidden */
  10265. _xSize: number;
  10266. /** @hidden */
  10267. _ySize: number;
  10268. /**
  10269. * Gets or sets the associated action manager
  10270. */
  10271. actionManager: Nullable<ActionManager>;
  10272. /**
  10273. * An event triggered when the control has been disposed
  10274. */
  10275. onDisposeObservable: Observable<Sprite>;
  10276. private _animationStarted;
  10277. private _loopAnimation;
  10278. private _fromIndex;
  10279. private _toIndex;
  10280. private _delay;
  10281. private _direction;
  10282. private _manager;
  10283. private _time;
  10284. private _onAnimationEnd;
  10285. /**
  10286. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10287. */
  10288. isVisible: boolean;
  10289. /**
  10290. * Gets or sets the sprite size
  10291. */
  10292. get size(): number;
  10293. set size(value: number);
  10294. /**
  10295. * Returns a boolean indicating if the animation is started
  10296. */
  10297. get animationStarted(): boolean;
  10298. /**
  10299. * Gets or sets the unique id of the sprite
  10300. */
  10301. uniqueId: number;
  10302. /**
  10303. * Gets the manager of this sprite
  10304. */
  10305. get manager(): ISpriteManager;
  10306. /**
  10307. * Creates a new Sprite
  10308. * @param name defines the name
  10309. * @param manager defines the manager
  10310. */
  10311. constructor(
  10312. /** defines the name */
  10313. name: string, manager: ISpriteManager);
  10314. /**
  10315. * Returns the string "Sprite"
  10316. * @returns "Sprite"
  10317. */
  10318. getClassName(): string;
  10319. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10320. get fromIndex(): number;
  10321. set fromIndex(value: number);
  10322. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10323. get toIndex(): number;
  10324. set toIndex(value: number);
  10325. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10326. get loopAnimation(): boolean;
  10327. set loopAnimation(value: boolean);
  10328. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10329. get delay(): number;
  10330. set delay(value: number);
  10331. /**
  10332. * Starts an animation
  10333. * @param from defines the initial key
  10334. * @param to defines the end key
  10335. * @param loop defines if the animation must loop
  10336. * @param delay defines the start delay (in ms)
  10337. * @param onAnimationEnd defines a callback to call when animation ends
  10338. */
  10339. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10340. /** Stops current animation (if any) */
  10341. stopAnimation(): void;
  10342. /** @hidden */
  10343. _animate(deltaTime: number): void;
  10344. /** Release associated resources */
  10345. dispose(): void;
  10346. /**
  10347. * Serializes the sprite to a JSON object
  10348. * @returns the JSON object
  10349. */
  10350. serialize(): any;
  10351. /**
  10352. * Parses a JSON object to create a new sprite
  10353. * @param parsedSprite The JSON object to parse
  10354. * @param manager defines the hosting manager
  10355. * @returns the new sprite
  10356. */
  10357. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10358. }
  10359. }
  10360. declare module BABYLON {
  10361. /**
  10362. * Information about the result of picking within a scene
  10363. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10364. */
  10365. export class PickingInfo {
  10366. /** @hidden */
  10367. _pickingUnavailable: boolean;
  10368. /**
  10369. * If the pick collided with an object
  10370. */
  10371. hit: boolean;
  10372. /**
  10373. * Distance away where the pick collided
  10374. */
  10375. distance: number;
  10376. /**
  10377. * The location of pick collision
  10378. */
  10379. pickedPoint: Nullable<Vector3>;
  10380. /**
  10381. * The mesh corresponding the the pick collision
  10382. */
  10383. pickedMesh: Nullable<AbstractMesh>;
  10384. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10385. bu: number;
  10386. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10387. bv: number;
  10388. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10389. faceId: number;
  10390. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10391. subMeshFaceId: number;
  10392. /** Id of the the submesh that was picked */
  10393. subMeshId: number;
  10394. /** If a sprite was picked, this will be the sprite the pick collided with */
  10395. pickedSprite: Nullable<Sprite>;
  10396. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10397. thinInstanceIndex: number;
  10398. /**
  10399. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10400. */
  10401. originMesh: Nullable<AbstractMesh>;
  10402. /**
  10403. * The ray that was used to perform the picking.
  10404. */
  10405. ray: Nullable<Ray>;
  10406. /**
  10407. * Gets the normal correspodning to the face the pick collided with
  10408. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10409. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10410. * @returns The normal correspodning to the face the pick collided with
  10411. */
  10412. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10413. /**
  10414. * Gets the texture coordinates of where the pick occured
  10415. * @returns the vector containing the coordnates of the texture
  10416. */
  10417. getTextureCoordinates(): Nullable<Vector2>;
  10418. }
  10419. }
  10420. declare module BABYLON {
  10421. /**
  10422. * Class representing a ray with position and direction
  10423. */
  10424. export class Ray {
  10425. /** origin point */
  10426. origin: Vector3;
  10427. /** direction */
  10428. direction: Vector3;
  10429. /** length of the ray */
  10430. length: number;
  10431. private static readonly _TmpVector3;
  10432. private _tmpRay;
  10433. /**
  10434. * Creates a new ray
  10435. * @param origin origin point
  10436. * @param direction direction
  10437. * @param length length of the ray
  10438. */
  10439. constructor(
  10440. /** origin point */
  10441. origin: Vector3,
  10442. /** direction */
  10443. direction: Vector3,
  10444. /** length of the ray */
  10445. length?: number);
  10446. /**
  10447. * Checks if the ray intersects a box
  10448. * This does not account for the ray lenght by design to improve perfs.
  10449. * @param minimum bound of the box
  10450. * @param maximum bound of the box
  10451. * @param intersectionTreshold extra extend to be added to the box in all direction
  10452. * @returns if the box was hit
  10453. */
  10454. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10455. /**
  10456. * Checks if the ray intersects a box
  10457. * This does not account for the ray lenght by design to improve perfs.
  10458. * @param box the bounding box to check
  10459. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10460. * @returns if the box was hit
  10461. */
  10462. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10463. /**
  10464. * If the ray hits a sphere
  10465. * @param sphere the bounding sphere to check
  10466. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10467. * @returns true if it hits the sphere
  10468. */
  10469. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10470. /**
  10471. * If the ray hits a triange
  10472. * @param vertex0 triangle vertex
  10473. * @param vertex1 triangle vertex
  10474. * @param vertex2 triangle vertex
  10475. * @returns intersection information if hit
  10476. */
  10477. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10478. /**
  10479. * Checks if ray intersects a plane
  10480. * @param plane the plane to check
  10481. * @returns the distance away it was hit
  10482. */
  10483. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10484. /**
  10485. * Calculate the intercept of a ray on a given axis
  10486. * @param axis to check 'x' | 'y' | 'z'
  10487. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10488. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10489. */
  10490. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10491. /**
  10492. * Checks if ray intersects a mesh
  10493. * @param mesh the mesh to check
  10494. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10495. * @returns picking info of the intersecton
  10496. */
  10497. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10498. /**
  10499. * Checks if ray intersects a mesh
  10500. * @param meshes the meshes to check
  10501. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10502. * @param results array to store result in
  10503. * @returns Array of picking infos
  10504. */
  10505. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10506. private _comparePickingInfo;
  10507. private static smallnum;
  10508. private static rayl;
  10509. /**
  10510. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10511. * @param sega the first point of the segment to test the intersection against
  10512. * @param segb the second point of the segment to test the intersection against
  10513. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10514. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10515. */
  10516. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10517. /**
  10518. * Update the ray from viewport position
  10519. * @param x position
  10520. * @param y y position
  10521. * @param viewportWidth viewport width
  10522. * @param viewportHeight viewport height
  10523. * @param world world matrix
  10524. * @param view view matrix
  10525. * @param projection projection matrix
  10526. * @returns this ray updated
  10527. */
  10528. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10529. /**
  10530. * Creates a ray with origin and direction of 0,0,0
  10531. * @returns the new ray
  10532. */
  10533. static Zero(): Ray;
  10534. /**
  10535. * Creates a new ray from screen space and viewport
  10536. * @param x position
  10537. * @param y y position
  10538. * @param viewportWidth viewport width
  10539. * @param viewportHeight viewport height
  10540. * @param world world matrix
  10541. * @param view view matrix
  10542. * @param projection projection matrix
  10543. * @returns new ray
  10544. */
  10545. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10546. /**
  10547. * 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
  10548. * transformed to the given world matrix.
  10549. * @param origin The origin point
  10550. * @param end The end point
  10551. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10552. * @returns the new ray
  10553. */
  10554. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10555. /**
  10556. * Transforms a ray by a matrix
  10557. * @param ray ray to transform
  10558. * @param matrix matrix to apply
  10559. * @returns the resulting new ray
  10560. */
  10561. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10562. /**
  10563. * Transforms a ray by a matrix
  10564. * @param ray ray to transform
  10565. * @param matrix matrix to apply
  10566. * @param result ray to store result in
  10567. */
  10568. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10569. /**
  10570. * Unproject a ray from screen space to object space
  10571. * @param sourceX defines the screen space x coordinate to use
  10572. * @param sourceY defines the screen space y coordinate to use
  10573. * @param viewportWidth defines the current width of the viewport
  10574. * @param viewportHeight defines the current height of the viewport
  10575. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10576. * @param view defines the view matrix to use
  10577. * @param projection defines the projection matrix to use
  10578. */
  10579. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10580. }
  10581. /**
  10582. * Type used to define predicate used to select faces when a mesh intersection is detected
  10583. */
  10584. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10585. interface Scene {
  10586. /** @hidden */
  10587. _tempPickingRay: Nullable<Ray>;
  10588. /** @hidden */
  10589. _cachedRayForTransform: Ray;
  10590. /** @hidden */
  10591. _pickWithRayInverseMatrix: Matrix;
  10592. /** @hidden */
  10593. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10594. /** @hidden */
  10595. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10596. /** @hidden */
  10597. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10598. }
  10599. }
  10600. declare module BABYLON {
  10601. /**
  10602. * Groups all the scene component constants in one place to ease maintenance.
  10603. * @hidden
  10604. */
  10605. export class SceneComponentConstants {
  10606. static readonly NAME_EFFECTLAYER: string;
  10607. static readonly NAME_LAYER: string;
  10608. static readonly NAME_LENSFLARESYSTEM: string;
  10609. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10610. static readonly NAME_PARTICLESYSTEM: string;
  10611. static readonly NAME_GAMEPAD: string;
  10612. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10613. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10614. static readonly NAME_PREPASSRENDERER: string;
  10615. static readonly NAME_DEPTHRENDERER: string;
  10616. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10617. static readonly NAME_SPRITE: string;
  10618. static readonly NAME_OUTLINERENDERER: string;
  10619. static readonly NAME_PROCEDURALTEXTURE: string;
  10620. static readonly NAME_SHADOWGENERATOR: string;
  10621. static readonly NAME_OCTREE: string;
  10622. static readonly NAME_PHYSICSENGINE: string;
  10623. static readonly NAME_AUDIO: string;
  10624. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10625. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10626. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10627. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10628. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10629. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10630. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10631. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10632. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10633. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10634. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10635. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10636. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10637. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10638. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10639. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10640. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10641. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10642. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10643. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10644. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10645. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10646. static readonly STEP_AFTERRENDER_AUDIO: number;
  10647. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10648. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10649. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10650. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10651. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10652. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10653. static readonly STEP_POINTERMOVE_SPRITE: number;
  10654. static readonly STEP_POINTERDOWN_SPRITE: number;
  10655. static readonly STEP_POINTERUP_SPRITE: number;
  10656. }
  10657. /**
  10658. * This represents a scene component.
  10659. *
  10660. * This is used to decouple the dependency the scene is having on the different workloads like
  10661. * layers, post processes...
  10662. */
  10663. export interface ISceneComponent {
  10664. /**
  10665. * The name of the component. Each component must have a unique name.
  10666. */
  10667. name: string;
  10668. /**
  10669. * The scene the component belongs to.
  10670. */
  10671. scene: Scene;
  10672. /**
  10673. * Register the component to one instance of a scene.
  10674. */
  10675. register(): void;
  10676. /**
  10677. * Rebuilds the elements related to this component in case of
  10678. * context lost for instance.
  10679. */
  10680. rebuild(): void;
  10681. /**
  10682. * Disposes the component and the associated ressources.
  10683. */
  10684. dispose(): void;
  10685. }
  10686. /**
  10687. * This represents a SERIALIZABLE scene component.
  10688. *
  10689. * This extends Scene Component to add Serialization methods on top.
  10690. */
  10691. export interface ISceneSerializableComponent extends ISceneComponent {
  10692. /**
  10693. * Adds all the elements from the container to the scene
  10694. * @param container the container holding the elements
  10695. */
  10696. addFromContainer(container: AbstractScene): void;
  10697. /**
  10698. * Removes all the elements in the container from the scene
  10699. * @param container contains the elements to remove
  10700. * @param dispose if the removed element should be disposed (default: false)
  10701. */
  10702. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10703. /**
  10704. * Serializes the component data to the specified json object
  10705. * @param serializationObject The object to serialize to
  10706. */
  10707. serialize(serializationObject: any): void;
  10708. }
  10709. /**
  10710. * Strong typing of a Mesh related stage step action
  10711. */
  10712. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10713. /**
  10714. * Strong typing of a Evaluate Sub Mesh related stage step action
  10715. */
  10716. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10717. /**
  10718. * Strong typing of a Active Mesh related stage step action
  10719. */
  10720. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10721. /**
  10722. * Strong typing of a Camera related stage step action
  10723. */
  10724. export type CameraStageAction = (camera: Camera) => void;
  10725. /**
  10726. * Strong typing of a Camera Frame buffer related stage step action
  10727. */
  10728. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10729. /**
  10730. * Strong typing of a Render Target related stage step action
  10731. */
  10732. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10733. /**
  10734. * Strong typing of a RenderingGroup related stage step action
  10735. */
  10736. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10737. /**
  10738. * Strong typing of a Mesh Render related stage step action
  10739. */
  10740. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10741. /**
  10742. * Strong typing of a simple stage step action
  10743. */
  10744. export type SimpleStageAction = () => void;
  10745. /**
  10746. * Strong typing of a render target action.
  10747. */
  10748. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10749. /**
  10750. * Strong typing of a pointer move action.
  10751. */
  10752. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10753. /**
  10754. * Strong typing of a pointer up/down action.
  10755. */
  10756. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10757. /**
  10758. * Representation of a stage in the scene (Basically a list of ordered steps)
  10759. * @hidden
  10760. */
  10761. export class Stage<T extends Function> extends Array<{
  10762. index: number;
  10763. component: ISceneComponent;
  10764. action: T;
  10765. }> {
  10766. /**
  10767. * Hide ctor from the rest of the world.
  10768. * @param items The items to add.
  10769. */
  10770. private constructor();
  10771. /**
  10772. * Creates a new Stage.
  10773. * @returns A new instance of a Stage
  10774. */
  10775. static Create<T extends Function>(): Stage<T>;
  10776. /**
  10777. * Registers a step in an ordered way in the targeted stage.
  10778. * @param index Defines the position to register the step in
  10779. * @param component Defines the component attached to the step
  10780. * @param action Defines the action to launch during the step
  10781. */
  10782. registerStep(index: number, component: ISceneComponent, action: T): void;
  10783. /**
  10784. * Clears all the steps from the stage.
  10785. */
  10786. clear(): void;
  10787. }
  10788. }
  10789. declare module BABYLON {
  10790. interface Scene {
  10791. /** @hidden */
  10792. _pointerOverSprite: Nullable<Sprite>;
  10793. /** @hidden */
  10794. _pickedDownSprite: Nullable<Sprite>;
  10795. /** @hidden */
  10796. _tempSpritePickingRay: Nullable<Ray>;
  10797. /**
  10798. * All of the sprite managers added to this scene
  10799. * @see https://doc.babylonjs.com/babylon101/sprites
  10800. */
  10801. spriteManagers: Array<ISpriteManager>;
  10802. /**
  10803. * An event triggered when sprites rendering is about to start
  10804. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10805. */
  10806. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10807. /**
  10808. * An event triggered when sprites rendering is done
  10809. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10810. */
  10811. onAfterSpritesRenderingObservable: Observable<Scene>;
  10812. /** @hidden */
  10813. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10814. /** Launch a ray to try to pick a sprite in the scene
  10815. * @param x position on screen
  10816. * @param y position on screen
  10817. * @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
  10818. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10819. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10820. * @returns a PickingInfo
  10821. */
  10822. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10823. /** Use the given ray to pick a sprite in the scene
  10824. * @param ray The ray (in world space) to use to pick meshes
  10825. * @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
  10826. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10827. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10828. * @returns a PickingInfo
  10829. */
  10830. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10831. /** @hidden */
  10832. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10833. /** Launch a ray to try to pick sprites in the scene
  10834. * @param x position on screen
  10835. * @param y position on screen
  10836. * @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
  10837. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10838. * @returns a PickingInfo array
  10839. */
  10840. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10841. /** Use the given ray to pick sprites in the scene
  10842. * @param ray The ray (in world space) to use to pick meshes
  10843. * @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
  10844. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10845. * @returns a PickingInfo array
  10846. */
  10847. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10848. /**
  10849. * Force the sprite under the pointer
  10850. * @param sprite defines the sprite to use
  10851. */
  10852. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10853. /**
  10854. * Gets the sprite under the pointer
  10855. * @returns a Sprite or null if no sprite is under the pointer
  10856. */
  10857. getPointerOverSprite(): Nullable<Sprite>;
  10858. }
  10859. /**
  10860. * Defines the sprite scene component responsible to manage sprites
  10861. * in a given scene.
  10862. */
  10863. export class SpriteSceneComponent implements ISceneComponent {
  10864. /**
  10865. * The component name helpfull to identify the component in the list of scene components.
  10866. */
  10867. readonly name: string;
  10868. /**
  10869. * The scene the component belongs to.
  10870. */
  10871. scene: Scene;
  10872. /** @hidden */
  10873. private _spritePredicate;
  10874. /**
  10875. * Creates a new instance of the component for the given scene
  10876. * @param scene Defines the scene to register the component in
  10877. */
  10878. constructor(scene: Scene);
  10879. /**
  10880. * Registers the component in a given scene
  10881. */
  10882. register(): void;
  10883. /**
  10884. * Rebuilds the elements related to this component in case of
  10885. * context lost for instance.
  10886. */
  10887. rebuild(): void;
  10888. /**
  10889. * Disposes the component and the associated ressources.
  10890. */
  10891. dispose(): void;
  10892. private _pickSpriteButKeepRay;
  10893. private _pointerMove;
  10894. private _pointerDown;
  10895. private _pointerUp;
  10896. }
  10897. }
  10898. declare module BABYLON {
  10899. /** @hidden */
  10900. export var fogFragmentDeclaration: {
  10901. name: string;
  10902. shader: string;
  10903. };
  10904. }
  10905. declare module BABYLON {
  10906. /** @hidden */
  10907. export var fogFragment: {
  10908. name: string;
  10909. shader: string;
  10910. };
  10911. }
  10912. declare module BABYLON {
  10913. /** @hidden */
  10914. export var spritesPixelShader: {
  10915. name: string;
  10916. shader: string;
  10917. };
  10918. }
  10919. declare module BABYLON {
  10920. /** @hidden */
  10921. export var fogVertexDeclaration: {
  10922. name: string;
  10923. shader: string;
  10924. };
  10925. }
  10926. declare module BABYLON {
  10927. /** @hidden */
  10928. export var spritesVertexShader: {
  10929. name: string;
  10930. shader: string;
  10931. };
  10932. }
  10933. declare module BABYLON {
  10934. /**
  10935. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10936. */
  10937. export interface ISpriteManager extends IDisposable {
  10938. /**
  10939. * Gets manager's name
  10940. */
  10941. name: string;
  10942. /**
  10943. * Restricts the camera to viewing objects with the same layerMask.
  10944. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10945. */
  10946. layerMask: number;
  10947. /**
  10948. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10949. */
  10950. isPickable: boolean;
  10951. /**
  10952. * Gets the hosting scene
  10953. */
  10954. scene: Scene;
  10955. /**
  10956. * Specifies the rendering group id for this mesh (0 by default)
  10957. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10958. */
  10959. renderingGroupId: number;
  10960. /**
  10961. * Defines the list of sprites managed by the manager.
  10962. */
  10963. sprites: Array<Sprite>;
  10964. /**
  10965. * Gets or sets the spritesheet texture
  10966. */
  10967. texture: Texture;
  10968. /** Defines the default width of a cell in the spritesheet */
  10969. cellWidth: number;
  10970. /** Defines the default height of a cell in the spritesheet */
  10971. cellHeight: number;
  10972. /**
  10973. * Tests the intersection of a sprite with a specific ray.
  10974. * @param ray The ray we are sending to test the collision
  10975. * @param camera The camera space we are sending rays in
  10976. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10977. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10978. * @returns picking info or null.
  10979. */
  10980. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10981. /**
  10982. * Intersects the sprites with a ray
  10983. * @param ray defines the ray to intersect with
  10984. * @param camera defines the current active camera
  10985. * @param predicate defines a predicate used to select candidate sprites
  10986. * @returns null if no hit or a PickingInfo array
  10987. */
  10988. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10989. /**
  10990. * Renders the list of sprites on screen.
  10991. */
  10992. render(): void;
  10993. }
  10994. /**
  10995. * Class used to manage multiple sprites on the same spritesheet
  10996. * @see https://doc.babylonjs.com/babylon101/sprites
  10997. */
  10998. export class SpriteManager implements ISpriteManager {
  10999. /** defines the manager's name */
  11000. name: string;
  11001. /** Define the Url to load snippets */
  11002. static SnippetUrl: string;
  11003. /** Snippet ID if the manager was created from the snippet server */
  11004. snippetId: string;
  11005. /** Gets the list of sprites */
  11006. sprites: Sprite[];
  11007. /** Gets or sets the rendering group id (0 by default) */
  11008. renderingGroupId: number;
  11009. /** Gets or sets camera layer mask */
  11010. layerMask: number;
  11011. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11012. fogEnabled: boolean;
  11013. /** Gets or sets a boolean indicating if the sprites are pickable */
  11014. isPickable: boolean;
  11015. /** Defines the default width of a cell in the spritesheet */
  11016. cellWidth: number;
  11017. /** Defines the default height of a cell in the spritesheet */
  11018. cellHeight: number;
  11019. /** Associative array from JSON sprite data file */
  11020. private _cellData;
  11021. /** Array of sprite names from JSON sprite data file */
  11022. private _spriteMap;
  11023. /** True when packed cell data from JSON file is ready*/
  11024. private _packedAndReady;
  11025. private _textureContent;
  11026. /**
  11027. * An event triggered when the manager is disposed.
  11028. */
  11029. onDisposeObservable: Observable<SpriteManager>;
  11030. private _onDisposeObserver;
  11031. /**
  11032. * Callback called when the manager is disposed
  11033. */
  11034. set onDispose(callback: () => void);
  11035. private _capacity;
  11036. private _fromPacked;
  11037. private _spriteTexture;
  11038. private _epsilon;
  11039. private _scene;
  11040. private _vertexData;
  11041. private _buffer;
  11042. private _vertexBuffers;
  11043. private _indexBuffer;
  11044. private _effectBase;
  11045. private _effectFog;
  11046. /**
  11047. * Gets or sets the unique id of the sprite
  11048. */
  11049. uniqueId: number;
  11050. /**
  11051. * Gets the array of sprites
  11052. */
  11053. get children(): Sprite[];
  11054. /**
  11055. * Gets the hosting scene
  11056. */
  11057. get scene(): Scene;
  11058. /**
  11059. * Gets the capacity of the manager
  11060. */
  11061. get capacity(): number;
  11062. /**
  11063. * Gets or sets the spritesheet texture
  11064. */
  11065. get texture(): Texture;
  11066. set texture(value: Texture);
  11067. private _blendMode;
  11068. /**
  11069. * Blend mode use to render the particle, it can be any of
  11070. * the static Constants.ALPHA_x properties provided in this class.
  11071. * Default value is Constants.ALPHA_COMBINE
  11072. */
  11073. get blendMode(): number;
  11074. set blendMode(blendMode: number);
  11075. /** Disables writing to the depth buffer when rendering the sprites.
  11076. * It can be handy to disable depth writing when using textures without alpha channel
  11077. * and setting some specific blend modes.
  11078. */
  11079. disableDepthWrite: boolean;
  11080. /**
  11081. * Creates a new sprite manager
  11082. * @param name defines the manager's name
  11083. * @param imgUrl defines the sprite sheet url
  11084. * @param capacity defines the maximum allowed number of sprites
  11085. * @param cellSize defines the size of a sprite cell
  11086. * @param scene defines the hosting scene
  11087. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11088. * @param samplingMode defines the smapling mode to use with spritesheet
  11089. * @param fromPacked set to false; do not alter
  11090. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11091. */
  11092. constructor(
  11093. /** defines the manager's name */
  11094. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11095. /**
  11096. * Returns the string "SpriteManager"
  11097. * @returns "SpriteManager"
  11098. */
  11099. getClassName(): string;
  11100. private _makePacked;
  11101. private _appendSpriteVertex;
  11102. private _checkTextureAlpha;
  11103. /**
  11104. * Intersects the sprites with a ray
  11105. * @param ray defines the ray to intersect with
  11106. * @param camera defines the current active camera
  11107. * @param predicate defines a predicate used to select candidate sprites
  11108. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11109. * @returns null if no hit or a PickingInfo
  11110. */
  11111. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11112. /**
  11113. * Intersects the sprites with a ray
  11114. * @param ray defines the ray to intersect with
  11115. * @param camera defines the current active camera
  11116. * @param predicate defines a predicate used to select candidate sprites
  11117. * @returns null if no hit or a PickingInfo array
  11118. */
  11119. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11120. /**
  11121. * Render all child sprites
  11122. */
  11123. render(): void;
  11124. /**
  11125. * Release associated resources
  11126. */
  11127. dispose(): void;
  11128. /**
  11129. * Serializes the sprite manager to a JSON object
  11130. * @param serializeTexture defines if the texture must be serialized as well
  11131. * @returns the JSON object
  11132. */
  11133. serialize(serializeTexture?: boolean): any;
  11134. /**
  11135. * Parses a JSON object to create a new sprite manager.
  11136. * @param parsedManager The JSON object to parse
  11137. * @param scene The scene to create the sprite managerin
  11138. * @param rootUrl The root url to use to load external dependencies like texture
  11139. * @returns the new sprite manager
  11140. */
  11141. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11142. /**
  11143. * Creates a sprite manager from a snippet saved in a remote file
  11144. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11145. * @param url defines the url to load from
  11146. * @param scene defines the hosting scene
  11147. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11148. * @returns a promise that will resolve to the new sprite manager
  11149. */
  11150. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11151. /**
  11152. * Creates a sprite manager from a snippet saved by the sprite editor
  11153. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11154. * @param scene defines the hosting scene
  11155. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11156. * @returns a promise that will resolve to the new sprite manager
  11157. */
  11158. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11159. }
  11160. }
  11161. declare module BABYLON {
  11162. /** Interface used by value gradients (color, factor, ...) */
  11163. export interface IValueGradient {
  11164. /**
  11165. * Gets or sets the gradient value (between 0 and 1)
  11166. */
  11167. gradient: number;
  11168. }
  11169. /** Class used to store color4 gradient */
  11170. export class ColorGradient implements IValueGradient {
  11171. /**
  11172. * Gets or sets the gradient value (between 0 and 1)
  11173. */
  11174. gradient: number;
  11175. /**
  11176. * Gets or sets first associated color
  11177. */
  11178. color1: Color4;
  11179. /**
  11180. * Gets or sets second associated color
  11181. */
  11182. color2?: Color4 | undefined;
  11183. /**
  11184. * Creates a new color4 gradient
  11185. * @param gradient gets or sets the gradient value (between 0 and 1)
  11186. * @param color1 gets or sets first associated color
  11187. * @param color2 gets or sets first second color
  11188. */
  11189. constructor(
  11190. /**
  11191. * Gets or sets the gradient value (between 0 and 1)
  11192. */
  11193. gradient: number,
  11194. /**
  11195. * Gets or sets first associated color
  11196. */
  11197. color1: Color4,
  11198. /**
  11199. * Gets or sets second associated color
  11200. */
  11201. color2?: Color4 | undefined);
  11202. /**
  11203. * Will get a color picked randomly between color1 and color2.
  11204. * If color2 is undefined then color1 will be used
  11205. * @param result defines the target Color4 to store the result in
  11206. */
  11207. getColorToRef(result: Color4): void;
  11208. }
  11209. /** Class used to store color 3 gradient */
  11210. export class Color3Gradient implements IValueGradient {
  11211. /**
  11212. * Gets or sets the gradient value (between 0 and 1)
  11213. */
  11214. gradient: number;
  11215. /**
  11216. * Gets or sets the associated color
  11217. */
  11218. color: Color3;
  11219. /**
  11220. * Creates a new color3 gradient
  11221. * @param gradient gets or sets the gradient value (between 0 and 1)
  11222. * @param color gets or sets associated color
  11223. */
  11224. constructor(
  11225. /**
  11226. * Gets or sets the gradient value (between 0 and 1)
  11227. */
  11228. gradient: number,
  11229. /**
  11230. * Gets or sets the associated color
  11231. */
  11232. color: Color3);
  11233. }
  11234. /** Class used to store factor gradient */
  11235. export class FactorGradient implements IValueGradient {
  11236. /**
  11237. * Gets or sets the gradient value (between 0 and 1)
  11238. */
  11239. gradient: number;
  11240. /**
  11241. * Gets or sets first associated factor
  11242. */
  11243. factor1: number;
  11244. /**
  11245. * Gets or sets second associated factor
  11246. */
  11247. factor2?: number | undefined;
  11248. /**
  11249. * Creates a new factor gradient
  11250. * @param gradient gets or sets the gradient value (between 0 and 1)
  11251. * @param factor1 gets or sets first associated factor
  11252. * @param factor2 gets or sets second associated factor
  11253. */
  11254. constructor(
  11255. /**
  11256. * Gets or sets the gradient value (between 0 and 1)
  11257. */
  11258. gradient: number,
  11259. /**
  11260. * Gets or sets first associated factor
  11261. */
  11262. factor1: number,
  11263. /**
  11264. * Gets or sets second associated factor
  11265. */
  11266. factor2?: number | undefined);
  11267. /**
  11268. * Will get a number picked randomly between factor1 and factor2.
  11269. * If factor2 is undefined then factor1 will be used
  11270. * @returns the picked number
  11271. */
  11272. getFactor(): number;
  11273. }
  11274. /**
  11275. * Helper used to simplify some generic gradient tasks
  11276. */
  11277. export class GradientHelper {
  11278. /**
  11279. * Gets the current gradient from an array of IValueGradient
  11280. * @param ratio defines the current ratio to get
  11281. * @param gradients defines the array of IValueGradient
  11282. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11283. */
  11284. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11285. }
  11286. }
  11287. declare module BABYLON {
  11288. interface ThinEngine {
  11289. /**
  11290. * Creates a raw texture
  11291. * @param data defines the data to store in the texture
  11292. * @param width defines the width of the texture
  11293. * @param height defines the height of the texture
  11294. * @param format defines the format of the data
  11295. * @param generateMipMaps defines if the engine should generate the mip levels
  11296. * @param invertY defines if data must be stored with Y axis inverted
  11297. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11298. * @param compression defines the compression used (null by default)
  11299. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11300. * @returns the raw texture inside an InternalTexture
  11301. */
  11302. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11303. /**
  11304. * Update a raw texture
  11305. * @param texture defines the texture to update
  11306. * @param data defines the data to store in the texture
  11307. * @param format defines the format of the data
  11308. * @param invertY defines if data must be stored with Y axis inverted
  11309. */
  11310. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11311. /**
  11312. * Update a raw texture
  11313. * @param texture defines the texture to update
  11314. * @param data defines the data to store in the texture
  11315. * @param format defines the format of the data
  11316. * @param invertY defines if data must be stored with Y axis inverted
  11317. * @param compression defines the compression used (null by default)
  11318. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11319. */
  11320. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11321. /**
  11322. * Creates a new raw cube texture
  11323. * @param data defines the array of data to use to create each face
  11324. * @param size defines the size of the textures
  11325. * @param format defines the format of the data
  11326. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11327. * @param generateMipMaps defines if the engine should generate the mip levels
  11328. * @param invertY defines if data must be stored with Y axis inverted
  11329. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11330. * @param compression defines the compression used (null by default)
  11331. * @returns the cube texture as an InternalTexture
  11332. */
  11333. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11334. /**
  11335. * Update a raw cube texture
  11336. * @param texture defines the texture to udpdate
  11337. * @param data defines the data to store
  11338. * @param format defines the data format
  11339. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11340. * @param invertY defines if data must be stored with Y axis inverted
  11341. */
  11342. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11343. /**
  11344. * Update a raw cube texture
  11345. * @param texture defines the texture to udpdate
  11346. * @param data defines the data to store
  11347. * @param format defines the data format
  11348. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11349. * @param invertY defines if data must be stored with Y axis inverted
  11350. * @param compression defines the compression used (null by default)
  11351. */
  11352. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11353. /**
  11354. * Update a raw cube texture
  11355. * @param texture defines the texture to udpdate
  11356. * @param data defines the data to store
  11357. * @param format defines the data format
  11358. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11359. * @param invertY defines if data must be stored with Y axis inverted
  11360. * @param compression defines the compression used (null by default)
  11361. * @param level defines which level of the texture to update
  11362. */
  11363. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11364. /**
  11365. * Creates a new raw cube texture from a specified url
  11366. * @param url defines the url where the data is located
  11367. * @param scene defines the current scene
  11368. * @param size defines the size of the textures
  11369. * @param format defines the format of the data
  11370. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11371. * @param noMipmap defines if the engine should avoid generating the mip levels
  11372. * @param callback defines a callback used to extract texture data from loaded data
  11373. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11374. * @param onLoad defines a callback called when texture is loaded
  11375. * @param onError defines a callback called if there is an error
  11376. * @returns the cube texture as an InternalTexture
  11377. */
  11378. 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;
  11379. /**
  11380. * Creates a new raw cube texture from a specified url
  11381. * @param url defines the url where the data is located
  11382. * @param scene defines the current scene
  11383. * @param size defines the size of the textures
  11384. * @param format defines the format of the data
  11385. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11386. * @param noMipmap defines if the engine should avoid generating the mip levels
  11387. * @param callback defines a callback used to extract texture data from loaded data
  11388. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11389. * @param onLoad defines a callback called when texture is loaded
  11390. * @param onError defines a callback called if there is an error
  11391. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11392. * @param invertY defines if data must be stored with Y axis inverted
  11393. * @returns the cube texture as an InternalTexture
  11394. */
  11395. 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;
  11396. /**
  11397. * Creates a new raw 3D texture
  11398. * @param data defines the data used to create the texture
  11399. * @param width defines the width of the texture
  11400. * @param height defines the height of the texture
  11401. * @param depth defines the depth of the texture
  11402. * @param format defines the format of the texture
  11403. * @param generateMipMaps defines if the engine must generate mip levels
  11404. * @param invertY defines if data must be stored with Y axis inverted
  11405. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11406. * @param compression defines the compressed used (can be null)
  11407. * @param textureType defines the compressed used (can be null)
  11408. * @returns a new raw 3D texture (stored in an InternalTexture)
  11409. */
  11410. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11411. /**
  11412. * Update a raw 3D texture
  11413. * @param texture defines the texture to update
  11414. * @param data defines the data to store
  11415. * @param format defines the data format
  11416. * @param invertY defines if data must be stored with Y axis inverted
  11417. */
  11418. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11419. /**
  11420. * Update a raw 3D texture
  11421. * @param texture defines the texture to update
  11422. * @param data defines the data to store
  11423. * @param format defines the data format
  11424. * @param invertY defines if data must be stored with Y axis inverted
  11425. * @param compression defines the used compression (can be null)
  11426. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11427. */
  11428. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11429. /**
  11430. * Creates a new raw 2D array texture
  11431. * @param data defines the data used to create the texture
  11432. * @param width defines the width of the texture
  11433. * @param height defines the height of the texture
  11434. * @param depth defines the number of layers of the texture
  11435. * @param format defines the format of the texture
  11436. * @param generateMipMaps defines if the engine must generate mip levels
  11437. * @param invertY defines if data must be stored with Y axis inverted
  11438. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11439. * @param compression defines the compressed used (can be null)
  11440. * @param textureType defines the compressed used (can be null)
  11441. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11442. */
  11443. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11444. /**
  11445. * Update a raw 2D array texture
  11446. * @param texture defines the texture to update
  11447. * @param data defines the data to store
  11448. * @param format defines the data format
  11449. * @param invertY defines if data must be stored with Y axis inverted
  11450. */
  11451. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11452. /**
  11453. * Update a raw 2D array texture
  11454. * @param texture defines the texture to update
  11455. * @param data defines the data to store
  11456. * @param format defines the data format
  11457. * @param invertY defines if data must be stored with Y axis inverted
  11458. * @param compression defines the used compression (can be null)
  11459. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11460. */
  11461. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11462. }
  11463. }
  11464. declare module BABYLON {
  11465. /**
  11466. * Raw texture can help creating a texture directly from an array of data.
  11467. * This can be super useful if you either get the data from an uncompressed source or
  11468. * if you wish to create your texture pixel by pixel.
  11469. */
  11470. export class RawTexture extends Texture {
  11471. /**
  11472. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11473. */
  11474. format: number;
  11475. /**
  11476. * Instantiates a new RawTexture.
  11477. * Raw texture can help creating a texture directly from an array of data.
  11478. * This can be super useful if you either get the data from an uncompressed source or
  11479. * if you wish to create your texture pixel by pixel.
  11480. * @param data define the array of data to use to create the texture
  11481. * @param width define the width of the texture
  11482. * @param height define the height of the texture
  11483. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11484. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11485. * @param generateMipMaps define whether mip maps should be generated or not
  11486. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11487. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11488. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11489. */
  11490. constructor(data: ArrayBufferView, width: number, height: number,
  11491. /**
  11492. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11493. */
  11494. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11495. /**
  11496. * Updates the texture underlying data.
  11497. * @param data Define the new data of the texture
  11498. */
  11499. update(data: ArrayBufferView): void;
  11500. /**
  11501. * Creates a luminance texture from some data.
  11502. * @param data Define the texture data
  11503. * @param width Define the width of the texture
  11504. * @param height Define the height of the texture
  11505. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11506. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11507. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11508. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11509. * @returns the luminance texture
  11510. */
  11511. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11512. /**
  11513. * Creates a luminance alpha texture from some data.
  11514. * @param data Define the texture data
  11515. * @param width Define the width of the texture
  11516. * @param height Define the height of the texture
  11517. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11518. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11519. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11520. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11521. * @returns the luminance alpha texture
  11522. */
  11523. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11524. /**
  11525. * Creates an alpha texture from some data.
  11526. * @param data Define the texture data
  11527. * @param width Define the width of the texture
  11528. * @param height Define the height of the texture
  11529. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11530. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11531. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11532. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11533. * @returns the alpha texture
  11534. */
  11535. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11536. /**
  11537. * Creates a RGB texture from some data.
  11538. * @param data Define the texture data
  11539. * @param width Define the width of the texture
  11540. * @param height Define the height of the texture
  11541. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11542. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11543. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11544. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11545. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11546. * @returns the RGB alpha texture
  11547. */
  11548. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11549. /**
  11550. * Creates a RGBA texture from some data.
  11551. * @param data Define the texture data
  11552. * @param width Define the width of the texture
  11553. * @param height Define the height of the texture
  11554. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11555. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11556. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11557. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11558. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11559. * @returns the RGBA texture
  11560. */
  11561. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11562. /**
  11563. * Creates a R texture from some data.
  11564. * @param data Define the texture data
  11565. * @param width Define the width of the texture
  11566. * @param height Define the height of the texture
  11567. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11568. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11569. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11570. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11571. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11572. * @returns the R texture
  11573. */
  11574. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11575. }
  11576. }
  11577. declare module BABYLON {
  11578. interface AbstractScene {
  11579. /**
  11580. * The list of procedural textures added to the scene
  11581. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11582. */
  11583. proceduralTextures: Array<ProceduralTexture>;
  11584. }
  11585. /**
  11586. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11587. * in a given scene.
  11588. */
  11589. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11590. /**
  11591. * The component name helpfull to identify the component in the list of scene components.
  11592. */
  11593. readonly name: string;
  11594. /**
  11595. * The scene the component belongs to.
  11596. */
  11597. scene: Scene;
  11598. /**
  11599. * Creates a new instance of the component for the given scene
  11600. * @param scene Defines the scene to register the component in
  11601. */
  11602. constructor(scene: Scene);
  11603. /**
  11604. * Registers the component in a given scene
  11605. */
  11606. register(): void;
  11607. /**
  11608. * Rebuilds the elements related to this component in case of
  11609. * context lost for instance.
  11610. */
  11611. rebuild(): void;
  11612. /**
  11613. * Disposes the component and the associated ressources.
  11614. */
  11615. dispose(): void;
  11616. private _beforeClear;
  11617. }
  11618. }
  11619. declare module BABYLON {
  11620. interface ThinEngine {
  11621. /**
  11622. * Creates a new render target cube texture
  11623. * @param size defines the size of the texture
  11624. * @param options defines the options used to create the texture
  11625. * @returns a new render target cube texture stored in an InternalTexture
  11626. */
  11627. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11628. }
  11629. }
  11630. declare module BABYLON {
  11631. /** @hidden */
  11632. export var proceduralVertexShader: {
  11633. name: string;
  11634. shader: string;
  11635. };
  11636. }
  11637. declare module BABYLON {
  11638. /**
  11639. * 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.
  11640. * This is the base class of any Procedural texture and contains most of the shareable code.
  11641. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11642. */
  11643. export class ProceduralTexture extends Texture {
  11644. isCube: boolean;
  11645. /**
  11646. * Define if the texture is enabled or not (disabled texture will not render)
  11647. */
  11648. isEnabled: boolean;
  11649. /**
  11650. * Define if the texture must be cleared before rendering (default is true)
  11651. */
  11652. autoClear: boolean;
  11653. /**
  11654. * Callback called when the texture is generated
  11655. */
  11656. onGenerated: () => void;
  11657. /**
  11658. * Event raised when the texture is generated
  11659. */
  11660. onGeneratedObservable: Observable<ProceduralTexture>;
  11661. /** @hidden */
  11662. _generateMipMaps: boolean;
  11663. /** @hidden **/
  11664. _effect: Effect;
  11665. /** @hidden */
  11666. _textures: {
  11667. [key: string]: Texture;
  11668. };
  11669. /** @hidden */
  11670. protected _fallbackTexture: Nullable<Texture>;
  11671. private _size;
  11672. private _currentRefreshId;
  11673. private _frameId;
  11674. private _refreshRate;
  11675. private _vertexBuffers;
  11676. private _indexBuffer;
  11677. private _uniforms;
  11678. private _samplers;
  11679. private _fragment;
  11680. private _floats;
  11681. private _ints;
  11682. private _floatsArrays;
  11683. private _colors3;
  11684. private _colors4;
  11685. private _vectors2;
  11686. private _vectors3;
  11687. private _matrices;
  11688. private _fallbackTextureUsed;
  11689. private _fullEngine;
  11690. private _cachedDefines;
  11691. private _contentUpdateId;
  11692. private _contentData;
  11693. /**
  11694. * Instantiates a new procedural texture.
  11695. * 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.
  11696. * This is the base class of any Procedural texture and contains most of the shareable code.
  11697. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11698. * @param name Define the name of the texture
  11699. * @param size Define the size of the texture to create
  11700. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11701. * @param scene Define the scene the texture belongs to
  11702. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11703. * @param generateMipMaps Define if the texture should creates mip maps or not
  11704. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11705. */
  11706. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11707. /**
  11708. * The effect that is created when initializing the post process.
  11709. * @returns The created effect corresponding the the postprocess.
  11710. */
  11711. getEffect(): Effect;
  11712. /**
  11713. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11714. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11715. */
  11716. getContent(): Nullable<ArrayBufferView>;
  11717. private _createIndexBuffer;
  11718. /** @hidden */
  11719. _rebuild(): void;
  11720. /**
  11721. * Resets the texture in order to recreate its associated resources.
  11722. * This can be called in case of context loss
  11723. */
  11724. reset(): void;
  11725. protected _getDefines(): string;
  11726. /**
  11727. * Is the texture ready to be used ? (rendered at least once)
  11728. * @returns true if ready, otherwise, false.
  11729. */
  11730. isReady(): boolean;
  11731. /**
  11732. * Resets the refresh counter of the texture and start bak from scratch.
  11733. * Could be useful to regenerate the texture if it is setup to render only once.
  11734. */
  11735. resetRefreshCounter(): void;
  11736. /**
  11737. * Set the fragment shader to use in order to render the texture.
  11738. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11739. */
  11740. setFragment(fragment: any): void;
  11741. /**
  11742. * Define the refresh rate of the texture or the rendering frequency.
  11743. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11744. */
  11745. get refreshRate(): number;
  11746. set refreshRate(value: number);
  11747. /** @hidden */
  11748. _shouldRender(): boolean;
  11749. /**
  11750. * Get the size the texture is rendering at.
  11751. * @returns the size (texture is always squared)
  11752. */
  11753. getRenderSize(): number;
  11754. /**
  11755. * Resize the texture to new value.
  11756. * @param size Define the new size the texture should have
  11757. * @param generateMipMaps Define whether the new texture should create mip maps
  11758. */
  11759. resize(size: number, generateMipMaps: boolean): void;
  11760. private _checkUniform;
  11761. /**
  11762. * Set a texture in the shader program used to render.
  11763. * @param name Define the name of the uniform samplers as defined in the shader
  11764. * @param texture Define the texture to bind to this sampler
  11765. * @return the texture itself allowing "fluent" like uniform updates
  11766. */
  11767. setTexture(name: string, texture: Texture): ProceduralTexture;
  11768. /**
  11769. * Set a float in the shader.
  11770. * @param name Define the name of the uniform as defined in the shader
  11771. * @param value Define the value to give to the uniform
  11772. * @return the texture itself allowing "fluent" like uniform updates
  11773. */
  11774. setFloat(name: string, value: number): ProceduralTexture;
  11775. /**
  11776. * Set a int in the shader.
  11777. * @param name Define the name of the uniform as defined in the shader
  11778. * @param value Define the value to give to the uniform
  11779. * @return the texture itself allowing "fluent" like uniform updates
  11780. */
  11781. setInt(name: string, value: number): ProceduralTexture;
  11782. /**
  11783. * Set an array of floats in the shader.
  11784. * @param name Define the name of the uniform as defined in the shader
  11785. * @param value Define the value to give to the uniform
  11786. * @return the texture itself allowing "fluent" like uniform updates
  11787. */
  11788. setFloats(name: string, value: number[]): ProceduralTexture;
  11789. /**
  11790. * Set a vec3 in the shader from a Color3.
  11791. * @param name Define the name of the uniform as defined in the shader
  11792. * @param value Define the value to give to the uniform
  11793. * @return the texture itself allowing "fluent" like uniform updates
  11794. */
  11795. setColor3(name: string, value: Color3): ProceduralTexture;
  11796. /**
  11797. * Set a vec4 in the shader from a Color4.
  11798. * @param name Define the name of the uniform as defined in the shader
  11799. * @param value Define the value to give to the uniform
  11800. * @return the texture itself allowing "fluent" like uniform updates
  11801. */
  11802. setColor4(name: string, value: Color4): ProceduralTexture;
  11803. /**
  11804. * Set a vec2 in the shader from a Vector2.
  11805. * @param name Define the name of the uniform as defined in the shader
  11806. * @param value Define the value to give to the uniform
  11807. * @return the texture itself allowing "fluent" like uniform updates
  11808. */
  11809. setVector2(name: string, value: Vector2): ProceduralTexture;
  11810. /**
  11811. * Set a vec3 in the shader from a Vector3.
  11812. * @param name Define the name of the uniform as defined in the shader
  11813. * @param value Define the value to give to the uniform
  11814. * @return the texture itself allowing "fluent" like uniform updates
  11815. */
  11816. setVector3(name: string, value: Vector3): ProceduralTexture;
  11817. /**
  11818. * Set a mat4 in the shader from a MAtrix.
  11819. * @param name Define the name of the uniform as defined in the shader
  11820. * @param value Define the value to give to the uniform
  11821. * @return the texture itself allowing "fluent" like uniform updates
  11822. */
  11823. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11824. /**
  11825. * Render the texture to its associated render target.
  11826. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11827. */
  11828. render(useCameraPostProcess?: boolean): void;
  11829. /**
  11830. * Clone the texture.
  11831. * @returns the cloned texture
  11832. */
  11833. clone(): ProceduralTexture;
  11834. /**
  11835. * Dispose the texture and release its asoociated resources.
  11836. */
  11837. dispose(): void;
  11838. }
  11839. }
  11840. declare module BABYLON {
  11841. /**
  11842. * This represents the base class for particle system in Babylon.
  11843. * 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.
  11844. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11845. * @example https://doc.babylonjs.com/babylon101/particles
  11846. */
  11847. export class BaseParticleSystem {
  11848. /**
  11849. * Source color is added to the destination color without alpha affecting the result
  11850. */
  11851. static BLENDMODE_ONEONE: number;
  11852. /**
  11853. * Blend current color and particle color using particle’s alpha
  11854. */
  11855. static BLENDMODE_STANDARD: number;
  11856. /**
  11857. * Add current color and particle color multiplied by particle’s alpha
  11858. */
  11859. static BLENDMODE_ADD: number;
  11860. /**
  11861. * Multiply current color with particle color
  11862. */
  11863. static BLENDMODE_MULTIPLY: number;
  11864. /**
  11865. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11866. */
  11867. static BLENDMODE_MULTIPLYADD: number;
  11868. /**
  11869. * List of animations used by the particle system.
  11870. */
  11871. animations: Animation[];
  11872. /**
  11873. * Gets or sets the unique id of the particle system
  11874. */
  11875. uniqueId: number;
  11876. /**
  11877. * The id of the Particle system.
  11878. */
  11879. id: string;
  11880. /**
  11881. * The friendly name of the Particle system.
  11882. */
  11883. name: string;
  11884. /**
  11885. * Snippet ID if the particle system was created from the snippet server
  11886. */
  11887. snippetId: string;
  11888. /**
  11889. * The rendering group used by the Particle system to chose when to render.
  11890. */
  11891. renderingGroupId: number;
  11892. /**
  11893. * The emitter represents the Mesh or position we are attaching the particle system to.
  11894. */
  11895. emitter: Nullable<AbstractMesh | Vector3>;
  11896. /**
  11897. * The maximum number of particles to emit per frame
  11898. */
  11899. emitRate: number;
  11900. /**
  11901. * If you want to launch only a few particles at once, that can be done, as well.
  11902. */
  11903. manualEmitCount: number;
  11904. /**
  11905. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11906. */
  11907. updateSpeed: number;
  11908. /**
  11909. * The amount of time the particle system is running (depends of the overall update speed).
  11910. */
  11911. targetStopDuration: number;
  11912. /**
  11913. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11914. */
  11915. disposeOnStop: boolean;
  11916. /**
  11917. * Minimum power of emitting particles.
  11918. */
  11919. minEmitPower: number;
  11920. /**
  11921. * Maximum power of emitting particles.
  11922. */
  11923. maxEmitPower: number;
  11924. /**
  11925. * Minimum life time of emitting particles.
  11926. */
  11927. minLifeTime: number;
  11928. /**
  11929. * Maximum life time of emitting particles.
  11930. */
  11931. maxLifeTime: number;
  11932. /**
  11933. * Minimum Size of emitting particles.
  11934. */
  11935. minSize: number;
  11936. /**
  11937. * Maximum Size of emitting particles.
  11938. */
  11939. maxSize: number;
  11940. /**
  11941. * Minimum scale of emitting particles on X axis.
  11942. */
  11943. minScaleX: number;
  11944. /**
  11945. * Maximum scale of emitting particles on X axis.
  11946. */
  11947. maxScaleX: number;
  11948. /**
  11949. * Minimum scale of emitting particles on Y axis.
  11950. */
  11951. minScaleY: number;
  11952. /**
  11953. * Maximum scale of emitting particles on Y axis.
  11954. */
  11955. maxScaleY: number;
  11956. /**
  11957. * Gets or sets the minimal initial rotation in radians.
  11958. */
  11959. minInitialRotation: number;
  11960. /**
  11961. * Gets or sets the maximal initial rotation in radians.
  11962. */
  11963. maxInitialRotation: number;
  11964. /**
  11965. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11966. */
  11967. minAngularSpeed: number;
  11968. /**
  11969. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11970. */
  11971. maxAngularSpeed: number;
  11972. /**
  11973. * The texture used to render each particle. (this can be a spritesheet)
  11974. */
  11975. particleTexture: Nullable<Texture>;
  11976. /**
  11977. * The layer mask we are rendering the particles through.
  11978. */
  11979. layerMask: number;
  11980. /**
  11981. * This can help using your own shader to render the particle system.
  11982. * The according effect will be created
  11983. */
  11984. customShader: any;
  11985. /**
  11986. * By default particle system starts as soon as they are created. This prevents the
  11987. * automatic start to happen and let you decide when to start emitting particles.
  11988. */
  11989. preventAutoStart: boolean;
  11990. private _noiseTexture;
  11991. /**
  11992. * Gets or sets a texture used to add random noise to particle positions
  11993. */
  11994. get noiseTexture(): Nullable<ProceduralTexture>;
  11995. set noiseTexture(value: Nullable<ProceduralTexture>);
  11996. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11997. noiseStrength: Vector3;
  11998. /**
  11999. * Callback triggered when the particle animation is ending.
  12000. */
  12001. onAnimationEnd: Nullable<() => void>;
  12002. /**
  12003. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12004. */
  12005. blendMode: number;
  12006. /**
  12007. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12008. * to override the particles.
  12009. */
  12010. forceDepthWrite: boolean;
  12011. /** 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 */
  12012. preWarmCycles: number;
  12013. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12014. preWarmStepOffset: number;
  12015. /**
  12016. * 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)
  12017. */
  12018. spriteCellChangeSpeed: number;
  12019. /**
  12020. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12021. */
  12022. startSpriteCellID: number;
  12023. /**
  12024. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12025. */
  12026. endSpriteCellID: number;
  12027. /**
  12028. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12029. */
  12030. spriteCellWidth: number;
  12031. /**
  12032. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12033. */
  12034. spriteCellHeight: number;
  12035. /**
  12036. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12037. */
  12038. spriteRandomStartCell: boolean;
  12039. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12040. translationPivot: Vector2;
  12041. /** @hidden */
  12042. protected _isAnimationSheetEnabled: boolean;
  12043. /**
  12044. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12045. */
  12046. beginAnimationOnStart: boolean;
  12047. /**
  12048. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12049. */
  12050. beginAnimationFrom: number;
  12051. /**
  12052. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12053. */
  12054. beginAnimationTo: number;
  12055. /**
  12056. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12057. */
  12058. beginAnimationLoop: boolean;
  12059. /**
  12060. * Gets or sets a world offset applied to all particles
  12061. */
  12062. worldOffset: Vector3;
  12063. /**
  12064. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12065. */
  12066. get isAnimationSheetEnabled(): boolean;
  12067. set isAnimationSheetEnabled(value: boolean);
  12068. /**
  12069. * Get hosting scene
  12070. * @returns the scene
  12071. */
  12072. getScene(): Nullable<Scene>;
  12073. /**
  12074. * You can use gravity if you want to give an orientation to your particles.
  12075. */
  12076. gravity: Vector3;
  12077. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12078. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12079. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12080. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12081. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12082. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12083. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12084. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12085. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12086. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12087. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12088. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12089. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12090. /**
  12091. * Defines the delay in milliseconds before starting the system (0 by default)
  12092. */
  12093. startDelay: number;
  12094. /**
  12095. * Gets the current list of drag gradients.
  12096. * You must use addDragGradient and removeDragGradient to udpate this list
  12097. * @returns the list of drag gradients
  12098. */
  12099. getDragGradients(): Nullable<Array<FactorGradient>>;
  12100. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12101. limitVelocityDamping: number;
  12102. /**
  12103. * Gets the current list of limit velocity gradients.
  12104. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12105. * @returns the list of limit velocity gradients
  12106. */
  12107. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12108. /**
  12109. * Gets the current list of color gradients.
  12110. * You must use addColorGradient and removeColorGradient to udpate this list
  12111. * @returns the list of color gradients
  12112. */
  12113. getColorGradients(): Nullable<Array<ColorGradient>>;
  12114. /**
  12115. * Gets the current list of size gradients.
  12116. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12117. * @returns the list of size gradients
  12118. */
  12119. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12120. /**
  12121. * Gets the current list of color remap gradients.
  12122. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12123. * @returns the list of color remap gradients
  12124. */
  12125. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12126. /**
  12127. * Gets the current list of alpha remap gradients.
  12128. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12129. * @returns the list of alpha remap gradients
  12130. */
  12131. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12132. /**
  12133. * Gets the current list of life time gradients.
  12134. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12135. * @returns the list of life time gradients
  12136. */
  12137. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12138. /**
  12139. * Gets the current list of angular speed gradients.
  12140. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12141. * @returns the list of angular speed gradients
  12142. */
  12143. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12144. /**
  12145. * Gets the current list of velocity gradients.
  12146. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12147. * @returns the list of velocity gradients
  12148. */
  12149. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12150. /**
  12151. * Gets the current list of start size gradients.
  12152. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12153. * @returns the list of start size gradients
  12154. */
  12155. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12156. /**
  12157. * Gets the current list of emit rate gradients.
  12158. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12159. * @returns the list of emit rate gradients
  12160. */
  12161. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12162. /**
  12163. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12164. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12165. */
  12166. get direction1(): Vector3;
  12167. set direction1(value: Vector3);
  12168. /**
  12169. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12170. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12171. */
  12172. get direction2(): Vector3;
  12173. set direction2(value: Vector3);
  12174. /**
  12175. * 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.
  12176. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12177. */
  12178. get minEmitBox(): Vector3;
  12179. set minEmitBox(value: Vector3);
  12180. /**
  12181. * 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.
  12182. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12183. */
  12184. get maxEmitBox(): Vector3;
  12185. set maxEmitBox(value: Vector3);
  12186. /**
  12187. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12188. */
  12189. color1: Color4;
  12190. /**
  12191. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12192. */
  12193. color2: Color4;
  12194. /**
  12195. * Color the particle will have at the end of its lifetime
  12196. */
  12197. colorDead: Color4;
  12198. /**
  12199. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12200. */
  12201. textureMask: Color4;
  12202. /**
  12203. * The particle emitter type defines the emitter used by the particle system.
  12204. * It can be for example box, sphere, or cone...
  12205. */
  12206. particleEmitterType: IParticleEmitterType;
  12207. /** @hidden */
  12208. _isSubEmitter: boolean;
  12209. /**
  12210. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12211. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12212. */
  12213. billboardMode: number;
  12214. protected _isBillboardBased: boolean;
  12215. /**
  12216. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12217. */
  12218. get isBillboardBased(): boolean;
  12219. set isBillboardBased(value: boolean);
  12220. /**
  12221. * The scene the particle system belongs to.
  12222. */
  12223. protected _scene: Nullable<Scene>;
  12224. /**
  12225. * The engine the particle system belongs to.
  12226. */
  12227. protected _engine: ThinEngine;
  12228. /**
  12229. * Local cache of defines for image processing.
  12230. */
  12231. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12232. /**
  12233. * Default configuration related to image processing available in the standard Material.
  12234. */
  12235. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12236. /**
  12237. * Gets the image processing configuration used either in this material.
  12238. */
  12239. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12240. /**
  12241. * Sets the Default image processing configuration used either in the this material.
  12242. *
  12243. * If sets to null, the scene one is in use.
  12244. */
  12245. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12246. /**
  12247. * Attaches a new image processing configuration to the Standard Material.
  12248. * @param configuration
  12249. */
  12250. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12251. /** @hidden */
  12252. protected _reset(): void;
  12253. /** @hidden */
  12254. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12255. /**
  12256. * Instantiates a particle system.
  12257. * 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.
  12258. * @param name The name of the particle system
  12259. */
  12260. constructor(name: string);
  12261. /**
  12262. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12263. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12264. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12265. * @returns the emitter
  12266. */
  12267. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12268. /**
  12269. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12270. * @param radius The radius of the hemisphere to emit from
  12271. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12272. * @returns the emitter
  12273. */
  12274. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12275. /**
  12276. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12277. * @param radius The radius of the sphere to emit from
  12278. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12279. * @returns the emitter
  12280. */
  12281. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12282. /**
  12283. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12284. * @param radius The radius of the sphere to emit from
  12285. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12286. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12287. * @returns the emitter
  12288. */
  12289. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12290. /**
  12291. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12292. * @param radius The radius of the emission cylinder
  12293. * @param height The height of the emission cylinder
  12294. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12295. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12296. * @returns the emitter
  12297. */
  12298. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12299. /**
  12300. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12301. * @param radius The radius of the cylinder to emit from
  12302. * @param height The height of the emission cylinder
  12303. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12304. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12305. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12306. * @returns the emitter
  12307. */
  12308. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12309. /**
  12310. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12311. * @param radius The radius of the cone to emit from
  12312. * @param angle The base angle of the cone
  12313. * @returns the emitter
  12314. */
  12315. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12316. /**
  12317. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12318. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12319. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12320. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12321. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12322. * @returns the emitter
  12323. */
  12324. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12325. }
  12326. }
  12327. declare module BABYLON {
  12328. /**
  12329. * Type of sub emitter
  12330. */
  12331. export enum SubEmitterType {
  12332. /**
  12333. * Attached to the particle over it's lifetime
  12334. */
  12335. ATTACHED = 0,
  12336. /**
  12337. * Created when the particle dies
  12338. */
  12339. END = 1
  12340. }
  12341. /**
  12342. * Sub emitter class used to emit particles from an existing particle
  12343. */
  12344. export class SubEmitter {
  12345. /**
  12346. * the particle system to be used by the sub emitter
  12347. */
  12348. particleSystem: ParticleSystem;
  12349. /**
  12350. * Type of the submitter (Default: END)
  12351. */
  12352. type: SubEmitterType;
  12353. /**
  12354. * 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)
  12355. * Note: This only is supported when using an emitter of type Mesh
  12356. */
  12357. inheritDirection: boolean;
  12358. /**
  12359. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12360. */
  12361. inheritedVelocityAmount: number;
  12362. /**
  12363. * Creates a sub emitter
  12364. * @param particleSystem the particle system to be used by the sub emitter
  12365. */
  12366. constructor(
  12367. /**
  12368. * the particle system to be used by the sub emitter
  12369. */
  12370. particleSystem: ParticleSystem);
  12371. /**
  12372. * Clones the sub emitter
  12373. * @returns the cloned sub emitter
  12374. */
  12375. clone(): SubEmitter;
  12376. /**
  12377. * Serialize current object to a JSON object
  12378. * @returns the serialized object
  12379. */
  12380. serialize(): any;
  12381. /** @hidden */
  12382. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12383. /**
  12384. * Creates a new SubEmitter from a serialized JSON version
  12385. * @param serializationObject defines the JSON object to read from
  12386. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12387. * @param rootUrl defines the rootUrl for data loading
  12388. * @returns a new SubEmitter
  12389. */
  12390. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12391. /** Release associated resources */
  12392. dispose(): void;
  12393. }
  12394. }
  12395. declare module BABYLON {
  12396. /** @hidden */
  12397. export var imageProcessingDeclaration: {
  12398. name: string;
  12399. shader: string;
  12400. };
  12401. }
  12402. declare module BABYLON {
  12403. /** @hidden */
  12404. export var imageProcessingFunctions: {
  12405. name: string;
  12406. shader: string;
  12407. };
  12408. }
  12409. declare module BABYLON {
  12410. /** @hidden */
  12411. export var particlesPixelShader: {
  12412. name: string;
  12413. shader: string;
  12414. };
  12415. }
  12416. declare module BABYLON {
  12417. /** @hidden */
  12418. export var particlesVertexShader: {
  12419. name: string;
  12420. shader: string;
  12421. };
  12422. }
  12423. declare module BABYLON {
  12424. /**
  12425. * This represents a particle system in Babylon.
  12426. * 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.
  12427. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12428. * @example https://doc.babylonjs.com/babylon101/particles
  12429. */
  12430. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12431. /**
  12432. * Billboard mode will only apply to Y axis
  12433. */
  12434. static readonly BILLBOARDMODE_Y: number;
  12435. /**
  12436. * Billboard mode will apply to all axes
  12437. */
  12438. static readonly BILLBOARDMODE_ALL: number;
  12439. /**
  12440. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12441. */
  12442. static readonly BILLBOARDMODE_STRETCHED: number;
  12443. /**
  12444. * This function can be defined to provide custom update for active particles.
  12445. * This function will be called instead of regular update (age, position, color, etc.).
  12446. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12447. */
  12448. updateFunction: (particles: Particle[]) => void;
  12449. private _emitterWorldMatrix;
  12450. /**
  12451. * This function can be defined to specify initial direction for every new particle.
  12452. * It by default use the emitterType defined function
  12453. */
  12454. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12455. /**
  12456. * This function can be defined to specify initial position for every new particle.
  12457. * It by default use the emitterType defined function
  12458. */
  12459. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12460. /**
  12461. * @hidden
  12462. */
  12463. _inheritedVelocityOffset: Vector3;
  12464. /**
  12465. * An event triggered when the system is disposed
  12466. */
  12467. onDisposeObservable: Observable<IParticleSystem>;
  12468. private _onDisposeObserver;
  12469. /**
  12470. * Sets a callback that will be triggered when the system is disposed
  12471. */
  12472. set onDispose(callback: () => void);
  12473. private _particles;
  12474. private _epsilon;
  12475. private _capacity;
  12476. private _stockParticles;
  12477. private _newPartsExcess;
  12478. private _vertexData;
  12479. private _vertexBuffer;
  12480. private _vertexBuffers;
  12481. private _spriteBuffer;
  12482. private _indexBuffer;
  12483. private _effect;
  12484. private _customEffect;
  12485. private _cachedDefines;
  12486. private _scaledColorStep;
  12487. private _colorDiff;
  12488. private _scaledDirection;
  12489. private _scaledGravity;
  12490. private _currentRenderId;
  12491. private _alive;
  12492. private _useInstancing;
  12493. private _started;
  12494. private _stopped;
  12495. private _actualFrame;
  12496. private _scaledUpdateSpeed;
  12497. private _vertexBufferSize;
  12498. /** @hidden */
  12499. _currentEmitRateGradient: Nullable<FactorGradient>;
  12500. /** @hidden */
  12501. _currentEmitRate1: number;
  12502. /** @hidden */
  12503. _currentEmitRate2: number;
  12504. /** @hidden */
  12505. _currentStartSizeGradient: Nullable<FactorGradient>;
  12506. /** @hidden */
  12507. _currentStartSize1: number;
  12508. /** @hidden */
  12509. _currentStartSize2: number;
  12510. private readonly _rawTextureWidth;
  12511. private _rampGradientsTexture;
  12512. private _useRampGradients;
  12513. /** Gets or sets a matrix to use to compute projection */
  12514. defaultProjectionMatrix: Matrix;
  12515. /** Gets or sets a boolean indicating that ramp gradients must be used
  12516. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12517. */
  12518. get useRampGradients(): boolean;
  12519. set useRampGradients(value: boolean);
  12520. /**
  12521. * 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.
  12522. * 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: [])
  12523. */
  12524. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12525. private _subEmitters;
  12526. /**
  12527. * @hidden
  12528. * If the particle systems emitter should be disposed when the particle system is disposed
  12529. */
  12530. _disposeEmitterOnDispose: boolean;
  12531. /**
  12532. * The current active Sub-systems, this property is used by the root particle system only.
  12533. */
  12534. activeSubSystems: Array<ParticleSystem>;
  12535. /**
  12536. * Specifies if the particles are updated in emitter local space or world space
  12537. */
  12538. isLocal: boolean;
  12539. private _rootParticleSystem;
  12540. /**
  12541. * Gets the current list of active particles
  12542. */
  12543. get particles(): Particle[];
  12544. /**
  12545. * Gets the number of particles active at the same time.
  12546. * @returns The number of active particles.
  12547. */
  12548. getActiveCount(): number;
  12549. /**
  12550. * Returns the string "ParticleSystem"
  12551. * @returns a string containing the class name
  12552. */
  12553. getClassName(): string;
  12554. /**
  12555. * Gets a boolean indicating that the system is stopping
  12556. * @returns true if the system is currently stopping
  12557. */
  12558. isStopping(): boolean;
  12559. /**
  12560. * Gets the custom effect used to render the particles
  12561. * @param blendMode Blend mode for which the effect should be retrieved
  12562. * @returns The effect
  12563. */
  12564. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12565. /**
  12566. * Sets the custom effect used to render the particles
  12567. * @param effect The effect to set
  12568. * @param blendMode Blend mode for which the effect should be set
  12569. */
  12570. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12571. /** @hidden */
  12572. private _onBeforeDrawParticlesObservable;
  12573. /**
  12574. * Observable that will be called just before the particles are drawn
  12575. */
  12576. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12577. /**
  12578. * Gets the name of the particle vertex shader
  12579. */
  12580. get vertexShaderName(): string;
  12581. /**
  12582. * Instantiates a particle system.
  12583. * 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.
  12584. * @param name The name of the particle system
  12585. * @param capacity The max number of particles alive at the same time
  12586. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  12587. * @param customEffect a custom effect used to change the way particles are rendered by default
  12588. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12589. * @param epsilon Offset used to render the particles
  12590. */
  12591. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12592. private _addFactorGradient;
  12593. private _removeFactorGradient;
  12594. /**
  12595. * Adds a new life time gradient
  12596. * @param gradient defines the gradient to use (between 0 and 1)
  12597. * @param factor defines the life time factor to affect to the specified gradient
  12598. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12599. * @returns the current particle system
  12600. */
  12601. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12602. /**
  12603. * Remove a specific life time gradient
  12604. * @param gradient defines the gradient to remove
  12605. * @returns the current particle system
  12606. */
  12607. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12608. /**
  12609. * Adds a new size gradient
  12610. * @param gradient defines the gradient to use (between 0 and 1)
  12611. * @param factor defines the size factor to affect to the specified gradient
  12612. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12613. * @returns the current particle system
  12614. */
  12615. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12616. /**
  12617. * Remove a specific size gradient
  12618. * @param gradient defines the gradient to remove
  12619. * @returns the current particle system
  12620. */
  12621. removeSizeGradient(gradient: number): IParticleSystem;
  12622. /**
  12623. * Adds a new color remap gradient
  12624. * @param gradient defines the gradient to use (between 0 and 1)
  12625. * @param min defines the color remap minimal range
  12626. * @param max defines the color remap maximal range
  12627. * @returns the current particle system
  12628. */
  12629. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12630. /**
  12631. * Remove a specific color remap gradient
  12632. * @param gradient defines the gradient to remove
  12633. * @returns the current particle system
  12634. */
  12635. removeColorRemapGradient(gradient: number): IParticleSystem;
  12636. /**
  12637. * Adds a new alpha remap gradient
  12638. * @param gradient defines the gradient to use (between 0 and 1)
  12639. * @param min defines the alpha remap minimal range
  12640. * @param max defines the alpha remap maximal range
  12641. * @returns the current particle system
  12642. */
  12643. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12644. /**
  12645. * Remove a specific alpha remap gradient
  12646. * @param gradient defines the gradient to remove
  12647. * @returns the current particle system
  12648. */
  12649. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12650. /**
  12651. * Adds a new angular speed gradient
  12652. * @param gradient defines the gradient to use (between 0 and 1)
  12653. * @param factor defines the angular speed to affect to the specified gradient
  12654. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12655. * @returns the current particle system
  12656. */
  12657. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12658. /**
  12659. * Remove a specific angular speed gradient
  12660. * @param gradient defines the gradient to remove
  12661. * @returns the current particle system
  12662. */
  12663. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12664. /**
  12665. * Adds a new velocity gradient
  12666. * @param gradient defines the gradient to use (between 0 and 1)
  12667. * @param factor defines the velocity to affect to the specified gradient
  12668. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12669. * @returns the current particle system
  12670. */
  12671. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12672. /**
  12673. * Remove a specific velocity gradient
  12674. * @param gradient defines the gradient to remove
  12675. * @returns the current particle system
  12676. */
  12677. removeVelocityGradient(gradient: number): IParticleSystem;
  12678. /**
  12679. * Adds a new limit velocity gradient
  12680. * @param gradient defines the gradient to use (between 0 and 1)
  12681. * @param factor defines the limit velocity value to affect to the specified gradient
  12682. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12683. * @returns the current particle system
  12684. */
  12685. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12686. /**
  12687. * Remove a specific limit velocity gradient
  12688. * @param gradient defines the gradient to remove
  12689. * @returns the current particle system
  12690. */
  12691. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12692. /**
  12693. * Adds a new drag gradient
  12694. * @param gradient defines the gradient to use (between 0 and 1)
  12695. * @param factor defines the drag value to affect to the specified gradient
  12696. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12697. * @returns the current particle system
  12698. */
  12699. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12700. /**
  12701. * Remove a specific drag gradient
  12702. * @param gradient defines the gradient to remove
  12703. * @returns the current particle system
  12704. */
  12705. removeDragGradient(gradient: number): IParticleSystem;
  12706. /**
  12707. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12708. * @param gradient defines the gradient to use (between 0 and 1)
  12709. * @param factor defines the emit rate value to affect to the specified gradient
  12710. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12711. * @returns the current particle system
  12712. */
  12713. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12714. /**
  12715. * Remove a specific emit rate gradient
  12716. * @param gradient defines the gradient to remove
  12717. * @returns the current particle system
  12718. */
  12719. removeEmitRateGradient(gradient: number): IParticleSystem;
  12720. /**
  12721. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12722. * @param gradient defines the gradient to use (between 0 and 1)
  12723. * @param factor defines the start size value to affect to the specified gradient
  12724. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12725. * @returns the current particle system
  12726. */
  12727. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12728. /**
  12729. * Remove a specific start size gradient
  12730. * @param gradient defines the gradient to remove
  12731. * @returns the current particle system
  12732. */
  12733. removeStartSizeGradient(gradient: number): IParticleSystem;
  12734. private _createRampGradientTexture;
  12735. /**
  12736. * Gets the current list of ramp gradients.
  12737. * You must use addRampGradient and removeRampGradient to udpate this list
  12738. * @returns the list of ramp gradients
  12739. */
  12740. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12741. /** Force the system to rebuild all gradients that need to be resync */
  12742. forceRefreshGradients(): void;
  12743. private _syncRampGradientTexture;
  12744. /**
  12745. * Adds a new ramp gradient used to remap particle colors
  12746. * @param gradient defines the gradient to use (between 0 and 1)
  12747. * @param color defines the color to affect to the specified gradient
  12748. * @returns the current particle system
  12749. */
  12750. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12751. /**
  12752. * Remove a specific ramp gradient
  12753. * @param gradient defines the gradient to remove
  12754. * @returns the current particle system
  12755. */
  12756. removeRampGradient(gradient: number): ParticleSystem;
  12757. /**
  12758. * Adds a new color gradient
  12759. * @param gradient defines the gradient to use (between 0 and 1)
  12760. * @param color1 defines the color to affect to the specified gradient
  12761. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12762. * @returns this particle system
  12763. */
  12764. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12765. /**
  12766. * Remove a specific color gradient
  12767. * @param gradient defines the gradient to remove
  12768. * @returns this particle system
  12769. */
  12770. removeColorGradient(gradient: number): IParticleSystem;
  12771. private _fetchR;
  12772. protected _reset(): void;
  12773. private _resetEffect;
  12774. private _createVertexBuffers;
  12775. private _createIndexBuffer;
  12776. /**
  12777. * Gets the maximum number of particles active at the same time.
  12778. * @returns The max number of active particles.
  12779. */
  12780. getCapacity(): number;
  12781. /**
  12782. * Gets whether there are still active particles in the system.
  12783. * @returns True if it is alive, otherwise false.
  12784. */
  12785. isAlive(): boolean;
  12786. /**
  12787. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12788. * @returns True if it has been started, otherwise false.
  12789. */
  12790. isStarted(): boolean;
  12791. private _prepareSubEmitterInternalArray;
  12792. /**
  12793. * Starts the particle system and begins to emit
  12794. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12795. */
  12796. start(delay?: number): void;
  12797. /**
  12798. * Stops the particle system.
  12799. * @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.
  12800. */
  12801. stop(stopSubEmitters?: boolean): void;
  12802. /**
  12803. * Remove all active particles
  12804. */
  12805. reset(): void;
  12806. /**
  12807. * @hidden (for internal use only)
  12808. */
  12809. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12810. /**
  12811. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12812. * Its lifetime will start back at 0.
  12813. */
  12814. recycleParticle: (particle: Particle) => void;
  12815. private _stopSubEmitters;
  12816. private _createParticle;
  12817. private _removeFromRoot;
  12818. private _emitFromParticle;
  12819. private _update;
  12820. /** @hidden */
  12821. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12822. /** @hidden */
  12823. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12824. /**
  12825. * Fill the defines array according to the current settings of the particle system
  12826. * @param defines Array to be updated
  12827. * @param blendMode blend mode to take into account when updating the array
  12828. */
  12829. fillDefines(defines: Array<string>, blendMode: number): void;
  12830. /**
  12831. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  12832. * @param uniforms Uniforms array to fill
  12833. * @param attributes Attributes array to fill
  12834. * @param samplers Samplers array to fill
  12835. */
  12836. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  12837. /** @hidden */
  12838. private _getEffect;
  12839. /**
  12840. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12841. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12842. */
  12843. animate(preWarmOnly?: boolean): void;
  12844. private _appendParticleVertices;
  12845. /**
  12846. * Rebuilds the particle system.
  12847. */
  12848. rebuild(): void;
  12849. /**
  12850. * Is this system ready to be used/rendered
  12851. * @return true if the system is ready
  12852. */
  12853. isReady(): boolean;
  12854. private _render;
  12855. /**
  12856. * Renders the particle system in its current state.
  12857. * @returns the current number of particles
  12858. */
  12859. render(): number;
  12860. /**
  12861. * Disposes the particle system and free the associated resources
  12862. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12863. */
  12864. dispose(disposeTexture?: boolean): void;
  12865. /**
  12866. * Clones the particle system.
  12867. * @param name The name of the cloned object
  12868. * @param newEmitter The new emitter to use
  12869. * @returns the cloned particle system
  12870. */
  12871. clone(name: string, newEmitter: any): ParticleSystem;
  12872. /**
  12873. * Serializes the particle system to a JSON object
  12874. * @param serializeTexture defines if the texture must be serialized as well
  12875. * @returns the JSON object
  12876. */
  12877. serialize(serializeTexture?: boolean): any;
  12878. /** @hidden */
  12879. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12880. /** @hidden */
  12881. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  12882. /**
  12883. * Parses a JSON object to create a particle system.
  12884. * @param parsedParticleSystem The JSON object to parse
  12885. * @param sceneOrEngine The scene or the engine to create the particle system in
  12886. * @param rootUrl The root url to use to load external dependencies like texture
  12887. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12888. * @returns the Parsed particle system
  12889. */
  12890. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12891. }
  12892. }
  12893. declare module BABYLON {
  12894. /**
  12895. * A particle represents one of the element emitted by a particle system.
  12896. * This is mainly define by its coordinates, direction, velocity and age.
  12897. */
  12898. export class Particle {
  12899. /**
  12900. * The particle system the particle belongs to.
  12901. */
  12902. particleSystem: ParticleSystem;
  12903. private static _Count;
  12904. /**
  12905. * Unique ID of the particle
  12906. */
  12907. id: number;
  12908. /**
  12909. * The world position of the particle in the scene.
  12910. */
  12911. position: Vector3;
  12912. /**
  12913. * The world direction of the particle in the scene.
  12914. */
  12915. direction: Vector3;
  12916. /**
  12917. * The color of the particle.
  12918. */
  12919. color: Color4;
  12920. /**
  12921. * The color change of the particle per step.
  12922. */
  12923. colorStep: Color4;
  12924. /**
  12925. * Defines how long will the life of the particle be.
  12926. */
  12927. lifeTime: number;
  12928. /**
  12929. * The current age of the particle.
  12930. */
  12931. age: number;
  12932. /**
  12933. * The current size of the particle.
  12934. */
  12935. size: number;
  12936. /**
  12937. * The current scale of the particle.
  12938. */
  12939. scale: Vector2;
  12940. /**
  12941. * The current angle of the particle.
  12942. */
  12943. angle: number;
  12944. /**
  12945. * Defines how fast is the angle changing.
  12946. */
  12947. angularSpeed: number;
  12948. /**
  12949. * Defines the cell index used by the particle to be rendered from a sprite.
  12950. */
  12951. cellIndex: number;
  12952. /**
  12953. * The information required to support color remapping
  12954. */
  12955. remapData: Vector4;
  12956. /** @hidden */
  12957. _randomCellOffset?: number;
  12958. /** @hidden */
  12959. _initialDirection: Nullable<Vector3>;
  12960. /** @hidden */
  12961. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12962. /** @hidden */
  12963. _initialStartSpriteCellID: number;
  12964. /** @hidden */
  12965. _initialEndSpriteCellID: number;
  12966. /** @hidden */
  12967. _currentColorGradient: Nullable<ColorGradient>;
  12968. /** @hidden */
  12969. _currentColor1: Color4;
  12970. /** @hidden */
  12971. _currentColor2: Color4;
  12972. /** @hidden */
  12973. _currentSizeGradient: Nullable<FactorGradient>;
  12974. /** @hidden */
  12975. _currentSize1: number;
  12976. /** @hidden */
  12977. _currentSize2: number;
  12978. /** @hidden */
  12979. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12980. /** @hidden */
  12981. _currentAngularSpeed1: number;
  12982. /** @hidden */
  12983. _currentAngularSpeed2: number;
  12984. /** @hidden */
  12985. _currentVelocityGradient: Nullable<FactorGradient>;
  12986. /** @hidden */
  12987. _currentVelocity1: number;
  12988. /** @hidden */
  12989. _currentVelocity2: number;
  12990. /** @hidden */
  12991. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12992. /** @hidden */
  12993. _currentLimitVelocity1: number;
  12994. /** @hidden */
  12995. _currentLimitVelocity2: number;
  12996. /** @hidden */
  12997. _currentDragGradient: Nullable<FactorGradient>;
  12998. /** @hidden */
  12999. _currentDrag1: number;
  13000. /** @hidden */
  13001. _currentDrag2: number;
  13002. /** @hidden */
  13003. _randomNoiseCoordinates1: Vector3;
  13004. /** @hidden */
  13005. _randomNoiseCoordinates2: Vector3;
  13006. /** @hidden */
  13007. _localPosition?: Vector3;
  13008. /**
  13009. * Creates a new instance Particle
  13010. * @param particleSystem the particle system the particle belongs to
  13011. */
  13012. constructor(
  13013. /**
  13014. * The particle system the particle belongs to.
  13015. */
  13016. particleSystem: ParticleSystem);
  13017. private updateCellInfoFromSystem;
  13018. /**
  13019. * Defines how the sprite cell index is updated for the particle
  13020. */
  13021. updateCellIndex(): void;
  13022. /** @hidden */
  13023. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13024. /** @hidden */
  13025. _inheritParticleInfoToSubEmitters(): void;
  13026. /** @hidden */
  13027. _reset(): void;
  13028. /**
  13029. * Copy the properties of particle to another one.
  13030. * @param other the particle to copy the information to.
  13031. */
  13032. copyTo(other: Particle): void;
  13033. }
  13034. }
  13035. declare module BABYLON {
  13036. /**
  13037. * Particle emitter represents a volume emitting particles.
  13038. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13039. */
  13040. export interface IParticleEmitterType {
  13041. /**
  13042. * Called by the particle System when the direction is computed for the created particle.
  13043. * @param worldMatrix is the world matrix of the particle system
  13044. * @param directionToUpdate is the direction vector to update with the result
  13045. * @param particle is the particle we are computed the direction for
  13046. * @param isLocal defines if the direction should be set in local space
  13047. */
  13048. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13049. /**
  13050. * Called by the particle System when the position is computed for the created particle.
  13051. * @param worldMatrix is the world matrix of the particle system
  13052. * @param positionToUpdate is the position vector to update with the result
  13053. * @param particle is the particle we are computed the position for
  13054. * @param isLocal defines if the position should be set in local space
  13055. */
  13056. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13057. /**
  13058. * Clones the current emitter and returns a copy of it
  13059. * @returns the new emitter
  13060. */
  13061. clone(): IParticleEmitterType;
  13062. /**
  13063. * Called by the GPUParticleSystem to setup the update shader
  13064. * @param effect defines the update shader
  13065. */
  13066. applyToShader(effect: Effect): void;
  13067. /**
  13068. * Returns a string to use to update the GPU particles update shader
  13069. * @returns the effect defines string
  13070. */
  13071. getEffectDefines(): string;
  13072. /**
  13073. * Returns a string representing the class name
  13074. * @returns a string containing the class name
  13075. */
  13076. getClassName(): string;
  13077. /**
  13078. * Serializes the particle system to a JSON object.
  13079. * @returns the JSON object
  13080. */
  13081. serialize(): any;
  13082. /**
  13083. * Parse properties from a JSON object
  13084. * @param serializationObject defines the JSON object
  13085. * @param scene defines the hosting scene
  13086. */
  13087. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13088. }
  13089. }
  13090. declare module BABYLON {
  13091. /**
  13092. * Particle emitter emitting particles from the inside of a box.
  13093. * It emits the particles randomly between 2 given directions.
  13094. */
  13095. export class BoxParticleEmitter implements IParticleEmitterType {
  13096. /**
  13097. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13098. */
  13099. direction1: Vector3;
  13100. /**
  13101. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13102. */
  13103. direction2: Vector3;
  13104. /**
  13105. * 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.
  13106. */
  13107. minEmitBox: Vector3;
  13108. /**
  13109. * 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.
  13110. */
  13111. maxEmitBox: Vector3;
  13112. /**
  13113. * Creates a new instance BoxParticleEmitter
  13114. */
  13115. constructor();
  13116. /**
  13117. * Called by the particle System when the direction is computed for the created particle.
  13118. * @param worldMatrix is the world matrix of the particle system
  13119. * @param directionToUpdate is the direction vector to update with the result
  13120. * @param particle is the particle we are computed the direction for
  13121. * @param isLocal defines if the direction should be set in local space
  13122. */
  13123. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13124. /**
  13125. * Called by the particle System when the position is computed for the created particle.
  13126. * @param worldMatrix is the world matrix of the particle system
  13127. * @param positionToUpdate is the position vector to update with the result
  13128. * @param particle is the particle we are computed the position for
  13129. * @param isLocal defines if the position should be set in local space
  13130. */
  13131. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13132. /**
  13133. * Clones the current emitter and returns a copy of it
  13134. * @returns the new emitter
  13135. */
  13136. clone(): BoxParticleEmitter;
  13137. /**
  13138. * Called by the GPUParticleSystem to setup the update shader
  13139. * @param effect defines the update shader
  13140. */
  13141. applyToShader(effect: Effect): void;
  13142. /**
  13143. * Returns a string to use to update the GPU particles update shader
  13144. * @returns a string containng the defines string
  13145. */
  13146. getEffectDefines(): string;
  13147. /**
  13148. * Returns the string "BoxParticleEmitter"
  13149. * @returns a string containing the class name
  13150. */
  13151. getClassName(): string;
  13152. /**
  13153. * Serializes the particle system to a JSON object.
  13154. * @returns the JSON object
  13155. */
  13156. serialize(): any;
  13157. /**
  13158. * Parse properties from a JSON object
  13159. * @param serializationObject defines the JSON object
  13160. */
  13161. parse(serializationObject: any): void;
  13162. }
  13163. }
  13164. declare module BABYLON {
  13165. /**
  13166. * Particle emitter emitting particles from the inside of a cone.
  13167. * It emits the particles alongside the cone volume from the base to the particle.
  13168. * The emission direction might be randomized.
  13169. */
  13170. export class ConeParticleEmitter implements IParticleEmitterType {
  13171. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13172. directionRandomizer: number;
  13173. private _radius;
  13174. private _angle;
  13175. private _height;
  13176. /**
  13177. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13178. */
  13179. radiusRange: number;
  13180. /**
  13181. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13182. */
  13183. heightRange: number;
  13184. /**
  13185. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13186. */
  13187. emitFromSpawnPointOnly: boolean;
  13188. /**
  13189. * Gets or sets the radius of the emission cone
  13190. */
  13191. get radius(): number;
  13192. set radius(value: number);
  13193. /**
  13194. * Gets or sets the angle of the emission cone
  13195. */
  13196. get angle(): number;
  13197. set angle(value: number);
  13198. private _buildHeight;
  13199. /**
  13200. * Creates a new instance ConeParticleEmitter
  13201. * @param radius the radius of the emission cone (1 by default)
  13202. * @param angle the cone base angle (PI by default)
  13203. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13204. */
  13205. constructor(radius?: number, angle?: number,
  13206. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13207. directionRandomizer?: number);
  13208. /**
  13209. * Called by the particle System when the direction is computed for the created particle.
  13210. * @param worldMatrix is the world matrix of the particle system
  13211. * @param directionToUpdate is the direction vector to update with the result
  13212. * @param particle is the particle we are computed the direction for
  13213. * @param isLocal defines if the direction should be set in local space
  13214. */
  13215. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13216. /**
  13217. * Called by the particle System when the position is computed for the created particle.
  13218. * @param worldMatrix is the world matrix of the particle system
  13219. * @param positionToUpdate is the position vector to update with the result
  13220. * @param particle is the particle we are computed the position for
  13221. * @param isLocal defines if the position should be set in local space
  13222. */
  13223. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13224. /**
  13225. * Clones the current emitter and returns a copy of it
  13226. * @returns the new emitter
  13227. */
  13228. clone(): ConeParticleEmitter;
  13229. /**
  13230. * Called by the GPUParticleSystem to setup the update shader
  13231. * @param effect defines the update shader
  13232. */
  13233. applyToShader(effect: Effect): void;
  13234. /**
  13235. * Returns a string to use to update the GPU particles update shader
  13236. * @returns a string containng the defines string
  13237. */
  13238. getEffectDefines(): string;
  13239. /**
  13240. * Returns the string "ConeParticleEmitter"
  13241. * @returns a string containing the class name
  13242. */
  13243. getClassName(): string;
  13244. /**
  13245. * Serializes the particle system to a JSON object.
  13246. * @returns the JSON object
  13247. */
  13248. serialize(): any;
  13249. /**
  13250. * Parse properties from a JSON object
  13251. * @param serializationObject defines the JSON object
  13252. */
  13253. parse(serializationObject: any): void;
  13254. }
  13255. }
  13256. declare module BABYLON {
  13257. /**
  13258. * Particle emitter emitting particles from the inside of a cylinder.
  13259. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13260. */
  13261. export class CylinderParticleEmitter implements IParticleEmitterType {
  13262. /**
  13263. * The radius of the emission cylinder.
  13264. */
  13265. radius: number;
  13266. /**
  13267. * The height of the emission cylinder.
  13268. */
  13269. height: number;
  13270. /**
  13271. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13272. */
  13273. radiusRange: number;
  13274. /**
  13275. * How much to randomize the particle direction [0-1].
  13276. */
  13277. directionRandomizer: number;
  13278. /**
  13279. * Creates a new instance CylinderParticleEmitter
  13280. * @param radius the radius of the emission cylinder (1 by default)
  13281. * @param height the height of the emission cylinder (1 by default)
  13282. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13283. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13284. */
  13285. constructor(
  13286. /**
  13287. * The radius of the emission cylinder.
  13288. */
  13289. radius?: number,
  13290. /**
  13291. * The height of the emission cylinder.
  13292. */
  13293. height?: number,
  13294. /**
  13295. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13296. */
  13297. radiusRange?: number,
  13298. /**
  13299. * How much to randomize the particle direction [0-1].
  13300. */
  13301. directionRandomizer?: number);
  13302. /**
  13303. * Called by the particle System when the direction is computed for the created particle.
  13304. * @param worldMatrix is the world matrix of the particle system
  13305. * @param directionToUpdate is the direction vector to update with the result
  13306. * @param particle is the particle we are computed the direction for
  13307. * @param isLocal defines if the direction should be set in local space
  13308. */
  13309. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13310. /**
  13311. * Called by the particle System when the position is computed for the created particle.
  13312. * @param worldMatrix is the world matrix of the particle system
  13313. * @param positionToUpdate is the position vector to update with the result
  13314. * @param particle is the particle we are computed the position for
  13315. * @param isLocal defines if the position should be set in local space
  13316. */
  13317. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13318. /**
  13319. * Clones the current emitter and returns a copy of it
  13320. * @returns the new emitter
  13321. */
  13322. clone(): CylinderParticleEmitter;
  13323. /**
  13324. * Called by the GPUParticleSystem to setup the update shader
  13325. * @param effect defines the update shader
  13326. */
  13327. applyToShader(effect: Effect): void;
  13328. /**
  13329. * Returns a string to use to update the GPU particles update shader
  13330. * @returns a string containng the defines string
  13331. */
  13332. getEffectDefines(): string;
  13333. /**
  13334. * Returns the string "CylinderParticleEmitter"
  13335. * @returns a string containing the class name
  13336. */
  13337. getClassName(): string;
  13338. /**
  13339. * Serializes the particle system to a JSON object.
  13340. * @returns the JSON object
  13341. */
  13342. serialize(): any;
  13343. /**
  13344. * Parse properties from a JSON object
  13345. * @param serializationObject defines the JSON object
  13346. */
  13347. parse(serializationObject: any): void;
  13348. }
  13349. /**
  13350. * Particle emitter emitting particles from the inside of a cylinder.
  13351. * It emits the particles randomly between two vectors.
  13352. */
  13353. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13354. /**
  13355. * The min limit of the emission direction.
  13356. */
  13357. direction1: Vector3;
  13358. /**
  13359. * The max limit of the emission direction.
  13360. */
  13361. direction2: Vector3;
  13362. /**
  13363. * Creates a new instance CylinderDirectedParticleEmitter
  13364. * @param radius the radius of the emission cylinder (1 by default)
  13365. * @param height the height of the emission cylinder (1 by default)
  13366. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13367. * @param direction1 the min limit of the emission direction (up vector by default)
  13368. * @param direction2 the max limit of the emission direction (up vector by default)
  13369. */
  13370. constructor(radius?: number, height?: number, radiusRange?: number,
  13371. /**
  13372. * The min limit of the emission direction.
  13373. */
  13374. direction1?: Vector3,
  13375. /**
  13376. * The max limit of the emission direction.
  13377. */
  13378. direction2?: Vector3);
  13379. /**
  13380. * Called by the particle System when the direction is computed for the created particle.
  13381. * @param worldMatrix is the world matrix of the particle system
  13382. * @param directionToUpdate is the direction vector to update with the result
  13383. * @param particle is the particle we are computed the direction for
  13384. */
  13385. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13386. /**
  13387. * Clones the current emitter and returns a copy of it
  13388. * @returns the new emitter
  13389. */
  13390. clone(): CylinderDirectedParticleEmitter;
  13391. /**
  13392. * Called by the GPUParticleSystem to setup the update shader
  13393. * @param effect defines the update shader
  13394. */
  13395. applyToShader(effect: Effect): void;
  13396. /**
  13397. * Returns a string to use to update the GPU particles update shader
  13398. * @returns a string containng the defines string
  13399. */
  13400. getEffectDefines(): string;
  13401. /**
  13402. * Returns the string "CylinderDirectedParticleEmitter"
  13403. * @returns a string containing the class name
  13404. */
  13405. getClassName(): string;
  13406. /**
  13407. * Serializes the particle system to a JSON object.
  13408. * @returns the JSON object
  13409. */
  13410. serialize(): any;
  13411. /**
  13412. * Parse properties from a JSON object
  13413. * @param serializationObject defines the JSON object
  13414. */
  13415. parse(serializationObject: any): void;
  13416. }
  13417. }
  13418. declare module BABYLON {
  13419. /**
  13420. * Particle emitter emitting particles from the inside of a hemisphere.
  13421. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13422. */
  13423. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13424. /**
  13425. * The radius of the emission hemisphere.
  13426. */
  13427. radius: number;
  13428. /**
  13429. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13430. */
  13431. radiusRange: number;
  13432. /**
  13433. * How much to randomize the particle direction [0-1].
  13434. */
  13435. directionRandomizer: number;
  13436. /**
  13437. * Creates a new instance HemisphericParticleEmitter
  13438. * @param radius the radius of the emission hemisphere (1 by default)
  13439. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13440. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13441. */
  13442. constructor(
  13443. /**
  13444. * The radius of the emission hemisphere.
  13445. */
  13446. radius?: number,
  13447. /**
  13448. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13449. */
  13450. radiusRange?: number,
  13451. /**
  13452. * How much to randomize the particle direction [0-1].
  13453. */
  13454. directionRandomizer?: number);
  13455. /**
  13456. * Called by the particle System when the direction is computed for the created particle.
  13457. * @param worldMatrix is the world matrix of the particle system
  13458. * @param directionToUpdate is the direction vector to update with the result
  13459. * @param particle is the particle we are computed the direction for
  13460. * @param isLocal defines if the direction should be set in local space
  13461. */
  13462. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13463. /**
  13464. * Called by the particle System when the position is computed for the created particle.
  13465. * @param worldMatrix is the world matrix of the particle system
  13466. * @param positionToUpdate is the position vector to update with the result
  13467. * @param particle is the particle we are computed the position for
  13468. * @param isLocal defines if the position should be set in local space
  13469. */
  13470. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13471. /**
  13472. * Clones the current emitter and returns a copy of it
  13473. * @returns the new emitter
  13474. */
  13475. clone(): HemisphericParticleEmitter;
  13476. /**
  13477. * Called by the GPUParticleSystem to setup the update shader
  13478. * @param effect defines the update shader
  13479. */
  13480. applyToShader(effect: Effect): void;
  13481. /**
  13482. * Returns a string to use to update the GPU particles update shader
  13483. * @returns a string containng the defines string
  13484. */
  13485. getEffectDefines(): string;
  13486. /**
  13487. * Returns the string "HemisphericParticleEmitter"
  13488. * @returns a string containing the class name
  13489. */
  13490. getClassName(): string;
  13491. /**
  13492. * Serializes the particle system to a JSON object.
  13493. * @returns the JSON object
  13494. */
  13495. serialize(): any;
  13496. /**
  13497. * Parse properties from a JSON object
  13498. * @param serializationObject defines the JSON object
  13499. */
  13500. parse(serializationObject: any): void;
  13501. }
  13502. }
  13503. declare module BABYLON {
  13504. /**
  13505. * Particle emitter emitting particles from a point.
  13506. * It emits the particles randomly between 2 given directions.
  13507. */
  13508. export class PointParticleEmitter implements IParticleEmitterType {
  13509. /**
  13510. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13511. */
  13512. direction1: Vector3;
  13513. /**
  13514. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13515. */
  13516. direction2: Vector3;
  13517. /**
  13518. * Creates a new instance PointParticleEmitter
  13519. */
  13520. constructor();
  13521. /**
  13522. * Called by the particle System when the direction is computed for the created particle.
  13523. * @param worldMatrix is the world matrix of the particle system
  13524. * @param directionToUpdate is the direction vector to update with the result
  13525. * @param particle is the particle we are computed the direction for
  13526. * @param isLocal defines if the direction should be set in local space
  13527. */
  13528. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13529. /**
  13530. * Called by the particle System when the position is computed for the created particle.
  13531. * @param worldMatrix is the world matrix of the particle system
  13532. * @param positionToUpdate is the position vector to update with the result
  13533. * @param particle is the particle we are computed the position for
  13534. * @param isLocal defines if the position should be set in local space
  13535. */
  13536. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13537. /**
  13538. * Clones the current emitter and returns a copy of it
  13539. * @returns the new emitter
  13540. */
  13541. clone(): PointParticleEmitter;
  13542. /**
  13543. * Called by the GPUParticleSystem to setup the update shader
  13544. * @param effect defines the update shader
  13545. */
  13546. applyToShader(effect: Effect): void;
  13547. /**
  13548. * Returns a string to use to update the GPU particles update shader
  13549. * @returns a string containng the defines string
  13550. */
  13551. getEffectDefines(): string;
  13552. /**
  13553. * Returns the string "PointParticleEmitter"
  13554. * @returns a string containing the class name
  13555. */
  13556. getClassName(): string;
  13557. /**
  13558. * Serializes the particle system to a JSON object.
  13559. * @returns the JSON object
  13560. */
  13561. serialize(): any;
  13562. /**
  13563. * Parse properties from a JSON object
  13564. * @param serializationObject defines the JSON object
  13565. */
  13566. parse(serializationObject: any): void;
  13567. }
  13568. }
  13569. declare module BABYLON {
  13570. /**
  13571. * Particle emitter emitting particles from the inside of a sphere.
  13572. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13573. */
  13574. export class SphereParticleEmitter implements IParticleEmitterType {
  13575. /**
  13576. * The radius of the emission sphere.
  13577. */
  13578. radius: number;
  13579. /**
  13580. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13581. */
  13582. radiusRange: number;
  13583. /**
  13584. * How much to randomize the particle direction [0-1].
  13585. */
  13586. directionRandomizer: number;
  13587. /**
  13588. * Creates a new instance SphereParticleEmitter
  13589. * @param radius the radius of the emission sphere (1 by default)
  13590. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13591. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13592. */
  13593. constructor(
  13594. /**
  13595. * The radius of the emission sphere.
  13596. */
  13597. radius?: number,
  13598. /**
  13599. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13600. */
  13601. radiusRange?: number,
  13602. /**
  13603. * How much to randomize the particle direction [0-1].
  13604. */
  13605. directionRandomizer?: number);
  13606. /**
  13607. * Called by the particle System when the direction is computed for the created particle.
  13608. * @param worldMatrix is the world matrix of the particle system
  13609. * @param directionToUpdate is the direction vector to update with the result
  13610. * @param particle is the particle we are computed the direction for
  13611. * @param isLocal defines if the direction should be set in local space
  13612. */
  13613. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13614. /**
  13615. * Called by the particle System when the position is computed for the created particle.
  13616. * @param worldMatrix is the world matrix of the particle system
  13617. * @param positionToUpdate is the position vector to update with the result
  13618. * @param particle is the particle we are computed the position for
  13619. * @param isLocal defines if the position should be set in local space
  13620. */
  13621. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13622. /**
  13623. * Clones the current emitter and returns a copy of it
  13624. * @returns the new emitter
  13625. */
  13626. clone(): SphereParticleEmitter;
  13627. /**
  13628. * Called by the GPUParticleSystem to setup the update shader
  13629. * @param effect defines the update shader
  13630. */
  13631. applyToShader(effect: Effect): void;
  13632. /**
  13633. * Returns a string to use to update the GPU particles update shader
  13634. * @returns a string containng the defines string
  13635. */
  13636. getEffectDefines(): string;
  13637. /**
  13638. * Returns the string "SphereParticleEmitter"
  13639. * @returns a string containing the class name
  13640. */
  13641. getClassName(): string;
  13642. /**
  13643. * Serializes the particle system to a JSON object.
  13644. * @returns the JSON object
  13645. */
  13646. serialize(): any;
  13647. /**
  13648. * Parse properties from a JSON object
  13649. * @param serializationObject defines the JSON object
  13650. */
  13651. parse(serializationObject: any): void;
  13652. }
  13653. /**
  13654. * Particle emitter emitting particles from the inside of a sphere.
  13655. * It emits the particles randomly between two vectors.
  13656. */
  13657. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13658. /**
  13659. * The min limit of the emission direction.
  13660. */
  13661. direction1: Vector3;
  13662. /**
  13663. * The max limit of the emission direction.
  13664. */
  13665. direction2: Vector3;
  13666. /**
  13667. * Creates a new instance SphereDirectedParticleEmitter
  13668. * @param radius the radius of the emission sphere (1 by default)
  13669. * @param direction1 the min limit of the emission direction (up vector by default)
  13670. * @param direction2 the max limit of the emission direction (up vector by default)
  13671. */
  13672. constructor(radius?: number,
  13673. /**
  13674. * The min limit of the emission direction.
  13675. */
  13676. direction1?: Vector3,
  13677. /**
  13678. * The max limit of the emission direction.
  13679. */
  13680. direction2?: Vector3);
  13681. /**
  13682. * Called by the particle System when the direction is computed for the created particle.
  13683. * @param worldMatrix is the world matrix of the particle system
  13684. * @param directionToUpdate is the direction vector to update with the result
  13685. * @param particle is the particle we are computed the direction for
  13686. */
  13687. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13688. /**
  13689. * Clones the current emitter and returns a copy of it
  13690. * @returns the new emitter
  13691. */
  13692. clone(): SphereDirectedParticleEmitter;
  13693. /**
  13694. * Called by the GPUParticleSystem to setup the update shader
  13695. * @param effect defines the update shader
  13696. */
  13697. applyToShader(effect: Effect): void;
  13698. /**
  13699. * Returns a string to use to update the GPU particles update shader
  13700. * @returns a string containng the defines string
  13701. */
  13702. getEffectDefines(): string;
  13703. /**
  13704. * Returns the string "SphereDirectedParticleEmitter"
  13705. * @returns a string containing the class name
  13706. */
  13707. getClassName(): string;
  13708. /**
  13709. * Serializes the particle system to a JSON object.
  13710. * @returns the JSON object
  13711. */
  13712. serialize(): any;
  13713. /**
  13714. * Parse properties from a JSON object
  13715. * @param serializationObject defines the JSON object
  13716. */
  13717. parse(serializationObject: any): void;
  13718. }
  13719. }
  13720. declare module BABYLON {
  13721. /**
  13722. * Particle emitter emitting particles from a custom list of positions.
  13723. */
  13724. export class CustomParticleEmitter implements IParticleEmitterType {
  13725. /**
  13726. * Gets or sets the position generator that will create the inital position of each particle.
  13727. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13728. */
  13729. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13730. /**
  13731. * Gets or sets the destination generator that will create the final destination of each particle.
  13732. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13733. */
  13734. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13735. /**
  13736. * Creates a new instance CustomParticleEmitter
  13737. */
  13738. constructor();
  13739. /**
  13740. * Called by the particle System when the direction is computed for the created particle.
  13741. * @param worldMatrix is the world matrix of the particle system
  13742. * @param directionToUpdate is the direction vector to update with the result
  13743. * @param particle is the particle we are computed the direction for
  13744. * @param isLocal defines if the direction should be set in local space
  13745. */
  13746. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13747. /**
  13748. * Called by the particle System when the position is computed for the created particle.
  13749. * @param worldMatrix is the world matrix of the particle system
  13750. * @param positionToUpdate is the position vector to update with the result
  13751. * @param particle is the particle we are computed the position for
  13752. * @param isLocal defines if the position should be set in local space
  13753. */
  13754. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13755. /**
  13756. * Clones the current emitter and returns a copy of it
  13757. * @returns the new emitter
  13758. */
  13759. clone(): CustomParticleEmitter;
  13760. /**
  13761. * Called by the GPUParticleSystem to setup the update shader
  13762. * @param effect defines the update shader
  13763. */
  13764. applyToShader(effect: Effect): void;
  13765. /**
  13766. * Returns a string to use to update the GPU particles update shader
  13767. * @returns a string containng the defines string
  13768. */
  13769. getEffectDefines(): string;
  13770. /**
  13771. * Returns the string "PointParticleEmitter"
  13772. * @returns a string containing the class name
  13773. */
  13774. getClassName(): string;
  13775. /**
  13776. * Serializes the particle system to a JSON object.
  13777. * @returns the JSON object
  13778. */
  13779. serialize(): any;
  13780. /**
  13781. * Parse properties from a JSON object
  13782. * @param serializationObject defines the JSON object
  13783. */
  13784. parse(serializationObject: any): void;
  13785. }
  13786. }
  13787. declare module BABYLON {
  13788. /**
  13789. * Particle emitter emitting particles from the inside of a box.
  13790. * It emits the particles randomly between 2 given directions.
  13791. */
  13792. export class MeshParticleEmitter implements IParticleEmitterType {
  13793. private _indices;
  13794. private _positions;
  13795. private _normals;
  13796. private _storedNormal;
  13797. private _mesh;
  13798. /**
  13799. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13800. */
  13801. direction1: Vector3;
  13802. /**
  13803. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13804. */
  13805. direction2: Vector3;
  13806. /**
  13807. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13808. */
  13809. useMeshNormalsForDirection: boolean;
  13810. /** Defines the mesh to use as source */
  13811. get mesh(): Nullable<AbstractMesh>;
  13812. set mesh(value: Nullable<AbstractMesh>);
  13813. /**
  13814. * Creates a new instance MeshParticleEmitter
  13815. * @param mesh defines the mesh to use as source
  13816. */
  13817. constructor(mesh?: Nullable<AbstractMesh>);
  13818. /**
  13819. * Called by the particle System when the direction is computed for the created particle.
  13820. * @param worldMatrix is the world matrix of the particle system
  13821. * @param directionToUpdate is the direction vector to update with the result
  13822. * @param particle is the particle we are computed the direction for
  13823. * @param isLocal defines if the direction should be set in local space
  13824. */
  13825. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13826. /**
  13827. * Called by the particle System when the position is computed for the created particle.
  13828. * @param worldMatrix is the world matrix of the particle system
  13829. * @param positionToUpdate is the position vector to update with the result
  13830. * @param particle is the particle we are computed the position for
  13831. * @param isLocal defines if the position should be set in local space
  13832. */
  13833. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13834. /**
  13835. * Clones the current emitter and returns a copy of it
  13836. * @returns the new emitter
  13837. */
  13838. clone(): MeshParticleEmitter;
  13839. /**
  13840. * Called by the GPUParticleSystem to setup the update shader
  13841. * @param effect defines the update shader
  13842. */
  13843. applyToShader(effect: Effect): void;
  13844. /**
  13845. * Returns a string to use to update the GPU particles update shader
  13846. * @returns a string containng the defines string
  13847. */
  13848. getEffectDefines(): string;
  13849. /**
  13850. * Returns the string "BoxParticleEmitter"
  13851. * @returns a string containing the class name
  13852. */
  13853. getClassName(): string;
  13854. /**
  13855. * Serializes the particle system to a JSON object.
  13856. * @returns the JSON object
  13857. */
  13858. serialize(): any;
  13859. /**
  13860. * Parse properties from a JSON object
  13861. * @param serializationObject defines the JSON object
  13862. * @param scene defines the hosting scene
  13863. */
  13864. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13865. }
  13866. }
  13867. declare module BABYLON {
  13868. /**
  13869. * Interface representing a particle system in Babylon.js.
  13870. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13871. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13872. */
  13873. export interface IParticleSystem {
  13874. /**
  13875. * List of animations used by the particle system.
  13876. */
  13877. animations: Animation[];
  13878. /**
  13879. * The id of the Particle system.
  13880. */
  13881. id: string;
  13882. /**
  13883. * The name of the Particle system.
  13884. */
  13885. name: string;
  13886. /**
  13887. * The emitter represents the Mesh or position we are attaching the particle system to.
  13888. */
  13889. emitter: Nullable<AbstractMesh | Vector3>;
  13890. /**
  13891. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13892. */
  13893. isBillboardBased: boolean;
  13894. /**
  13895. * The rendering group used by the Particle system to chose when to render.
  13896. */
  13897. renderingGroupId: number;
  13898. /**
  13899. * The layer mask we are rendering the particles through.
  13900. */
  13901. layerMask: number;
  13902. /**
  13903. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13904. */
  13905. updateSpeed: number;
  13906. /**
  13907. * The amount of time the particle system is running (depends of the overall update speed).
  13908. */
  13909. targetStopDuration: number;
  13910. /**
  13911. * The texture used to render each particle. (this can be a spritesheet)
  13912. */
  13913. particleTexture: Nullable<BaseTexture>;
  13914. /**
  13915. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13916. */
  13917. blendMode: number;
  13918. /**
  13919. * Minimum life time of emitting particles.
  13920. */
  13921. minLifeTime: number;
  13922. /**
  13923. * Maximum life time of emitting particles.
  13924. */
  13925. maxLifeTime: number;
  13926. /**
  13927. * Minimum Size of emitting particles.
  13928. */
  13929. minSize: number;
  13930. /**
  13931. * Maximum Size of emitting particles.
  13932. */
  13933. maxSize: number;
  13934. /**
  13935. * Minimum scale of emitting particles on X axis.
  13936. */
  13937. minScaleX: number;
  13938. /**
  13939. * Maximum scale of emitting particles on X axis.
  13940. */
  13941. maxScaleX: number;
  13942. /**
  13943. * Minimum scale of emitting particles on Y axis.
  13944. */
  13945. minScaleY: number;
  13946. /**
  13947. * Maximum scale of emitting particles on Y axis.
  13948. */
  13949. maxScaleY: number;
  13950. /**
  13951. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13952. */
  13953. color1: Color4;
  13954. /**
  13955. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13956. */
  13957. color2: Color4;
  13958. /**
  13959. * Color the particle will have at the end of its lifetime.
  13960. */
  13961. colorDead: Color4;
  13962. /**
  13963. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13964. */
  13965. emitRate: number;
  13966. /**
  13967. * You can use gravity if you want to give an orientation to your particles.
  13968. */
  13969. gravity: Vector3;
  13970. /**
  13971. * Minimum power of emitting particles.
  13972. */
  13973. minEmitPower: number;
  13974. /**
  13975. * Maximum power of emitting particles.
  13976. */
  13977. maxEmitPower: number;
  13978. /**
  13979. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13980. */
  13981. minAngularSpeed: number;
  13982. /**
  13983. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13984. */
  13985. maxAngularSpeed: number;
  13986. /**
  13987. * Gets or sets the minimal initial rotation in radians.
  13988. */
  13989. minInitialRotation: number;
  13990. /**
  13991. * Gets or sets the maximal initial rotation in radians.
  13992. */
  13993. maxInitialRotation: number;
  13994. /**
  13995. * The particle emitter type defines the emitter used by the particle system.
  13996. * It can be for example box, sphere, or cone...
  13997. */
  13998. particleEmitterType: Nullable<IParticleEmitterType>;
  13999. /**
  14000. * Defines the delay in milliseconds before starting the system (0 by default)
  14001. */
  14002. startDelay: number;
  14003. /**
  14004. * 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
  14005. */
  14006. preWarmCycles: number;
  14007. /**
  14008. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14009. */
  14010. preWarmStepOffset: number;
  14011. /**
  14012. * 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)
  14013. */
  14014. spriteCellChangeSpeed: number;
  14015. /**
  14016. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14017. */
  14018. startSpriteCellID: number;
  14019. /**
  14020. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14021. */
  14022. endSpriteCellID: number;
  14023. /**
  14024. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14025. */
  14026. spriteCellWidth: number;
  14027. /**
  14028. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14029. */
  14030. spriteCellHeight: number;
  14031. /**
  14032. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14033. */
  14034. spriteRandomStartCell: boolean;
  14035. /**
  14036. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14037. */
  14038. isAnimationSheetEnabled: boolean;
  14039. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14040. translationPivot: Vector2;
  14041. /**
  14042. * Gets or sets a texture used to add random noise to particle positions
  14043. */
  14044. noiseTexture: Nullable<BaseTexture>;
  14045. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14046. noiseStrength: Vector3;
  14047. /**
  14048. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14049. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14050. */
  14051. billboardMode: number;
  14052. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14053. limitVelocityDamping: number;
  14054. /**
  14055. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14056. */
  14057. beginAnimationOnStart: boolean;
  14058. /**
  14059. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14060. */
  14061. beginAnimationFrom: number;
  14062. /**
  14063. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14064. */
  14065. beginAnimationTo: number;
  14066. /**
  14067. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14068. */
  14069. beginAnimationLoop: boolean;
  14070. /**
  14071. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14072. */
  14073. disposeOnStop: boolean;
  14074. /**
  14075. * Specifies if the particles are updated in emitter local space or world space
  14076. */
  14077. isLocal: boolean;
  14078. /** Snippet ID if the particle system was created from the snippet server */
  14079. snippetId: string;
  14080. /** Gets or sets a matrix to use to compute projection */
  14081. defaultProjectionMatrix: Matrix;
  14082. /**
  14083. * Gets the maximum number of particles active at the same time.
  14084. * @returns The max number of active particles.
  14085. */
  14086. getCapacity(): number;
  14087. /**
  14088. * Gets the number of particles active at the same time.
  14089. * @returns The number of active particles.
  14090. */
  14091. getActiveCount(): number;
  14092. /**
  14093. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14094. * @returns True if it has been started, otherwise false.
  14095. */
  14096. isStarted(): boolean;
  14097. /**
  14098. * Animates the particle system for this frame.
  14099. */
  14100. animate(): void;
  14101. /**
  14102. * Renders the particle system in its current state.
  14103. * @returns the current number of particles
  14104. */
  14105. render(): number;
  14106. /**
  14107. * Dispose the particle system and frees its associated resources.
  14108. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14109. */
  14110. dispose(disposeTexture?: boolean): void;
  14111. /**
  14112. * An event triggered when the system is disposed
  14113. */
  14114. onDisposeObservable: Observable<IParticleSystem>;
  14115. /**
  14116. * Clones the particle system.
  14117. * @param name The name of the cloned object
  14118. * @param newEmitter The new emitter to use
  14119. * @returns the cloned particle system
  14120. */
  14121. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14122. /**
  14123. * Serializes the particle system to a JSON object
  14124. * @param serializeTexture defines if the texture must be serialized as well
  14125. * @returns the JSON object
  14126. */
  14127. serialize(serializeTexture: boolean): any;
  14128. /**
  14129. * Rebuild the particle system
  14130. */
  14131. rebuild(): void;
  14132. /** Force the system to rebuild all gradients that need to be resync */
  14133. forceRefreshGradients(): void;
  14134. /**
  14135. * Starts the particle system and begins to emit
  14136. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14137. */
  14138. start(delay?: number): void;
  14139. /**
  14140. * Stops the particle system.
  14141. */
  14142. stop(): void;
  14143. /**
  14144. * Remove all active particles
  14145. */
  14146. reset(): void;
  14147. /**
  14148. * Gets a boolean indicating that the system is stopping
  14149. * @returns true if the system is currently stopping
  14150. */
  14151. isStopping(): boolean;
  14152. /**
  14153. * Is this system ready to be used/rendered
  14154. * @return true if the system is ready
  14155. */
  14156. isReady(): boolean;
  14157. /**
  14158. * Returns the string "ParticleSystem"
  14159. * @returns a string containing the class name
  14160. */
  14161. getClassName(): string;
  14162. /**
  14163. * Gets the custom effect used to render the particles
  14164. * @param blendMode Blend mode for which the effect should be retrieved
  14165. * @returns The effect
  14166. */
  14167. getCustomEffect(blendMode: number): Nullable<Effect>;
  14168. /**
  14169. * Sets the custom effect used to render the particles
  14170. * @param effect The effect to set
  14171. * @param blendMode Blend mode for which the effect should be set
  14172. */
  14173. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14174. /**
  14175. * Fill the defines array according to the current settings of the particle system
  14176. * @param defines Array to be updated
  14177. * @param blendMode blend mode to take into account when updating the array
  14178. */
  14179. fillDefines(defines: Array<string>, blendMode: number): void;
  14180. /**
  14181. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14182. * @param uniforms Uniforms array to fill
  14183. * @param attributes Attributes array to fill
  14184. * @param samplers Samplers array to fill
  14185. */
  14186. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14187. /**
  14188. * Observable that will be called just before the particles are drawn
  14189. */
  14190. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14191. /**
  14192. * Gets the name of the particle vertex shader
  14193. */
  14194. vertexShaderName: string;
  14195. /**
  14196. * Adds a new color gradient
  14197. * @param gradient defines the gradient to use (between 0 and 1)
  14198. * @param color1 defines the color to affect to the specified gradient
  14199. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14200. * @returns the current particle system
  14201. */
  14202. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14203. /**
  14204. * Remove a specific color gradient
  14205. * @param gradient defines the gradient to remove
  14206. * @returns the current particle system
  14207. */
  14208. removeColorGradient(gradient: number): IParticleSystem;
  14209. /**
  14210. * Adds a new size gradient
  14211. * @param gradient defines the gradient to use (between 0 and 1)
  14212. * @param factor defines the size factor to affect to the specified gradient
  14213. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14214. * @returns the current particle system
  14215. */
  14216. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14217. /**
  14218. * Remove a specific size gradient
  14219. * @param gradient defines the gradient to remove
  14220. * @returns the current particle system
  14221. */
  14222. removeSizeGradient(gradient: number): IParticleSystem;
  14223. /**
  14224. * Gets the current list of color gradients.
  14225. * You must use addColorGradient and removeColorGradient to udpate this list
  14226. * @returns the list of color gradients
  14227. */
  14228. getColorGradients(): Nullable<Array<ColorGradient>>;
  14229. /**
  14230. * Gets the current list of size gradients.
  14231. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14232. * @returns the list of size gradients
  14233. */
  14234. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14235. /**
  14236. * Gets the current list of angular speed gradients.
  14237. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14238. * @returns the list of angular speed gradients
  14239. */
  14240. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14241. /**
  14242. * Adds a new angular speed gradient
  14243. * @param gradient defines the gradient to use (between 0 and 1)
  14244. * @param factor defines the angular speed to affect to the specified gradient
  14245. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14246. * @returns the current particle system
  14247. */
  14248. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14249. /**
  14250. * Remove a specific angular speed gradient
  14251. * @param gradient defines the gradient to remove
  14252. * @returns the current particle system
  14253. */
  14254. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14255. /**
  14256. * Gets the current list of velocity gradients.
  14257. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14258. * @returns the list of velocity gradients
  14259. */
  14260. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14261. /**
  14262. * Adds a new velocity gradient
  14263. * @param gradient defines the gradient to use (between 0 and 1)
  14264. * @param factor defines the velocity to affect to the specified gradient
  14265. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14266. * @returns the current particle system
  14267. */
  14268. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14269. /**
  14270. * Remove a specific velocity gradient
  14271. * @param gradient defines the gradient to remove
  14272. * @returns the current particle system
  14273. */
  14274. removeVelocityGradient(gradient: number): IParticleSystem;
  14275. /**
  14276. * Gets the current list of limit velocity gradients.
  14277. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14278. * @returns the list of limit velocity gradients
  14279. */
  14280. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14281. /**
  14282. * Adds a new limit velocity gradient
  14283. * @param gradient defines the gradient to use (between 0 and 1)
  14284. * @param factor defines the limit velocity to affect to the specified gradient
  14285. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14286. * @returns the current particle system
  14287. */
  14288. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14289. /**
  14290. * Remove a specific limit velocity gradient
  14291. * @param gradient defines the gradient to remove
  14292. * @returns the current particle system
  14293. */
  14294. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14295. /**
  14296. * Adds a new drag gradient
  14297. * @param gradient defines the gradient to use (between 0 and 1)
  14298. * @param factor defines the drag to affect to the specified gradient
  14299. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14300. * @returns the current particle system
  14301. */
  14302. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14303. /**
  14304. * Remove a specific drag gradient
  14305. * @param gradient defines the gradient to remove
  14306. * @returns the current particle system
  14307. */
  14308. removeDragGradient(gradient: number): IParticleSystem;
  14309. /**
  14310. * Gets the current list of drag gradients.
  14311. * You must use addDragGradient and removeDragGradient to udpate this list
  14312. * @returns the list of drag gradients
  14313. */
  14314. getDragGradients(): Nullable<Array<FactorGradient>>;
  14315. /**
  14316. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14317. * @param gradient defines the gradient to use (between 0 and 1)
  14318. * @param factor defines the emit rate to affect to the specified gradient
  14319. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14320. * @returns the current particle system
  14321. */
  14322. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14323. /**
  14324. * Remove a specific emit rate gradient
  14325. * @param gradient defines the gradient to remove
  14326. * @returns the current particle system
  14327. */
  14328. removeEmitRateGradient(gradient: number): IParticleSystem;
  14329. /**
  14330. * Gets the current list of emit rate gradients.
  14331. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14332. * @returns the list of emit rate gradients
  14333. */
  14334. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14335. /**
  14336. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14337. * @param gradient defines the gradient to use (between 0 and 1)
  14338. * @param factor defines the start size to affect to the specified gradient
  14339. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14340. * @returns the current particle system
  14341. */
  14342. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14343. /**
  14344. * Remove a specific start size gradient
  14345. * @param gradient defines the gradient to remove
  14346. * @returns the current particle system
  14347. */
  14348. removeStartSizeGradient(gradient: number): IParticleSystem;
  14349. /**
  14350. * Gets the current list of start size gradients.
  14351. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14352. * @returns the list of start size gradients
  14353. */
  14354. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14355. /**
  14356. * Adds a new life time gradient
  14357. * @param gradient defines the gradient to use (between 0 and 1)
  14358. * @param factor defines the life time factor to affect to the specified gradient
  14359. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14360. * @returns the current particle system
  14361. */
  14362. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14363. /**
  14364. * Remove a specific life time gradient
  14365. * @param gradient defines the gradient to remove
  14366. * @returns the current particle system
  14367. */
  14368. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14369. /**
  14370. * Gets the current list of life time gradients.
  14371. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14372. * @returns the list of life time gradients
  14373. */
  14374. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14375. /**
  14376. * Gets the current list of color gradients.
  14377. * You must use addColorGradient and removeColorGradient to udpate this list
  14378. * @returns the list of color gradients
  14379. */
  14380. getColorGradients(): Nullable<Array<ColorGradient>>;
  14381. /**
  14382. * Adds a new ramp gradient used to remap particle colors
  14383. * @param gradient defines the gradient to use (between 0 and 1)
  14384. * @param color defines the color to affect to the specified gradient
  14385. * @returns the current particle system
  14386. */
  14387. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14388. /**
  14389. * Gets the current list of ramp gradients.
  14390. * You must use addRampGradient and removeRampGradient to udpate this list
  14391. * @returns the list of ramp gradients
  14392. */
  14393. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14394. /** Gets or sets a boolean indicating that ramp gradients must be used
  14395. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14396. */
  14397. useRampGradients: boolean;
  14398. /**
  14399. * Adds a new color remap gradient
  14400. * @param gradient defines the gradient to use (between 0 and 1)
  14401. * @param min defines the color remap minimal range
  14402. * @param max defines the color remap maximal range
  14403. * @returns the current particle system
  14404. */
  14405. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14406. /**
  14407. * Gets the current list of color remap gradients.
  14408. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14409. * @returns the list of color remap gradients
  14410. */
  14411. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14412. /**
  14413. * Adds a new alpha remap gradient
  14414. * @param gradient defines the gradient to use (between 0 and 1)
  14415. * @param min defines the alpha remap minimal range
  14416. * @param max defines the alpha remap maximal range
  14417. * @returns the current particle system
  14418. */
  14419. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14420. /**
  14421. * Gets the current list of alpha remap gradients.
  14422. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14423. * @returns the list of alpha remap gradients
  14424. */
  14425. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14426. /**
  14427. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14428. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14429. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14430. * @returns the emitter
  14431. */
  14432. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14433. /**
  14434. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14435. * @param radius The radius of the hemisphere to emit from
  14436. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14437. * @returns the emitter
  14438. */
  14439. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14440. /**
  14441. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14442. * @param radius The radius of the sphere to emit from
  14443. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14444. * @returns the emitter
  14445. */
  14446. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14447. /**
  14448. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14449. * @param radius The radius of the sphere to emit from
  14450. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14451. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14452. * @returns the emitter
  14453. */
  14454. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14455. /**
  14456. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14457. * @param radius The radius of the emission cylinder
  14458. * @param height The height of the emission cylinder
  14459. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14460. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14461. * @returns the emitter
  14462. */
  14463. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14464. /**
  14465. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14466. * @param radius The radius of the cylinder to emit from
  14467. * @param height The height of the emission cylinder
  14468. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14469. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14470. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14471. * @returns the emitter
  14472. */
  14473. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14474. /**
  14475. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14476. * @param radius The radius of the cone to emit from
  14477. * @param angle The base angle of the cone
  14478. * @returns the emitter
  14479. */
  14480. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14481. /**
  14482. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14483. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14484. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14485. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14486. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14487. * @returns the emitter
  14488. */
  14489. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14490. /**
  14491. * Get hosting scene
  14492. * @returns the scene
  14493. */
  14494. getScene(): Nullable<Scene>;
  14495. }
  14496. }
  14497. declare module BABYLON {
  14498. /**
  14499. * 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.
  14500. * @see https://doc.babylonjs.com/how_to/transformnode
  14501. */
  14502. export class TransformNode extends Node {
  14503. /**
  14504. * Object will not rotate to face the camera
  14505. */
  14506. static BILLBOARDMODE_NONE: number;
  14507. /**
  14508. * Object will rotate to face the camera but only on the x axis
  14509. */
  14510. static BILLBOARDMODE_X: number;
  14511. /**
  14512. * Object will rotate to face the camera but only on the y axis
  14513. */
  14514. static BILLBOARDMODE_Y: number;
  14515. /**
  14516. * Object will rotate to face the camera but only on the z axis
  14517. */
  14518. static BILLBOARDMODE_Z: number;
  14519. /**
  14520. * Object will rotate to face the camera
  14521. */
  14522. static BILLBOARDMODE_ALL: number;
  14523. /**
  14524. * Object will rotate to face the camera's position instead of orientation
  14525. */
  14526. static BILLBOARDMODE_USE_POSITION: number;
  14527. private static _TmpRotation;
  14528. private static _TmpScaling;
  14529. private static _TmpTranslation;
  14530. private _forward;
  14531. private _forwardInverted;
  14532. private _up;
  14533. private _right;
  14534. private _rightInverted;
  14535. private _position;
  14536. private _rotation;
  14537. private _rotationQuaternion;
  14538. protected _scaling: Vector3;
  14539. protected _isDirty: boolean;
  14540. private _transformToBoneReferal;
  14541. private _isAbsoluteSynced;
  14542. private _billboardMode;
  14543. /**
  14544. * Gets or sets the billboard mode. Default is 0.
  14545. *
  14546. * | Value | Type | Description |
  14547. * | --- | --- | --- |
  14548. * | 0 | BILLBOARDMODE_NONE | |
  14549. * | 1 | BILLBOARDMODE_X | |
  14550. * | 2 | BILLBOARDMODE_Y | |
  14551. * | 4 | BILLBOARDMODE_Z | |
  14552. * | 7 | BILLBOARDMODE_ALL | |
  14553. *
  14554. */
  14555. get billboardMode(): number;
  14556. set billboardMode(value: number);
  14557. private _preserveParentRotationForBillboard;
  14558. /**
  14559. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14560. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14561. */
  14562. get preserveParentRotationForBillboard(): boolean;
  14563. set preserveParentRotationForBillboard(value: boolean);
  14564. /**
  14565. * 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
  14566. */
  14567. scalingDeterminant: number;
  14568. private _infiniteDistance;
  14569. /**
  14570. * Gets or sets the distance of the object to max, often used by skybox
  14571. */
  14572. get infiniteDistance(): boolean;
  14573. set infiniteDistance(value: boolean);
  14574. /**
  14575. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14576. * By default the system will update normals to compensate
  14577. */
  14578. ignoreNonUniformScaling: boolean;
  14579. /**
  14580. * 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
  14581. */
  14582. reIntegrateRotationIntoRotationQuaternion: boolean;
  14583. /** @hidden */
  14584. _poseMatrix: Nullable<Matrix>;
  14585. /** @hidden */
  14586. _localMatrix: Matrix;
  14587. private _usePivotMatrix;
  14588. private _absolutePosition;
  14589. private _absoluteScaling;
  14590. private _absoluteRotationQuaternion;
  14591. private _pivotMatrix;
  14592. private _pivotMatrixInverse;
  14593. protected _postMultiplyPivotMatrix: boolean;
  14594. protected _isWorldMatrixFrozen: boolean;
  14595. /** @hidden */
  14596. _indexInSceneTransformNodesArray: number;
  14597. /**
  14598. * An event triggered after the world matrix is updated
  14599. */
  14600. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14601. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14602. /**
  14603. * Gets a string identifying the name of the class
  14604. * @returns "TransformNode" string
  14605. */
  14606. getClassName(): string;
  14607. /**
  14608. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14609. */
  14610. get position(): Vector3;
  14611. set position(newPosition: Vector3);
  14612. /**
  14613. * 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)).
  14614. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14615. */
  14616. get rotation(): Vector3;
  14617. set rotation(newRotation: Vector3);
  14618. /**
  14619. * 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)).
  14620. */
  14621. get scaling(): Vector3;
  14622. set scaling(newScaling: Vector3);
  14623. /**
  14624. * 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).
  14625. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14626. */
  14627. get rotationQuaternion(): Nullable<Quaternion>;
  14628. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14629. /**
  14630. * The forward direction of that transform in world space.
  14631. */
  14632. get forward(): Vector3;
  14633. /**
  14634. * The up direction of that transform in world space.
  14635. */
  14636. get up(): Vector3;
  14637. /**
  14638. * The right direction of that transform in world space.
  14639. */
  14640. get right(): Vector3;
  14641. /**
  14642. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14643. * @param matrix the matrix to copy the pose from
  14644. * @returns this TransformNode.
  14645. */
  14646. updatePoseMatrix(matrix: Matrix): TransformNode;
  14647. /**
  14648. * Returns the mesh Pose matrix.
  14649. * @returns the pose matrix
  14650. */
  14651. getPoseMatrix(): Matrix;
  14652. /** @hidden */
  14653. _isSynchronized(): boolean;
  14654. /** @hidden */
  14655. _initCache(): void;
  14656. /**
  14657. * Flag the transform node as dirty (Forcing it to update everything)
  14658. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14659. * @returns this transform node
  14660. */
  14661. markAsDirty(property: string): TransformNode;
  14662. /**
  14663. * Returns the current mesh absolute position.
  14664. * Returns a Vector3.
  14665. */
  14666. get absolutePosition(): Vector3;
  14667. /**
  14668. * Returns the current mesh absolute scaling.
  14669. * Returns a Vector3.
  14670. */
  14671. get absoluteScaling(): Vector3;
  14672. /**
  14673. * Returns the current mesh absolute rotation.
  14674. * Returns a Quaternion.
  14675. */
  14676. get absoluteRotationQuaternion(): Quaternion;
  14677. /**
  14678. * Sets a new matrix to apply before all other transformation
  14679. * @param matrix defines the transform matrix
  14680. * @returns the current TransformNode
  14681. */
  14682. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14683. /**
  14684. * Sets a new pivot matrix to the current node
  14685. * @param matrix defines the new pivot matrix to use
  14686. * @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
  14687. * @returns the current TransformNode
  14688. */
  14689. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14690. /**
  14691. * Returns the mesh pivot matrix.
  14692. * Default : Identity.
  14693. * @returns the matrix
  14694. */
  14695. getPivotMatrix(): Matrix;
  14696. /**
  14697. * Instantiate (when possible) or clone that node with its hierarchy
  14698. * @param newParent defines the new parent to use for the instance (or clone)
  14699. * @param options defines options to configure how copy is done
  14700. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14701. * @returns an instance (or a clone) of the current node with its hiearchy
  14702. */
  14703. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14704. doNotInstantiate: boolean;
  14705. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14706. /**
  14707. * Prevents the World matrix to be computed any longer
  14708. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14709. * @returns the TransformNode.
  14710. */
  14711. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14712. /**
  14713. * Allows back the World matrix computation.
  14714. * @returns the TransformNode.
  14715. */
  14716. unfreezeWorldMatrix(): this;
  14717. /**
  14718. * True if the World matrix has been frozen.
  14719. */
  14720. get isWorldMatrixFrozen(): boolean;
  14721. /**
  14722. * Retuns the mesh absolute position in the World.
  14723. * @returns a Vector3.
  14724. */
  14725. getAbsolutePosition(): Vector3;
  14726. /**
  14727. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14728. * @param absolutePosition the absolute position to set
  14729. * @returns the TransformNode.
  14730. */
  14731. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14732. /**
  14733. * Sets the mesh position in its local space.
  14734. * @param vector3 the position to set in localspace
  14735. * @returns the TransformNode.
  14736. */
  14737. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14738. /**
  14739. * Returns the mesh position in the local space from the current World matrix values.
  14740. * @returns a new Vector3.
  14741. */
  14742. getPositionExpressedInLocalSpace(): Vector3;
  14743. /**
  14744. * Translates the mesh along the passed Vector3 in its local space.
  14745. * @param vector3 the distance to translate in localspace
  14746. * @returns the TransformNode.
  14747. */
  14748. locallyTranslate(vector3: Vector3): TransformNode;
  14749. private static _lookAtVectorCache;
  14750. /**
  14751. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14752. * @param targetPoint the position (must be in same space as current mesh) to look at
  14753. * @param yawCor optional yaw (y-axis) correction in radians
  14754. * @param pitchCor optional pitch (x-axis) correction in radians
  14755. * @param rollCor optional roll (z-axis) correction in radians
  14756. * @param space the choosen space of the target
  14757. * @returns the TransformNode.
  14758. */
  14759. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14760. /**
  14761. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14762. * This Vector3 is expressed in the World space.
  14763. * @param localAxis axis to rotate
  14764. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14765. */
  14766. getDirection(localAxis: Vector3): Vector3;
  14767. /**
  14768. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14769. * localAxis is expressed in the mesh local space.
  14770. * result is computed in the Wordl space from the mesh World matrix.
  14771. * @param localAxis axis to rotate
  14772. * @param result the resulting transformnode
  14773. * @returns this TransformNode.
  14774. */
  14775. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14776. /**
  14777. * Sets this transform node rotation to the given local axis.
  14778. * @param localAxis the axis in local space
  14779. * @param yawCor optional yaw (y-axis) correction in radians
  14780. * @param pitchCor optional pitch (x-axis) correction in radians
  14781. * @param rollCor optional roll (z-axis) correction in radians
  14782. * @returns this TransformNode
  14783. */
  14784. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14785. /**
  14786. * Sets a new pivot point to the current node
  14787. * @param point defines the new pivot point to use
  14788. * @param space defines if the point is in world or local space (local by default)
  14789. * @returns the current TransformNode
  14790. */
  14791. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14792. /**
  14793. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14794. * @returns the pivot point
  14795. */
  14796. getPivotPoint(): Vector3;
  14797. /**
  14798. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14799. * @param result the vector3 to store the result
  14800. * @returns this TransformNode.
  14801. */
  14802. getPivotPointToRef(result: Vector3): TransformNode;
  14803. /**
  14804. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14805. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14806. */
  14807. getAbsolutePivotPoint(): Vector3;
  14808. /**
  14809. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14810. * @param result vector3 to store the result
  14811. * @returns this TransformNode.
  14812. */
  14813. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14814. /**
  14815. * Defines the passed node as the parent of the current node.
  14816. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14817. * @see https://doc.babylonjs.com/how_to/parenting
  14818. * @param node the node ot set as the parent
  14819. * @returns this TransformNode.
  14820. */
  14821. setParent(node: Nullable<Node>): TransformNode;
  14822. private _nonUniformScaling;
  14823. /**
  14824. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14825. */
  14826. get nonUniformScaling(): boolean;
  14827. /** @hidden */
  14828. _updateNonUniformScalingState(value: boolean): boolean;
  14829. /**
  14830. * Attach the current TransformNode to another TransformNode associated with a bone
  14831. * @param bone Bone affecting the TransformNode
  14832. * @param affectedTransformNode TransformNode associated with the bone
  14833. * @returns this object
  14834. */
  14835. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14836. /**
  14837. * Detach the transform node if its associated with a bone
  14838. * @returns this object
  14839. */
  14840. detachFromBone(): TransformNode;
  14841. private static _rotationAxisCache;
  14842. /**
  14843. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14844. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14845. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14846. * The passed axis is also normalized.
  14847. * @param axis the axis to rotate around
  14848. * @param amount the amount to rotate in radians
  14849. * @param space Space to rotate in (Default: local)
  14850. * @returns the TransformNode.
  14851. */
  14852. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14853. /**
  14854. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14855. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14856. * The passed axis is also normalized. .
  14857. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14858. * @param point the point to rotate around
  14859. * @param axis the axis to rotate around
  14860. * @param amount the amount to rotate in radians
  14861. * @returns the TransformNode
  14862. */
  14863. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14864. /**
  14865. * Translates the mesh along the axis vector for the passed distance in the given space.
  14866. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14867. * @param axis the axis to translate in
  14868. * @param distance the distance to translate
  14869. * @param space Space to rotate in (Default: local)
  14870. * @returns the TransformNode.
  14871. */
  14872. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14873. /**
  14874. * Adds a rotation step to the mesh current rotation.
  14875. * x, y, z are Euler angles expressed in radians.
  14876. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14877. * This means this rotation is made in the mesh local space only.
  14878. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14879. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14880. * ```javascript
  14881. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14882. * ```
  14883. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14884. * 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.
  14885. * @param x Rotation to add
  14886. * @param y Rotation to add
  14887. * @param z Rotation to add
  14888. * @returns the TransformNode.
  14889. */
  14890. addRotation(x: number, y: number, z: number): TransformNode;
  14891. /**
  14892. * @hidden
  14893. */
  14894. protected _getEffectiveParent(): Nullable<Node>;
  14895. /**
  14896. * Computes the world matrix of the node
  14897. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14898. * @returns the world matrix
  14899. */
  14900. computeWorldMatrix(force?: boolean): Matrix;
  14901. /**
  14902. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14903. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14904. */
  14905. resetLocalMatrix(independentOfChildren?: boolean): void;
  14906. protected _afterComputeWorldMatrix(): void;
  14907. /**
  14908. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14909. * @param func callback function to add
  14910. *
  14911. * @returns the TransformNode.
  14912. */
  14913. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14914. /**
  14915. * Removes a registered callback function.
  14916. * @param func callback function to remove
  14917. * @returns the TransformNode.
  14918. */
  14919. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14920. /**
  14921. * Gets the position of the current mesh in camera space
  14922. * @param camera defines the camera to use
  14923. * @returns a position
  14924. */
  14925. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14926. /**
  14927. * Returns the distance from the mesh to the active camera
  14928. * @param camera defines the camera to use
  14929. * @returns the distance
  14930. */
  14931. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14932. /**
  14933. * Clone the current transform node
  14934. * @param name Name of the new clone
  14935. * @param newParent New parent for the clone
  14936. * @param doNotCloneChildren Do not clone children hierarchy
  14937. * @returns the new transform node
  14938. */
  14939. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14940. /**
  14941. * Serializes the objects information.
  14942. * @param currentSerializationObject defines the object to serialize in
  14943. * @returns the serialized object
  14944. */
  14945. serialize(currentSerializationObject?: any): any;
  14946. /**
  14947. * Returns a new TransformNode object parsed from the source provided.
  14948. * @param parsedTransformNode is the source.
  14949. * @param scene the scne the object belongs to
  14950. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14951. * @returns a new TransformNode object parsed from the source provided.
  14952. */
  14953. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14954. /**
  14955. * Get all child-transformNodes of this node
  14956. * @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
  14957. * @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
  14958. * @returns an array of TransformNode
  14959. */
  14960. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14961. /**
  14962. * Releases resources associated with this transform node.
  14963. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14964. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14965. */
  14966. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14967. /**
  14968. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14969. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14970. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14971. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14972. * @returns the current mesh
  14973. */
  14974. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14975. private _syncAbsoluteScalingAndRotation;
  14976. }
  14977. }
  14978. declare module BABYLON {
  14979. /**
  14980. * Class used to override all child animations of a given target
  14981. */
  14982. export class AnimationPropertiesOverride {
  14983. /**
  14984. * Gets or sets a value indicating if animation blending must be used
  14985. */
  14986. enableBlending: boolean;
  14987. /**
  14988. * Gets or sets the blending speed to use when enableBlending is true
  14989. */
  14990. blendingSpeed: number;
  14991. /**
  14992. * Gets or sets the default loop mode to use
  14993. */
  14994. loopMode: number;
  14995. }
  14996. }
  14997. declare module BABYLON {
  14998. /**
  14999. * Class used to store bone information
  15000. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15001. */
  15002. export class Bone extends Node {
  15003. /**
  15004. * defines the bone name
  15005. */
  15006. name: string;
  15007. private static _tmpVecs;
  15008. private static _tmpQuat;
  15009. private static _tmpMats;
  15010. /**
  15011. * Gets the list of child bones
  15012. */
  15013. children: Bone[];
  15014. /** Gets the animations associated with this bone */
  15015. animations: Animation[];
  15016. /**
  15017. * Gets or sets bone length
  15018. */
  15019. length: number;
  15020. /**
  15021. * @hidden Internal only
  15022. * Set this value to map this bone to a different index in the transform matrices
  15023. * Set this value to -1 to exclude the bone from the transform matrices
  15024. */
  15025. _index: Nullable<number>;
  15026. private _skeleton;
  15027. private _localMatrix;
  15028. private _restPose;
  15029. private _bindPose;
  15030. private _baseMatrix;
  15031. private _absoluteTransform;
  15032. private _invertedAbsoluteTransform;
  15033. private _parent;
  15034. private _scalingDeterminant;
  15035. private _worldTransform;
  15036. private _localScaling;
  15037. private _localRotation;
  15038. private _localPosition;
  15039. private _needToDecompose;
  15040. private _needToCompose;
  15041. /** @hidden */
  15042. _linkedTransformNode: Nullable<TransformNode>;
  15043. /** @hidden */
  15044. _waitingTransformNodeId: Nullable<string>;
  15045. /** @hidden */
  15046. get _matrix(): Matrix;
  15047. /** @hidden */
  15048. set _matrix(value: Matrix);
  15049. /**
  15050. * Create a new bone
  15051. * @param name defines the bone name
  15052. * @param skeleton defines the parent skeleton
  15053. * @param parentBone defines the parent (can be null if the bone is the root)
  15054. * @param localMatrix defines the local matrix
  15055. * @param restPose defines the rest pose matrix
  15056. * @param baseMatrix defines the base matrix
  15057. * @param index defines index of the bone in the hiearchy
  15058. */
  15059. constructor(
  15060. /**
  15061. * defines the bone name
  15062. */
  15063. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15064. /**
  15065. * Gets the current object class name.
  15066. * @return the class name
  15067. */
  15068. getClassName(): string;
  15069. /**
  15070. * Gets the parent skeleton
  15071. * @returns a skeleton
  15072. */
  15073. getSkeleton(): Skeleton;
  15074. /**
  15075. * Gets parent bone
  15076. * @returns a bone or null if the bone is the root of the bone hierarchy
  15077. */
  15078. getParent(): Nullable<Bone>;
  15079. /**
  15080. * Returns an array containing the root bones
  15081. * @returns an array containing the root bones
  15082. */
  15083. getChildren(): Array<Bone>;
  15084. /**
  15085. * Gets the node index in matrix array generated for rendering
  15086. * @returns the node index
  15087. */
  15088. getIndex(): number;
  15089. /**
  15090. * Sets the parent bone
  15091. * @param parent defines the parent (can be null if the bone is the root)
  15092. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15093. */
  15094. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15095. /**
  15096. * Gets the local matrix
  15097. * @returns a matrix
  15098. */
  15099. getLocalMatrix(): Matrix;
  15100. /**
  15101. * Gets the base matrix (initial matrix which remains unchanged)
  15102. * @returns a matrix
  15103. */
  15104. getBaseMatrix(): Matrix;
  15105. /**
  15106. * Gets the rest pose matrix
  15107. * @returns a matrix
  15108. */
  15109. getRestPose(): Matrix;
  15110. /**
  15111. * Sets the rest pose matrix
  15112. * @param matrix the local-space rest pose to set for this bone
  15113. */
  15114. setRestPose(matrix: Matrix): void;
  15115. /**
  15116. * Gets the bind pose matrix
  15117. * @returns the bind pose matrix
  15118. */
  15119. getBindPose(): Matrix;
  15120. /**
  15121. * Sets the bind pose matrix
  15122. * @param matrix the local-space bind pose to set for this bone
  15123. */
  15124. setBindPose(matrix: Matrix): void;
  15125. /**
  15126. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15127. */
  15128. getWorldMatrix(): Matrix;
  15129. /**
  15130. * Sets the local matrix to rest pose matrix
  15131. */
  15132. returnToRest(): void;
  15133. /**
  15134. * Gets the inverse of the absolute transform matrix.
  15135. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15136. * @returns a matrix
  15137. */
  15138. getInvertedAbsoluteTransform(): Matrix;
  15139. /**
  15140. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15141. * @returns a matrix
  15142. */
  15143. getAbsoluteTransform(): Matrix;
  15144. /**
  15145. * Links with the given transform node.
  15146. * The local matrix of this bone is copied from the transform node every frame.
  15147. * @param transformNode defines the transform node to link to
  15148. */
  15149. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15150. /**
  15151. * Gets the node used to drive the bone's transformation
  15152. * @returns a transform node or null
  15153. */
  15154. getTransformNode(): Nullable<TransformNode>;
  15155. /** Gets or sets current position (in local space) */
  15156. get position(): Vector3;
  15157. set position(newPosition: Vector3);
  15158. /** Gets or sets current rotation (in local space) */
  15159. get rotation(): Vector3;
  15160. set rotation(newRotation: Vector3);
  15161. /** Gets or sets current rotation quaternion (in local space) */
  15162. get rotationQuaternion(): Quaternion;
  15163. set rotationQuaternion(newRotation: Quaternion);
  15164. /** Gets or sets current scaling (in local space) */
  15165. get scaling(): Vector3;
  15166. set scaling(newScaling: Vector3);
  15167. /**
  15168. * Gets the animation properties override
  15169. */
  15170. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15171. private _decompose;
  15172. private _compose;
  15173. /**
  15174. * Update the base and local matrices
  15175. * @param matrix defines the new base or local matrix
  15176. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15177. * @param updateLocalMatrix defines if the local matrix should be updated
  15178. */
  15179. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15180. /** @hidden */
  15181. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15182. /**
  15183. * Flag the bone as dirty (Forcing it to update everything)
  15184. */
  15185. markAsDirty(): void;
  15186. /** @hidden */
  15187. _markAsDirtyAndCompose(): void;
  15188. private _markAsDirtyAndDecompose;
  15189. /**
  15190. * Translate the bone in local or world space
  15191. * @param vec The amount to translate the bone
  15192. * @param space The space that the translation is in
  15193. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15194. */
  15195. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15196. /**
  15197. * Set the postion of the bone in local or world space
  15198. * @param position The position to set the bone
  15199. * @param space The space that the position is in
  15200. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15201. */
  15202. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15203. /**
  15204. * Set the absolute position of the bone (world space)
  15205. * @param position The position to set the bone
  15206. * @param mesh The mesh that this bone is attached to
  15207. */
  15208. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15209. /**
  15210. * Scale the bone on the x, y and z axes (in local space)
  15211. * @param x The amount to scale the bone on the x axis
  15212. * @param y The amount to scale the bone on the y axis
  15213. * @param z The amount to scale the bone on the z axis
  15214. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15215. */
  15216. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15217. /**
  15218. * Set the bone scaling in local space
  15219. * @param scale defines the scaling vector
  15220. */
  15221. setScale(scale: Vector3): void;
  15222. /**
  15223. * Gets the current scaling in local space
  15224. * @returns the current scaling vector
  15225. */
  15226. getScale(): Vector3;
  15227. /**
  15228. * Gets the current scaling in local space and stores it in a target vector
  15229. * @param result defines the target vector
  15230. */
  15231. getScaleToRef(result: Vector3): void;
  15232. /**
  15233. * Set the yaw, pitch, and roll of the bone in local or world space
  15234. * @param yaw The rotation of the bone on the y axis
  15235. * @param pitch The rotation of the bone on the x axis
  15236. * @param roll The rotation of the bone on the z axis
  15237. * @param space The space that the axes of rotation are in
  15238. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15239. */
  15240. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15241. /**
  15242. * Add a rotation to the bone on an axis in local or world space
  15243. * @param axis The axis to rotate the bone on
  15244. * @param amount The amount to rotate the bone
  15245. * @param space The space that the axis is in
  15246. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15247. */
  15248. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15249. /**
  15250. * Set the rotation of the bone to a particular axis angle in local or world space
  15251. * @param axis The axis to rotate the bone on
  15252. * @param angle The angle that the bone should be rotated to
  15253. * @param space The space that the axis is in
  15254. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15255. */
  15256. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15257. /**
  15258. * Set the euler rotation of the bone in local of world space
  15259. * @param rotation The euler rotation that the bone should be set to
  15260. * @param space The space that the rotation is in
  15261. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15262. */
  15263. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15264. /**
  15265. * Set the quaternion rotation of the bone in local of world space
  15266. * @param quat The quaternion rotation that the bone should be set to
  15267. * @param space The space that the rotation is in
  15268. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15269. */
  15270. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15271. /**
  15272. * Set the rotation matrix of the bone in local of world space
  15273. * @param rotMat The rotation matrix that the bone should be set to
  15274. * @param space The space that the rotation is in
  15275. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15276. */
  15277. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15278. private _rotateWithMatrix;
  15279. private _getNegativeRotationToRef;
  15280. /**
  15281. * Get the position of the bone in local or world space
  15282. * @param space The space that the returned position is in
  15283. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15284. * @returns The position of the bone
  15285. */
  15286. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15287. /**
  15288. * Copy the position of the bone to a vector3 in local or world space
  15289. * @param space The space that the returned position is in
  15290. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15291. * @param result The vector3 to copy the position to
  15292. */
  15293. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15294. /**
  15295. * Get the absolute position of the bone (world space)
  15296. * @param mesh The mesh that this bone is attached to
  15297. * @returns The absolute position of the bone
  15298. */
  15299. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15300. /**
  15301. * Copy the absolute position of the bone (world space) to the result param
  15302. * @param mesh The mesh that this bone is attached to
  15303. * @param result The vector3 to copy the absolute position to
  15304. */
  15305. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15306. /**
  15307. * Compute the absolute transforms of this bone and its children
  15308. */
  15309. computeAbsoluteTransforms(): void;
  15310. /**
  15311. * Get the world direction from an axis that is in the local space of the bone
  15312. * @param localAxis The local direction that is used to compute the world direction
  15313. * @param mesh The mesh that this bone is attached to
  15314. * @returns The world direction
  15315. */
  15316. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15317. /**
  15318. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15319. * @param localAxis The local direction that is used to compute the world direction
  15320. * @param mesh The mesh that this bone is attached to
  15321. * @param result The vector3 that the world direction will be copied to
  15322. */
  15323. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15324. /**
  15325. * Get the euler rotation of the bone in local or world space
  15326. * @param space The space that the rotation should be in
  15327. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15328. * @returns The euler rotation
  15329. */
  15330. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15331. /**
  15332. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15333. * @param space The space that the rotation should be in
  15334. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15335. * @param result The vector3 that the rotation should be copied to
  15336. */
  15337. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15338. /**
  15339. * Get the quaternion rotation of the bone in either local or world space
  15340. * @param space The space that the rotation should be in
  15341. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15342. * @returns The quaternion rotation
  15343. */
  15344. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15345. /**
  15346. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15347. * @param space The space that the rotation should be in
  15348. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15349. * @param result The quaternion that the rotation should be copied to
  15350. */
  15351. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15352. /**
  15353. * Get the rotation matrix of the bone in local or world space
  15354. * @param space The space that the rotation should be in
  15355. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15356. * @returns The rotation matrix
  15357. */
  15358. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15359. /**
  15360. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15361. * @param space The space that the rotation should be in
  15362. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15363. * @param result The quaternion that the rotation should be copied to
  15364. */
  15365. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15366. /**
  15367. * Get the world position of a point that is in the local space of the bone
  15368. * @param position The local position
  15369. * @param mesh The mesh that this bone is attached to
  15370. * @returns The world position
  15371. */
  15372. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15373. /**
  15374. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15375. * @param position The local position
  15376. * @param mesh The mesh that this bone is attached to
  15377. * @param result The vector3 that the world position should be copied to
  15378. */
  15379. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15380. /**
  15381. * Get the local position of a point that is in world space
  15382. * @param position The world position
  15383. * @param mesh The mesh that this bone is attached to
  15384. * @returns The local position
  15385. */
  15386. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15387. /**
  15388. * Get the local position of a point that is in world space and copy it to the result param
  15389. * @param position The world position
  15390. * @param mesh The mesh that this bone is attached to
  15391. * @param result The vector3 that the local position should be copied to
  15392. */
  15393. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15394. }
  15395. }
  15396. declare module BABYLON {
  15397. /**
  15398. * Defines a runtime animation
  15399. */
  15400. export class RuntimeAnimation {
  15401. private _events;
  15402. /**
  15403. * The current frame of the runtime animation
  15404. */
  15405. private _currentFrame;
  15406. /**
  15407. * The animation used by the runtime animation
  15408. */
  15409. private _animation;
  15410. /**
  15411. * The target of the runtime animation
  15412. */
  15413. private _target;
  15414. /**
  15415. * The initiating animatable
  15416. */
  15417. private _host;
  15418. /**
  15419. * The original value of the runtime animation
  15420. */
  15421. private _originalValue;
  15422. /**
  15423. * The original blend value of the runtime animation
  15424. */
  15425. private _originalBlendValue;
  15426. /**
  15427. * The offsets cache of the runtime animation
  15428. */
  15429. private _offsetsCache;
  15430. /**
  15431. * The high limits cache of the runtime animation
  15432. */
  15433. private _highLimitsCache;
  15434. /**
  15435. * Specifies if the runtime animation has been stopped
  15436. */
  15437. private _stopped;
  15438. /**
  15439. * The blending factor of the runtime animation
  15440. */
  15441. private _blendingFactor;
  15442. /**
  15443. * The BabylonJS scene
  15444. */
  15445. private _scene;
  15446. /**
  15447. * The current value of the runtime animation
  15448. */
  15449. private _currentValue;
  15450. /** @hidden */
  15451. _animationState: _IAnimationState;
  15452. /**
  15453. * The active target of the runtime animation
  15454. */
  15455. private _activeTargets;
  15456. private _currentActiveTarget;
  15457. private _directTarget;
  15458. /**
  15459. * The target path of the runtime animation
  15460. */
  15461. private _targetPath;
  15462. /**
  15463. * The weight of the runtime animation
  15464. */
  15465. private _weight;
  15466. /**
  15467. * The ratio offset of the runtime animation
  15468. */
  15469. private _ratioOffset;
  15470. /**
  15471. * The previous delay of the runtime animation
  15472. */
  15473. private _previousDelay;
  15474. /**
  15475. * The previous ratio of the runtime animation
  15476. */
  15477. private _previousRatio;
  15478. private _enableBlending;
  15479. private _keys;
  15480. private _minFrame;
  15481. private _maxFrame;
  15482. private _minValue;
  15483. private _maxValue;
  15484. private _targetIsArray;
  15485. /**
  15486. * Gets the current frame of the runtime animation
  15487. */
  15488. get currentFrame(): number;
  15489. /**
  15490. * Gets the weight of the runtime animation
  15491. */
  15492. get weight(): number;
  15493. /**
  15494. * Gets the current value of the runtime animation
  15495. */
  15496. get currentValue(): any;
  15497. /**
  15498. * Gets the target path of the runtime animation
  15499. */
  15500. get targetPath(): string;
  15501. /**
  15502. * Gets the actual target of the runtime animation
  15503. */
  15504. get target(): any;
  15505. /**
  15506. * Gets the additive state of the runtime animation
  15507. */
  15508. get isAdditive(): boolean;
  15509. /** @hidden */
  15510. _onLoop: () => void;
  15511. /**
  15512. * Create a new RuntimeAnimation object
  15513. * @param target defines the target of the animation
  15514. * @param animation defines the source animation object
  15515. * @param scene defines the hosting scene
  15516. * @param host defines the initiating Animatable
  15517. */
  15518. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15519. private _preparePath;
  15520. /**
  15521. * Gets the animation from the runtime animation
  15522. */
  15523. get animation(): Animation;
  15524. /**
  15525. * Resets the runtime animation to the beginning
  15526. * @param restoreOriginal defines whether to restore the target property to the original value
  15527. */
  15528. reset(restoreOriginal?: boolean): void;
  15529. /**
  15530. * Specifies if the runtime animation is stopped
  15531. * @returns Boolean specifying if the runtime animation is stopped
  15532. */
  15533. isStopped(): boolean;
  15534. /**
  15535. * Disposes of the runtime animation
  15536. */
  15537. dispose(): void;
  15538. /**
  15539. * Apply the interpolated value to the target
  15540. * @param currentValue defines the value computed by the animation
  15541. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15542. */
  15543. setValue(currentValue: any, weight: number): void;
  15544. private _getOriginalValues;
  15545. private _setValue;
  15546. /**
  15547. * Gets the loop pmode of the runtime animation
  15548. * @returns Loop Mode
  15549. */
  15550. private _getCorrectLoopMode;
  15551. /**
  15552. * Move the current animation to a given frame
  15553. * @param frame defines the frame to move to
  15554. */
  15555. goToFrame(frame: number): void;
  15556. /**
  15557. * @hidden Internal use only
  15558. */
  15559. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15560. /**
  15561. * Execute the current animation
  15562. * @param delay defines the delay to add to the current frame
  15563. * @param from defines the lower bound of the animation range
  15564. * @param to defines the upper bound of the animation range
  15565. * @param loop defines if the current animation must loop
  15566. * @param speedRatio defines the current speed ratio
  15567. * @param weight defines the weight of the animation (default is -1 so no weight)
  15568. * @param onLoop optional callback called when animation loops
  15569. * @returns a boolean indicating if the animation is running
  15570. */
  15571. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15572. }
  15573. }
  15574. declare module BABYLON {
  15575. /**
  15576. * Class used to store an actual running animation
  15577. */
  15578. export class Animatable {
  15579. /** defines the target object */
  15580. target: any;
  15581. /** defines the starting frame number (default is 0) */
  15582. fromFrame: number;
  15583. /** defines the ending frame number (default is 100) */
  15584. toFrame: number;
  15585. /** defines if the animation must loop (default is false) */
  15586. loopAnimation: boolean;
  15587. /** defines a callback to call when animation ends if it is not looping */
  15588. onAnimationEnd?: (() => void) | null | undefined;
  15589. /** defines a callback to call when animation loops */
  15590. onAnimationLoop?: (() => void) | null | undefined;
  15591. /** defines whether the animation should be evaluated additively */
  15592. isAdditive: boolean;
  15593. private _localDelayOffset;
  15594. private _pausedDelay;
  15595. private _runtimeAnimations;
  15596. private _paused;
  15597. private _scene;
  15598. private _speedRatio;
  15599. private _weight;
  15600. private _syncRoot;
  15601. /**
  15602. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15603. * This will only apply for non looping animation (default is true)
  15604. */
  15605. disposeOnEnd: boolean;
  15606. /**
  15607. * Gets a boolean indicating if the animation has started
  15608. */
  15609. animationStarted: boolean;
  15610. /**
  15611. * Observer raised when the animation ends
  15612. */
  15613. onAnimationEndObservable: Observable<Animatable>;
  15614. /**
  15615. * Observer raised when the animation loops
  15616. */
  15617. onAnimationLoopObservable: Observable<Animatable>;
  15618. /**
  15619. * Gets the root Animatable used to synchronize and normalize animations
  15620. */
  15621. get syncRoot(): Nullable<Animatable>;
  15622. /**
  15623. * Gets the current frame of the first RuntimeAnimation
  15624. * Used to synchronize Animatables
  15625. */
  15626. get masterFrame(): number;
  15627. /**
  15628. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15629. */
  15630. get weight(): number;
  15631. set weight(value: number);
  15632. /**
  15633. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15634. */
  15635. get speedRatio(): number;
  15636. set speedRatio(value: number);
  15637. /**
  15638. * Creates a new Animatable
  15639. * @param scene defines the hosting scene
  15640. * @param target defines the target object
  15641. * @param fromFrame defines the starting frame number (default is 0)
  15642. * @param toFrame defines the ending frame number (default is 100)
  15643. * @param loopAnimation defines if the animation must loop (default is false)
  15644. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15645. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15646. * @param animations defines a group of animation to add to the new Animatable
  15647. * @param onAnimationLoop defines a callback to call when animation loops
  15648. * @param isAdditive defines whether the animation should be evaluated additively
  15649. */
  15650. constructor(scene: Scene,
  15651. /** defines the target object */
  15652. target: any,
  15653. /** defines the starting frame number (default is 0) */
  15654. fromFrame?: number,
  15655. /** defines the ending frame number (default is 100) */
  15656. toFrame?: number,
  15657. /** defines if the animation must loop (default is false) */
  15658. loopAnimation?: boolean, speedRatio?: number,
  15659. /** defines a callback to call when animation ends if it is not looping */
  15660. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15661. /** defines a callback to call when animation loops */
  15662. onAnimationLoop?: (() => void) | null | undefined,
  15663. /** defines whether the animation should be evaluated additively */
  15664. isAdditive?: boolean);
  15665. /**
  15666. * Synchronize and normalize current Animatable with a source Animatable
  15667. * This is useful when using animation weights and when animations are not of the same length
  15668. * @param root defines the root Animatable to synchronize with
  15669. * @returns the current Animatable
  15670. */
  15671. syncWith(root: Animatable): Animatable;
  15672. /**
  15673. * Gets the list of runtime animations
  15674. * @returns an array of RuntimeAnimation
  15675. */
  15676. getAnimations(): RuntimeAnimation[];
  15677. /**
  15678. * Adds more animations to the current animatable
  15679. * @param target defines the target of the animations
  15680. * @param animations defines the new animations to add
  15681. */
  15682. appendAnimations(target: any, animations: Animation[]): void;
  15683. /**
  15684. * Gets the source animation for a specific property
  15685. * @param property defines the propertyu to look for
  15686. * @returns null or the source animation for the given property
  15687. */
  15688. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15689. /**
  15690. * Gets the runtime animation for a specific property
  15691. * @param property defines the propertyu to look for
  15692. * @returns null or the runtime animation for the given property
  15693. */
  15694. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15695. /**
  15696. * Resets the animatable to its original state
  15697. */
  15698. reset(): void;
  15699. /**
  15700. * Allows the animatable to blend with current running animations
  15701. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15702. * @param blendingSpeed defines the blending speed to use
  15703. */
  15704. enableBlending(blendingSpeed: number): void;
  15705. /**
  15706. * Disable animation blending
  15707. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15708. */
  15709. disableBlending(): void;
  15710. /**
  15711. * Jump directly to a given frame
  15712. * @param frame defines the frame to jump to
  15713. */
  15714. goToFrame(frame: number): void;
  15715. /**
  15716. * Pause the animation
  15717. */
  15718. pause(): void;
  15719. /**
  15720. * Restart the animation
  15721. */
  15722. restart(): void;
  15723. private _raiseOnAnimationEnd;
  15724. /**
  15725. * Stop and delete the current animation
  15726. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15727. * @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)
  15728. */
  15729. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15730. /**
  15731. * Wait asynchronously for the animation to end
  15732. * @returns a promise which will be fullfilled when the animation ends
  15733. */
  15734. waitAsync(): Promise<Animatable>;
  15735. /** @hidden */
  15736. _animate(delay: number): boolean;
  15737. }
  15738. interface Scene {
  15739. /** @hidden */
  15740. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15741. /** @hidden */
  15742. _processLateAnimationBindingsForMatrices(holder: {
  15743. totalWeight: number;
  15744. totalAdditiveWeight: number;
  15745. animations: RuntimeAnimation[];
  15746. additiveAnimations: RuntimeAnimation[];
  15747. originalValue: Matrix;
  15748. }): any;
  15749. /** @hidden */
  15750. _processLateAnimationBindingsForQuaternions(holder: {
  15751. totalWeight: number;
  15752. totalAdditiveWeight: number;
  15753. animations: RuntimeAnimation[];
  15754. additiveAnimations: RuntimeAnimation[];
  15755. originalValue: Quaternion;
  15756. }, refQuaternion: Quaternion): Quaternion;
  15757. /** @hidden */
  15758. _processLateAnimationBindings(): void;
  15759. /**
  15760. * Will start the animation sequence of a given target
  15761. * @param target defines the target
  15762. * @param from defines from which frame should animation start
  15763. * @param to defines until which frame should animation run.
  15764. * @param weight defines the weight to apply to the animation (1.0 by default)
  15765. * @param loop defines if the animation loops
  15766. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15767. * @param onAnimationEnd defines the function to be executed when the animation ends
  15768. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15769. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15770. * @param onAnimationLoop defines the callback to call when an animation loops
  15771. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15772. * @returns the animatable object created for this animation
  15773. */
  15774. 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;
  15775. /**
  15776. * Will start the animation sequence of a given target
  15777. * @param target defines the target
  15778. * @param from defines from which frame should animation start
  15779. * @param to defines until which frame should animation run.
  15780. * @param loop defines if the animation loops
  15781. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15782. * @param onAnimationEnd defines the function to be executed when the animation ends
  15783. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15784. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15785. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15786. * @param onAnimationLoop defines the callback to call when an animation loops
  15787. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15788. * @returns the animatable object created for this animation
  15789. */
  15790. 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;
  15791. /**
  15792. * Will start the animation sequence of a given target and its hierarchy
  15793. * @param target defines the target
  15794. * @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.
  15795. * @param from defines from which frame should animation start
  15796. * @param to defines until which frame should animation run.
  15797. * @param loop defines if the animation loops
  15798. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15799. * @param onAnimationEnd defines the function to be executed when the animation ends
  15800. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15801. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15802. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15803. * @param onAnimationLoop defines the callback to call when an animation loops
  15804. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15805. * @returns the list of created animatables
  15806. */
  15807. 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[];
  15808. /**
  15809. * Begin a new animation on a given node
  15810. * @param target defines the target where the animation will take place
  15811. * @param animations defines the list of animations to start
  15812. * @param from defines the initial value
  15813. * @param to defines the final value
  15814. * @param loop defines if you want animation to loop (off by default)
  15815. * @param speedRatio defines the speed ratio to apply to all animations
  15816. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15817. * @param onAnimationLoop defines the callback to call when an animation loops
  15818. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15819. * @returns the list of created animatables
  15820. */
  15821. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15822. /**
  15823. * Begin a new animation on a given node and its hierarchy
  15824. * @param target defines the root node where the animation will take place
  15825. * @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.
  15826. * @param animations defines the list of animations to start
  15827. * @param from defines the initial value
  15828. * @param to defines the final value
  15829. * @param loop defines if you want animation to loop (off by default)
  15830. * @param speedRatio defines the speed ratio to apply to all animations
  15831. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15832. * @param onAnimationLoop defines the callback to call when an animation loops
  15833. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15834. * @returns the list of animatables created for all nodes
  15835. */
  15836. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15837. /**
  15838. * Gets the animatable associated with a specific target
  15839. * @param target defines the target of the animatable
  15840. * @returns the required animatable if found
  15841. */
  15842. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15843. /**
  15844. * Gets all animatables associated with a given target
  15845. * @param target defines the target to look animatables for
  15846. * @returns an array of Animatables
  15847. */
  15848. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15849. /**
  15850. * Stops and removes all animations that have been applied to the scene
  15851. */
  15852. stopAllAnimations(): void;
  15853. /**
  15854. * Gets the current delta time used by animation engine
  15855. */
  15856. deltaTime: number;
  15857. }
  15858. interface Bone {
  15859. /**
  15860. * Copy an animation range from another bone
  15861. * @param source defines the source bone
  15862. * @param rangeName defines the range name to copy
  15863. * @param frameOffset defines the frame offset
  15864. * @param rescaleAsRequired defines if rescaling must be applied if required
  15865. * @param skelDimensionsRatio defines the scaling ratio
  15866. * @returns true if operation was successful
  15867. */
  15868. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15869. }
  15870. }
  15871. declare module BABYLON {
  15872. /**
  15873. * Class used to handle skinning animations
  15874. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15875. */
  15876. export class Skeleton implements IAnimatable {
  15877. /** defines the skeleton name */
  15878. name: string;
  15879. /** defines the skeleton Id */
  15880. id: string;
  15881. /**
  15882. * Defines the list of child bones
  15883. */
  15884. bones: Bone[];
  15885. /**
  15886. * Defines an estimate of the dimension of the skeleton at rest
  15887. */
  15888. dimensionsAtRest: Vector3;
  15889. /**
  15890. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15891. */
  15892. needInitialSkinMatrix: boolean;
  15893. /**
  15894. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15895. */
  15896. overrideMesh: Nullable<AbstractMesh>;
  15897. /**
  15898. * Gets the list of animations attached to this skeleton
  15899. */
  15900. animations: Array<Animation>;
  15901. private _scene;
  15902. private _isDirty;
  15903. private _transformMatrices;
  15904. private _transformMatrixTexture;
  15905. private _meshesWithPoseMatrix;
  15906. private _animatables;
  15907. private _identity;
  15908. private _synchronizedWithMesh;
  15909. private _ranges;
  15910. private _lastAbsoluteTransformsUpdateId;
  15911. private _canUseTextureForBones;
  15912. private _uniqueId;
  15913. /** @hidden */
  15914. _numBonesWithLinkedTransformNode: number;
  15915. /** @hidden */
  15916. _hasWaitingData: Nullable<boolean>;
  15917. /**
  15918. * Specifies if the skeleton should be serialized
  15919. */
  15920. doNotSerialize: boolean;
  15921. private _useTextureToStoreBoneMatrices;
  15922. /**
  15923. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15924. * Please note that this option is not available if the hardware does not support it
  15925. */
  15926. get useTextureToStoreBoneMatrices(): boolean;
  15927. set useTextureToStoreBoneMatrices(value: boolean);
  15928. private _animationPropertiesOverride;
  15929. /**
  15930. * Gets or sets the animation properties override
  15931. */
  15932. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15933. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15934. /**
  15935. * List of inspectable custom properties (used by the Inspector)
  15936. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15937. */
  15938. inspectableCustomProperties: IInspectable[];
  15939. /**
  15940. * An observable triggered before computing the skeleton's matrices
  15941. */
  15942. onBeforeComputeObservable: Observable<Skeleton>;
  15943. /**
  15944. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15945. */
  15946. get isUsingTextureForMatrices(): boolean;
  15947. /**
  15948. * Gets the unique ID of this skeleton
  15949. */
  15950. get uniqueId(): number;
  15951. /**
  15952. * Creates a new skeleton
  15953. * @param name defines the skeleton name
  15954. * @param id defines the skeleton Id
  15955. * @param scene defines the hosting scene
  15956. */
  15957. constructor(
  15958. /** defines the skeleton name */
  15959. name: string,
  15960. /** defines the skeleton Id */
  15961. id: string, scene: Scene);
  15962. /**
  15963. * Gets the current object class name.
  15964. * @return the class name
  15965. */
  15966. getClassName(): string;
  15967. /**
  15968. * Returns an array containing the root bones
  15969. * @returns an array containing the root bones
  15970. */
  15971. getChildren(): Array<Bone>;
  15972. /**
  15973. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15974. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15975. * @returns a Float32Array containing matrices data
  15976. */
  15977. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15978. /**
  15979. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15980. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15981. * @returns a raw texture containing the data
  15982. */
  15983. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15984. /**
  15985. * Gets the current hosting scene
  15986. * @returns a scene object
  15987. */
  15988. getScene(): Scene;
  15989. /**
  15990. * Gets a string representing the current skeleton data
  15991. * @param fullDetails defines a boolean indicating if we want a verbose version
  15992. * @returns a string representing the current skeleton data
  15993. */
  15994. toString(fullDetails?: boolean): string;
  15995. /**
  15996. * Get bone's index searching by name
  15997. * @param name defines bone's name to search for
  15998. * @return the indice of the bone. Returns -1 if not found
  15999. */
  16000. getBoneIndexByName(name: string): number;
  16001. /**
  16002. * Creater a new animation range
  16003. * @param name defines the name of the range
  16004. * @param from defines the start key
  16005. * @param to defines the end key
  16006. */
  16007. createAnimationRange(name: string, from: number, to: number): void;
  16008. /**
  16009. * Delete a specific animation range
  16010. * @param name defines the name of the range
  16011. * @param deleteFrames defines if frames must be removed as well
  16012. */
  16013. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16014. /**
  16015. * Gets a specific animation range
  16016. * @param name defines the name of the range to look for
  16017. * @returns the requested animation range or null if not found
  16018. */
  16019. getAnimationRange(name: string): Nullable<AnimationRange>;
  16020. /**
  16021. * Gets the list of all animation ranges defined on this skeleton
  16022. * @returns an array
  16023. */
  16024. getAnimationRanges(): Nullable<AnimationRange>[];
  16025. /**
  16026. * Copy animation range from a source skeleton.
  16027. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16028. * @param source defines the source skeleton
  16029. * @param name defines the name of the range to copy
  16030. * @param rescaleAsRequired defines if rescaling must be applied if required
  16031. * @returns true if operation was successful
  16032. */
  16033. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16034. /**
  16035. * Forces the skeleton to go to rest pose
  16036. */
  16037. returnToRest(): void;
  16038. private _getHighestAnimationFrame;
  16039. /**
  16040. * Begin a specific animation range
  16041. * @param name defines the name of the range to start
  16042. * @param loop defines if looping must be turned on (false by default)
  16043. * @param speedRatio defines the speed ratio to apply (1 by default)
  16044. * @param onAnimationEnd defines a callback which will be called when animation will end
  16045. * @returns a new animatable
  16046. */
  16047. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16048. /**
  16049. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16050. * @param skeleton defines the Skeleton containing the animation range to convert
  16051. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16052. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16053. * @returns the original skeleton
  16054. */
  16055. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16056. /** @hidden */
  16057. _markAsDirty(): void;
  16058. /** @hidden */
  16059. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16060. /** @hidden */
  16061. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16062. private _computeTransformMatrices;
  16063. /**
  16064. * Build all resources required to render a skeleton
  16065. */
  16066. prepare(): void;
  16067. /**
  16068. * Gets the list of animatables currently running for this skeleton
  16069. * @returns an array of animatables
  16070. */
  16071. getAnimatables(): IAnimatable[];
  16072. /**
  16073. * Clone the current skeleton
  16074. * @param name defines the name of the new skeleton
  16075. * @param id defines the id of the new skeleton
  16076. * @returns the new skeleton
  16077. */
  16078. clone(name: string, id?: string): Skeleton;
  16079. /**
  16080. * Enable animation blending for this skeleton
  16081. * @param blendingSpeed defines the blending speed to apply
  16082. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16083. */
  16084. enableBlending(blendingSpeed?: number): void;
  16085. /**
  16086. * Releases all resources associated with the current skeleton
  16087. */
  16088. dispose(): void;
  16089. /**
  16090. * Serialize the skeleton in a JSON object
  16091. * @returns a JSON object
  16092. */
  16093. serialize(): any;
  16094. /**
  16095. * Creates a new skeleton from serialized data
  16096. * @param parsedSkeleton defines the serialized data
  16097. * @param scene defines the hosting scene
  16098. * @returns a new skeleton
  16099. */
  16100. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16101. /**
  16102. * Compute all node absolute transforms
  16103. * @param forceUpdate defines if computation must be done even if cache is up to date
  16104. */
  16105. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16106. /**
  16107. * Gets the root pose matrix
  16108. * @returns a matrix
  16109. */
  16110. getPoseMatrix(): Nullable<Matrix>;
  16111. /**
  16112. * Sorts bones per internal index
  16113. */
  16114. sortBones(): void;
  16115. private _sortBones;
  16116. }
  16117. }
  16118. declare module BABYLON {
  16119. /**
  16120. * Creates an instance based on a source mesh.
  16121. */
  16122. export class InstancedMesh extends AbstractMesh {
  16123. private _sourceMesh;
  16124. private _currentLOD;
  16125. /** @hidden */
  16126. _indexInSourceMeshInstanceArray: number;
  16127. constructor(name: string, source: Mesh);
  16128. /**
  16129. * Returns the string "InstancedMesh".
  16130. */
  16131. getClassName(): string;
  16132. /** Gets the list of lights affecting that mesh */
  16133. get lightSources(): Light[];
  16134. _resyncLightSources(): void;
  16135. _resyncLightSource(light: Light): void;
  16136. _removeLightSource(light: Light, dispose: boolean): void;
  16137. /**
  16138. * If the source mesh receives shadows
  16139. */
  16140. get receiveShadows(): boolean;
  16141. /**
  16142. * The material of the source mesh
  16143. */
  16144. get material(): Nullable<Material>;
  16145. /**
  16146. * Visibility of the source mesh
  16147. */
  16148. get visibility(): number;
  16149. /**
  16150. * Skeleton of the source mesh
  16151. */
  16152. get skeleton(): Nullable<Skeleton>;
  16153. /**
  16154. * Rendering ground id of the source mesh
  16155. */
  16156. get renderingGroupId(): number;
  16157. set renderingGroupId(value: number);
  16158. /**
  16159. * Returns the total number of vertices (integer).
  16160. */
  16161. getTotalVertices(): number;
  16162. /**
  16163. * Returns a positive integer : the total number of indices in this mesh geometry.
  16164. * @returns the numner of indices or zero if the mesh has no geometry.
  16165. */
  16166. getTotalIndices(): number;
  16167. /**
  16168. * The source mesh of the instance
  16169. */
  16170. get sourceMesh(): Mesh;
  16171. /**
  16172. * Creates a new InstancedMesh object from the mesh model.
  16173. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16174. * @param name defines the name of the new instance
  16175. * @returns a new InstancedMesh
  16176. */
  16177. createInstance(name: string): InstancedMesh;
  16178. /**
  16179. * Is this node ready to be used/rendered
  16180. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16181. * @return {boolean} is it ready
  16182. */
  16183. isReady(completeCheck?: boolean): boolean;
  16184. /**
  16185. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16186. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16187. * @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.
  16188. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16189. */
  16190. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16191. /**
  16192. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16193. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16194. * The `data` are either a numeric array either a Float32Array.
  16195. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16196. * 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).
  16197. * Note that a new underlying VertexBuffer object is created each call.
  16198. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16199. *
  16200. * Possible `kind` values :
  16201. * - VertexBuffer.PositionKind
  16202. * - VertexBuffer.UVKind
  16203. * - VertexBuffer.UV2Kind
  16204. * - VertexBuffer.UV3Kind
  16205. * - VertexBuffer.UV4Kind
  16206. * - VertexBuffer.UV5Kind
  16207. * - VertexBuffer.UV6Kind
  16208. * - VertexBuffer.ColorKind
  16209. * - VertexBuffer.MatricesIndicesKind
  16210. * - VertexBuffer.MatricesIndicesExtraKind
  16211. * - VertexBuffer.MatricesWeightsKind
  16212. * - VertexBuffer.MatricesWeightsExtraKind
  16213. *
  16214. * Returns the Mesh.
  16215. */
  16216. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16217. /**
  16218. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16219. * If the mesh has no geometry, it is simply returned as it is.
  16220. * The `data` are either a numeric array either a Float32Array.
  16221. * No new underlying VertexBuffer object is created.
  16222. * 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.
  16223. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16224. *
  16225. * Possible `kind` values :
  16226. * - VertexBuffer.PositionKind
  16227. * - VertexBuffer.UVKind
  16228. * - VertexBuffer.UV2Kind
  16229. * - VertexBuffer.UV3Kind
  16230. * - VertexBuffer.UV4Kind
  16231. * - VertexBuffer.UV5Kind
  16232. * - VertexBuffer.UV6Kind
  16233. * - VertexBuffer.ColorKind
  16234. * - VertexBuffer.MatricesIndicesKind
  16235. * - VertexBuffer.MatricesIndicesExtraKind
  16236. * - VertexBuffer.MatricesWeightsKind
  16237. * - VertexBuffer.MatricesWeightsExtraKind
  16238. *
  16239. * Returns the Mesh.
  16240. */
  16241. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16242. /**
  16243. * Sets the mesh indices.
  16244. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16245. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16246. * This method creates a new index buffer each call.
  16247. * Returns the Mesh.
  16248. */
  16249. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16250. /**
  16251. * Boolean : True if the mesh owns the requested kind of data.
  16252. */
  16253. isVerticesDataPresent(kind: string): boolean;
  16254. /**
  16255. * Returns an array of indices (IndicesArray).
  16256. */
  16257. getIndices(): Nullable<IndicesArray>;
  16258. get _positions(): Nullable<Vector3[]>;
  16259. /**
  16260. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16261. * This means the mesh underlying bounding box and sphere are recomputed.
  16262. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16263. * @returns the current mesh
  16264. */
  16265. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16266. /** @hidden */
  16267. _preActivate(): InstancedMesh;
  16268. /** @hidden */
  16269. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16270. /** @hidden */
  16271. _postActivate(): void;
  16272. getWorldMatrix(): Matrix;
  16273. get isAnInstance(): boolean;
  16274. /**
  16275. * Returns the current associated LOD AbstractMesh.
  16276. */
  16277. getLOD(camera: Camera): AbstractMesh;
  16278. /** @hidden */
  16279. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16280. /** @hidden */
  16281. _syncSubMeshes(): InstancedMesh;
  16282. /** @hidden */
  16283. _generatePointsArray(): boolean;
  16284. /**
  16285. * Creates a new InstancedMesh from the current mesh.
  16286. * - name (string) : the cloned mesh name
  16287. * - newParent (optional Node) : the optional Node to parent the clone to.
  16288. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16289. *
  16290. * Returns the clone.
  16291. */
  16292. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16293. /**
  16294. * Disposes the InstancedMesh.
  16295. * Returns nothing.
  16296. */
  16297. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16298. }
  16299. interface Mesh {
  16300. /**
  16301. * Register a custom buffer that will be instanced
  16302. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16303. * @param kind defines the buffer kind
  16304. * @param stride defines the stride in floats
  16305. */
  16306. registerInstancedBuffer(kind: string, stride: number): void;
  16307. /**
  16308. * true to use the edge renderer for all instances of this mesh
  16309. */
  16310. edgesShareWithInstances: boolean;
  16311. /** @hidden */
  16312. _userInstancedBuffersStorage: {
  16313. data: {
  16314. [key: string]: Float32Array;
  16315. };
  16316. sizes: {
  16317. [key: string]: number;
  16318. };
  16319. vertexBuffers: {
  16320. [key: string]: Nullable<VertexBuffer>;
  16321. };
  16322. strides: {
  16323. [key: string]: number;
  16324. };
  16325. };
  16326. }
  16327. interface AbstractMesh {
  16328. /**
  16329. * Object used to store instanced buffers defined by user
  16330. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16331. */
  16332. instancedBuffers: {
  16333. [key: string]: any;
  16334. };
  16335. }
  16336. }
  16337. declare module BABYLON {
  16338. /**
  16339. * Defines the options associated with the creation of a shader material.
  16340. */
  16341. export interface IShaderMaterialOptions {
  16342. /**
  16343. * Does the material work in alpha blend mode
  16344. */
  16345. needAlphaBlending: boolean;
  16346. /**
  16347. * Does the material work in alpha test mode
  16348. */
  16349. needAlphaTesting: boolean;
  16350. /**
  16351. * The list of attribute names used in the shader
  16352. */
  16353. attributes: string[];
  16354. /**
  16355. * The list of unifrom names used in the shader
  16356. */
  16357. uniforms: string[];
  16358. /**
  16359. * The list of UBO names used in the shader
  16360. */
  16361. uniformBuffers: string[];
  16362. /**
  16363. * The list of sampler names used in the shader
  16364. */
  16365. samplers: string[];
  16366. /**
  16367. * The list of defines used in the shader
  16368. */
  16369. defines: string[];
  16370. }
  16371. /**
  16372. * 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.
  16373. *
  16374. * This returned material effects how the mesh will look based on the code in the shaders.
  16375. *
  16376. * @see https://doc.babylonjs.com/how_to/shader_material
  16377. */
  16378. export class ShaderMaterial extends Material {
  16379. private _shaderPath;
  16380. private _options;
  16381. private _textures;
  16382. private _textureArrays;
  16383. private _floats;
  16384. private _ints;
  16385. private _floatsArrays;
  16386. private _colors3;
  16387. private _colors3Arrays;
  16388. private _colors4;
  16389. private _colors4Arrays;
  16390. private _vectors2;
  16391. private _vectors3;
  16392. private _vectors4;
  16393. private _matrices;
  16394. private _matrixArrays;
  16395. private _matrices3x3;
  16396. private _matrices2x2;
  16397. private _vectors2Arrays;
  16398. private _vectors3Arrays;
  16399. private _vectors4Arrays;
  16400. private _cachedWorldViewMatrix;
  16401. private _cachedWorldViewProjectionMatrix;
  16402. private _renderId;
  16403. private _multiview;
  16404. private _cachedDefines;
  16405. /** Define the Url to load snippets */
  16406. static SnippetUrl: string;
  16407. /** Snippet ID if the material was created from the snippet server */
  16408. snippetId: string;
  16409. /**
  16410. * Instantiate a new shader material.
  16411. * 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.
  16412. * This returned material effects how the mesh will look based on the code in the shaders.
  16413. * @see https://doc.babylonjs.com/how_to/shader_material
  16414. * @param name Define the name of the material in the scene
  16415. * @param scene Define the scene the material belongs to
  16416. * @param shaderPath Defines the route to the shader code in one of three ways:
  16417. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16418. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16419. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16420. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16421. * @param options Define the options used to create the shader
  16422. */
  16423. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16424. /**
  16425. * Gets the shader path used to define the shader code
  16426. * It can be modified to trigger a new compilation
  16427. */
  16428. get shaderPath(): any;
  16429. /**
  16430. * Sets the shader path used to define the shader code
  16431. * It can be modified to trigger a new compilation
  16432. */
  16433. set shaderPath(shaderPath: any);
  16434. /**
  16435. * Gets the options used to compile the shader.
  16436. * They can be modified to trigger a new compilation
  16437. */
  16438. get options(): IShaderMaterialOptions;
  16439. /**
  16440. * Gets the current class name of the material e.g. "ShaderMaterial"
  16441. * Mainly use in serialization.
  16442. * @returns the class name
  16443. */
  16444. getClassName(): string;
  16445. /**
  16446. * Specifies if the material will require alpha blending
  16447. * @returns a boolean specifying if alpha blending is needed
  16448. */
  16449. needAlphaBlending(): boolean;
  16450. /**
  16451. * Specifies if this material should be rendered in alpha test mode
  16452. * @returns a boolean specifying if an alpha test is needed.
  16453. */
  16454. needAlphaTesting(): boolean;
  16455. private _checkUniform;
  16456. /**
  16457. * Set a texture in the shader.
  16458. * @param name Define the name of the uniform samplers as defined in the shader
  16459. * @param texture Define the texture to bind to this sampler
  16460. * @return the material itself allowing "fluent" like uniform updates
  16461. */
  16462. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16463. /**
  16464. * Set a texture array in the shader.
  16465. * @param name Define the name of the uniform sampler array as defined in the shader
  16466. * @param textures Define the list of textures to bind to this sampler
  16467. * @return the material itself allowing "fluent" like uniform updates
  16468. */
  16469. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16470. /**
  16471. * Set a float in the shader.
  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. setFloat(name: string, value: number): ShaderMaterial;
  16477. /**
  16478. * Set a int in the shader.
  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. setInt(name: string, value: number): ShaderMaterial;
  16484. /**
  16485. * Set an array of floats in the shader.
  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. setFloats(name: string, value: number[]): ShaderMaterial;
  16491. /**
  16492. * Set a vec3 in the shader from a Color3.
  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. setColor3(name: string, value: Color3): ShaderMaterial;
  16498. /**
  16499. * Set a vec3 array in the shader from a Color3 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. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16505. /**
  16506. * Set a vec4 in the shader from a Color4.
  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. setColor4(name: string, value: Color4): ShaderMaterial;
  16512. /**
  16513. * Set a vec4 array in the shader from a Color4 array.
  16514. * @param name Define the name of the uniform as defined in the shader
  16515. * @param value Define the value to give to the uniform
  16516. * @return the material itself allowing "fluent" like uniform updates
  16517. */
  16518. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16519. /**
  16520. * Set a vec2 in the shader from a Vector2.
  16521. * @param name Define the name of the uniform as defined in the shader
  16522. * @param value Define the value to give to the uniform
  16523. * @return the material itself allowing "fluent" like uniform updates
  16524. */
  16525. setVector2(name: string, value: Vector2): ShaderMaterial;
  16526. /**
  16527. * Set a vec3 in the shader from a Vector3.
  16528. * @param name Define the name of the uniform as defined in the shader
  16529. * @param value Define the value to give to the uniform
  16530. * @return the material itself allowing "fluent" like uniform updates
  16531. */
  16532. setVector3(name: string, value: Vector3): ShaderMaterial;
  16533. /**
  16534. * Set a vec4 in the shader from a Vector4.
  16535. * @param name Define the name of the uniform as defined in the shader
  16536. * @param value Define the value to give to the uniform
  16537. * @return the material itself allowing "fluent" like uniform updates
  16538. */
  16539. setVector4(name: string, value: Vector4): ShaderMaterial;
  16540. /**
  16541. * Set a mat4 in the shader from a Matrix.
  16542. * @param name Define the name of the uniform as defined in the shader
  16543. * @param value Define the value to give to the uniform
  16544. * @return the material itself allowing "fluent" like uniform updates
  16545. */
  16546. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16547. /**
  16548. * Set a float32Array in the shader from a matrix array.
  16549. * @param name Define the name of the uniform as defined in the shader
  16550. * @param value Define the value to give to the uniform
  16551. * @return the material itself allowing "fluent" like uniform updates
  16552. */
  16553. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16554. /**
  16555. * Set a mat3 in the shader from a Float32Array.
  16556. * @param name Define the name of the uniform as defined in the shader
  16557. * @param value Define the value to give to the uniform
  16558. * @return the material itself allowing "fluent" like uniform updates
  16559. */
  16560. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16561. /**
  16562. * Set a mat2 in the shader from a Float32Array.
  16563. * @param name Define the name of the uniform as defined in the shader
  16564. * @param value Define the value to give to the uniform
  16565. * @return the material itself allowing "fluent" like uniform updates
  16566. */
  16567. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16568. /**
  16569. * Set a vec2 array in the shader from a number array.
  16570. * @param name Define the name of the uniform as defined in the shader
  16571. * @param value Define the value to give to the uniform
  16572. * @return the material itself allowing "fluent" like uniform updates
  16573. */
  16574. setArray2(name: string, value: number[]): ShaderMaterial;
  16575. /**
  16576. * Set a vec3 array in the shader from a number array.
  16577. * @param name Define the name of the uniform as defined in the shader
  16578. * @param value Define the value to give to the uniform
  16579. * @return the material itself allowing "fluent" like uniform updates
  16580. */
  16581. setArray3(name: string, value: number[]): ShaderMaterial;
  16582. /**
  16583. * Set a vec4 array in the shader from a number array.
  16584. * @param name Define the name of the uniform as defined in the shader
  16585. * @param value Define the value to give to the uniform
  16586. * @return the material itself allowing "fluent" like uniform updates
  16587. */
  16588. setArray4(name: string, value: number[]): ShaderMaterial;
  16589. private _checkCache;
  16590. /**
  16591. * Specifies that the submesh is ready to be used
  16592. * @param mesh defines the mesh to check
  16593. * @param subMesh defines which submesh to check
  16594. * @param useInstances specifies that instances should be used
  16595. * @returns a boolean indicating that the submesh is ready or not
  16596. */
  16597. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16598. /**
  16599. * Checks if the material is ready to render the requested mesh
  16600. * @param mesh Define the mesh to render
  16601. * @param useInstances Define whether or not the material is used with instances
  16602. * @returns true if ready, otherwise false
  16603. */
  16604. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16605. /**
  16606. * Binds the world matrix to the material
  16607. * @param world defines the world transformation matrix
  16608. * @param effectOverride - If provided, use this effect instead of internal effect
  16609. */
  16610. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16611. /**
  16612. * Binds the submesh to this material by preparing the effect and shader to draw
  16613. * @param world defines the world transformation matrix
  16614. * @param mesh defines the mesh containing the submesh
  16615. * @param subMesh defines the submesh to bind the material to
  16616. */
  16617. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16618. /**
  16619. * Binds the material to the mesh
  16620. * @param world defines the world transformation matrix
  16621. * @param mesh defines the mesh to bind the material to
  16622. * @param effectOverride - If provided, use this effect instead of internal effect
  16623. */
  16624. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16625. protected _afterBind(mesh?: Mesh): void;
  16626. /**
  16627. * Gets the active textures from the material
  16628. * @returns an array of textures
  16629. */
  16630. getActiveTextures(): BaseTexture[];
  16631. /**
  16632. * Specifies if the material uses a texture
  16633. * @param texture defines the texture to check against the material
  16634. * @returns a boolean specifying if the material uses the texture
  16635. */
  16636. hasTexture(texture: BaseTexture): boolean;
  16637. /**
  16638. * Makes a duplicate of the material, and gives it a new name
  16639. * @param name defines the new name for the duplicated material
  16640. * @returns the cloned material
  16641. */
  16642. clone(name: string): ShaderMaterial;
  16643. /**
  16644. * Disposes the material
  16645. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16646. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16647. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16648. */
  16649. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16650. /**
  16651. * Serializes this material in a JSON representation
  16652. * @returns the serialized material object
  16653. */
  16654. serialize(): any;
  16655. /**
  16656. * Creates a shader material from parsed shader material data
  16657. * @param source defines the JSON represnetation of the material
  16658. * @param scene defines the hosting scene
  16659. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16660. * @returns a new material
  16661. */
  16662. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16663. /**
  16664. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16665. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16666. * @param url defines the url to load from
  16667. * @param scene defines the hosting scene
  16668. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16669. * @returns a promise that will resolve to the new ShaderMaterial
  16670. */
  16671. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16672. /**
  16673. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16674. * @param snippetId defines the snippet to load
  16675. * @param scene defines the hosting scene
  16676. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16677. * @returns a promise that will resolve to the new ShaderMaterial
  16678. */
  16679. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16680. }
  16681. }
  16682. declare module BABYLON {
  16683. /** @hidden */
  16684. export var colorPixelShader: {
  16685. name: string;
  16686. shader: string;
  16687. };
  16688. }
  16689. declare module BABYLON {
  16690. /** @hidden */
  16691. export var colorVertexShader: {
  16692. name: string;
  16693. shader: string;
  16694. };
  16695. }
  16696. declare module BABYLON {
  16697. /**
  16698. * Line mesh
  16699. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16700. */
  16701. export class LinesMesh extends Mesh {
  16702. /**
  16703. * If vertex color should be applied to the mesh
  16704. */
  16705. readonly useVertexColor?: boolean | undefined;
  16706. /**
  16707. * If vertex alpha should be applied to the mesh
  16708. */
  16709. readonly useVertexAlpha?: boolean | undefined;
  16710. /**
  16711. * Color of the line (Default: White)
  16712. */
  16713. color: Color3;
  16714. /**
  16715. * Alpha of the line (Default: 1)
  16716. */
  16717. alpha: number;
  16718. /**
  16719. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16720. * This margin is expressed in world space coordinates, so its value may vary.
  16721. * Default value is 0.1
  16722. */
  16723. intersectionThreshold: number;
  16724. private _colorShader;
  16725. private color4;
  16726. /**
  16727. * Creates a new LinesMesh
  16728. * @param name defines the name
  16729. * @param scene defines the hosting scene
  16730. * @param parent defines the parent mesh if any
  16731. * @param source defines the optional source LinesMesh used to clone data from
  16732. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16733. * When false, achieved by calling a clone(), also passing False.
  16734. * This will make creation of children, recursive.
  16735. * @param useVertexColor defines if this LinesMesh supports vertex color
  16736. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16737. */
  16738. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16739. /**
  16740. * If vertex color should be applied to the mesh
  16741. */
  16742. useVertexColor?: boolean | undefined,
  16743. /**
  16744. * If vertex alpha should be applied to the mesh
  16745. */
  16746. useVertexAlpha?: boolean | undefined);
  16747. private _addClipPlaneDefine;
  16748. private _removeClipPlaneDefine;
  16749. isReady(): boolean;
  16750. /**
  16751. * Returns the string "LineMesh"
  16752. */
  16753. getClassName(): string;
  16754. /**
  16755. * @hidden
  16756. */
  16757. get material(): Material;
  16758. /**
  16759. * @hidden
  16760. */
  16761. set material(value: Material);
  16762. /**
  16763. * @hidden
  16764. */
  16765. get checkCollisions(): boolean;
  16766. /** @hidden */
  16767. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16768. /** @hidden */
  16769. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16770. /**
  16771. * Disposes of the line mesh
  16772. * @param doNotRecurse If children should be disposed
  16773. */
  16774. dispose(doNotRecurse?: boolean): void;
  16775. /**
  16776. * Returns a new LineMesh object cloned from the current one.
  16777. */
  16778. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16779. /**
  16780. * Creates a new InstancedLinesMesh object from the mesh model.
  16781. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16782. * @param name defines the name of the new instance
  16783. * @returns a new InstancedLinesMesh
  16784. */
  16785. createInstance(name: string): InstancedLinesMesh;
  16786. }
  16787. /**
  16788. * Creates an instance based on a source LinesMesh
  16789. */
  16790. export class InstancedLinesMesh extends InstancedMesh {
  16791. /**
  16792. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16793. * This margin is expressed in world space coordinates, so its value may vary.
  16794. * Initilized with the intersectionThreshold value of the source LinesMesh
  16795. */
  16796. intersectionThreshold: number;
  16797. constructor(name: string, source: LinesMesh);
  16798. /**
  16799. * Returns the string "InstancedLinesMesh".
  16800. */
  16801. getClassName(): string;
  16802. }
  16803. }
  16804. declare module BABYLON {
  16805. /** @hidden */
  16806. export var linePixelShader: {
  16807. name: string;
  16808. shader: string;
  16809. };
  16810. }
  16811. declare module BABYLON {
  16812. /** @hidden */
  16813. export var lineVertexShader: {
  16814. name: string;
  16815. shader: string;
  16816. };
  16817. }
  16818. declare module BABYLON {
  16819. interface Scene {
  16820. /** @hidden */
  16821. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  16822. }
  16823. interface AbstractMesh {
  16824. /**
  16825. * Gets the edgesRenderer associated with the mesh
  16826. */
  16827. edgesRenderer: Nullable<EdgesRenderer>;
  16828. }
  16829. interface LinesMesh {
  16830. /**
  16831. * Enables the edge rendering mode on the mesh.
  16832. * This mode makes the mesh edges visible
  16833. * @param epsilon defines the maximal distance between two angles to detect a face
  16834. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16835. * @returns the currentAbstractMesh
  16836. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16837. */
  16838. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16839. }
  16840. interface InstancedLinesMesh {
  16841. /**
  16842. * Enables the edge rendering mode on the mesh.
  16843. * This mode makes the mesh edges visible
  16844. * @param epsilon defines the maximal distance between two angles to detect a face
  16845. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16846. * @returns the current InstancedLinesMesh
  16847. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16848. */
  16849. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16850. }
  16851. /**
  16852. * Defines the minimum contract an Edges renderer should follow.
  16853. */
  16854. export interface IEdgesRenderer extends IDisposable {
  16855. /**
  16856. * Gets or sets a boolean indicating if the edgesRenderer is active
  16857. */
  16858. isEnabled: boolean;
  16859. /**
  16860. * Renders the edges of the attached mesh,
  16861. */
  16862. render(): void;
  16863. /**
  16864. * Checks wether or not the edges renderer is ready to render.
  16865. * @return true if ready, otherwise false.
  16866. */
  16867. isReady(): boolean;
  16868. /**
  16869. * List of instances to render in case the source mesh has instances
  16870. */
  16871. customInstances: SmartArray<Matrix>;
  16872. }
  16873. /**
  16874. * Defines the additional options of the edges renderer
  16875. */
  16876. export interface IEdgesRendererOptions {
  16877. /**
  16878. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  16879. * If not defined, the default value is true
  16880. */
  16881. useAlternateEdgeFinder?: boolean;
  16882. /**
  16883. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  16884. * If not defined, the default value is true.
  16885. * 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)
  16886. * This option is used only if useAlternateEdgeFinder = true
  16887. */
  16888. useFastVertexMerger?: boolean;
  16889. /**
  16890. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  16891. * The default value is 1e-6
  16892. * This option is used only if useAlternateEdgeFinder = true
  16893. */
  16894. epsilonVertexMerge?: number;
  16895. /**
  16896. * 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
  16897. * 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.
  16898. * This option is used only if useAlternateEdgeFinder = true
  16899. */
  16900. applyTessellation?: boolean;
  16901. /**
  16902. * 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
  16903. * The default value is 1e-6
  16904. * This option is used only if useAlternateEdgeFinder = true
  16905. */
  16906. epsilonVertexAligned?: number;
  16907. }
  16908. /**
  16909. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16910. */
  16911. export class EdgesRenderer implements IEdgesRenderer {
  16912. /**
  16913. * Define the size of the edges with an orthographic camera
  16914. */
  16915. edgesWidthScalerForOrthographic: number;
  16916. /**
  16917. * Define the size of the edges with a perspective camera
  16918. */
  16919. edgesWidthScalerForPerspective: number;
  16920. protected _source: AbstractMesh;
  16921. protected _linesPositions: number[];
  16922. protected _linesNormals: number[];
  16923. protected _linesIndices: number[];
  16924. protected _epsilon: number;
  16925. protected _indicesCount: number;
  16926. protected _lineShader: ShaderMaterial;
  16927. protected _ib: DataBuffer;
  16928. protected _buffers: {
  16929. [key: string]: Nullable<VertexBuffer>;
  16930. };
  16931. protected _buffersForInstances: {
  16932. [key: string]: Nullable<VertexBuffer>;
  16933. };
  16934. protected _checkVerticesInsteadOfIndices: boolean;
  16935. protected _options: Nullable<IEdgesRendererOptions>;
  16936. private _meshRebuildObserver;
  16937. private _meshDisposeObserver;
  16938. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16939. isEnabled: boolean;
  16940. /**
  16941. * List of instances to render in case the source mesh has instances
  16942. */
  16943. customInstances: SmartArray<Matrix>;
  16944. private static GetShader;
  16945. /**
  16946. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16947. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16948. * @param source Mesh used to create edges
  16949. * @param epsilon sum of angles in adjacency to check for edge
  16950. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  16951. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16952. * @param options The options to apply when generating the edges
  16953. */
  16954. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  16955. protected _prepareRessources(): void;
  16956. /** @hidden */
  16957. _rebuild(): void;
  16958. /**
  16959. * Releases the required resources for the edges renderer
  16960. */
  16961. dispose(): void;
  16962. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16963. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16964. /**
  16965. * Checks if the pair of p0 and p1 is en edge
  16966. * @param faceIndex
  16967. * @param edge
  16968. * @param faceNormals
  16969. * @param p0
  16970. * @param p1
  16971. * @private
  16972. */
  16973. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16974. /**
  16975. * push line into the position, normal and index buffer
  16976. * @protected
  16977. */
  16978. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16979. /**
  16980. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  16981. */
  16982. private _tessellateTriangle;
  16983. private _generateEdgesLinesAlternate;
  16984. /**
  16985. * Generates lines edges from adjacencjes
  16986. * @private
  16987. */
  16988. _generateEdgesLines(): void;
  16989. /**
  16990. * Checks wether or not the edges renderer is ready to render.
  16991. * @return true if ready, otherwise false.
  16992. */
  16993. isReady(): boolean;
  16994. /**
  16995. * Renders the edges of the attached mesh,
  16996. */
  16997. render(): void;
  16998. }
  16999. /**
  17000. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17001. */
  17002. export class LineEdgesRenderer extends EdgesRenderer {
  17003. /**
  17004. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17005. * @param source LineMesh used to generate edges
  17006. * @param epsilon not important (specified angle for edge detection)
  17007. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17008. */
  17009. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17010. /**
  17011. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17012. */
  17013. _generateEdgesLines(): void;
  17014. }
  17015. }
  17016. declare module BABYLON {
  17017. /**
  17018. * This represents the object necessary to create a rendering group.
  17019. * This is exclusively used and created by the rendering manager.
  17020. * To modify the behavior, you use the available helpers in your scene or meshes.
  17021. * @hidden
  17022. */
  17023. export class RenderingGroup {
  17024. index: number;
  17025. private static _zeroVector;
  17026. private _scene;
  17027. private _opaqueSubMeshes;
  17028. private _transparentSubMeshes;
  17029. private _alphaTestSubMeshes;
  17030. private _depthOnlySubMeshes;
  17031. private _particleSystems;
  17032. private _spriteManagers;
  17033. private _opaqueSortCompareFn;
  17034. private _alphaTestSortCompareFn;
  17035. private _transparentSortCompareFn;
  17036. private _renderOpaque;
  17037. private _renderAlphaTest;
  17038. private _renderTransparent;
  17039. /** @hidden */
  17040. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17041. onBeforeTransparentRendering: () => void;
  17042. /**
  17043. * Set the opaque sort comparison function.
  17044. * If null the sub meshes will be render in the order they were created
  17045. */
  17046. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17047. /**
  17048. * Set the alpha test sort comparison function.
  17049. * If null the sub meshes will be render in the order they were created
  17050. */
  17051. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17052. /**
  17053. * Set the transparent sort comparison function.
  17054. * If null the sub meshes will be render in the order they were created
  17055. */
  17056. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17057. /**
  17058. * Creates a new rendering group.
  17059. * @param index The rendering group index
  17060. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17061. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17062. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17063. */
  17064. 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>);
  17065. /**
  17066. * Render all the sub meshes contained in the group.
  17067. * @param customRenderFunction Used to override the default render behaviour of the group.
  17068. * @returns true if rendered some submeshes.
  17069. */
  17070. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17071. /**
  17072. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17073. * @param subMeshes The submeshes to render
  17074. */
  17075. private renderOpaqueSorted;
  17076. /**
  17077. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17078. * @param subMeshes The submeshes to render
  17079. */
  17080. private renderAlphaTestSorted;
  17081. /**
  17082. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17083. * @param subMeshes The submeshes to render
  17084. */
  17085. private renderTransparentSorted;
  17086. /**
  17087. * Renders the submeshes in a specified order.
  17088. * @param subMeshes The submeshes to sort before render
  17089. * @param sortCompareFn The comparison function use to sort
  17090. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17091. * @param transparent Specifies to activate blending if true
  17092. */
  17093. private static renderSorted;
  17094. /**
  17095. * Renders the submeshes in the order they were dispatched (no sort applied).
  17096. * @param subMeshes The submeshes to render
  17097. */
  17098. private static renderUnsorted;
  17099. /**
  17100. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17101. * are rendered back to front if in the same alpha index.
  17102. *
  17103. * @param a The first submesh
  17104. * @param b The second submesh
  17105. * @returns The result of the comparison
  17106. */
  17107. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17108. /**
  17109. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17110. * are rendered back to front.
  17111. *
  17112. * @param a The first submesh
  17113. * @param b The second submesh
  17114. * @returns The result of the comparison
  17115. */
  17116. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17117. /**
  17118. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17119. * are rendered front to back (prevent overdraw).
  17120. *
  17121. * @param a The first submesh
  17122. * @param b The second submesh
  17123. * @returns The result of the comparison
  17124. */
  17125. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17126. /**
  17127. * Resets the different lists of submeshes to prepare a new frame.
  17128. */
  17129. prepare(): void;
  17130. dispose(): void;
  17131. /**
  17132. * Inserts the submesh in its correct queue depending on its material.
  17133. * @param subMesh The submesh to dispatch
  17134. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17135. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17136. */
  17137. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17138. dispatchSprites(spriteManager: ISpriteManager): void;
  17139. dispatchParticles(particleSystem: IParticleSystem): void;
  17140. private _renderParticles;
  17141. private _renderSprites;
  17142. }
  17143. }
  17144. declare module BABYLON {
  17145. /**
  17146. * Interface describing the different options available in the rendering manager
  17147. * regarding Auto Clear between groups.
  17148. */
  17149. export interface IRenderingManagerAutoClearSetup {
  17150. /**
  17151. * Defines whether or not autoclear is enable.
  17152. */
  17153. autoClear: boolean;
  17154. /**
  17155. * Defines whether or not to autoclear the depth buffer.
  17156. */
  17157. depth: boolean;
  17158. /**
  17159. * Defines whether or not to autoclear the stencil buffer.
  17160. */
  17161. stencil: boolean;
  17162. }
  17163. /**
  17164. * This class is used by the onRenderingGroupObservable
  17165. */
  17166. export class RenderingGroupInfo {
  17167. /**
  17168. * The Scene that being rendered
  17169. */
  17170. scene: Scene;
  17171. /**
  17172. * The camera currently used for the rendering pass
  17173. */
  17174. camera: Nullable<Camera>;
  17175. /**
  17176. * The ID of the renderingGroup being processed
  17177. */
  17178. renderingGroupId: number;
  17179. }
  17180. /**
  17181. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17182. * It is enable to manage the different groups as well as the different necessary sort functions.
  17183. * This should not be used directly aside of the few static configurations
  17184. */
  17185. export class RenderingManager {
  17186. /**
  17187. * The max id used for rendering groups (not included)
  17188. */
  17189. static MAX_RENDERINGGROUPS: number;
  17190. /**
  17191. * The min id used for rendering groups (included)
  17192. */
  17193. static MIN_RENDERINGGROUPS: number;
  17194. /**
  17195. * Used to globally prevent autoclearing scenes.
  17196. */
  17197. static AUTOCLEAR: boolean;
  17198. /**
  17199. * @hidden
  17200. */
  17201. _useSceneAutoClearSetup: boolean;
  17202. private _scene;
  17203. private _renderingGroups;
  17204. private _depthStencilBufferAlreadyCleaned;
  17205. private _autoClearDepthStencil;
  17206. private _customOpaqueSortCompareFn;
  17207. private _customAlphaTestSortCompareFn;
  17208. private _customTransparentSortCompareFn;
  17209. private _renderingGroupInfo;
  17210. /**
  17211. * Instantiates a new rendering group for a particular scene
  17212. * @param scene Defines the scene the groups belongs to
  17213. */
  17214. constructor(scene: Scene);
  17215. private _clearDepthStencilBuffer;
  17216. /**
  17217. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17218. * @hidden
  17219. */
  17220. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17221. /**
  17222. * Resets the different information of the group to prepare a new frame
  17223. * @hidden
  17224. */
  17225. reset(): void;
  17226. /**
  17227. * Dispose and release the group and its associated resources.
  17228. * @hidden
  17229. */
  17230. dispose(): void;
  17231. /**
  17232. * Clear the info related to rendering groups preventing retention points during dispose.
  17233. */
  17234. freeRenderingGroups(): void;
  17235. private _prepareRenderingGroup;
  17236. /**
  17237. * Add a sprite manager to the rendering manager in order to render it this frame.
  17238. * @param spriteManager Define the sprite manager to render
  17239. */
  17240. dispatchSprites(spriteManager: ISpriteManager): void;
  17241. /**
  17242. * Add a particle system to the rendering manager in order to render it this frame.
  17243. * @param particleSystem Define the particle system to render
  17244. */
  17245. dispatchParticles(particleSystem: IParticleSystem): void;
  17246. /**
  17247. * Add a submesh to the manager in order to render it this frame
  17248. * @param subMesh The submesh to dispatch
  17249. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17250. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17251. */
  17252. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17253. /**
  17254. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17255. * This allowed control for front to back rendering or reversly depending of the special needs.
  17256. *
  17257. * @param renderingGroupId The rendering group id corresponding to its index
  17258. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17259. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17260. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17261. */
  17262. 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;
  17263. /**
  17264. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17265. *
  17266. * @param renderingGroupId The rendering group id corresponding to its index
  17267. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17268. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17269. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17270. */
  17271. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17272. /**
  17273. * Gets the current auto clear configuration for one rendering group of the rendering
  17274. * manager.
  17275. * @param index the rendering group index to get the information for
  17276. * @returns The auto clear setup for the requested rendering group
  17277. */
  17278. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17279. }
  17280. }
  17281. declare module BABYLON {
  17282. /**
  17283. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17284. */
  17285. export interface ICustomShaderOptions {
  17286. /**
  17287. * Gets or sets the custom shader name to use
  17288. */
  17289. shaderName: string;
  17290. /**
  17291. * The list of attribute names used in the shader
  17292. */
  17293. attributes?: string[];
  17294. /**
  17295. * The list of unifrom names used in the shader
  17296. */
  17297. uniforms?: string[];
  17298. /**
  17299. * The list of sampler names used in the shader
  17300. */
  17301. samplers?: string[];
  17302. /**
  17303. * The list of defines used in the shader
  17304. */
  17305. defines?: string[];
  17306. }
  17307. /**
  17308. * Interface to implement to create a shadow generator compatible with BJS.
  17309. */
  17310. export interface IShadowGenerator {
  17311. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17312. id: string;
  17313. /**
  17314. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17315. * @returns The render target texture if present otherwise, null
  17316. */
  17317. getShadowMap(): Nullable<RenderTargetTexture>;
  17318. /**
  17319. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17320. * @param subMesh The submesh we want to render in the shadow map
  17321. * @param useInstances Defines wether will draw in the map using instances
  17322. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17323. * @returns true if ready otherwise, false
  17324. */
  17325. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17326. /**
  17327. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17328. * @param defines Defines of the material we want to update
  17329. * @param lightIndex Index of the light in the enabled light list of the material
  17330. */
  17331. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17332. /**
  17333. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17334. * defined in the generator but impacting the effect).
  17335. * It implies the unifroms available on the materials are the standard BJS ones.
  17336. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17337. * @param effect The effect we are binfing the information for
  17338. */
  17339. bindShadowLight(lightIndex: string, effect: Effect): void;
  17340. /**
  17341. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17342. * (eq to shadow prjection matrix * light transform matrix)
  17343. * @returns The transform matrix used to create the shadow map
  17344. */
  17345. getTransformMatrix(): Matrix;
  17346. /**
  17347. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17348. * Cube and 2D textures for instance.
  17349. */
  17350. recreateShadowMap(): void;
  17351. /**
  17352. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17353. * @param onCompiled Callback triggered at the and of the effects compilation
  17354. * @param options Sets of optional options forcing the compilation with different modes
  17355. */
  17356. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17357. useInstances: boolean;
  17358. }>): void;
  17359. /**
  17360. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17361. * @param options Sets of optional options forcing the compilation with different modes
  17362. * @returns A promise that resolves when the compilation completes
  17363. */
  17364. forceCompilationAsync(options?: Partial<{
  17365. useInstances: boolean;
  17366. }>): Promise<void>;
  17367. /**
  17368. * Serializes the shadow generator setup to a json object.
  17369. * @returns The serialized JSON object
  17370. */
  17371. serialize(): any;
  17372. /**
  17373. * Disposes the Shadow map and related Textures and effects.
  17374. */
  17375. dispose(): void;
  17376. }
  17377. /**
  17378. * Default implementation IShadowGenerator.
  17379. * This is the main object responsible of generating shadows in the framework.
  17380. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17381. */
  17382. export class ShadowGenerator implements IShadowGenerator {
  17383. /**
  17384. * Name of the shadow generator class
  17385. */
  17386. static CLASSNAME: string;
  17387. /**
  17388. * Shadow generator mode None: no filtering applied.
  17389. */
  17390. static readonly FILTER_NONE: number;
  17391. /**
  17392. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17393. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17394. */
  17395. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17396. /**
  17397. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17398. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17399. */
  17400. static readonly FILTER_POISSONSAMPLING: number;
  17401. /**
  17402. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17403. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17404. */
  17405. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17406. /**
  17407. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17408. * edge artifacts on steep falloff.
  17409. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17410. */
  17411. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17412. /**
  17413. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17414. * edge artifacts on steep falloff.
  17415. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17416. */
  17417. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17418. /**
  17419. * Shadow generator mode PCF: Percentage Closer Filtering
  17420. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17421. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17422. */
  17423. static readonly FILTER_PCF: number;
  17424. /**
  17425. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17426. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17427. * Contact Hardening
  17428. */
  17429. static readonly FILTER_PCSS: number;
  17430. /**
  17431. * Reserved for PCF and PCSS
  17432. * Highest Quality.
  17433. *
  17434. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17435. *
  17436. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17437. */
  17438. static readonly QUALITY_HIGH: number;
  17439. /**
  17440. * Reserved for PCF and PCSS
  17441. * Good tradeoff for quality/perf cross devices
  17442. *
  17443. * Execute PCF on a 3*3 kernel.
  17444. *
  17445. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17446. */
  17447. static readonly QUALITY_MEDIUM: number;
  17448. /**
  17449. * Reserved for PCF and PCSS
  17450. * The lowest quality but the fastest.
  17451. *
  17452. * Execute PCF on a 1*1 kernel.
  17453. *
  17454. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17455. */
  17456. static readonly QUALITY_LOW: number;
  17457. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17458. id: string;
  17459. /** Gets or sets the custom shader name to use */
  17460. customShaderOptions: ICustomShaderOptions;
  17461. /**
  17462. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17463. */
  17464. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17465. /**
  17466. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17467. */
  17468. onAfterShadowMapRenderObservable: Observable<Effect>;
  17469. /**
  17470. * Observable triggered before a mesh is rendered in the shadow map.
  17471. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17472. */
  17473. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17474. /**
  17475. * Observable triggered after a mesh is rendered in the shadow map.
  17476. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17477. */
  17478. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17479. protected _bias: number;
  17480. /**
  17481. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17482. */
  17483. get bias(): number;
  17484. /**
  17485. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17486. */
  17487. set bias(bias: number);
  17488. protected _normalBias: number;
  17489. /**
  17490. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17491. */
  17492. get normalBias(): number;
  17493. /**
  17494. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17495. */
  17496. set normalBias(normalBias: number);
  17497. protected _blurBoxOffset: number;
  17498. /**
  17499. * Gets the blur box offset: offset applied during the blur pass.
  17500. * Only useful if useKernelBlur = false
  17501. */
  17502. get blurBoxOffset(): number;
  17503. /**
  17504. * Sets the blur box offset: offset applied during the blur pass.
  17505. * Only useful if useKernelBlur = false
  17506. */
  17507. set blurBoxOffset(value: number);
  17508. protected _blurScale: number;
  17509. /**
  17510. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17511. * 2 means half of the size.
  17512. */
  17513. get blurScale(): number;
  17514. /**
  17515. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17516. * 2 means half of the size.
  17517. */
  17518. set blurScale(value: number);
  17519. protected _blurKernel: number;
  17520. /**
  17521. * Gets the blur kernel: kernel size of the blur pass.
  17522. * Only useful if useKernelBlur = true
  17523. */
  17524. get blurKernel(): number;
  17525. /**
  17526. * Sets the blur kernel: kernel size of the blur pass.
  17527. * Only useful if useKernelBlur = true
  17528. */
  17529. set blurKernel(value: number);
  17530. protected _useKernelBlur: boolean;
  17531. /**
  17532. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17533. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17534. */
  17535. get useKernelBlur(): boolean;
  17536. /**
  17537. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17538. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17539. */
  17540. set useKernelBlur(value: boolean);
  17541. protected _depthScale: number;
  17542. /**
  17543. * Gets the depth scale used in ESM mode.
  17544. */
  17545. get depthScale(): number;
  17546. /**
  17547. * Sets the depth scale used in ESM mode.
  17548. * This can override the scale stored on the light.
  17549. */
  17550. set depthScale(value: number);
  17551. protected _validateFilter(filter: number): number;
  17552. protected _filter: number;
  17553. /**
  17554. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17555. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17556. */
  17557. get filter(): number;
  17558. /**
  17559. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17560. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17561. */
  17562. set filter(value: number);
  17563. /**
  17564. * Gets if the current filter is set to Poisson Sampling.
  17565. */
  17566. get usePoissonSampling(): boolean;
  17567. /**
  17568. * Sets the current filter to Poisson Sampling.
  17569. */
  17570. set usePoissonSampling(value: boolean);
  17571. /**
  17572. * Gets if the current filter is set to ESM.
  17573. */
  17574. get useExponentialShadowMap(): boolean;
  17575. /**
  17576. * Sets the current filter is to ESM.
  17577. */
  17578. set useExponentialShadowMap(value: boolean);
  17579. /**
  17580. * Gets if the current filter is set to filtered ESM.
  17581. */
  17582. get useBlurExponentialShadowMap(): boolean;
  17583. /**
  17584. * Gets if the current filter is set to filtered ESM.
  17585. */
  17586. set useBlurExponentialShadowMap(value: boolean);
  17587. /**
  17588. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17589. * exponential to prevent steep falloff artifacts).
  17590. */
  17591. get useCloseExponentialShadowMap(): boolean;
  17592. /**
  17593. * Sets the current filter to "close ESM" (using the inverse of the
  17594. * exponential to prevent steep falloff artifacts).
  17595. */
  17596. set useCloseExponentialShadowMap(value: boolean);
  17597. /**
  17598. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17599. * exponential to prevent steep falloff artifacts).
  17600. */
  17601. get useBlurCloseExponentialShadowMap(): boolean;
  17602. /**
  17603. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17604. * exponential to prevent steep falloff artifacts).
  17605. */
  17606. set useBlurCloseExponentialShadowMap(value: boolean);
  17607. /**
  17608. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17609. */
  17610. get usePercentageCloserFiltering(): boolean;
  17611. /**
  17612. * Sets the current filter to "PCF" (percentage closer filtering).
  17613. */
  17614. set usePercentageCloserFiltering(value: boolean);
  17615. protected _filteringQuality: number;
  17616. /**
  17617. * Gets the PCF or PCSS Quality.
  17618. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17619. */
  17620. get filteringQuality(): number;
  17621. /**
  17622. * Sets the PCF or PCSS Quality.
  17623. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17624. */
  17625. set filteringQuality(filteringQuality: number);
  17626. /**
  17627. * Gets if the current filter is set to "PCSS" (contact hardening).
  17628. */
  17629. get useContactHardeningShadow(): boolean;
  17630. /**
  17631. * Sets the current filter to "PCSS" (contact hardening).
  17632. */
  17633. set useContactHardeningShadow(value: boolean);
  17634. protected _contactHardeningLightSizeUVRatio: number;
  17635. /**
  17636. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17637. * Using a ratio helps keeping shape stability independently of the map size.
  17638. *
  17639. * It does not account for the light projection as it was having too much
  17640. * instability during the light setup or during light position changes.
  17641. *
  17642. * Only valid if useContactHardeningShadow is true.
  17643. */
  17644. get contactHardeningLightSizeUVRatio(): number;
  17645. /**
  17646. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17647. * Using a ratio helps keeping shape stability independently of the map size.
  17648. *
  17649. * It does not account for the light projection as it was having too much
  17650. * instability during the light setup or during light position changes.
  17651. *
  17652. * Only valid if useContactHardeningShadow is true.
  17653. */
  17654. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17655. protected _darkness: number;
  17656. /** Gets or sets the actual darkness of a shadow */
  17657. get darkness(): number;
  17658. set darkness(value: number);
  17659. /**
  17660. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17661. * 0 means strongest and 1 would means no shadow.
  17662. * @returns the darkness.
  17663. */
  17664. getDarkness(): number;
  17665. /**
  17666. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17667. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17668. * @returns the shadow generator allowing fluent coding.
  17669. */
  17670. setDarkness(darkness: number): ShadowGenerator;
  17671. protected _transparencyShadow: boolean;
  17672. /** Gets or sets the ability to have transparent shadow */
  17673. get transparencyShadow(): boolean;
  17674. set transparencyShadow(value: boolean);
  17675. /**
  17676. * Sets the ability to have transparent shadow (boolean).
  17677. * @param transparent True if transparent else False
  17678. * @returns the shadow generator allowing fluent coding
  17679. */
  17680. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17681. /**
  17682. * Enables or disables shadows with varying strength based on the transparency
  17683. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17684. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17685. * mesh.visibility * alphaTexture.a
  17686. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17687. */
  17688. enableSoftTransparentShadow: boolean;
  17689. protected _shadowMap: Nullable<RenderTargetTexture>;
  17690. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17691. /**
  17692. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17693. * @returns The render target texture if present otherwise, null
  17694. */
  17695. getShadowMap(): Nullable<RenderTargetTexture>;
  17696. /**
  17697. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17698. * @returns The render target texture if the shadow map is present otherwise, null
  17699. */
  17700. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17701. /**
  17702. * Gets the class name of that object
  17703. * @returns "ShadowGenerator"
  17704. */
  17705. getClassName(): string;
  17706. /**
  17707. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17708. * @param mesh Mesh to add
  17709. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17710. * @returns the Shadow Generator itself
  17711. */
  17712. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17713. /**
  17714. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17715. * @param mesh Mesh to remove
  17716. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17717. * @returns the Shadow Generator itself
  17718. */
  17719. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17720. /**
  17721. * Controls the extent to which the shadows fade out at the edge of the frustum
  17722. */
  17723. frustumEdgeFalloff: number;
  17724. protected _light: IShadowLight;
  17725. /**
  17726. * Returns the associated light object.
  17727. * @returns the light generating the shadow
  17728. */
  17729. getLight(): IShadowLight;
  17730. /**
  17731. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17732. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17733. * It might on the other hand introduce peter panning.
  17734. */
  17735. forceBackFacesOnly: boolean;
  17736. protected _scene: Scene;
  17737. protected _lightDirection: Vector3;
  17738. protected _effect: Effect;
  17739. protected _viewMatrix: Matrix;
  17740. protected _projectionMatrix: Matrix;
  17741. protected _transformMatrix: Matrix;
  17742. protected _cachedPosition: Vector3;
  17743. protected _cachedDirection: Vector3;
  17744. protected _cachedDefines: string;
  17745. protected _currentRenderID: number;
  17746. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17747. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17748. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17749. protected _blurPostProcesses: PostProcess[];
  17750. protected _mapSize: number;
  17751. protected _currentFaceIndex: number;
  17752. protected _currentFaceIndexCache: number;
  17753. protected _textureType: number;
  17754. protected _defaultTextureMatrix: Matrix;
  17755. protected _storedUniqueId: Nullable<number>;
  17756. /** @hidden */
  17757. static _SceneComponentInitialization: (scene: Scene) => void;
  17758. /**
  17759. * Creates a ShadowGenerator object.
  17760. * A ShadowGenerator is the required tool to use the shadows.
  17761. * Each light casting shadows needs to use its own ShadowGenerator.
  17762. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17763. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17764. * @param light The light object generating the shadows.
  17765. * @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.
  17766. */
  17767. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17768. protected _initializeGenerator(): void;
  17769. protected _createTargetRenderTexture(): void;
  17770. protected _initializeShadowMap(): void;
  17771. protected _initializeBlurRTTAndPostProcesses(): void;
  17772. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17773. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17774. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  17775. protected _applyFilterValues(): void;
  17776. /**
  17777. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17778. * @param onCompiled Callback triggered at the and of the effects compilation
  17779. * @param options Sets of optional options forcing the compilation with different modes
  17780. */
  17781. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17782. useInstances: boolean;
  17783. }>): void;
  17784. /**
  17785. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17786. * @param options Sets of optional options forcing the compilation with different modes
  17787. * @returns A promise that resolves when the compilation completes
  17788. */
  17789. forceCompilationAsync(options?: Partial<{
  17790. useInstances: boolean;
  17791. }>): Promise<void>;
  17792. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17793. private _prepareShadowDefines;
  17794. /**
  17795. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17796. * @param subMesh The submesh we want to render in the shadow map
  17797. * @param useInstances Defines wether will draw in the map using instances
  17798. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17799. * @returns true if ready otherwise, false
  17800. */
  17801. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17802. /**
  17803. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17804. * @param defines Defines of the material we want to update
  17805. * @param lightIndex Index of the light in the enabled light list of the material
  17806. */
  17807. prepareDefines(defines: any, lightIndex: number): void;
  17808. /**
  17809. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17810. * defined in the generator but impacting the effect).
  17811. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17812. * @param effect The effect we are binfing the information for
  17813. */
  17814. bindShadowLight(lightIndex: string, effect: Effect): void;
  17815. /**
  17816. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17817. * (eq to shadow prjection matrix * light transform matrix)
  17818. * @returns The transform matrix used to create the shadow map
  17819. */
  17820. getTransformMatrix(): Matrix;
  17821. /**
  17822. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17823. * Cube and 2D textures for instance.
  17824. */
  17825. recreateShadowMap(): void;
  17826. protected _disposeBlurPostProcesses(): void;
  17827. protected _disposeRTTandPostProcesses(): void;
  17828. /**
  17829. * Disposes the ShadowGenerator.
  17830. * Returns nothing.
  17831. */
  17832. dispose(): void;
  17833. /**
  17834. * Serializes the shadow generator setup to a json object.
  17835. * @returns The serialized JSON object
  17836. */
  17837. serialize(): any;
  17838. /**
  17839. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17840. * @param parsedShadowGenerator The JSON object to parse
  17841. * @param scene The scene to create the shadow map for
  17842. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17843. * @returns The parsed shadow generator
  17844. */
  17845. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17846. }
  17847. }
  17848. declare module BABYLON {
  17849. /**
  17850. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17851. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17852. * 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.
  17853. */
  17854. export abstract class Light extends Node {
  17855. /**
  17856. * Falloff Default: light is falling off following the material specification:
  17857. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17858. */
  17859. static readonly FALLOFF_DEFAULT: number;
  17860. /**
  17861. * Falloff Physical: light is falling off following the inverse squared distance law.
  17862. */
  17863. static readonly FALLOFF_PHYSICAL: number;
  17864. /**
  17865. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17866. * to enhance interoperability with other engines.
  17867. */
  17868. static readonly FALLOFF_GLTF: number;
  17869. /**
  17870. * Falloff Standard: light is falling off like in the standard material
  17871. * to enhance interoperability with other materials.
  17872. */
  17873. static readonly FALLOFF_STANDARD: number;
  17874. /**
  17875. * If every light affecting the material is in this lightmapMode,
  17876. * material.lightmapTexture adds or multiplies
  17877. * (depends on material.useLightmapAsShadowmap)
  17878. * after every other light calculations.
  17879. */
  17880. static readonly LIGHTMAP_DEFAULT: number;
  17881. /**
  17882. * material.lightmapTexture as only diffuse lighting from this light
  17883. * adds only specular lighting from this light
  17884. * adds dynamic shadows
  17885. */
  17886. static readonly LIGHTMAP_SPECULAR: number;
  17887. /**
  17888. * material.lightmapTexture as only lighting
  17889. * no light calculation from this light
  17890. * only adds dynamic shadows from this light
  17891. */
  17892. static readonly LIGHTMAP_SHADOWSONLY: number;
  17893. /**
  17894. * Each light type uses the default quantity according to its type:
  17895. * point/spot lights use luminous intensity
  17896. * directional lights use illuminance
  17897. */
  17898. static readonly INTENSITYMODE_AUTOMATIC: number;
  17899. /**
  17900. * lumen (lm)
  17901. */
  17902. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17903. /**
  17904. * candela (lm/sr)
  17905. */
  17906. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17907. /**
  17908. * lux (lm/m^2)
  17909. */
  17910. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17911. /**
  17912. * nit (cd/m^2)
  17913. */
  17914. static readonly INTENSITYMODE_LUMINANCE: number;
  17915. /**
  17916. * Light type const id of the point light.
  17917. */
  17918. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17919. /**
  17920. * Light type const id of the directional light.
  17921. */
  17922. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17923. /**
  17924. * Light type const id of the spot light.
  17925. */
  17926. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17927. /**
  17928. * Light type const id of the hemispheric light.
  17929. */
  17930. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17931. /**
  17932. * Diffuse gives the basic color to an object.
  17933. */
  17934. diffuse: Color3;
  17935. /**
  17936. * Specular produces a highlight color on an object.
  17937. * Note: This is note affecting PBR materials.
  17938. */
  17939. specular: Color3;
  17940. /**
  17941. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17942. * falling off base on range or angle.
  17943. * This can be set to any values in Light.FALLOFF_x.
  17944. *
  17945. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17946. * other types of materials.
  17947. */
  17948. falloffType: number;
  17949. /**
  17950. * Strength of the light.
  17951. * Note: By default it is define in the framework own unit.
  17952. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17953. */
  17954. intensity: number;
  17955. private _range;
  17956. protected _inverseSquaredRange: number;
  17957. /**
  17958. * Defines how far from the source the light is impacting in scene units.
  17959. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17960. */
  17961. get range(): number;
  17962. /**
  17963. * Defines how far from the source the light is impacting in scene units.
  17964. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17965. */
  17966. set range(value: number);
  17967. /**
  17968. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17969. * of light.
  17970. */
  17971. private _photometricScale;
  17972. private _intensityMode;
  17973. /**
  17974. * Gets the photometric scale used to interpret the intensity.
  17975. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17976. */
  17977. get intensityMode(): number;
  17978. /**
  17979. * Sets the photometric scale used to interpret the intensity.
  17980. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17981. */
  17982. set intensityMode(value: number);
  17983. private _radius;
  17984. /**
  17985. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17986. */
  17987. get radius(): number;
  17988. /**
  17989. * sets the light radius used by PBR Materials to simulate soft area lights.
  17990. */
  17991. set radius(value: number);
  17992. private _renderPriority;
  17993. /**
  17994. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17995. * exceeding the number allowed of the materials.
  17996. */
  17997. renderPriority: number;
  17998. private _shadowEnabled;
  17999. /**
  18000. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18001. * the current shadow generator.
  18002. */
  18003. get shadowEnabled(): boolean;
  18004. /**
  18005. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18006. * the current shadow generator.
  18007. */
  18008. set shadowEnabled(value: boolean);
  18009. private _includedOnlyMeshes;
  18010. /**
  18011. * Gets the only meshes impacted by this light.
  18012. */
  18013. get includedOnlyMeshes(): AbstractMesh[];
  18014. /**
  18015. * Sets the only meshes impacted by this light.
  18016. */
  18017. set includedOnlyMeshes(value: AbstractMesh[]);
  18018. private _excludedMeshes;
  18019. /**
  18020. * Gets the meshes not impacted by this light.
  18021. */
  18022. get excludedMeshes(): AbstractMesh[];
  18023. /**
  18024. * Sets the meshes not impacted by this light.
  18025. */
  18026. set excludedMeshes(value: AbstractMesh[]);
  18027. private _excludeWithLayerMask;
  18028. /**
  18029. * Gets the layer id use to find what meshes are not impacted by the light.
  18030. * Inactive if 0
  18031. */
  18032. get excludeWithLayerMask(): number;
  18033. /**
  18034. * Sets the layer id use to find what meshes are not impacted by the light.
  18035. * Inactive if 0
  18036. */
  18037. set excludeWithLayerMask(value: number);
  18038. private _includeOnlyWithLayerMask;
  18039. /**
  18040. * Gets the layer id use to find what meshes are impacted by the light.
  18041. * Inactive if 0
  18042. */
  18043. get includeOnlyWithLayerMask(): number;
  18044. /**
  18045. * Sets the layer id use to find what meshes are impacted by the light.
  18046. * Inactive if 0
  18047. */
  18048. set includeOnlyWithLayerMask(value: number);
  18049. private _lightmapMode;
  18050. /**
  18051. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18052. */
  18053. get lightmapMode(): number;
  18054. /**
  18055. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18056. */
  18057. set lightmapMode(value: number);
  18058. /**
  18059. * Shadow generator associted to the light.
  18060. * @hidden Internal use only.
  18061. */
  18062. _shadowGenerator: Nullable<IShadowGenerator>;
  18063. /**
  18064. * @hidden Internal use only.
  18065. */
  18066. _excludedMeshesIds: string[];
  18067. /**
  18068. * @hidden Internal use only.
  18069. */
  18070. _includedOnlyMeshesIds: string[];
  18071. /**
  18072. * The current light unifom buffer.
  18073. * @hidden Internal use only.
  18074. */
  18075. _uniformBuffer: UniformBuffer;
  18076. /** @hidden */
  18077. _renderId: number;
  18078. /**
  18079. * Creates a Light object in the scene.
  18080. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18081. * @param name The firendly name of the light
  18082. * @param scene The scene the light belongs too
  18083. */
  18084. constructor(name: string, scene: Scene);
  18085. protected abstract _buildUniformLayout(): void;
  18086. /**
  18087. * Sets the passed Effect "effect" with the Light information.
  18088. * @param effect The effect to update
  18089. * @param lightIndex The index of the light in the effect to update
  18090. * @returns The light
  18091. */
  18092. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18093. /**
  18094. * Sets the passed Effect "effect" with the Light textures.
  18095. * @param effect The effect to update
  18096. * @param lightIndex The index of the light in the effect to update
  18097. * @returns The light
  18098. */
  18099. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18100. /**
  18101. * Binds the lights information from the scene to the effect for the given mesh.
  18102. * @param lightIndex Light index
  18103. * @param scene The scene where the light belongs to
  18104. * @param effect The effect we are binding the data to
  18105. * @param useSpecular Defines if specular is supported
  18106. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18107. */
  18108. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18109. /**
  18110. * Sets the passed Effect "effect" with the Light information.
  18111. * @param effect The effect to update
  18112. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18113. * @returns The light
  18114. */
  18115. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18116. /**
  18117. * Returns the string "Light".
  18118. * @returns the class name
  18119. */
  18120. getClassName(): string;
  18121. /** @hidden */
  18122. readonly _isLight: boolean;
  18123. /**
  18124. * Converts the light information to a readable string for debug purpose.
  18125. * @param fullDetails Supports for multiple levels of logging within scene loading
  18126. * @returns the human readable light info
  18127. */
  18128. toString(fullDetails?: boolean): string;
  18129. /** @hidden */
  18130. protected _syncParentEnabledState(): void;
  18131. /**
  18132. * Set the enabled state of this node.
  18133. * @param value - the new enabled state
  18134. */
  18135. setEnabled(value: boolean): void;
  18136. /**
  18137. * Returns the Light associated shadow generator if any.
  18138. * @return the associated shadow generator.
  18139. */
  18140. getShadowGenerator(): Nullable<IShadowGenerator>;
  18141. /**
  18142. * Returns a Vector3, the absolute light position in the World.
  18143. * @returns the world space position of the light
  18144. */
  18145. getAbsolutePosition(): Vector3;
  18146. /**
  18147. * Specifies if the light will affect the passed mesh.
  18148. * @param mesh The mesh to test against the light
  18149. * @return true the mesh is affected otherwise, false.
  18150. */
  18151. canAffectMesh(mesh: AbstractMesh): boolean;
  18152. /**
  18153. * Sort function to order lights for rendering.
  18154. * @param a First Light object to compare to second.
  18155. * @param b Second Light object to compare first.
  18156. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18157. */
  18158. static CompareLightsPriority(a: Light, b: Light): number;
  18159. /**
  18160. * Releases resources associated with this node.
  18161. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18162. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18163. */
  18164. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18165. /**
  18166. * Returns the light type ID (integer).
  18167. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18168. */
  18169. getTypeID(): number;
  18170. /**
  18171. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18172. * @returns the scaled intensity in intensity mode unit
  18173. */
  18174. getScaledIntensity(): number;
  18175. /**
  18176. * Returns a new Light object, named "name", from the current one.
  18177. * @param name The name of the cloned light
  18178. * @param newParent The parent of this light, if it has one
  18179. * @returns the new created light
  18180. */
  18181. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18182. /**
  18183. * Serializes the current light into a Serialization object.
  18184. * @returns the serialized object.
  18185. */
  18186. serialize(): any;
  18187. /**
  18188. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18189. * This new light is named "name" and added to the passed scene.
  18190. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18191. * @param name The friendly name of the light
  18192. * @param scene The scene the new light will belong to
  18193. * @returns the constructor function
  18194. */
  18195. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18196. /**
  18197. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18198. * @param parsedLight The JSON representation of the light
  18199. * @param scene The scene to create the parsed light in
  18200. * @returns the created light after parsing
  18201. */
  18202. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18203. private _hookArrayForExcluded;
  18204. private _hookArrayForIncludedOnly;
  18205. private _resyncMeshes;
  18206. /**
  18207. * Forces the meshes to update their light related information in their rendering used effects
  18208. * @hidden Internal Use Only
  18209. */
  18210. _markMeshesAsLightDirty(): void;
  18211. /**
  18212. * Recomputes the cached photometric scale if needed.
  18213. */
  18214. private _computePhotometricScale;
  18215. /**
  18216. * Returns the Photometric Scale according to the light type and intensity mode.
  18217. */
  18218. private _getPhotometricScale;
  18219. /**
  18220. * Reorder the light in the scene according to their defined priority.
  18221. * @hidden Internal Use Only
  18222. */
  18223. _reorderLightsInScene(): void;
  18224. /**
  18225. * Prepares the list of defines specific to the light type.
  18226. * @param defines the list of defines
  18227. * @param lightIndex defines the index of the light for the effect
  18228. */
  18229. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18230. }
  18231. }
  18232. declare module BABYLON {
  18233. /**
  18234. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18235. * This is the base of the follow, arc rotate cameras and Free camera
  18236. * @see https://doc.babylonjs.com/features/cameras
  18237. */
  18238. export class TargetCamera extends Camera {
  18239. private static _RigCamTransformMatrix;
  18240. private static _TargetTransformMatrix;
  18241. private static _TargetFocalPoint;
  18242. private _tmpUpVector;
  18243. private _tmpTargetVector;
  18244. /**
  18245. * Define the current direction the camera is moving to
  18246. */
  18247. cameraDirection: Vector3;
  18248. /**
  18249. * Define the current rotation the camera is rotating to
  18250. */
  18251. cameraRotation: Vector2;
  18252. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18253. ignoreParentScaling: boolean;
  18254. /**
  18255. * When set, the up vector of the camera will be updated by the rotation of the camera
  18256. */
  18257. updateUpVectorFromRotation: boolean;
  18258. private _tmpQuaternion;
  18259. /**
  18260. * Define the current rotation of the camera
  18261. */
  18262. rotation: Vector3;
  18263. /**
  18264. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18265. */
  18266. rotationQuaternion: Quaternion;
  18267. /**
  18268. * Define the current speed of the camera
  18269. */
  18270. speed: number;
  18271. /**
  18272. * Add constraint to the camera to prevent it to move freely in all directions and
  18273. * around all axis.
  18274. */
  18275. noRotationConstraint: boolean;
  18276. /**
  18277. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18278. * panning
  18279. */
  18280. invertRotation: boolean;
  18281. /**
  18282. * Speed multiplier for inverse camera panning
  18283. */
  18284. inverseRotationSpeed: number;
  18285. /**
  18286. * Define the current target of the camera as an object or a position.
  18287. */
  18288. lockedTarget: any;
  18289. /** @hidden */
  18290. _currentTarget: Vector3;
  18291. /** @hidden */
  18292. _initialFocalDistance: number;
  18293. /** @hidden */
  18294. _viewMatrix: Matrix;
  18295. /** @hidden */
  18296. _camMatrix: Matrix;
  18297. /** @hidden */
  18298. _cameraTransformMatrix: Matrix;
  18299. /** @hidden */
  18300. _cameraRotationMatrix: Matrix;
  18301. /** @hidden */
  18302. _referencePoint: Vector3;
  18303. /** @hidden */
  18304. _transformedReferencePoint: Vector3;
  18305. /** @hidden */
  18306. _reset: () => void;
  18307. private _defaultUp;
  18308. /**
  18309. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18310. * This is the base of the follow, arc rotate cameras and Free camera
  18311. * @see https://doc.babylonjs.com/features/cameras
  18312. * @param name Defines the name of the camera in the scene
  18313. * @param position Defines the start position of the camera in the scene
  18314. * @param scene Defines the scene the camera belongs to
  18315. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18316. */
  18317. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18318. /**
  18319. * Gets the position in front of the camera at a given distance.
  18320. * @param distance The distance from the camera we want the position to be
  18321. * @returns the position
  18322. */
  18323. getFrontPosition(distance: number): Vector3;
  18324. /** @hidden */
  18325. _getLockedTargetPosition(): Nullable<Vector3>;
  18326. private _storedPosition;
  18327. private _storedRotation;
  18328. private _storedRotationQuaternion;
  18329. /**
  18330. * Store current camera state of the camera (fov, position, rotation, etc..)
  18331. * @returns the camera
  18332. */
  18333. storeState(): Camera;
  18334. /**
  18335. * Restored camera state. You must call storeState() first
  18336. * @returns whether it was successful or not
  18337. * @hidden
  18338. */
  18339. _restoreStateValues(): boolean;
  18340. /** @hidden */
  18341. _initCache(): void;
  18342. /** @hidden */
  18343. _updateCache(ignoreParentClass?: boolean): void;
  18344. /** @hidden */
  18345. _isSynchronizedViewMatrix(): boolean;
  18346. /** @hidden */
  18347. _computeLocalCameraSpeed(): number;
  18348. /**
  18349. * Defines the target the camera should look at.
  18350. * @param target Defines the new target as a Vector or a mesh
  18351. */
  18352. setTarget(target: Vector3): void;
  18353. /**
  18354. * Defines the target point of the camera.
  18355. * The camera looks towards it form the radius distance.
  18356. */
  18357. get target(): Vector3;
  18358. set target(value: Vector3);
  18359. /**
  18360. * Return the current target position of the camera. This value is expressed in local space.
  18361. * @returns the target position
  18362. */
  18363. getTarget(): Vector3;
  18364. /** @hidden */
  18365. _decideIfNeedsToMove(): boolean;
  18366. /** @hidden */
  18367. _updatePosition(): void;
  18368. /** @hidden */
  18369. _checkInputs(): void;
  18370. protected _updateCameraRotationMatrix(): void;
  18371. /**
  18372. * 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)
  18373. * @returns the current camera
  18374. */
  18375. private _rotateUpVectorWithCameraRotationMatrix;
  18376. private _cachedRotationZ;
  18377. private _cachedQuaternionRotationZ;
  18378. /** @hidden */
  18379. _getViewMatrix(): Matrix;
  18380. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18381. /**
  18382. * @hidden
  18383. */
  18384. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18385. /**
  18386. * @hidden
  18387. */
  18388. _updateRigCameras(): void;
  18389. private _getRigCamPositionAndTarget;
  18390. /**
  18391. * Gets the current object class name.
  18392. * @return the class name
  18393. */
  18394. getClassName(): string;
  18395. }
  18396. }
  18397. declare module BABYLON {
  18398. /**
  18399. * Gather the list of keyboard event types as constants.
  18400. */
  18401. export class KeyboardEventTypes {
  18402. /**
  18403. * The keydown event is fired when a key becomes active (pressed).
  18404. */
  18405. static readonly KEYDOWN: number;
  18406. /**
  18407. * The keyup event is fired when a key has been released.
  18408. */
  18409. static readonly KEYUP: number;
  18410. }
  18411. /**
  18412. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18413. */
  18414. export class KeyboardInfo {
  18415. /**
  18416. * Defines the type of event (KeyboardEventTypes)
  18417. */
  18418. type: number;
  18419. /**
  18420. * Defines the related dom event
  18421. */
  18422. event: KeyboardEvent;
  18423. /**
  18424. * Instantiates a new keyboard info.
  18425. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18426. * @param type Defines the type of event (KeyboardEventTypes)
  18427. * @param event Defines the related dom event
  18428. */
  18429. constructor(
  18430. /**
  18431. * Defines the type of event (KeyboardEventTypes)
  18432. */
  18433. type: number,
  18434. /**
  18435. * Defines the related dom event
  18436. */
  18437. event: KeyboardEvent);
  18438. }
  18439. /**
  18440. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18441. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18442. */
  18443. export class KeyboardInfoPre extends KeyboardInfo {
  18444. /**
  18445. * Defines the type of event (KeyboardEventTypes)
  18446. */
  18447. type: number;
  18448. /**
  18449. * Defines the related dom event
  18450. */
  18451. event: KeyboardEvent;
  18452. /**
  18453. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18454. */
  18455. skipOnPointerObservable: boolean;
  18456. /**
  18457. * Instantiates a new keyboard pre info.
  18458. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18459. * @param type Defines the type of event (KeyboardEventTypes)
  18460. * @param event Defines the related dom event
  18461. */
  18462. constructor(
  18463. /**
  18464. * Defines the type of event (KeyboardEventTypes)
  18465. */
  18466. type: number,
  18467. /**
  18468. * Defines the related dom event
  18469. */
  18470. event: KeyboardEvent);
  18471. }
  18472. }
  18473. declare module BABYLON {
  18474. /**
  18475. * Manage the keyboard inputs to control the movement of a free camera.
  18476. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18477. */
  18478. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18479. /**
  18480. * Defines the camera the input is attached to.
  18481. */
  18482. camera: FreeCamera;
  18483. /**
  18484. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18485. */
  18486. keysUp: number[];
  18487. /**
  18488. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18489. */
  18490. keysUpward: number[];
  18491. /**
  18492. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18493. */
  18494. keysDown: number[];
  18495. /**
  18496. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18497. */
  18498. keysDownward: number[];
  18499. /**
  18500. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18501. */
  18502. keysLeft: number[];
  18503. /**
  18504. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18505. */
  18506. keysRight: number[];
  18507. private _keys;
  18508. private _onCanvasBlurObserver;
  18509. private _onKeyboardObserver;
  18510. private _engine;
  18511. private _scene;
  18512. /**
  18513. * Attach the input controls to a specific dom element to get the input from.
  18514. * @param element Defines the element the controls should be listened from
  18515. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18516. */
  18517. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18518. /**
  18519. * Detach the current controls from the specified dom element.
  18520. * @param element Defines the element to stop listening the inputs from
  18521. */
  18522. detachControl(element: Nullable<HTMLElement>): void;
  18523. /**
  18524. * Update the current camera state depending on the inputs that have been used this frame.
  18525. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18526. */
  18527. checkInputs(): void;
  18528. /**
  18529. * Gets the class name of the current intput.
  18530. * @returns the class name
  18531. */
  18532. getClassName(): string;
  18533. /** @hidden */
  18534. _onLostFocus(): void;
  18535. /**
  18536. * Get the friendly name associated with the input class.
  18537. * @returns the input friendly name
  18538. */
  18539. getSimpleName(): string;
  18540. }
  18541. }
  18542. declare module BABYLON {
  18543. /**
  18544. * Gather the list of pointer event types as constants.
  18545. */
  18546. export class PointerEventTypes {
  18547. /**
  18548. * 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.
  18549. */
  18550. static readonly POINTERDOWN: number;
  18551. /**
  18552. * The pointerup event is fired when a pointer is no longer active.
  18553. */
  18554. static readonly POINTERUP: number;
  18555. /**
  18556. * The pointermove event is fired when a pointer changes coordinates.
  18557. */
  18558. static readonly POINTERMOVE: number;
  18559. /**
  18560. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18561. */
  18562. static readonly POINTERWHEEL: number;
  18563. /**
  18564. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18565. */
  18566. static readonly POINTERPICK: number;
  18567. /**
  18568. * The pointertap event is fired when a the object has been touched and released without drag.
  18569. */
  18570. static readonly POINTERTAP: number;
  18571. /**
  18572. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18573. */
  18574. static readonly POINTERDOUBLETAP: number;
  18575. }
  18576. /**
  18577. * Base class of pointer info types.
  18578. */
  18579. export class PointerInfoBase {
  18580. /**
  18581. * Defines the type of event (PointerEventTypes)
  18582. */
  18583. type: number;
  18584. /**
  18585. * Defines the related dom event
  18586. */
  18587. event: PointerEvent | MouseWheelEvent;
  18588. /**
  18589. * Instantiates the base class of pointers info.
  18590. * @param type Defines the type of event (PointerEventTypes)
  18591. * @param event Defines the related dom event
  18592. */
  18593. constructor(
  18594. /**
  18595. * Defines the type of event (PointerEventTypes)
  18596. */
  18597. type: number,
  18598. /**
  18599. * Defines the related dom event
  18600. */
  18601. event: PointerEvent | MouseWheelEvent);
  18602. }
  18603. /**
  18604. * This class is used to store pointer related info for the onPrePointerObservable event.
  18605. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18606. */
  18607. export class PointerInfoPre extends PointerInfoBase {
  18608. /**
  18609. * Ray from a pointer if availible (eg. 6dof controller)
  18610. */
  18611. ray: Nullable<Ray>;
  18612. /**
  18613. * Defines the local position of the pointer on the canvas.
  18614. */
  18615. localPosition: Vector2;
  18616. /**
  18617. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18618. */
  18619. skipOnPointerObservable: boolean;
  18620. /**
  18621. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18622. * @param type Defines the type of event (PointerEventTypes)
  18623. * @param event Defines the related dom event
  18624. * @param localX Defines the local x coordinates of the pointer when the event occured
  18625. * @param localY Defines the local y coordinates of the pointer when the event occured
  18626. */
  18627. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18628. }
  18629. /**
  18630. * This type contains all the data related to a pointer event in Babylon.js.
  18631. * 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.
  18632. */
  18633. export class PointerInfo extends PointerInfoBase {
  18634. /**
  18635. * Defines the picking info associated to the info (if any)\
  18636. */
  18637. pickInfo: Nullable<PickingInfo>;
  18638. /**
  18639. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18640. * @param type Defines the type of event (PointerEventTypes)
  18641. * @param event Defines the related dom event
  18642. * @param pickInfo Defines the picking info associated to the info (if any)\
  18643. */
  18644. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18645. /**
  18646. * Defines the picking info associated to the info (if any)\
  18647. */
  18648. pickInfo: Nullable<PickingInfo>);
  18649. }
  18650. /**
  18651. * Data relating to a touch event on the screen.
  18652. */
  18653. export interface PointerTouch {
  18654. /**
  18655. * X coordinate of touch.
  18656. */
  18657. x: number;
  18658. /**
  18659. * Y coordinate of touch.
  18660. */
  18661. y: number;
  18662. /**
  18663. * Id of touch. Unique for each finger.
  18664. */
  18665. pointerId: number;
  18666. /**
  18667. * Event type passed from DOM.
  18668. */
  18669. type: any;
  18670. }
  18671. }
  18672. declare module BABYLON {
  18673. /**
  18674. * Manage the mouse inputs to control the movement of a free camera.
  18675. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18676. */
  18677. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18678. /**
  18679. * Define if touch is enabled in the mouse input
  18680. */
  18681. touchEnabled: boolean;
  18682. /**
  18683. * Defines the camera the input is attached to.
  18684. */
  18685. camera: FreeCamera;
  18686. /**
  18687. * Defines the buttons associated with the input to handle camera move.
  18688. */
  18689. buttons: number[];
  18690. /**
  18691. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18692. */
  18693. angularSensibility: number;
  18694. private _pointerInput;
  18695. private _onMouseMove;
  18696. private _observer;
  18697. private previousPosition;
  18698. /**
  18699. * Observable for when a pointer move event occurs containing the move offset
  18700. */
  18701. onPointerMovedObservable: Observable<{
  18702. offsetX: number;
  18703. offsetY: number;
  18704. }>;
  18705. /**
  18706. * @hidden
  18707. * If the camera should be rotated automatically based on pointer movement
  18708. */
  18709. _allowCameraRotation: boolean;
  18710. /**
  18711. * Manage the mouse inputs to control the movement of a free camera.
  18712. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18713. * @param touchEnabled Defines if touch is enabled or not
  18714. */
  18715. constructor(
  18716. /**
  18717. * Define if touch is enabled in the mouse input
  18718. */
  18719. touchEnabled?: boolean);
  18720. /**
  18721. * Attach the input controls to a specific dom element to get the input from.
  18722. * @param element Defines the element the controls should be listened from
  18723. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18724. */
  18725. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18726. /**
  18727. * Called on JS contextmenu event.
  18728. * Override this method to provide functionality.
  18729. */
  18730. protected onContextMenu(evt: PointerEvent): void;
  18731. /**
  18732. * Detach the current controls from the specified dom element.
  18733. * @param element Defines the element to stop listening the inputs from
  18734. */
  18735. detachControl(element: Nullable<HTMLElement>): void;
  18736. /**
  18737. * Gets the class name of the current intput.
  18738. * @returns the class name
  18739. */
  18740. getClassName(): string;
  18741. /**
  18742. * Get the friendly name associated with the input class.
  18743. * @returns the input friendly name
  18744. */
  18745. getSimpleName(): string;
  18746. }
  18747. }
  18748. declare module BABYLON {
  18749. /**
  18750. * Manage the touch inputs to control the movement of a free camera.
  18751. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18752. */
  18753. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18754. /**
  18755. * Defines the camera the input is attached to.
  18756. */
  18757. camera: FreeCamera;
  18758. /**
  18759. * Defines the touch sensibility for rotation.
  18760. * The higher the faster.
  18761. */
  18762. touchAngularSensibility: number;
  18763. /**
  18764. * Defines the touch sensibility for move.
  18765. * The higher the faster.
  18766. */
  18767. touchMoveSensibility: number;
  18768. private _offsetX;
  18769. private _offsetY;
  18770. private _pointerPressed;
  18771. private _pointerInput;
  18772. private _observer;
  18773. private _onLostFocus;
  18774. /**
  18775. * Attach the input controls to a specific dom element to get the input from.
  18776. * @param element Defines the element the controls should be listened from
  18777. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18778. */
  18779. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18780. /**
  18781. * Detach the current controls from the specified dom element.
  18782. * @param element Defines the element to stop listening the inputs from
  18783. */
  18784. detachControl(element: Nullable<HTMLElement>): void;
  18785. /**
  18786. * Update the current camera state depending on the inputs that have been used this frame.
  18787. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18788. */
  18789. checkInputs(): void;
  18790. /**
  18791. * Gets the class name of the current intput.
  18792. * @returns the class name
  18793. */
  18794. getClassName(): string;
  18795. /**
  18796. * Get the friendly name associated with the input class.
  18797. * @returns the input friendly name
  18798. */
  18799. getSimpleName(): string;
  18800. }
  18801. }
  18802. declare module BABYLON {
  18803. /**
  18804. * Default Inputs manager for the FreeCamera.
  18805. * It groups all the default supported inputs for ease of use.
  18806. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18807. */
  18808. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18809. /**
  18810. * @hidden
  18811. */
  18812. _mouseInput: Nullable<FreeCameraMouseInput>;
  18813. /**
  18814. * Instantiates a new FreeCameraInputsManager.
  18815. * @param camera Defines the camera the inputs belong to
  18816. */
  18817. constructor(camera: FreeCamera);
  18818. /**
  18819. * Add keyboard input support to the input manager.
  18820. * @returns the current input manager
  18821. */
  18822. addKeyboard(): FreeCameraInputsManager;
  18823. /**
  18824. * Add mouse input support to the input manager.
  18825. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18826. * @returns the current input manager
  18827. */
  18828. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18829. /**
  18830. * Removes the mouse input support from the manager
  18831. * @returns the current input manager
  18832. */
  18833. removeMouse(): FreeCameraInputsManager;
  18834. /**
  18835. * Add touch input support to the input manager.
  18836. * @returns the current input manager
  18837. */
  18838. addTouch(): FreeCameraInputsManager;
  18839. /**
  18840. * Remove all attached input methods from a camera
  18841. */
  18842. clear(): void;
  18843. }
  18844. }
  18845. declare module BABYLON {
  18846. /**
  18847. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18848. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18849. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  18850. */
  18851. export class FreeCamera extends TargetCamera {
  18852. /**
  18853. * Define the collision ellipsoid of the camera.
  18854. * This is helpful to simulate a camera body like the player body around the camera
  18855. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18856. */
  18857. ellipsoid: Vector3;
  18858. /**
  18859. * Define an offset for the position of the ellipsoid around the camera.
  18860. * This can be helpful to determine the center of the body near the gravity center of the body
  18861. * instead of its head.
  18862. */
  18863. ellipsoidOffset: Vector3;
  18864. /**
  18865. * Enable or disable collisions of the camera with the rest of the scene objects.
  18866. */
  18867. checkCollisions: boolean;
  18868. /**
  18869. * Enable or disable gravity on the camera.
  18870. */
  18871. applyGravity: boolean;
  18872. /**
  18873. * Define the input manager associated to the camera.
  18874. */
  18875. inputs: FreeCameraInputsManager;
  18876. /**
  18877. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18878. * Higher values reduce sensitivity.
  18879. */
  18880. get angularSensibility(): number;
  18881. /**
  18882. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18883. * Higher values reduce sensitivity.
  18884. */
  18885. set angularSensibility(value: number);
  18886. /**
  18887. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18888. */
  18889. get keysUp(): number[];
  18890. set keysUp(value: number[]);
  18891. /**
  18892. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18893. */
  18894. get keysUpward(): number[];
  18895. set keysUpward(value: number[]);
  18896. /**
  18897. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18898. */
  18899. get keysDown(): number[];
  18900. set keysDown(value: number[]);
  18901. /**
  18902. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18903. */
  18904. get keysDownward(): number[];
  18905. set keysDownward(value: number[]);
  18906. /**
  18907. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18908. */
  18909. get keysLeft(): number[];
  18910. set keysLeft(value: number[]);
  18911. /**
  18912. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18913. */
  18914. get keysRight(): number[];
  18915. set keysRight(value: number[]);
  18916. /**
  18917. * Event raised when the camera collide with a mesh in the scene.
  18918. */
  18919. onCollide: (collidedMesh: AbstractMesh) => void;
  18920. private _collider;
  18921. private _needMoveForGravity;
  18922. private _oldPosition;
  18923. private _diffPosition;
  18924. private _newPosition;
  18925. /** @hidden */
  18926. _localDirection: Vector3;
  18927. /** @hidden */
  18928. _transformedDirection: Vector3;
  18929. /**
  18930. * Instantiates a Free Camera.
  18931. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18932. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18933. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  18934. * @param name Define the name of the camera in the scene
  18935. * @param position Define the start position of the camera in the scene
  18936. * @param scene Define the scene the camera belongs to
  18937. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18938. */
  18939. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18940. /**
  18941. * Attached controls to the current camera.
  18942. * @param element Defines the element the controls should be listened from
  18943. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18944. */
  18945. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18946. /**
  18947. * Detach the current controls from the camera.
  18948. * The camera will stop reacting to inputs.
  18949. * @param element Defines the element to stop listening the inputs from
  18950. */
  18951. detachControl(element: HTMLElement): void;
  18952. private _collisionMask;
  18953. /**
  18954. * Define a collision mask to limit the list of object the camera can collide with
  18955. */
  18956. get collisionMask(): number;
  18957. set collisionMask(mask: number);
  18958. /** @hidden */
  18959. _collideWithWorld(displacement: Vector3): void;
  18960. private _onCollisionPositionChange;
  18961. /** @hidden */
  18962. _checkInputs(): void;
  18963. /** @hidden */
  18964. _decideIfNeedsToMove(): boolean;
  18965. /** @hidden */
  18966. _updatePosition(): void;
  18967. /**
  18968. * Destroy the camera and release the current resources hold by it.
  18969. */
  18970. dispose(): void;
  18971. /**
  18972. * Gets the current object class name.
  18973. * @return the class name
  18974. */
  18975. getClassName(): string;
  18976. }
  18977. }
  18978. declare module BABYLON {
  18979. /**
  18980. * Represents a gamepad control stick position
  18981. */
  18982. export class StickValues {
  18983. /**
  18984. * The x component of the control stick
  18985. */
  18986. x: number;
  18987. /**
  18988. * The y component of the control stick
  18989. */
  18990. y: number;
  18991. /**
  18992. * Initializes the gamepad x and y control stick values
  18993. * @param x The x component of the gamepad control stick value
  18994. * @param y The y component of the gamepad control stick value
  18995. */
  18996. constructor(
  18997. /**
  18998. * The x component of the control stick
  18999. */
  19000. x: number,
  19001. /**
  19002. * The y component of the control stick
  19003. */
  19004. y: number);
  19005. }
  19006. /**
  19007. * An interface which manages callbacks for gamepad button changes
  19008. */
  19009. export interface GamepadButtonChanges {
  19010. /**
  19011. * Called when a gamepad has been changed
  19012. */
  19013. changed: boolean;
  19014. /**
  19015. * Called when a gamepad press event has been triggered
  19016. */
  19017. pressChanged: boolean;
  19018. /**
  19019. * Called when a touch event has been triggered
  19020. */
  19021. touchChanged: boolean;
  19022. /**
  19023. * Called when a value has changed
  19024. */
  19025. valueChanged: boolean;
  19026. }
  19027. /**
  19028. * Represents a gamepad
  19029. */
  19030. export class Gamepad {
  19031. /**
  19032. * The id of the gamepad
  19033. */
  19034. id: string;
  19035. /**
  19036. * The index of the gamepad
  19037. */
  19038. index: number;
  19039. /**
  19040. * The browser gamepad
  19041. */
  19042. browserGamepad: any;
  19043. /**
  19044. * Specifies what type of gamepad this represents
  19045. */
  19046. type: number;
  19047. private _leftStick;
  19048. private _rightStick;
  19049. /** @hidden */
  19050. _isConnected: boolean;
  19051. private _leftStickAxisX;
  19052. private _leftStickAxisY;
  19053. private _rightStickAxisX;
  19054. private _rightStickAxisY;
  19055. /**
  19056. * Triggered when the left control stick has been changed
  19057. */
  19058. private _onleftstickchanged;
  19059. /**
  19060. * Triggered when the right control stick has been changed
  19061. */
  19062. private _onrightstickchanged;
  19063. /**
  19064. * Represents a gamepad controller
  19065. */
  19066. static GAMEPAD: number;
  19067. /**
  19068. * Represents a generic controller
  19069. */
  19070. static GENERIC: number;
  19071. /**
  19072. * Represents an XBox controller
  19073. */
  19074. static XBOX: number;
  19075. /**
  19076. * Represents a pose-enabled controller
  19077. */
  19078. static POSE_ENABLED: number;
  19079. /**
  19080. * Represents an Dual Shock controller
  19081. */
  19082. static DUALSHOCK: number;
  19083. /**
  19084. * Specifies whether the left control stick should be Y-inverted
  19085. */
  19086. protected _invertLeftStickY: boolean;
  19087. /**
  19088. * Specifies if the gamepad has been connected
  19089. */
  19090. get isConnected(): boolean;
  19091. /**
  19092. * Initializes the gamepad
  19093. * @param id The id of the gamepad
  19094. * @param index The index of the gamepad
  19095. * @param browserGamepad The browser gamepad
  19096. * @param leftStickX The x component of the left joystick
  19097. * @param leftStickY The y component of the left joystick
  19098. * @param rightStickX The x component of the right joystick
  19099. * @param rightStickY The y component of the right joystick
  19100. */
  19101. constructor(
  19102. /**
  19103. * The id of the gamepad
  19104. */
  19105. id: string,
  19106. /**
  19107. * The index of the gamepad
  19108. */
  19109. index: number,
  19110. /**
  19111. * The browser gamepad
  19112. */
  19113. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19114. /**
  19115. * Callback triggered when the left joystick has changed
  19116. * @param callback
  19117. */
  19118. onleftstickchanged(callback: (values: StickValues) => void): void;
  19119. /**
  19120. * Callback triggered when the right joystick has changed
  19121. * @param callback
  19122. */
  19123. onrightstickchanged(callback: (values: StickValues) => void): void;
  19124. /**
  19125. * Gets the left joystick
  19126. */
  19127. get leftStick(): StickValues;
  19128. /**
  19129. * Sets the left joystick values
  19130. */
  19131. set leftStick(newValues: StickValues);
  19132. /**
  19133. * Gets the right joystick
  19134. */
  19135. get rightStick(): StickValues;
  19136. /**
  19137. * Sets the right joystick value
  19138. */
  19139. set rightStick(newValues: StickValues);
  19140. /**
  19141. * Updates the gamepad joystick positions
  19142. */
  19143. update(): void;
  19144. /**
  19145. * Disposes the gamepad
  19146. */
  19147. dispose(): void;
  19148. }
  19149. /**
  19150. * Represents a generic gamepad
  19151. */
  19152. export class GenericPad extends Gamepad {
  19153. private _buttons;
  19154. private _onbuttondown;
  19155. private _onbuttonup;
  19156. /**
  19157. * Observable triggered when a button has been pressed
  19158. */
  19159. onButtonDownObservable: Observable<number>;
  19160. /**
  19161. * Observable triggered when a button has been released
  19162. */
  19163. onButtonUpObservable: Observable<number>;
  19164. /**
  19165. * Callback triggered when a button has been pressed
  19166. * @param callback Called when a button has been pressed
  19167. */
  19168. onbuttondown(callback: (buttonPressed: number) => void): void;
  19169. /**
  19170. * Callback triggered when a button has been released
  19171. * @param callback Called when a button has been released
  19172. */
  19173. onbuttonup(callback: (buttonReleased: number) => void): void;
  19174. /**
  19175. * Initializes the generic gamepad
  19176. * @param id The id of the generic gamepad
  19177. * @param index The index of the generic gamepad
  19178. * @param browserGamepad The browser gamepad
  19179. */
  19180. constructor(id: string, index: number, browserGamepad: any);
  19181. private _setButtonValue;
  19182. /**
  19183. * Updates the generic gamepad
  19184. */
  19185. update(): void;
  19186. /**
  19187. * Disposes the generic gamepad
  19188. */
  19189. dispose(): void;
  19190. }
  19191. }
  19192. declare module BABYLON {
  19193. /**
  19194. * Defines the types of pose enabled controllers that are supported
  19195. */
  19196. export enum PoseEnabledControllerType {
  19197. /**
  19198. * HTC Vive
  19199. */
  19200. VIVE = 0,
  19201. /**
  19202. * Oculus Rift
  19203. */
  19204. OCULUS = 1,
  19205. /**
  19206. * Windows mixed reality
  19207. */
  19208. WINDOWS = 2,
  19209. /**
  19210. * Samsung gear VR
  19211. */
  19212. GEAR_VR = 3,
  19213. /**
  19214. * Google Daydream
  19215. */
  19216. DAYDREAM = 4,
  19217. /**
  19218. * Generic
  19219. */
  19220. GENERIC = 5
  19221. }
  19222. /**
  19223. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19224. */
  19225. export interface MutableGamepadButton {
  19226. /**
  19227. * Value of the button/trigger
  19228. */
  19229. value: number;
  19230. /**
  19231. * If the button/trigger is currently touched
  19232. */
  19233. touched: boolean;
  19234. /**
  19235. * If the button/trigger is currently pressed
  19236. */
  19237. pressed: boolean;
  19238. }
  19239. /**
  19240. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19241. * @hidden
  19242. */
  19243. export interface ExtendedGamepadButton extends GamepadButton {
  19244. /**
  19245. * If the button/trigger is currently pressed
  19246. */
  19247. readonly pressed: boolean;
  19248. /**
  19249. * If the button/trigger is currently touched
  19250. */
  19251. readonly touched: boolean;
  19252. /**
  19253. * Value of the button/trigger
  19254. */
  19255. readonly value: number;
  19256. }
  19257. /** @hidden */
  19258. export interface _GamePadFactory {
  19259. /**
  19260. * Returns whether or not the current gamepad can be created for this type of controller.
  19261. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19262. * @returns true if it can be created, otherwise false
  19263. */
  19264. canCreate(gamepadInfo: any): boolean;
  19265. /**
  19266. * Creates a new instance of the Gamepad.
  19267. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19268. * @returns the new gamepad instance
  19269. */
  19270. create(gamepadInfo: any): Gamepad;
  19271. }
  19272. /**
  19273. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19274. */
  19275. export class PoseEnabledControllerHelper {
  19276. /** @hidden */
  19277. static _ControllerFactories: _GamePadFactory[];
  19278. /** @hidden */
  19279. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19280. /**
  19281. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19282. * @param vrGamepad the gamepad to initialized
  19283. * @returns a vr controller of the type the gamepad identified as
  19284. */
  19285. static InitiateController(vrGamepad: any): Gamepad;
  19286. }
  19287. /**
  19288. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19289. */
  19290. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19291. /**
  19292. * If the controller is used in a webXR session
  19293. */
  19294. isXR: boolean;
  19295. private _deviceRoomPosition;
  19296. private _deviceRoomRotationQuaternion;
  19297. /**
  19298. * The device position in babylon space
  19299. */
  19300. devicePosition: Vector3;
  19301. /**
  19302. * The device rotation in babylon space
  19303. */
  19304. deviceRotationQuaternion: Quaternion;
  19305. /**
  19306. * The scale factor of the device in babylon space
  19307. */
  19308. deviceScaleFactor: number;
  19309. /**
  19310. * (Likely devicePosition should be used instead) The device position in its room space
  19311. */
  19312. position: Vector3;
  19313. /**
  19314. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19315. */
  19316. rotationQuaternion: Quaternion;
  19317. /**
  19318. * The type of controller (Eg. Windows mixed reality)
  19319. */
  19320. controllerType: PoseEnabledControllerType;
  19321. protected _calculatedPosition: Vector3;
  19322. private _calculatedRotation;
  19323. /**
  19324. * The raw pose from the device
  19325. */
  19326. rawPose: DevicePose;
  19327. private _trackPosition;
  19328. private _maxRotationDistFromHeadset;
  19329. private _draggedRoomRotation;
  19330. /**
  19331. * @hidden
  19332. */
  19333. _disableTrackPosition(fixedPosition: Vector3): void;
  19334. /**
  19335. * Internal, the mesh attached to the controller
  19336. * @hidden
  19337. */
  19338. _mesh: Nullable<AbstractMesh>;
  19339. private _poseControlledCamera;
  19340. private _leftHandSystemQuaternion;
  19341. /**
  19342. * Internal, matrix used to convert room space to babylon space
  19343. * @hidden
  19344. */
  19345. _deviceToWorld: Matrix;
  19346. /**
  19347. * Node to be used when casting a ray from the controller
  19348. * @hidden
  19349. */
  19350. _pointingPoseNode: Nullable<TransformNode>;
  19351. /**
  19352. * Name of the child mesh that can be used to cast a ray from the controller
  19353. */
  19354. static readonly POINTING_POSE: string;
  19355. /**
  19356. * Creates a new PoseEnabledController from a gamepad
  19357. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19358. */
  19359. constructor(browserGamepad: any);
  19360. private _workingMatrix;
  19361. /**
  19362. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19363. */
  19364. update(): void;
  19365. /**
  19366. * Updates only the pose device and mesh without doing any button event checking
  19367. */
  19368. protected _updatePoseAndMesh(): void;
  19369. /**
  19370. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19371. * @param poseData raw pose fromthe device
  19372. */
  19373. updateFromDevice(poseData: DevicePose): void;
  19374. /**
  19375. * @hidden
  19376. */
  19377. _meshAttachedObservable: Observable<AbstractMesh>;
  19378. /**
  19379. * Attaches a mesh to the controller
  19380. * @param mesh the mesh to be attached
  19381. */
  19382. attachToMesh(mesh: AbstractMesh): void;
  19383. /**
  19384. * Attaches the controllers mesh to a camera
  19385. * @param camera the camera the mesh should be attached to
  19386. */
  19387. attachToPoseControlledCamera(camera: TargetCamera): void;
  19388. /**
  19389. * Disposes of the controller
  19390. */
  19391. dispose(): void;
  19392. /**
  19393. * The mesh that is attached to the controller
  19394. */
  19395. get mesh(): Nullable<AbstractMesh>;
  19396. /**
  19397. * Gets the ray of the controller in the direction the controller is pointing
  19398. * @param length the length the resulting ray should be
  19399. * @returns a ray in the direction the controller is pointing
  19400. */
  19401. getForwardRay(length?: number): Ray;
  19402. }
  19403. }
  19404. declare module BABYLON {
  19405. /**
  19406. * Defines the WebVRController object that represents controllers tracked in 3D space
  19407. */
  19408. export abstract class WebVRController extends PoseEnabledController {
  19409. /**
  19410. * Internal, the default controller model for the controller
  19411. */
  19412. protected _defaultModel: Nullable<AbstractMesh>;
  19413. /**
  19414. * Fired when the trigger state has changed
  19415. */
  19416. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19417. /**
  19418. * Fired when the main button state has changed
  19419. */
  19420. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19421. /**
  19422. * Fired when the secondary button state has changed
  19423. */
  19424. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19425. /**
  19426. * Fired when the pad state has changed
  19427. */
  19428. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19429. /**
  19430. * Fired when controllers stick values have changed
  19431. */
  19432. onPadValuesChangedObservable: Observable<StickValues>;
  19433. /**
  19434. * Array of button availible on the controller
  19435. */
  19436. protected _buttons: Array<MutableGamepadButton>;
  19437. private _onButtonStateChange;
  19438. /**
  19439. * Fired when a controller button's state has changed
  19440. * @param callback the callback containing the button that was modified
  19441. */
  19442. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19443. /**
  19444. * X and Y axis corresponding to the controllers joystick
  19445. */
  19446. pad: StickValues;
  19447. /**
  19448. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19449. */
  19450. hand: string;
  19451. /**
  19452. * The default controller model for the controller
  19453. */
  19454. get defaultModel(): Nullable<AbstractMesh>;
  19455. /**
  19456. * Creates a new WebVRController from a gamepad
  19457. * @param vrGamepad the gamepad that the WebVRController should be created from
  19458. */
  19459. constructor(vrGamepad: any);
  19460. /**
  19461. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19462. */
  19463. update(): void;
  19464. /**
  19465. * Function to be called when a button is modified
  19466. */
  19467. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19468. /**
  19469. * Loads a mesh and attaches it to the controller
  19470. * @param scene the scene the mesh should be added to
  19471. * @param meshLoaded callback for when the mesh has been loaded
  19472. */
  19473. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19474. private _setButtonValue;
  19475. private _changes;
  19476. private _checkChanges;
  19477. /**
  19478. * Disposes of th webVRCOntroller
  19479. */
  19480. dispose(): void;
  19481. }
  19482. }
  19483. declare module BABYLON {
  19484. /**
  19485. * The HemisphericLight simulates the ambient environment light,
  19486. * so the passed direction is the light reflection direction, not the incoming direction.
  19487. */
  19488. export class HemisphericLight extends Light {
  19489. /**
  19490. * The groundColor is the light in the opposite direction to the one specified during creation.
  19491. * 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.
  19492. */
  19493. groundColor: Color3;
  19494. /**
  19495. * The light reflection direction, not the incoming direction.
  19496. */
  19497. direction: Vector3;
  19498. /**
  19499. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19500. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19501. * The HemisphericLight can't cast shadows.
  19502. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19503. * @param name The friendly name of the light
  19504. * @param direction The direction of the light reflection
  19505. * @param scene The scene the light belongs to
  19506. */
  19507. constructor(name: string, direction: Vector3, scene: Scene);
  19508. protected _buildUniformLayout(): void;
  19509. /**
  19510. * Returns the string "HemisphericLight".
  19511. * @return The class name
  19512. */
  19513. getClassName(): string;
  19514. /**
  19515. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19516. * Returns the updated direction.
  19517. * @param target The target the direction should point to
  19518. * @return The computed direction
  19519. */
  19520. setDirectionToTarget(target: Vector3): Vector3;
  19521. /**
  19522. * Returns the shadow generator associated to the light.
  19523. * @returns Always null for hemispheric lights because it does not support shadows.
  19524. */
  19525. getShadowGenerator(): Nullable<IShadowGenerator>;
  19526. /**
  19527. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19528. * @param effect The effect to update
  19529. * @param lightIndex The index of the light in the effect to update
  19530. * @returns The hemispheric light
  19531. */
  19532. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19533. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19534. /**
  19535. * Computes the world matrix of the node
  19536. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19537. * @param useWasUpdatedFlag defines a reserved property
  19538. * @returns the world matrix
  19539. */
  19540. computeWorldMatrix(): Matrix;
  19541. /**
  19542. * Returns the integer 3.
  19543. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19544. */
  19545. getTypeID(): number;
  19546. /**
  19547. * Prepares the list of defines specific to the light type.
  19548. * @param defines the list of defines
  19549. * @param lightIndex defines the index of the light for the effect
  19550. */
  19551. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19552. }
  19553. }
  19554. declare module BABYLON {
  19555. /** @hidden */
  19556. export var vrMultiviewToSingleviewPixelShader: {
  19557. name: string;
  19558. shader: string;
  19559. };
  19560. }
  19561. declare module BABYLON {
  19562. /**
  19563. * Renders to multiple views with a single draw call
  19564. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19565. */
  19566. export class MultiviewRenderTarget extends RenderTargetTexture {
  19567. /**
  19568. * Creates a multiview render target
  19569. * @param scene scene used with the render target
  19570. * @param size the size of the render target (used for each view)
  19571. */
  19572. constructor(scene: Scene, size?: number | {
  19573. width: number;
  19574. height: number;
  19575. } | {
  19576. ratio: number;
  19577. });
  19578. /**
  19579. * @hidden
  19580. * @param faceIndex the face index, if its a cube texture
  19581. */
  19582. _bindFrameBuffer(faceIndex?: number): void;
  19583. /**
  19584. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19585. * @returns the view count
  19586. */
  19587. getViewCount(): number;
  19588. }
  19589. }
  19590. declare module BABYLON {
  19591. interface Engine {
  19592. /**
  19593. * Creates a new multiview render target
  19594. * @param width defines the width of the texture
  19595. * @param height defines the height of the texture
  19596. * @returns the created multiview texture
  19597. */
  19598. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19599. /**
  19600. * Binds a multiview framebuffer to be drawn to
  19601. * @param multiviewTexture texture to bind
  19602. */
  19603. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19604. }
  19605. interface Camera {
  19606. /**
  19607. * @hidden
  19608. * 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)
  19609. */
  19610. _useMultiviewToSingleView: boolean;
  19611. /**
  19612. * @hidden
  19613. * 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)
  19614. */
  19615. _multiviewTexture: Nullable<RenderTargetTexture>;
  19616. /**
  19617. * @hidden
  19618. * ensures the multiview texture of the camera exists and has the specified width/height
  19619. * @param width height to set on the multiview texture
  19620. * @param height width to set on the multiview texture
  19621. */
  19622. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19623. }
  19624. interface Scene {
  19625. /** @hidden */
  19626. _transformMatrixR: Matrix;
  19627. /** @hidden */
  19628. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19629. /** @hidden */
  19630. _createMultiviewUbo(): void;
  19631. /** @hidden */
  19632. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19633. /** @hidden */
  19634. _renderMultiviewToSingleView(camera: Camera): void;
  19635. }
  19636. }
  19637. declare module BABYLON {
  19638. /**
  19639. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19640. * This will not be used for webXR as it supports displaying texture arrays directly
  19641. */
  19642. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19643. /**
  19644. * Initializes a VRMultiviewToSingleview
  19645. * @param name name of the post process
  19646. * @param camera camera to be applied to
  19647. * @param scaleFactor scaling factor to the size of the output texture
  19648. */
  19649. constructor(name: string, camera: Camera, scaleFactor: number);
  19650. }
  19651. }
  19652. declare module BABYLON {
  19653. /**
  19654. * Interface used to define additional presentation attributes
  19655. */
  19656. export interface IVRPresentationAttributes {
  19657. /**
  19658. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19659. */
  19660. highRefreshRate: boolean;
  19661. /**
  19662. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19663. */
  19664. foveationLevel: number;
  19665. }
  19666. interface Engine {
  19667. /** @hidden */
  19668. _vrDisplay: any;
  19669. /** @hidden */
  19670. _vrSupported: boolean;
  19671. /** @hidden */
  19672. _oldSize: Size;
  19673. /** @hidden */
  19674. _oldHardwareScaleFactor: number;
  19675. /** @hidden */
  19676. _vrExclusivePointerMode: boolean;
  19677. /** @hidden */
  19678. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19679. /** @hidden */
  19680. _onVRDisplayPointerRestricted: () => void;
  19681. /** @hidden */
  19682. _onVRDisplayPointerUnrestricted: () => void;
  19683. /** @hidden */
  19684. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19685. /** @hidden */
  19686. _onVrDisplayDisconnect: Nullable<() => void>;
  19687. /** @hidden */
  19688. _onVrDisplayPresentChange: Nullable<() => void>;
  19689. /**
  19690. * Observable signaled when VR display mode changes
  19691. */
  19692. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19693. /**
  19694. * Observable signaled when VR request present is complete
  19695. */
  19696. onVRRequestPresentComplete: Observable<boolean>;
  19697. /**
  19698. * Observable signaled when VR request present starts
  19699. */
  19700. onVRRequestPresentStart: Observable<Engine>;
  19701. /**
  19702. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19703. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19704. */
  19705. isInVRExclusivePointerMode: boolean;
  19706. /**
  19707. * Gets a boolean indicating if a webVR device was detected
  19708. * @returns true if a webVR device was detected
  19709. */
  19710. isVRDevicePresent(): boolean;
  19711. /**
  19712. * Gets the current webVR device
  19713. * @returns the current webVR device (or null)
  19714. */
  19715. getVRDevice(): any;
  19716. /**
  19717. * Initializes a webVR display and starts listening to display change events
  19718. * The onVRDisplayChangedObservable will be notified upon these changes
  19719. * @returns A promise containing a VRDisplay and if vr is supported
  19720. */
  19721. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19722. /** @hidden */
  19723. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19724. /**
  19725. * Gets or sets the presentation attributes used to configure VR rendering
  19726. */
  19727. vrPresentationAttributes?: IVRPresentationAttributes;
  19728. /**
  19729. * Call this function to switch to webVR mode
  19730. * Will do nothing if webVR is not supported or if there is no webVR device
  19731. * @param options the webvr options provided to the camera. mainly used for multiview
  19732. * @see https://doc.babylonjs.com/how_to/webvr_camera
  19733. */
  19734. enableVR(options: WebVROptions): void;
  19735. /** @hidden */
  19736. _onVRFullScreenTriggered(): void;
  19737. }
  19738. }
  19739. declare module BABYLON {
  19740. /**
  19741. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19742. * IMPORTANT!! The data is right-hand data.
  19743. * @export
  19744. * @interface DevicePose
  19745. */
  19746. export interface DevicePose {
  19747. /**
  19748. * The position of the device, values in array are [x,y,z].
  19749. */
  19750. readonly position: Nullable<Float32Array>;
  19751. /**
  19752. * The linearVelocity of the device, values in array are [x,y,z].
  19753. */
  19754. readonly linearVelocity: Nullable<Float32Array>;
  19755. /**
  19756. * The linearAcceleration of the device, values in array are [x,y,z].
  19757. */
  19758. readonly linearAcceleration: Nullable<Float32Array>;
  19759. /**
  19760. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19761. */
  19762. readonly orientation: Nullable<Float32Array>;
  19763. /**
  19764. * The angularVelocity of the device, values in array are [x,y,z].
  19765. */
  19766. readonly angularVelocity: Nullable<Float32Array>;
  19767. /**
  19768. * The angularAcceleration of the device, values in array are [x,y,z].
  19769. */
  19770. readonly angularAcceleration: Nullable<Float32Array>;
  19771. }
  19772. /**
  19773. * Interface representing a pose controlled object in Babylon.
  19774. * A pose controlled object has both regular pose values as well as pose values
  19775. * from an external device such as a VR head mounted display
  19776. */
  19777. export interface PoseControlled {
  19778. /**
  19779. * The position of the object in babylon space.
  19780. */
  19781. position: Vector3;
  19782. /**
  19783. * The rotation quaternion of the object in babylon space.
  19784. */
  19785. rotationQuaternion: Quaternion;
  19786. /**
  19787. * The position of the device in babylon space.
  19788. */
  19789. devicePosition?: Vector3;
  19790. /**
  19791. * The rotation quaternion of the device in babylon space.
  19792. */
  19793. deviceRotationQuaternion: Quaternion;
  19794. /**
  19795. * The raw pose coming from the device.
  19796. */
  19797. rawPose: Nullable<DevicePose>;
  19798. /**
  19799. * The scale of the device to be used when translating from device space to babylon space.
  19800. */
  19801. deviceScaleFactor: number;
  19802. /**
  19803. * Updates the poseControlled values based on the input device pose.
  19804. * @param poseData the pose data to update the object with
  19805. */
  19806. updateFromDevice(poseData: DevicePose): void;
  19807. }
  19808. /**
  19809. * Set of options to customize the webVRCamera
  19810. */
  19811. export interface WebVROptions {
  19812. /**
  19813. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19814. */
  19815. trackPosition?: boolean;
  19816. /**
  19817. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19818. */
  19819. positionScale?: number;
  19820. /**
  19821. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19822. */
  19823. displayName?: string;
  19824. /**
  19825. * Should the native controller meshes be initialized. (default: true)
  19826. */
  19827. controllerMeshes?: boolean;
  19828. /**
  19829. * Creating a default HemiLight only on controllers. (default: true)
  19830. */
  19831. defaultLightingOnControllers?: boolean;
  19832. /**
  19833. * If you don't want to use the default VR button of the helper. (default: false)
  19834. */
  19835. useCustomVRButton?: boolean;
  19836. /**
  19837. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19838. */
  19839. customVRButton?: HTMLButtonElement;
  19840. /**
  19841. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19842. */
  19843. rayLength?: number;
  19844. /**
  19845. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19846. */
  19847. defaultHeight?: number;
  19848. /**
  19849. * If multiview should be used if availible (default: false)
  19850. */
  19851. useMultiview?: boolean;
  19852. }
  19853. /**
  19854. * This represents a WebVR camera.
  19855. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19856. * @example https://doc.babylonjs.com/how_to/webvr_camera
  19857. */
  19858. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19859. private webVROptions;
  19860. /**
  19861. * @hidden
  19862. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19863. */
  19864. _vrDevice: any;
  19865. /**
  19866. * The rawPose of the vrDevice.
  19867. */
  19868. rawPose: Nullable<DevicePose>;
  19869. private _onVREnabled;
  19870. private _specsVersion;
  19871. private _attached;
  19872. private _frameData;
  19873. protected _descendants: Array<Node>;
  19874. private _deviceRoomPosition;
  19875. /** @hidden */
  19876. _deviceRoomRotationQuaternion: Quaternion;
  19877. private _standingMatrix;
  19878. /**
  19879. * Represents device position in babylon space.
  19880. */
  19881. devicePosition: Vector3;
  19882. /**
  19883. * Represents device rotation in babylon space.
  19884. */
  19885. deviceRotationQuaternion: Quaternion;
  19886. /**
  19887. * The scale of the device to be used when translating from device space to babylon space.
  19888. */
  19889. deviceScaleFactor: number;
  19890. private _deviceToWorld;
  19891. private _worldToDevice;
  19892. /**
  19893. * References to the webVR controllers for the vrDevice.
  19894. */
  19895. controllers: Array<WebVRController>;
  19896. /**
  19897. * Emits an event when a controller is attached.
  19898. */
  19899. onControllersAttachedObservable: Observable<WebVRController[]>;
  19900. /**
  19901. * Emits an event when a controller's mesh has been loaded;
  19902. */
  19903. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19904. /**
  19905. * Emits an event when the HMD's pose has been updated.
  19906. */
  19907. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19908. private _poseSet;
  19909. /**
  19910. * If the rig cameras be used as parent instead of this camera.
  19911. */
  19912. rigParenting: boolean;
  19913. private _lightOnControllers;
  19914. private _defaultHeight?;
  19915. /**
  19916. * Instantiates a WebVRFreeCamera.
  19917. * @param name The name of the WebVRFreeCamera
  19918. * @param position The starting anchor position for the camera
  19919. * @param scene The scene the camera belongs to
  19920. * @param webVROptions a set of customizable options for the webVRCamera
  19921. */
  19922. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19923. /**
  19924. * Gets the device distance from the ground in meters.
  19925. * @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.
  19926. */
  19927. deviceDistanceToRoomGround(): number;
  19928. /**
  19929. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19930. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19931. */
  19932. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19933. /**
  19934. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19935. * @returns A promise with a boolean set to if the standing matrix is supported.
  19936. */
  19937. useStandingMatrixAsync(): Promise<boolean>;
  19938. /**
  19939. * Disposes the camera
  19940. */
  19941. dispose(): void;
  19942. /**
  19943. * Gets a vrController by name.
  19944. * @param name The name of the controller to retreive
  19945. * @returns the controller matching the name specified or null if not found
  19946. */
  19947. getControllerByName(name: string): Nullable<WebVRController>;
  19948. private _leftController;
  19949. /**
  19950. * The controller corresponding to the users left hand.
  19951. */
  19952. get leftController(): Nullable<WebVRController>;
  19953. private _rightController;
  19954. /**
  19955. * The controller corresponding to the users right hand.
  19956. */
  19957. get rightController(): Nullable<WebVRController>;
  19958. /**
  19959. * Casts a ray forward from the vrCamera's gaze.
  19960. * @param length Length of the ray (default: 100)
  19961. * @returns the ray corresponding to the gaze
  19962. */
  19963. getForwardRay(length?: number): Ray;
  19964. /**
  19965. * @hidden
  19966. * Updates the camera based on device's frame data
  19967. */
  19968. _checkInputs(): void;
  19969. /**
  19970. * Updates the poseControlled values based on the input device pose.
  19971. * @param poseData Pose coming from the device
  19972. */
  19973. updateFromDevice(poseData: DevicePose): void;
  19974. private _htmlElementAttached;
  19975. private _detachIfAttached;
  19976. /**
  19977. * WebVR's attach control will start broadcasting frames to the device.
  19978. * Note that in certain browsers (chrome for example) this function must be called
  19979. * within a user-interaction callback. Example:
  19980. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19981. *
  19982. * @param element html element to attach the vrDevice to
  19983. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19984. */
  19985. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19986. /**
  19987. * Detaches the camera from the html element and disables VR
  19988. *
  19989. * @param element html element to detach from
  19990. */
  19991. detachControl(element: HTMLElement): void;
  19992. /**
  19993. * @returns the name of this class
  19994. */
  19995. getClassName(): string;
  19996. /**
  19997. * Calls resetPose on the vrDisplay
  19998. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19999. */
  20000. resetToCurrentRotation(): void;
  20001. /**
  20002. * @hidden
  20003. * Updates the rig cameras (left and right eye)
  20004. */
  20005. _updateRigCameras(): void;
  20006. private _workingVector;
  20007. private _oneVector;
  20008. private _workingMatrix;
  20009. private updateCacheCalled;
  20010. private _correctPositionIfNotTrackPosition;
  20011. /**
  20012. * @hidden
  20013. * Updates the cached values of the camera
  20014. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20015. */
  20016. _updateCache(ignoreParentClass?: boolean): void;
  20017. /**
  20018. * @hidden
  20019. * Get current device position in babylon world
  20020. */
  20021. _computeDevicePosition(): void;
  20022. /**
  20023. * Updates the current device position and rotation in the babylon world
  20024. */
  20025. update(): void;
  20026. /**
  20027. * @hidden
  20028. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20029. * @returns an identity matrix
  20030. */
  20031. _getViewMatrix(): Matrix;
  20032. private _tmpMatrix;
  20033. /**
  20034. * This function is called by the two RIG cameras.
  20035. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20036. * @hidden
  20037. */
  20038. _getWebVRViewMatrix(): Matrix;
  20039. /** @hidden */
  20040. _getWebVRProjectionMatrix(): Matrix;
  20041. private _onGamepadConnectedObserver;
  20042. private _onGamepadDisconnectedObserver;
  20043. private _updateCacheWhenTrackingDisabledObserver;
  20044. /**
  20045. * Initializes the controllers and their meshes
  20046. */
  20047. initControllers(): void;
  20048. }
  20049. }
  20050. declare module BABYLON {
  20051. /**
  20052. * "Static Class" containing the most commonly used helper while dealing with material for
  20053. * rendering purpose.
  20054. *
  20055. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20056. *
  20057. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20058. */
  20059. export class MaterialHelper {
  20060. /**
  20061. * Bind the current view position to an effect.
  20062. * @param effect The effect to be bound
  20063. * @param scene The scene the eyes position is used from
  20064. * @param variableName name of the shader variable that will hold the eye position
  20065. */
  20066. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20067. /**
  20068. * Helps preparing the defines values about the UVs in used in the effect.
  20069. * UVs are shared as much as we can accross channels in the shaders.
  20070. * @param texture The texture we are preparing the UVs for
  20071. * @param defines The defines to update
  20072. * @param key The channel key "diffuse", "specular"... used in the shader
  20073. */
  20074. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20075. /**
  20076. * Binds a texture matrix value to its corrsponding uniform
  20077. * @param texture The texture to bind the matrix for
  20078. * @param uniformBuffer The uniform buffer receivin the data
  20079. * @param key The channel key "diffuse", "specular"... used in the shader
  20080. */
  20081. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20082. /**
  20083. * Gets the current status of the fog (should it be enabled?)
  20084. * @param mesh defines the mesh to evaluate for fog support
  20085. * @param scene defines the hosting scene
  20086. * @returns true if fog must be enabled
  20087. */
  20088. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20089. /**
  20090. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20091. * @param mesh defines the current mesh
  20092. * @param scene defines the current scene
  20093. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20094. * @param pointsCloud defines if point cloud rendering has to be turned on
  20095. * @param fogEnabled defines if fog has to be turned on
  20096. * @param alphaTest defines if alpha testing has to be turned on
  20097. * @param defines defines the current list of defines
  20098. */
  20099. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20100. /**
  20101. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20102. * @param scene defines the current scene
  20103. * @param engine defines the current engine
  20104. * @param defines specifies the list of active defines
  20105. * @param useInstances defines if instances have to be turned on
  20106. * @param useClipPlane defines if clip plane have to be turned on
  20107. * @param useInstances defines if instances have to be turned on
  20108. * @param useThinInstances defines if thin instances have to be turned on
  20109. */
  20110. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20111. /**
  20112. * Prepares the defines for bones
  20113. * @param mesh The mesh containing the geometry data we will draw
  20114. * @param defines The defines to update
  20115. */
  20116. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20117. /**
  20118. * Prepares the defines for morph targets
  20119. * @param mesh The mesh containing the geometry data we will draw
  20120. * @param defines The defines to update
  20121. */
  20122. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20123. /**
  20124. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20125. * @param mesh The mesh containing the geometry data we will draw
  20126. * @param defines The defines to update
  20127. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20128. * @param useBones Precise whether bones should be used or not (override mesh info)
  20129. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20130. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20131. * @returns false if defines are considered not dirty and have not been checked
  20132. */
  20133. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20134. /**
  20135. * Prepares the defines related to multiview
  20136. * @param scene The scene we are intending to draw
  20137. * @param defines The defines to update
  20138. */
  20139. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20140. /**
  20141. * Prepares the defines related to the prepass
  20142. * @param scene The scene we are intending to draw
  20143. * @param defines The defines to update
  20144. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20145. */
  20146. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20147. /**
  20148. * Prepares the defines related to the light information passed in parameter
  20149. * @param scene The scene we are intending to draw
  20150. * @param mesh The mesh the effect is compiling for
  20151. * @param light The light the effect is compiling for
  20152. * @param lightIndex The index of the light
  20153. * @param defines The defines to update
  20154. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20155. * @param state Defines the current state regarding what is needed (normals, etc...)
  20156. */
  20157. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20158. needNormals: boolean;
  20159. needRebuild: boolean;
  20160. shadowEnabled: boolean;
  20161. specularEnabled: boolean;
  20162. lightmapMode: boolean;
  20163. }): void;
  20164. /**
  20165. * Prepares the defines related to the light information passed in parameter
  20166. * @param scene The scene we are intending to draw
  20167. * @param mesh The mesh the effect is compiling for
  20168. * @param defines The defines to update
  20169. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20170. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20171. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20172. * @returns true if normals will be required for the rest of the effect
  20173. */
  20174. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20175. /**
  20176. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20177. * @param lightIndex defines the light index
  20178. * @param uniformsList The uniform list
  20179. * @param samplersList The sampler list
  20180. * @param projectedLightTexture defines if projected texture must be used
  20181. * @param uniformBuffersList defines an optional list of uniform buffers
  20182. */
  20183. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20184. /**
  20185. * Prepares the uniforms and samplers list to be used in the effect
  20186. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20187. * @param samplersList The sampler list
  20188. * @param defines The defines helping in the list generation
  20189. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20190. */
  20191. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20192. /**
  20193. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20194. * @param defines The defines to update while falling back
  20195. * @param fallbacks The authorized effect fallbacks
  20196. * @param maxSimultaneousLights The maximum number of lights allowed
  20197. * @param rank the current rank of the Effect
  20198. * @returns The newly affected rank
  20199. */
  20200. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20201. private static _TmpMorphInfluencers;
  20202. /**
  20203. * Prepares the list of attributes required for morph targets according to the effect defines.
  20204. * @param attribs The current list of supported attribs
  20205. * @param mesh The mesh to prepare the morph targets attributes for
  20206. * @param influencers The number of influencers
  20207. */
  20208. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20209. /**
  20210. * Prepares the list of attributes required for morph targets according to the effect defines.
  20211. * @param attribs The current list of supported attribs
  20212. * @param mesh The mesh to prepare the morph targets attributes for
  20213. * @param defines The current Defines of the effect
  20214. */
  20215. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20216. /**
  20217. * Prepares the list of attributes required for bones according to the effect defines.
  20218. * @param attribs The current list of supported attribs
  20219. * @param mesh The mesh to prepare the bones attributes for
  20220. * @param defines The current Defines of the effect
  20221. * @param fallbacks The current efffect fallback strategy
  20222. */
  20223. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20224. /**
  20225. * Check and prepare the list of attributes required for instances according to the effect defines.
  20226. * @param attribs The current list of supported attribs
  20227. * @param defines The current MaterialDefines of the effect
  20228. */
  20229. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20230. /**
  20231. * Add the list of attributes required for instances to the attribs array.
  20232. * @param attribs The current list of supported attribs
  20233. */
  20234. static PushAttributesForInstances(attribs: string[]): void;
  20235. /**
  20236. * Binds the light information to the effect.
  20237. * @param light The light containing the generator
  20238. * @param effect The effect we are binding the data to
  20239. * @param lightIndex The light index in the effect used to render
  20240. */
  20241. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20242. /**
  20243. * Binds the lights information from the scene to the effect for the given mesh.
  20244. * @param light Light to bind
  20245. * @param lightIndex Light index
  20246. * @param scene The scene where the light belongs to
  20247. * @param effect The effect we are binding the data to
  20248. * @param useSpecular Defines if specular is supported
  20249. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20250. */
  20251. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20252. /**
  20253. * Binds the lights information from the scene to the effect for the given mesh.
  20254. * @param scene The scene the lights belongs to
  20255. * @param mesh The mesh we are binding the information to render
  20256. * @param effect The effect we are binding the data to
  20257. * @param defines The generated defines for the effect
  20258. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20259. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20260. */
  20261. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20262. private static _tempFogColor;
  20263. /**
  20264. * Binds the fog information from the scene to the effect for the given mesh.
  20265. * @param scene The scene the lights belongs to
  20266. * @param mesh The mesh we are binding the information to render
  20267. * @param effect The effect we are binding the data to
  20268. * @param linearSpace Defines if the fog effect is applied in linear space
  20269. */
  20270. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20271. /**
  20272. * Binds the bones information from the mesh to the effect.
  20273. * @param mesh The mesh we are binding the information to render
  20274. * @param effect The effect we are binding the data to
  20275. */
  20276. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20277. /**
  20278. * Binds the morph targets information from the mesh to the effect.
  20279. * @param abstractMesh The mesh we are binding the information to render
  20280. * @param effect The effect we are binding the data to
  20281. */
  20282. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20283. /**
  20284. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20285. * @param defines The generated defines used in the effect
  20286. * @param effect The effect we are binding the data to
  20287. * @param scene The scene we are willing to render with logarithmic scale for
  20288. */
  20289. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20290. /**
  20291. * Binds the clip plane information from the scene to the effect.
  20292. * @param scene The scene the clip plane information are extracted from
  20293. * @param effect The effect we are binding the data to
  20294. */
  20295. static BindClipPlane(effect: Effect, scene: Scene): void;
  20296. }
  20297. }
  20298. declare module BABYLON {
  20299. /**
  20300. * Block used to expose an input value
  20301. */
  20302. export class InputBlock extends NodeMaterialBlock {
  20303. private _mode;
  20304. private _associatedVariableName;
  20305. private _storedValue;
  20306. private _valueCallback;
  20307. private _type;
  20308. private _animationType;
  20309. /** Gets or set a value used to limit the range of float values */
  20310. min: number;
  20311. /** Gets or set a value used to limit the range of float values */
  20312. max: number;
  20313. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20314. isBoolean: boolean;
  20315. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20316. matrixMode: number;
  20317. /** @hidden */
  20318. _systemValue: Nullable<NodeMaterialSystemValues>;
  20319. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20320. visibleInInspector: boolean;
  20321. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20322. isConstant: boolean;
  20323. /** Gets or sets the group to use to display this block in the Inspector */
  20324. groupInInspector: string;
  20325. /** Gets an observable raised when the value is changed */
  20326. onValueChangedObservable: Observable<InputBlock>;
  20327. /**
  20328. * Gets or sets the connection point type (default is float)
  20329. */
  20330. get type(): NodeMaterialBlockConnectionPointTypes;
  20331. /**
  20332. * Creates a new InputBlock
  20333. * @param name defines the block name
  20334. * @param target defines the target of that block (Vertex by default)
  20335. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20336. */
  20337. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20338. /**
  20339. * Validates if a name is a reserve word.
  20340. * @param newName the new name to be given to the node.
  20341. * @returns false if the name is a reserve word, else true.
  20342. */
  20343. validateBlockName(newName: string): boolean;
  20344. /**
  20345. * Gets the output component
  20346. */
  20347. get output(): NodeMaterialConnectionPoint;
  20348. /**
  20349. * Set the source of this connection point to a vertex attribute
  20350. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20351. * @returns the current connection point
  20352. */
  20353. setAsAttribute(attributeName?: string): InputBlock;
  20354. /**
  20355. * Set the source of this connection point to a system value
  20356. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20357. * @returns the current connection point
  20358. */
  20359. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20360. /**
  20361. * Gets or sets the value of that point.
  20362. * Please note that this value will be ignored if valueCallback is defined
  20363. */
  20364. get value(): any;
  20365. set value(value: any);
  20366. /**
  20367. * Gets or sets a callback used to get the value of that point.
  20368. * Please note that setting this value will force the connection point to ignore the value property
  20369. */
  20370. get valueCallback(): () => any;
  20371. set valueCallback(value: () => any);
  20372. /**
  20373. * Gets or sets the associated variable name in the shader
  20374. */
  20375. get associatedVariableName(): string;
  20376. set associatedVariableName(value: string);
  20377. /** Gets or sets the type of animation applied to the input */
  20378. get animationType(): AnimatedInputBlockTypes;
  20379. set animationType(value: AnimatedInputBlockTypes);
  20380. /**
  20381. * Gets a boolean indicating that this connection point not defined yet
  20382. */
  20383. get isUndefined(): boolean;
  20384. /**
  20385. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20386. * In this case the connection point name must be the name of the uniform to use.
  20387. * Can only be set on inputs
  20388. */
  20389. get isUniform(): boolean;
  20390. set isUniform(value: boolean);
  20391. /**
  20392. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20393. * In this case the connection point name must be the name of the attribute to use
  20394. * Can only be set on inputs
  20395. */
  20396. get isAttribute(): boolean;
  20397. set isAttribute(value: boolean);
  20398. /**
  20399. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20400. * Can only be set on exit points
  20401. */
  20402. get isVarying(): boolean;
  20403. set isVarying(value: boolean);
  20404. /**
  20405. * Gets a boolean indicating that the current connection point is a system value
  20406. */
  20407. get isSystemValue(): boolean;
  20408. /**
  20409. * Gets or sets the current well known value or null if not defined as a system value
  20410. */
  20411. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20412. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20413. /**
  20414. * Gets the current class name
  20415. * @returns the class name
  20416. */
  20417. getClassName(): string;
  20418. /**
  20419. * Animate the input if animationType !== None
  20420. * @param scene defines the rendering scene
  20421. */
  20422. animate(scene: Scene): void;
  20423. private _emitDefine;
  20424. initialize(state: NodeMaterialBuildState): void;
  20425. /**
  20426. * Set the input block to its default value (based on its type)
  20427. */
  20428. setDefaultValue(): void;
  20429. private _emitConstant;
  20430. /** @hidden */
  20431. get _noContextSwitch(): boolean;
  20432. private _emit;
  20433. /** @hidden */
  20434. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20435. /** @hidden */
  20436. _transmit(effect: Effect, scene: Scene): void;
  20437. protected _buildBlock(state: NodeMaterialBuildState): void;
  20438. protected _dumpPropertiesCode(): string;
  20439. dispose(): void;
  20440. serialize(): any;
  20441. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20442. }
  20443. }
  20444. declare module BABYLON {
  20445. /**
  20446. * Enum used to define the compatibility state between two connection points
  20447. */
  20448. export enum NodeMaterialConnectionPointCompatibilityStates {
  20449. /** Points are compatibles */
  20450. Compatible = 0,
  20451. /** Points are incompatible because of their types */
  20452. TypeIncompatible = 1,
  20453. /** Points are incompatible because of their targets (vertex vs fragment) */
  20454. TargetIncompatible = 2
  20455. }
  20456. /**
  20457. * Defines the direction of a connection point
  20458. */
  20459. export enum NodeMaterialConnectionPointDirection {
  20460. /** Input */
  20461. Input = 0,
  20462. /** Output */
  20463. Output = 1
  20464. }
  20465. /**
  20466. * Defines a connection point for a block
  20467. */
  20468. export class NodeMaterialConnectionPoint {
  20469. /** @hidden */
  20470. _ownerBlock: NodeMaterialBlock;
  20471. /** @hidden */
  20472. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20473. private _endpoints;
  20474. private _associatedVariableName;
  20475. private _direction;
  20476. /** @hidden */
  20477. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20478. /** @hidden */
  20479. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20480. private _type;
  20481. /** @hidden */
  20482. _enforceAssociatedVariableName: boolean;
  20483. /** Gets the direction of the point */
  20484. get direction(): NodeMaterialConnectionPointDirection;
  20485. /** Indicates that this connection point needs dual validation before being connected to another point */
  20486. needDualDirectionValidation: boolean;
  20487. /**
  20488. * Gets or sets the additional types supported by this connection point
  20489. */
  20490. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20491. /**
  20492. * Gets or sets the additional types excluded by this connection point
  20493. */
  20494. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20495. /**
  20496. * Observable triggered when this point is connected
  20497. */
  20498. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20499. /**
  20500. * Gets or sets the associated variable name in the shader
  20501. */
  20502. get associatedVariableName(): string;
  20503. set associatedVariableName(value: string);
  20504. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20505. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20506. /**
  20507. * Gets or sets the connection point type (default is float)
  20508. */
  20509. get type(): NodeMaterialBlockConnectionPointTypes;
  20510. set type(value: NodeMaterialBlockConnectionPointTypes);
  20511. /**
  20512. * Gets or sets the connection point name
  20513. */
  20514. name: string;
  20515. /**
  20516. * Gets or sets the connection point name
  20517. */
  20518. displayName: string;
  20519. /**
  20520. * Gets or sets a boolean indicating that this connection point can be omitted
  20521. */
  20522. isOptional: boolean;
  20523. /**
  20524. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  20525. */
  20526. isExposedOnFrame: boolean;
  20527. /**
  20528. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20529. */
  20530. define: string;
  20531. /** @hidden */
  20532. _prioritizeVertex: boolean;
  20533. private _target;
  20534. /** Gets or sets the target of that connection point */
  20535. get target(): NodeMaterialBlockTargets;
  20536. set target(value: NodeMaterialBlockTargets);
  20537. /**
  20538. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20539. */
  20540. get isConnected(): boolean;
  20541. /**
  20542. * Gets a boolean indicating that the current point is connected to an input block
  20543. */
  20544. get isConnectedToInputBlock(): boolean;
  20545. /**
  20546. * Gets a the connected input block (if any)
  20547. */
  20548. get connectInputBlock(): Nullable<InputBlock>;
  20549. /** Get the other side of the connection (if any) */
  20550. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20551. /** Get the block that owns this connection point */
  20552. get ownerBlock(): NodeMaterialBlock;
  20553. /** Get the block connected on the other side of this connection (if any) */
  20554. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20555. /** Get the block connected on the endpoints of this connection (if any) */
  20556. get connectedBlocks(): Array<NodeMaterialBlock>;
  20557. /** Gets the list of connected endpoints */
  20558. get endpoints(): NodeMaterialConnectionPoint[];
  20559. /** Gets a boolean indicating if that output point is connected to at least one input */
  20560. get hasEndpoints(): boolean;
  20561. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20562. get isConnectedInVertexShader(): boolean;
  20563. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20564. get isConnectedInFragmentShader(): boolean;
  20565. /**
  20566. * Creates a block suitable to be used as an input for this input point.
  20567. * If null is returned, a block based on the point type will be created.
  20568. * @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
  20569. */
  20570. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20571. /**
  20572. * Creates a new connection point
  20573. * @param name defines the connection point name
  20574. * @param ownerBlock defines the block hosting this connection point
  20575. * @param direction defines the direction of the connection point
  20576. */
  20577. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20578. /**
  20579. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20580. * @returns the class name
  20581. */
  20582. getClassName(): string;
  20583. /**
  20584. * Gets a boolean indicating if the current point can be connected to another point
  20585. * @param connectionPoint defines the other connection point
  20586. * @returns a boolean
  20587. */
  20588. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20589. /**
  20590. * Gets a number indicating if the current point can be connected to another point
  20591. * @param connectionPoint defines the other connection point
  20592. * @returns a number defining the compatibility state
  20593. */
  20594. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20595. /**
  20596. * Connect this point to another connection point
  20597. * @param connectionPoint defines the other connection point
  20598. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20599. * @returns the current connection point
  20600. */
  20601. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20602. /**
  20603. * Disconnect this point from one of his endpoint
  20604. * @param endpoint defines the other connection point
  20605. * @returns the current connection point
  20606. */
  20607. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20608. /**
  20609. * Serializes this point in a JSON representation
  20610. * @param isInput defines if the connection point is an input (default is true)
  20611. * @returns the serialized point object
  20612. */
  20613. serialize(isInput?: boolean): any;
  20614. /**
  20615. * Release resources
  20616. */
  20617. dispose(): void;
  20618. }
  20619. }
  20620. declare module BABYLON {
  20621. /**
  20622. * Enum used to define the material modes
  20623. */
  20624. export enum NodeMaterialModes {
  20625. /** Regular material */
  20626. Material = 0,
  20627. /** For post process */
  20628. PostProcess = 1,
  20629. /** For particle system */
  20630. Particle = 2
  20631. }
  20632. }
  20633. declare module BABYLON {
  20634. /**
  20635. * Block used to read a texture from a sampler
  20636. */
  20637. export class TextureBlock extends NodeMaterialBlock {
  20638. private _defineName;
  20639. private _linearDefineName;
  20640. private _gammaDefineName;
  20641. private _tempTextureRead;
  20642. private _samplerName;
  20643. private _transformedUVName;
  20644. private _textureTransformName;
  20645. private _textureInfoName;
  20646. private _mainUVName;
  20647. private _mainUVDefineName;
  20648. private _fragmentOnly;
  20649. /**
  20650. * Gets or sets the texture associated with the node
  20651. */
  20652. texture: Nullable<Texture>;
  20653. /**
  20654. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20655. */
  20656. convertToGammaSpace: boolean;
  20657. /**
  20658. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20659. */
  20660. convertToLinearSpace: boolean;
  20661. /**
  20662. * Create a new TextureBlock
  20663. * @param name defines the block name
  20664. */
  20665. constructor(name: string, fragmentOnly?: boolean);
  20666. /**
  20667. * Gets the current class name
  20668. * @returns the class name
  20669. */
  20670. getClassName(): string;
  20671. /**
  20672. * Gets the uv input component
  20673. */
  20674. get uv(): NodeMaterialConnectionPoint;
  20675. /**
  20676. * Gets the rgba output component
  20677. */
  20678. get rgba(): NodeMaterialConnectionPoint;
  20679. /**
  20680. * Gets the rgb output component
  20681. */
  20682. get rgb(): NodeMaterialConnectionPoint;
  20683. /**
  20684. * Gets the r output component
  20685. */
  20686. get r(): NodeMaterialConnectionPoint;
  20687. /**
  20688. * Gets the g output component
  20689. */
  20690. get g(): NodeMaterialConnectionPoint;
  20691. /**
  20692. * Gets the b output component
  20693. */
  20694. get b(): NodeMaterialConnectionPoint;
  20695. /**
  20696. * Gets the a output component
  20697. */
  20698. get a(): NodeMaterialConnectionPoint;
  20699. get target(): NodeMaterialBlockTargets;
  20700. autoConfigure(material: NodeMaterial): void;
  20701. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  20702. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20703. isReady(): boolean;
  20704. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20705. private get _isMixed();
  20706. private _injectVertexCode;
  20707. private _writeTextureRead;
  20708. private _writeOutput;
  20709. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20710. protected _dumpPropertiesCode(): string;
  20711. serialize(): any;
  20712. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20713. }
  20714. }
  20715. declare module BABYLON {
  20716. /** @hidden */
  20717. export var reflectionFunction: {
  20718. name: string;
  20719. shader: string;
  20720. };
  20721. }
  20722. declare module BABYLON {
  20723. /**
  20724. * Base block used to read a reflection texture from a sampler
  20725. */
  20726. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  20727. /** @hidden */
  20728. _define3DName: string;
  20729. /** @hidden */
  20730. _defineCubicName: string;
  20731. /** @hidden */
  20732. _defineExplicitName: string;
  20733. /** @hidden */
  20734. _defineProjectionName: string;
  20735. /** @hidden */
  20736. _defineLocalCubicName: string;
  20737. /** @hidden */
  20738. _defineSphericalName: string;
  20739. /** @hidden */
  20740. _definePlanarName: string;
  20741. /** @hidden */
  20742. _defineEquirectangularName: string;
  20743. /** @hidden */
  20744. _defineMirroredEquirectangularFixedName: string;
  20745. /** @hidden */
  20746. _defineEquirectangularFixedName: string;
  20747. /** @hidden */
  20748. _defineSkyboxName: string;
  20749. /** @hidden */
  20750. _defineOppositeZ: string;
  20751. /** @hidden */
  20752. _cubeSamplerName: string;
  20753. /** @hidden */
  20754. _2DSamplerName: string;
  20755. protected _positionUVWName: string;
  20756. protected _directionWName: string;
  20757. protected _reflectionVectorName: string;
  20758. /** @hidden */
  20759. _reflectionCoordsName: string;
  20760. /** @hidden */
  20761. _reflectionMatrixName: string;
  20762. protected _reflectionColorName: string;
  20763. /**
  20764. * Gets or sets the texture associated with the node
  20765. */
  20766. texture: Nullable<BaseTexture>;
  20767. /**
  20768. * Create a new ReflectionTextureBaseBlock
  20769. * @param name defines the block name
  20770. */
  20771. constructor(name: string);
  20772. /**
  20773. * Gets the current class name
  20774. * @returns the class name
  20775. */
  20776. getClassName(): string;
  20777. /**
  20778. * Gets the world position input component
  20779. */
  20780. abstract get position(): NodeMaterialConnectionPoint;
  20781. /**
  20782. * Gets the world position input component
  20783. */
  20784. abstract get worldPosition(): NodeMaterialConnectionPoint;
  20785. /**
  20786. * Gets the world normal input component
  20787. */
  20788. abstract get worldNormal(): NodeMaterialConnectionPoint;
  20789. /**
  20790. * Gets the world input component
  20791. */
  20792. abstract get world(): NodeMaterialConnectionPoint;
  20793. /**
  20794. * Gets the camera (or eye) position component
  20795. */
  20796. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  20797. /**
  20798. * Gets the view input component
  20799. */
  20800. abstract get view(): NodeMaterialConnectionPoint;
  20801. protected _getTexture(): Nullable<BaseTexture>;
  20802. autoConfigure(material: NodeMaterial): void;
  20803. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20804. isReady(): boolean;
  20805. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20806. /**
  20807. * Gets the code to inject in the vertex shader
  20808. * @param state current state of the node material building
  20809. * @returns the shader code
  20810. */
  20811. handleVertexSide(state: NodeMaterialBuildState): string;
  20812. /**
  20813. * Handles the inits for the fragment code path
  20814. * @param state node material build state
  20815. */
  20816. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  20817. /**
  20818. * Generates the reflection coords code for the fragment code path
  20819. * @param worldNormalVarName name of the world normal variable
  20820. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  20821. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  20822. * @returns the shader code
  20823. */
  20824. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  20825. /**
  20826. * Generates the reflection color code for the fragment code path
  20827. * @param lodVarName name of the lod variable
  20828. * @param swizzleLookupTexture swizzle to use for the final color variable
  20829. * @returns the shader code
  20830. */
  20831. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  20832. /**
  20833. * Generates the code corresponding to the connected output points
  20834. * @param state node material build state
  20835. * @param varName name of the variable to output
  20836. * @returns the shader code
  20837. */
  20838. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  20839. protected _buildBlock(state: NodeMaterialBuildState): this;
  20840. protected _dumpPropertiesCode(): string;
  20841. serialize(): any;
  20842. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20843. }
  20844. }
  20845. declare module BABYLON {
  20846. /**
  20847. * Defines a connection point to be used for points with a custom object type
  20848. */
  20849. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  20850. private _blockType;
  20851. private _blockName;
  20852. private _nameForCheking?;
  20853. /**
  20854. * Creates a new connection point
  20855. * @param name defines the connection point name
  20856. * @param ownerBlock defines the block hosting this connection point
  20857. * @param direction defines the direction of the connection point
  20858. */
  20859. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  20860. /**
  20861. * Gets a number indicating if the current point can be connected to another point
  20862. * @param connectionPoint defines the other connection point
  20863. * @returns a number defining the compatibility state
  20864. */
  20865. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20866. /**
  20867. * Creates a block suitable to be used as an input for this input point.
  20868. * If null is returned, a block based on the point type will be created.
  20869. * @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
  20870. */
  20871. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20872. }
  20873. }
  20874. declare module BABYLON {
  20875. /**
  20876. * Enum defining the type of properties that can be edited in the property pages in the NME
  20877. */
  20878. export enum PropertyTypeForEdition {
  20879. /** property is a boolean */
  20880. Boolean = 0,
  20881. /** property is a float */
  20882. Float = 1,
  20883. /** property is a Vector2 */
  20884. Vector2 = 2,
  20885. /** property is a list of values */
  20886. List = 3
  20887. }
  20888. /**
  20889. * Interface that defines an option in a variable of type list
  20890. */
  20891. export interface IEditablePropertyListOption {
  20892. /** label of the option */
  20893. "label": string;
  20894. /** value of the option */
  20895. "value": number;
  20896. }
  20897. /**
  20898. * Interface that defines the options available for an editable property
  20899. */
  20900. export interface IEditablePropertyOption {
  20901. /** min value */
  20902. "min"?: number;
  20903. /** max value */
  20904. "max"?: number;
  20905. /** notifiers: indicates which actions to take when the property is changed */
  20906. "notifiers"?: {
  20907. /** the material should be rebuilt */
  20908. "rebuild"?: boolean;
  20909. /** the preview should be updated */
  20910. "update"?: boolean;
  20911. };
  20912. /** list of the options for a variable of type list */
  20913. "options"?: IEditablePropertyListOption[];
  20914. }
  20915. /**
  20916. * Interface that describes an editable property
  20917. */
  20918. export interface IPropertyDescriptionForEdition {
  20919. /** name of the property */
  20920. "propertyName": string;
  20921. /** display name of the property */
  20922. "displayName": string;
  20923. /** type of the property */
  20924. "type": PropertyTypeForEdition;
  20925. /** group of the property - all properties with the same group value will be displayed in a specific section */
  20926. "groupName": string;
  20927. /** options for the property */
  20928. "options": IEditablePropertyOption;
  20929. }
  20930. /**
  20931. * Decorator that flags a property in a node material block as being editable
  20932. */
  20933. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  20934. }
  20935. declare module BABYLON {
  20936. /**
  20937. * Block used to implement the refraction part of the sub surface module of the PBR material
  20938. */
  20939. export class RefractionBlock extends NodeMaterialBlock {
  20940. /** @hidden */
  20941. _define3DName: string;
  20942. /** @hidden */
  20943. _refractionMatrixName: string;
  20944. /** @hidden */
  20945. _defineLODRefractionAlpha: string;
  20946. /** @hidden */
  20947. _defineLinearSpecularRefraction: string;
  20948. /** @hidden */
  20949. _defineOppositeZ: string;
  20950. /** @hidden */
  20951. _cubeSamplerName: string;
  20952. /** @hidden */
  20953. _2DSamplerName: string;
  20954. /** @hidden */
  20955. _vRefractionMicrosurfaceInfosName: string;
  20956. /** @hidden */
  20957. _vRefractionInfosName: string;
  20958. private _scene;
  20959. /**
  20960. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20961. * Materials half opaque for instance using refraction could benefit from this control.
  20962. */
  20963. linkRefractionWithTransparency: boolean;
  20964. /**
  20965. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20966. */
  20967. invertRefractionY: boolean;
  20968. /**
  20969. * Gets or sets the texture associated with the node
  20970. */
  20971. texture: Nullable<BaseTexture>;
  20972. /**
  20973. * Create a new RefractionBlock
  20974. * @param name defines the block name
  20975. */
  20976. constructor(name: string);
  20977. /**
  20978. * Gets the current class name
  20979. * @returns the class name
  20980. */
  20981. getClassName(): string;
  20982. /**
  20983. * Gets the intensity input component
  20984. */
  20985. get intensity(): NodeMaterialConnectionPoint;
  20986. /**
  20987. * Gets the index of refraction input component
  20988. */
  20989. get indexOfRefraction(): NodeMaterialConnectionPoint;
  20990. /**
  20991. * Gets the tint at distance input component
  20992. */
  20993. get tintAtDistance(): NodeMaterialConnectionPoint;
  20994. /**
  20995. * Gets the view input component
  20996. */
  20997. get view(): NodeMaterialConnectionPoint;
  20998. /**
  20999. * Gets the refraction object output component
  21000. */
  21001. get refraction(): NodeMaterialConnectionPoint;
  21002. /**
  21003. * Returns true if the block has a texture
  21004. */
  21005. get hasTexture(): boolean;
  21006. protected _getTexture(): Nullable<BaseTexture>;
  21007. autoConfigure(material: NodeMaterial): void;
  21008. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21009. isReady(): boolean;
  21010. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21011. /**
  21012. * Gets the main code of the block (fragment side)
  21013. * @param state current state of the node material building
  21014. * @returns the shader code
  21015. */
  21016. getCode(state: NodeMaterialBuildState): string;
  21017. protected _buildBlock(state: NodeMaterialBuildState): this;
  21018. protected _dumpPropertiesCode(): string;
  21019. serialize(): any;
  21020. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21021. }
  21022. }
  21023. declare module BABYLON {
  21024. /**
  21025. * Base block used as input for post process
  21026. */
  21027. export class CurrentScreenBlock extends NodeMaterialBlock {
  21028. private _samplerName;
  21029. private _linearDefineName;
  21030. private _gammaDefineName;
  21031. private _mainUVName;
  21032. private _tempTextureRead;
  21033. /**
  21034. * Gets or sets the texture associated with the node
  21035. */
  21036. texture: Nullable<BaseTexture>;
  21037. /**
  21038. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21039. */
  21040. convertToGammaSpace: boolean;
  21041. /**
  21042. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21043. */
  21044. convertToLinearSpace: boolean;
  21045. /**
  21046. * Create a new CurrentScreenBlock
  21047. * @param name defines the block name
  21048. */
  21049. constructor(name: string);
  21050. /**
  21051. * Gets the current class name
  21052. * @returns the class name
  21053. */
  21054. getClassName(): string;
  21055. /**
  21056. * Gets the uv input component
  21057. */
  21058. get uv(): NodeMaterialConnectionPoint;
  21059. /**
  21060. * Gets the rgba output component
  21061. */
  21062. get rgba(): NodeMaterialConnectionPoint;
  21063. /**
  21064. * Gets the rgb output component
  21065. */
  21066. get rgb(): NodeMaterialConnectionPoint;
  21067. /**
  21068. * Gets the r output component
  21069. */
  21070. get r(): NodeMaterialConnectionPoint;
  21071. /**
  21072. * Gets the g output component
  21073. */
  21074. get g(): NodeMaterialConnectionPoint;
  21075. /**
  21076. * Gets the b output component
  21077. */
  21078. get b(): NodeMaterialConnectionPoint;
  21079. /**
  21080. * Gets the a output component
  21081. */
  21082. get a(): NodeMaterialConnectionPoint;
  21083. /**
  21084. * Initialize the block and prepare the context for build
  21085. * @param state defines the state that will be used for the build
  21086. */
  21087. initialize(state: NodeMaterialBuildState): void;
  21088. get target(): NodeMaterialBlockTargets;
  21089. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21090. isReady(): boolean;
  21091. private _injectVertexCode;
  21092. private _writeTextureRead;
  21093. private _writeOutput;
  21094. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21095. serialize(): any;
  21096. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21097. }
  21098. }
  21099. declare module BABYLON {
  21100. /**
  21101. * Base block used for the particle texture
  21102. */
  21103. export class ParticleTextureBlock extends NodeMaterialBlock {
  21104. private _samplerName;
  21105. private _linearDefineName;
  21106. private _gammaDefineName;
  21107. private _tempTextureRead;
  21108. /**
  21109. * Gets or sets the texture associated with the node
  21110. */
  21111. texture: Nullable<BaseTexture>;
  21112. /**
  21113. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21114. */
  21115. convertToGammaSpace: boolean;
  21116. /**
  21117. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21118. */
  21119. convertToLinearSpace: boolean;
  21120. /**
  21121. * Create a new ParticleTextureBlock
  21122. * @param name defines the block name
  21123. */
  21124. constructor(name: string);
  21125. /**
  21126. * Gets the current class name
  21127. * @returns the class name
  21128. */
  21129. getClassName(): string;
  21130. /**
  21131. * Gets the uv input component
  21132. */
  21133. get uv(): NodeMaterialConnectionPoint;
  21134. /**
  21135. * Gets the rgba output component
  21136. */
  21137. get rgba(): NodeMaterialConnectionPoint;
  21138. /**
  21139. * Gets the rgb output component
  21140. */
  21141. get rgb(): NodeMaterialConnectionPoint;
  21142. /**
  21143. * Gets the r output component
  21144. */
  21145. get r(): NodeMaterialConnectionPoint;
  21146. /**
  21147. * Gets the g output component
  21148. */
  21149. get g(): NodeMaterialConnectionPoint;
  21150. /**
  21151. * Gets the b output component
  21152. */
  21153. get b(): NodeMaterialConnectionPoint;
  21154. /**
  21155. * Gets the a output component
  21156. */
  21157. get a(): NodeMaterialConnectionPoint;
  21158. /**
  21159. * Initialize the block and prepare the context for build
  21160. * @param state defines the state that will be used for the build
  21161. */
  21162. initialize(state: NodeMaterialBuildState): void;
  21163. autoConfigure(material: NodeMaterial): void;
  21164. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21165. isReady(): boolean;
  21166. private _writeOutput;
  21167. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21168. serialize(): any;
  21169. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21170. }
  21171. }
  21172. declare module BABYLON {
  21173. /**
  21174. * Class used to store shared data between 2 NodeMaterialBuildState
  21175. */
  21176. export class NodeMaterialBuildStateSharedData {
  21177. /**
  21178. * Gets the list of emitted varyings
  21179. */
  21180. temps: string[];
  21181. /**
  21182. * Gets the list of emitted varyings
  21183. */
  21184. varyings: string[];
  21185. /**
  21186. * Gets the varying declaration string
  21187. */
  21188. varyingDeclaration: string;
  21189. /**
  21190. * Input blocks
  21191. */
  21192. inputBlocks: InputBlock[];
  21193. /**
  21194. * Input blocks
  21195. */
  21196. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21197. /**
  21198. * Bindable blocks (Blocks that need to set data to the effect)
  21199. */
  21200. bindableBlocks: NodeMaterialBlock[];
  21201. /**
  21202. * List of blocks that can provide a compilation fallback
  21203. */
  21204. blocksWithFallbacks: NodeMaterialBlock[];
  21205. /**
  21206. * List of blocks that can provide a define update
  21207. */
  21208. blocksWithDefines: NodeMaterialBlock[];
  21209. /**
  21210. * List of blocks that can provide a repeatable content
  21211. */
  21212. repeatableContentBlocks: NodeMaterialBlock[];
  21213. /**
  21214. * List of blocks that can provide a dynamic list of uniforms
  21215. */
  21216. dynamicUniformBlocks: NodeMaterialBlock[];
  21217. /**
  21218. * List of blocks that can block the isReady function for the material
  21219. */
  21220. blockingBlocks: NodeMaterialBlock[];
  21221. /**
  21222. * Gets the list of animated inputs
  21223. */
  21224. animatedInputs: InputBlock[];
  21225. /**
  21226. * Build Id used to avoid multiple recompilations
  21227. */
  21228. buildId: number;
  21229. /** List of emitted variables */
  21230. variableNames: {
  21231. [key: string]: number;
  21232. };
  21233. /** List of emitted defines */
  21234. defineNames: {
  21235. [key: string]: number;
  21236. };
  21237. /** Should emit comments? */
  21238. emitComments: boolean;
  21239. /** Emit build activity */
  21240. verbose: boolean;
  21241. /** Gets or sets the hosting scene */
  21242. scene: Scene;
  21243. /**
  21244. * Gets the compilation hints emitted at compilation time
  21245. */
  21246. hints: {
  21247. needWorldViewMatrix: boolean;
  21248. needWorldViewProjectionMatrix: boolean;
  21249. needAlphaBlending: boolean;
  21250. needAlphaTesting: boolean;
  21251. };
  21252. /**
  21253. * List of compilation checks
  21254. */
  21255. checks: {
  21256. emitVertex: boolean;
  21257. emitFragment: boolean;
  21258. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21259. };
  21260. /**
  21261. * Is vertex program allowed to be empty?
  21262. */
  21263. allowEmptyVertexProgram: boolean;
  21264. /** Creates a new shared data */
  21265. constructor();
  21266. /**
  21267. * Emits console errors and exceptions if there is a failing check
  21268. */
  21269. emitErrors(): void;
  21270. }
  21271. }
  21272. declare module BABYLON {
  21273. /**
  21274. * Class used to store node based material build state
  21275. */
  21276. export class NodeMaterialBuildState {
  21277. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21278. supportUniformBuffers: boolean;
  21279. /**
  21280. * Gets the list of emitted attributes
  21281. */
  21282. attributes: string[];
  21283. /**
  21284. * Gets the list of emitted uniforms
  21285. */
  21286. uniforms: string[];
  21287. /**
  21288. * Gets the list of emitted constants
  21289. */
  21290. constants: string[];
  21291. /**
  21292. * Gets the list of emitted samplers
  21293. */
  21294. samplers: string[];
  21295. /**
  21296. * Gets the list of emitted functions
  21297. */
  21298. functions: {
  21299. [key: string]: string;
  21300. };
  21301. /**
  21302. * Gets the list of emitted extensions
  21303. */
  21304. extensions: {
  21305. [key: string]: string;
  21306. };
  21307. /**
  21308. * Gets the target of the compilation state
  21309. */
  21310. target: NodeMaterialBlockTargets;
  21311. /**
  21312. * Gets the list of emitted counters
  21313. */
  21314. counters: {
  21315. [key: string]: number;
  21316. };
  21317. /**
  21318. * Shared data between multiple NodeMaterialBuildState instances
  21319. */
  21320. sharedData: NodeMaterialBuildStateSharedData;
  21321. /** @hidden */
  21322. _vertexState: NodeMaterialBuildState;
  21323. /** @hidden */
  21324. _attributeDeclaration: string;
  21325. /** @hidden */
  21326. _uniformDeclaration: string;
  21327. /** @hidden */
  21328. _constantDeclaration: string;
  21329. /** @hidden */
  21330. _samplerDeclaration: string;
  21331. /** @hidden */
  21332. _varyingTransfer: string;
  21333. /** @hidden */
  21334. _injectAtEnd: string;
  21335. private _repeatableContentAnchorIndex;
  21336. /** @hidden */
  21337. _builtCompilationString: string;
  21338. /**
  21339. * Gets the emitted compilation strings
  21340. */
  21341. compilationString: string;
  21342. /**
  21343. * Finalize the compilation strings
  21344. * @param state defines the current compilation state
  21345. */
  21346. finalize(state: NodeMaterialBuildState): void;
  21347. /** @hidden */
  21348. get _repeatableContentAnchor(): string;
  21349. /** @hidden */
  21350. _getFreeVariableName(prefix: string): string;
  21351. /** @hidden */
  21352. _getFreeDefineName(prefix: string): string;
  21353. /** @hidden */
  21354. _excludeVariableName(name: string): void;
  21355. /** @hidden */
  21356. _emit2DSampler(name: string): void;
  21357. /** @hidden */
  21358. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21359. /** @hidden */
  21360. _emitExtension(name: string, extension: string, define?: string): void;
  21361. /** @hidden */
  21362. _emitFunction(name: string, code: string, comments: string): void;
  21363. /** @hidden */
  21364. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21365. replaceStrings?: {
  21366. search: RegExp;
  21367. replace: string;
  21368. }[];
  21369. repeatKey?: string;
  21370. }): string;
  21371. /** @hidden */
  21372. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21373. repeatKey?: string;
  21374. removeAttributes?: boolean;
  21375. removeUniforms?: boolean;
  21376. removeVaryings?: boolean;
  21377. removeIfDef?: boolean;
  21378. replaceStrings?: {
  21379. search: RegExp;
  21380. replace: string;
  21381. }[];
  21382. }, storeKey?: string): void;
  21383. /** @hidden */
  21384. _registerTempVariable(name: string): boolean;
  21385. /** @hidden */
  21386. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21387. /** @hidden */
  21388. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21389. /** @hidden */
  21390. _emitFloat(value: number): string;
  21391. }
  21392. }
  21393. declare module BABYLON {
  21394. /**
  21395. * Helper class used to generate session unique ID
  21396. */
  21397. export class UniqueIdGenerator {
  21398. private static _UniqueIdCounter;
  21399. /**
  21400. * Gets an unique (relatively to the current scene) Id
  21401. */
  21402. static get UniqueId(): number;
  21403. }
  21404. }
  21405. declare module BABYLON {
  21406. /**
  21407. * Defines a block that can be used inside a node based material
  21408. */
  21409. export class NodeMaterialBlock {
  21410. private _buildId;
  21411. private _buildTarget;
  21412. private _target;
  21413. private _isFinalMerger;
  21414. private _isInput;
  21415. private _name;
  21416. protected _isUnique: boolean;
  21417. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21418. inputsAreExclusive: boolean;
  21419. /** @hidden */
  21420. _codeVariableName: string;
  21421. /** @hidden */
  21422. _inputs: NodeMaterialConnectionPoint[];
  21423. /** @hidden */
  21424. _outputs: NodeMaterialConnectionPoint[];
  21425. /** @hidden */
  21426. _preparationId: number;
  21427. /**
  21428. * Gets the name of the block
  21429. */
  21430. get name(): string;
  21431. /**
  21432. * Sets the name of the block. Will check if the name is valid.
  21433. */
  21434. set name(newName: string);
  21435. /**
  21436. * Gets or sets the unique id of the node
  21437. */
  21438. uniqueId: number;
  21439. /**
  21440. * Gets or sets the comments associated with this block
  21441. */
  21442. comments: string;
  21443. /**
  21444. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21445. */
  21446. get isUnique(): boolean;
  21447. /**
  21448. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21449. */
  21450. get isFinalMerger(): boolean;
  21451. /**
  21452. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21453. */
  21454. get isInput(): boolean;
  21455. /**
  21456. * Gets or sets the build Id
  21457. */
  21458. get buildId(): number;
  21459. set buildId(value: number);
  21460. /**
  21461. * Gets or sets the target of the block
  21462. */
  21463. get target(): NodeMaterialBlockTargets;
  21464. set target(value: NodeMaterialBlockTargets);
  21465. /**
  21466. * Gets the list of input points
  21467. */
  21468. get inputs(): NodeMaterialConnectionPoint[];
  21469. /** Gets the list of output points */
  21470. get outputs(): NodeMaterialConnectionPoint[];
  21471. /**
  21472. * Find an input by its name
  21473. * @param name defines the name of the input to look for
  21474. * @returns the input or null if not found
  21475. */
  21476. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21477. /**
  21478. * Find an output by its name
  21479. * @param name defines the name of the outputto look for
  21480. * @returns the output or null if not found
  21481. */
  21482. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21483. /**
  21484. * Creates a new NodeMaterialBlock
  21485. * @param name defines the block name
  21486. * @param target defines the target of that block (Vertex by default)
  21487. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21488. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21489. */
  21490. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21491. /**
  21492. * Initialize the block and prepare the context for build
  21493. * @param state defines the state that will be used for the build
  21494. */
  21495. initialize(state: NodeMaterialBuildState): void;
  21496. /**
  21497. * Bind data to effect. Will only be called for blocks with isBindable === true
  21498. * @param effect defines the effect to bind data to
  21499. * @param nodeMaterial defines the hosting NodeMaterial
  21500. * @param mesh defines the mesh that will be rendered
  21501. * @param subMesh defines the submesh that will be rendered
  21502. */
  21503. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21504. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21505. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21506. protected _writeFloat(value: number): string;
  21507. /**
  21508. * Gets the current class name e.g. "NodeMaterialBlock"
  21509. * @returns the class name
  21510. */
  21511. getClassName(): string;
  21512. /**
  21513. * Register a new input. Must be called inside a block constructor
  21514. * @param name defines the connection point name
  21515. * @param type defines the connection point type
  21516. * @param isOptional defines a boolean indicating that this input can be omitted
  21517. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21518. * @param point an already created connection point. If not provided, create a new one
  21519. * @returns the current block
  21520. */
  21521. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21522. /**
  21523. * Register a new output. Must be called inside a block constructor
  21524. * @param name defines the connection point name
  21525. * @param type defines the connection point type
  21526. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21527. * @param point an already created connection point. If not provided, create a new one
  21528. * @returns the current block
  21529. */
  21530. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21531. /**
  21532. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21533. * @param forOutput defines an optional connection point to check compatibility with
  21534. * @returns the first available input or null
  21535. */
  21536. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21537. /**
  21538. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21539. * @param forBlock defines an optional block to check compatibility with
  21540. * @returns the first available input or null
  21541. */
  21542. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21543. /**
  21544. * Gets the sibling of the given output
  21545. * @param current defines the current output
  21546. * @returns the next output in the list or null
  21547. */
  21548. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21549. /**
  21550. * Connect current block with another block
  21551. * @param other defines the block to connect with
  21552. * @param options define the various options to help pick the right connections
  21553. * @returns the current block
  21554. */
  21555. connectTo(other: NodeMaterialBlock, options?: {
  21556. input?: string;
  21557. output?: string;
  21558. outputSwizzle?: string;
  21559. }): this | undefined;
  21560. protected _buildBlock(state: NodeMaterialBuildState): void;
  21561. /**
  21562. * Add uniforms, samplers and uniform buffers at compilation time
  21563. * @param state defines the state to update
  21564. * @param nodeMaterial defines the node material requesting the update
  21565. * @param defines defines the material defines to update
  21566. * @param uniformBuffers defines the list of uniform buffer names
  21567. */
  21568. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21569. /**
  21570. * Add potential fallbacks if shader compilation fails
  21571. * @param mesh defines the mesh to be rendered
  21572. * @param fallbacks defines the current prioritized list of fallbacks
  21573. */
  21574. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21575. /**
  21576. * Initialize defines for shader compilation
  21577. * @param mesh defines the mesh to be rendered
  21578. * @param nodeMaterial defines the node material requesting the update
  21579. * @param defines defines the material defines to update
  21580. * @param useInstances specifies that instances should be used
  21581. */
  21582. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21583. /**
  21584. * Update defines for shader compilation
  21585. * @param mesh defines the mesh to be rendered
  21586. * @param nodeMaterial defines the node material requesting the update
  21587. * @param defines defines the material defines to update
  21588. * @param useInstances specifies that instances should be used
  21589. * @param subMesh defines which submesh to render
  21590. */
  21591. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21592. /**
  21593. * Lets the block try to connect some inputs automatically
  21594. * @param material defines the hosting NodeMaterial
  21595. */
  21596. autoConfigure(material: NodeMaterial): void;
  21597. /**
  21598. * Function called when a block is declared as repeatable content generator
  21599. * @param vertexShaderState defines the current compilation state for the vertex shader
  21600. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21601. * @param mesh defines the mesh to be rendered
  21602. * @param defines defines the material defines to update
  21603. */
  21604. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21605. /**
  21606. * Checks if the block is ready
  21607. * @param mesh defines the mesh to be rendered
  21608. * @param nodeMaterial defines the node material requesting the update
  21609. * @param defines defines the material defines to update
  21610. * @param useInstances specifies that instances should be used
  21611. * @returns true if the block is ready
  21612. */
  21613. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21614. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21615. private _processBuild;
  21616. /**
  21617. * Validates the new name for the block node.
  21618. * @param newName the new name to be given to the node.
  21619. * @returns false if the name is a reserve word, else true.
  21620. */
  21621. validateBlockName(newName: string): boolean;
  21622. /**
  21623. * Compile the current node and generate the shader code
  21624. * @param state defines the current compilation state (uniforms, samplers, current string)
  21625. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21626. * @returns true if already built
  21627. */
  21628. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21629. protected _inputRename(name: string): string;
  21630. protected _outputRename(name: string): string;
  21631. protected _dumpPropertiesCode(): string;
  21632. /** @hidden */
  21633. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21634. /** @hidden */
  21635. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21636. /**
  21637. * Clone the current block to a new identical block
  21638. * @param scene defines the hosting scene
  21639. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21640. * @returns a copy of the current block
  21641. */
  21642. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21643. /**
  21644. * Serializes this block in a JSON representation
  21645. * @returns the serialized block object
  21646. */
  21647. serialize(): any;
  21648. /** @hidden */
  21649. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21650. private _deserializePortDisplayNamesAndExposedOnFrame;
  21651. /**
  21652. * Release resources
  21653. */
  21654. dispose(): void;
  21655. }
  21656. }
  21657. declare module BABYLON {
  21658. /**
  21659. * Base class of materials working in push mode in babylon JS
  21660. * @hidden
  21661. */
  21662. export class PushMaterial extends Material {
  21663. protected _activeEffect: Effect;
  21664. protected _normalMatrix: Matrix;
  21665. constructor(name: string, scene: Scene);
  21666. getEffect(): Effect;
  21667. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21668. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21669. /**
  21670. * Binds the given world matrix to the active effect
  21671. *
  21672. * @param world the matrix to bind
  21673. */
  21674. bindOnlyWorldMatrix(world: Matrix): void;
  21675. /**
  21676. * Binds the given normal matrix to the active effect
  21677. *
  21678. * @param normalMatrix the matrix to bind
  21679. */
  21680. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21681. bind(world: Matrix, mesh?: Mesh): void;
  21682. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21683. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21684. }
  21685. }
  21686. declare module BABYLON {
  21687. /**
  21688. * Root class for all node material optimizers
  21689. */
  21690. export class NodeMaterialOptimizer {
  21691. /**
  21692. * Function used to optimize a NodeMaterial graph
  21693. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  21694. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  21695. */
  21696. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  21697. }
  21698. }
  21699. declare module BABYLON {
  21700. /**
  21701. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  21702. */
  21703. export class TransformBlock extends NodeMaterialBlock {
  21704. /**
  21705. * Defines the value to use to complement W value to transform it to a Vector4
  21706. */
  21707. complementW: number;
  21708. /**
  21709. * Defines the value to use to complement z value to transform it to a Vector4
  21710. */
  21711. complementZ: number;
  21712. /**
  21713. * Creates a new TransformBlock
  21714. * @param name defines the block name
  21715. */
  21716. constructor(name: string);
  21717. /**
  21718. * Gets the current class name
  21719. * @returns the class name
  21720. */
  21721. getClassName(): string;
  21722. /**
  21723. * Gets the vector input
  21724. */
  21725. get vector(): NodeMaterialConnectionPoint;
  21726. /**
  21727. * Gets the output component
  21728. */
  21729. get output(): NodeMaterialConnectionPoint;
  21730. /**
  21731. * Gets the xyz output component
  21732. */
  21733. get xyz(): NodeMaterialConnectionPoint;
  21734. /**
  21735. * Gets the matrix transform input
  21736. */
  21737. get transform(): NodeMaterialConnectionPoint;
  21738. protected _buildBlock(state: NodeMaterialBuildState): this;
  21739. /**
  21740. * Update defines for shader compilation
  21741. * @param mesh defines the mesh to be rendered
  21742. * @param nodeMaterial defines the node material requesting the update
  21743. * @param defines defines the material defines to update
  21744. * @param useInstances specifies that instances should be used
  21745. * @param subMesh defines which submesh to render
  21746. */
  21747. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21748. serialize(): any;
  21749. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21750. protected _dumpPropertiesCode(): string;
  21751. }
  21752. }
  21753. declare module BABYLON {
  21754. /**
  21755. * Block used to output the vertex position
  21756. */
  21757. export class VertexOutputBlock extends NodeMaterialBlock {
  21758. /**
  21759. * Creates a new VertexOutputBlock
  21760. * @param name defines the block name
  21761. */
  21762. constructor(name: string);
  21763. /**
  21764. * Gets the current class name
  21765. * @returns the class name
  21766. */
  21767. getClassName(): string;
  21768. /**
  21769. * Gets the vector input component
  21770. */
  21771. get vector(): NodeMaterialConnectionPoint;
  21772. protected _buildBlock(state: NodeMaterialBuildState): this;
  21773. }
  21774. }
  21775. declare module BABYLON {
  21776. /**
  21777. * Block used to output the final color
  21778. */
  21779. export class FragmentOutputBlock extends NodeMaterialBlock {
  21780. /**
  21781. * Create a new FragmentOutputBlock
  21782. * @param name defines the block name
  21783. */
  21784. constructor(name: string);
  21785. /**
  21786. * Gets the current class name
  21787. * @returns the class name
  21788. */
  21789. getClassName(): string;
  21790. /**
  21791. * Gets the rgba input component
  21792. */
  21793. get rgba(): NodeMaterialConnectionPoint;
  21794. /**
  21795. * Gets the rgb input component
  21796. */
  21797. get rgb(): NodeMaterialConnectionPoint;
  21798. /**
  21799. * Gets the a input component
  21800. */
  21801. get a(): NodeMaterialConnectionPoint;
  21802. protected _buildBlock(state: NodeMaterialBuildState): this;
  21803. }
  21804. }
  21805. declare module BABYLON {
  21806. /**
  21807. * Block used for the particle ramp gradient section
  21808. */
  21809. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  21810. /**
  21811. * Create a new ParticleRampGradientBlock
  21812. * @param name defines the block name
  21813. */
  21814. constructor(name: string);
  21815. /**
  21816. * Gets the current class name
  21817. * @returns the class name
  21818. */
  21819. getClassName(): string;
  21820. /**
  21821. * Gets the color input component
  21822. */
  21823. get color(): NodeMaterialConnectionPoint;
  21824. /**
  21825. * Gets the rampColor output component
  21826. */
  21827. get rampColor(): NodeMaterialConnectionPoint;
  21828. /**
  21829. * Initialize the block and prepare the context for build
  21830. * @param state defines the state that will be used for the build
  21831. */
  21832. initialize(state: NodeMaterialBuildState): void;
  21833. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21834. }
  21835. }
  21836. declare module BABYLON {
  21837. /**
  21838. * Block used for the particle blend multiply section
  21839. */
  21840. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  21841. /**
  21842. * Create a new ParticleBlendMultiplyBlock
  21843. * @param name defines the block name
  21844. */
  21845. constructor(name: string);
  21846. /**
  21847. * Gets the current class name
  21848. * @returns the class name
  21849. */
  21850. getClassName(): string;
  21851. /**
  21852. * Gets the color input component
  21853. */
  21854. get color(): NodeMaterialConnectionPoint;
  21855. /**
  21856. * Gets the alphaTexture input component
  21857. */
  21858. get alphaTexture(): NodeMaterialConnectionPoint;
  21859. /**
  21860. * Gets the alphaColor input component
  21861. */
  21862. get alphaColor(): NodeMaterialConnectionPoint;
  21863. /**
  21864. * Gets the blendColor output component
  21865. */
  21866. get blendColor(): NodeMaterialConnectionPoint;
  21867. /**
  21868. * Initialize the block and prepare the context for build
  21869. * @param state defines the state that will be used for the build
  21870. */
  21871. initialize(state: NodeMaterialBuildState): void;
  21872. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21873. }
  21874. }
  21875. declare module BABYLON {
  21876. /**
  21877. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  21878. */
  21879. export class VectorMergerBlock extends NodeMaterialBlock {
  21880. /**
  21881. * Create a new VectorMergerBlock
  21882. * @param name defines the block name
  21883. */
  21884. constructor(name: string);
  21885. /**
  21886. * Gets the current class name
  21887. * @returns the class name
  21888. */
  21889. getClassName(): string;
  21890. /**
  21891. * Gets the xyz component (input)
  21892. */
  21893. get xyzIn(): NodeMaterialConnectionPoint;
  21894. /**
  21895. * Gets the xy component (input)
  21896. */
  21897. get xyIn(): NodeMaterialConnectionPoint;
  21898. /**
  21899. * Gets the x component (input)
  21900. */
  21901. get x(): NodeMaterialConnectionPoint;
  21902. /**
  21903. * Gets the y component (input)
  21904. */
  21905. get y(): NodeMaterialConnectionPoint;
  21906. /**
  21907. * Gets the z component (input)
  21908. */
  21909. get z(): NodeMaterialConnectionPoint;
  21910. /**
  21911. * Gets the w component (input)
  21912. */
  21913. get w(): NodeMaterialConnectionPoint;
  21914. /**
  21915. * Gets the xyzw component (output)
  21916. */
  21917. get xyzw(): NodeMaterialConnectionPoint;
  21918. /**
  21919. * Gets the xyz component (output)
  21920. */
  21921. get xyzOut(): NodeMaterialConnectionPoint;
  21922. /**
  21923. * Gets the xy component (output)
  21924. */
  21925. get xyOut(): NodeMaterialConnectionPoint;
  21926. /**
  21927. * Gets the xy component (output)
  21928. * @deprecated Please use xyOut instead.
  21929. */
  21930. get xy(): NodeMaterialConnectionPoint;
  21931. /**
  21932. * Gets the xyz component (output)
  21933. * @deprecated Please use xyzOut instead.
  21934. */
  21935. get xyz(): NodeMaterialConnectionPoint;
  21936. protected _buildBlock(state: NodeMaterialBuildState): this;
  21937. }
  21938. }
  21939. declare module BABYLON {
  21940. /**
  21941. * Block used to remap a float from a range to a new one
  21942. */
  21943. export class RemapBlock extends NodeMaterialBlock {
  21944. /**
  21945. * Gets or sets the source range
  21946. */
  21947. sourceRange: Vector2;
  21948. /**
  21949. * Gets or sets the target range
  21950. */
  21951. targetRange: Vector2;
  21952. /**
  21953. * Creates a new RemapBlock
  21954. * @param name defines the block name
  21955. */
  21956. constructor(name: string);
  21957. /**
  21958. * Gets the current class name
  21959. * @returns the class name
  21960. */
  21961. getClassName(): string;
  21962. /**
  21963. * Gets the input component
  21964. */
  21965. get input(): NodeMaterialConnectionPoint;
  21966. /**
  21967. * Gets the source min input component
  21968. */
  21969. get sourceMin(): NodeMaterialConnectionPoint;
  21970. /**
  21971. * Gets the source max input component
  21972. */
  21973. get sourceMax(): NodeMaterialConnectionPoint;
  21974. /**
  21975. * Gets the target min input component
  21976. */
  21977. get targetMin(): NodeMaterialConnectionPoint;
  21978. /**
  21979. * Gets the target max input component
  21980. */
  21981. get targetMax(): NodeMaterialConnectionPoint;
  21982. /**
  21983. * Gets the output component
  21984. */
  21985. get output(): NodeMaterialConnectionPoint;
  21986. protected _buildBlock(state: NodeMaterialBuildState): this;
  21987. protected _dumpPropertiesCode(): string;
  21988. serialize(): any;
  21989. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21990. }
  21991. }
  21992. declare module BABYLON {
  21993. /**
  21994. * Block used to multiply 2 values
  21995. */
  21996. export class MultiplyBlock extends NodeMaterialBlock {
  21997. /**
  21998. * Creates a new MultiplyBlock
  21999. * @param name defines the block name
  22000. */
  22001. constructor(name: string);
  22002. /**
  22003. * Gets the current class name
  22004. * @returns the class name
  22005. */
  22006. getClassName(): string;
  22007. /**
  22008. * Gets the left operand input component
  22009. */
  22010. get left(): NodeMaterialConnectionPoint;
  22011. /**
  22012. * Gets the right operand input component
  22013. */
  22014. get right(): NodeMaterialConnectionPoint;
  22015. /**
  22016. * Gets the output component
  22017. */
  22018. get output(): NodeMaterialConnectionPoint;
  22019. protected _buildBlock(state: NodeMaterialBuildState): this;
  22020. }
  22021. }
  22022. declare module BABYLON {
  22023. /**
  22024. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22025. */
  22026. export class ColorSplitterBlock extends NodeMaterialBlock {
  22027. /**
  22028. * Create a new ColorSplitterBlock
  22029. * @param name defines the block name
  22030. */
  22031. constructor(name: string);
  22032. /**
  22033. * Gets the current class name
  22034. * @returns the class name
  22035. */
  22036. getClassName(): string;
  22037. /**
  22038. * Gets the rgba component (input)
  22039. */
  22040. get rgba(): NodeMaterialConnectionPoint;
  22041. /**
  22042. * Gets the rgb component (input)
  22043. */
  22044. get rgbIn(): NodeMaterialConnectionPoint;
  22045. /**
  22046. * Gets the rgb component (output)
  22047. */
  22048. get rgbOut(): NodeMaterialConnectionPoint;
  22049. /**
  22050. * Gets the r component (output)
  22051. */
  22052. get r(): NodeMaterialConnectionPoint;
  22053. /**
  22054. * Gets the g component (output)
  22055. */
  22056. get g(): NodeMaterialConnectionPoint;
  22057. /**
  22058. * Gets the b component (output)
  22059. */
  22060. get b(): NodeMaterialConnectionPoint;
  22061. /**
  22062. * Gets the a component (output)
  22063. */
  22064. get a(): NodeMaterialConnectionPoint;
  22065. protected _inputRename(name: string): string;
  22066. protected _outputRename(name: string): string;
  22067. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22068. }
  22069. }
  22070. declare module BABYLON {
  22071. /**
  22072. * Interface used to configure the node material editor
  22073. */
  22074. export interface INodeMaterialEditorOptions {
  22075. /** Define the URl to load node editor script */
  22076. editorURL?: string;
  22077. }
  22078. /** @hidden */
  22079. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22080. NORMAL: boolean;
  22081. TANGENT: boolean;
  22082. UV1: boolean;
  22083. /** BONES */
  22084. NUM_BONE_INFLUENCERS: number;
  22085. BonesPerMesh: number;
  22086. BONETEXTURE: boolean;
  22087. /** MORPH TARGETS */
  22088. MORPHTARGETS: boolean;
  22089. MORPHTARGETS_NORMAL: boolean;
  22090. MORPHTARGETS_TANGENT: boolean;
  22091. MORPHTARGETS_UV: boolean;
  22092. NUM_MORPH_INFLUENCERS: number;
  22093. /** IMAGE PROCESSING */
  22094. IMAGEPROCESSING: boolean;
  22095. VIGNETTE: boolean;
  22096. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22097. VIGNETTEBLENDMODEOPAQUE: boolean;
  22098. TONEMAPPING: boolean;
  22099. TONEMAPPING_ACES: boolean;
  22100. CONTRAST: boolean;
  22101. EXPOSURE: boolean;
  22102. COLORCURVES: boolean;
  22103. COLORGRADING: boolean;
  22104. COLORGRADING3D: boolean;
  22105. SAMPLER3DGREENDEPTH: boolean;
  22106. SAMPLER3DBGRMAP: boolean;
  22107. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22108. /** MISC. */
  22109. BUMPDIRECTUV: number;
  22110. constructor();
  22111. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22112. }
  22113. /**
  22114. * Class used to configure NodeMaterial
  22115. */
  22116. export interface INodeMaterialOptions {
  22117. /**
  22118. * Defines if blocks should emit comments
  22119. */
  22120. emitComments: boolean;
  22121. }
  22122. /**
  22123. * Class used to create a node based material built by assembling shader blocks
  22124. */
  22125. export class NodeMaterial extends PushMaterial {
  22126. private static _BuildIdGenerator;
  22127. private _options;
  22128. private _vertexCompilationState;
  22129. private _fragmentCompilationState;
  22130. private _sharedData;
  22131. private _buildId;
  22132. private _buildWasSuccessful;
  22133. private _cachedWorldViewMatrix;
  22134. private _cachedWorldViewProjectionMatrix;
  22135. private _optimizers;
  22136. private _animationFrame;
  22137. /** Define the Url to load node editor script */
  22138. static EditorURL: string;
  22139. /** Define the Url to load snippets */
  22140. static SnippetUrl: string;
  22141. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22142. static IgnoreTexturesAtLoadTime: boolean;
  22143. private BJSNODEMATERIALEDITOR;
  22144. /** Get the inspector from bundle or global */
  22145. private _getGlobalNodeMaterialEditor;
  22146. /**
  22147. * Snippet ID if the material was created from the snippet server
  22148. */
  22149. snippetId: string;
  22150. /**
  22151. * Gets or sets data used by visual editor
  22152. * @see https://nme.babylonjs.com
  22153. */
  22154. editorData: any;
  22155. /**
  22156. * 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)
  22157. */
  22158. ignoreAlpha: boolean;
  22159. /**
  22160. * Defines the maximum number of lights that can be used in the material
  22161. */
  22162. maxSimultaneousLights: number;
  22163. /**
  22164. * Observable raised when the material is built
  22165. */
  22166. onBuildObservable: Observable<NodeMaterial>;
  22167. /**
  22168. * Gets or sets the root nodes of the material vertex shader
  22169. */
  22170. _vertexOutputNodes: NodeMaterialBlock[];
  22171. /**
  22172. * Gets or sets the root nodes of the material fragment (pixel) shader
  22173. */
  22174. _fragmentOutputNodes: NodeMaterialBlock[];
  22175. /** Gets or sets options to control the node material overall behavior */
  22176. get options(): INodeMaterialOptions;
  22177. set options(options: INodeMaterialOptions);
  22178. /**
  22179. * Default configuration related to image processing available in the standard Material.
  22180. */
  22181. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22182. /**
  22183. * Gets the image processing configuration used either in this material.
  22184. */
  22185. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22186. /**
  22187. * Sets the Default image processing configuration used either in the this material.
  22188. *
  22189. * If sets to null, the scene one is in use.
  22190. */
  22191. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22192. /**
  22193. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22194. */
  22195. attachedBlocks: NodeMaterialBlock[];
  22196. /**
  22197. * Specifies the mode of the node material
  22198. * @hidden
  22199. */
  22200. _mode: NodeMaterialModes;
  22201. /**
  22202. * Gets the mode property
  22203. */
  22204. get mode(): NodeMaterialModes;
  22205. /**
  22206. * Create a new node based material
  22207. * @param name defines the material name
  22208. * @param scene defines the hosting scene
  22209. * @param options defines creation option
  22210. */
  22211. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22212. /**
  22213. * Gets the current class name of the material e.g. "NodeMaterial"
  22214. * @returns the class name
  22215. */
  22216. getClassName(): string;
  22217. /**
  22218. * Keep track of the image processing observer to allow dispose and replace.
  22219. */
  22220. private _imageProcessingObserver;
  22221. /**
  22222. * Attaches a new image processing configuration to the Standard Material.
  22223. * @param configuration
  22224. */
  22225. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22226. /**
  22227. * Get a block by its name
  22228. * @param name defines the name of the block to retrieve
  22229. * @returns the required block or null if not found
  22230. */
  22231. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22232. /**
  22233. * Get a block by its name
  22234. * @param predicate defines the predicate used to find the good candidate
  22235. * @returns the required block or null if not found
  22236. */
  22237. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22238. /**
  22239. * Get an input block by its name
  22240. * @param predicate defines the predicate used to find the good candidate
  22241. * @returns the required input block or null if not found
  22242. */
  22243. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22244. /**
  22245. * Gets the list of input blocks attached to this material
  22246. * @returns an array of InputBlocks
  22247. */
  22248. getInputBlocks(): InputBlock[];
  22249. /**
  22250. * Adds a new optimizer to the list of optimizers
  22251. * @param optimizer defines the optimizers to add
  22252. * @returns the current material
  22253. */
  22254. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22255. /**
  22256. * Remove an optimizer from the list of optimizers
  22257. * @param optimizer defines the optimizers to remove
  22258. * @returns the current material
  22259. */
  22260. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22261. /**
  22262. * Add a new block to the list of output nodes
  22263. * @param node defines the node to add
  22264. * @returns the current material
  22265. */
  22266. addOutputNode(node: NodeMaterialBlock): this;
  22267. /**
  22268. * Remove a block from the list of root nodes
  22269. * @param node defines the node to remove
  22270. * @returns the current material
  22271. */
  22272. removeOutputNode(node: NodeMaterialBlock): this;
  22273. private _addVertexOutputNode;
  22274. private _removeVertexOutputNode;
  22275. private _addFragmentOutputNode;
  22276. private _removeFragmentOutputNode;
  22277. /**
  22278. * Specifies if the material will require alpha blending
  22279. * @returns a boolean specifying if alpha blending is needed
  22280. */
  22281. needAlphaBlending(): boolean;
  22282. /**
  22283. * Specifies if this material should be rendered in alpha test mode
  22284. * @returns a boolean specifying if an alpha test is needed.
  22285. */
  22286. needAlphaTesting(): boolean;
  22287. private _initializeBlock;
  22288. private _resetDualBlocks;
  22289. /**
  22290. * Remove a block from the current node material
  22291. * @param block defines the block to remove
  22292. */
  22293. removeBlock(block: NodeMaterialBlock): void;
  22294. /**
  22295. * Build the material and generates the inner effect
  22296. * @param verbose defines if the build should log activity
  22297. */
  22298. build(verbose?: boolean): void;
  22299. /**
  22300. * Runs an otpimization phase to try to improve the shader code
  22301. */
  22302. optimize(): void;
  22303. private _prepareDefinesForAttributes;
  22304. /**
  22305. * Create a post process from the material
  22306. * @param camera The camera to apply the render pass to.
  22307. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22308. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22309. * @param engine The engine which the post process will be applied. (default: current engine)
  22310. * @param reusable If the post process can be reused on the same frame. (default: false)
  22311. * @param textureType Type of textures used when performing the post process. (default: 0)
  22312. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22313. * @returns the post process created
  22314. */
  22315. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22316. /**
  22317. * Create the post process effect from the material
  22318. * @param postProcess The post process to create the effect for
  22319. */
  22320. createEffectForPostProcess(postProcess: PostProcess): void;
  22321. private _createEffectOrPostProcess;
  22322. private _createEffectForParticles;
  22323. /**
  22324. * Create the effect to be used as the custom effect for a particle system
  22325. * @param particleSystem Particle system to create the effect for
  22326. * @param onCompiled defines a function to call when the effect creation is successful
  22327. * @param onError defines a function to call when the effect creation has failed
  22328. */
  22329. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22330. private _processDefines;
  22331. /**
  22332. * Get if the submesh is ready to be used and all its information available.
  22333. * Child classes can use it to update shaders
  22334. * @param mesh defines the mesh to check
  22335. * @param subMesh defines which submesh to check
  22336. * @param useInstances specifies that instances should be used
  22337. * @returns a boolean indicating that the submesh is ready or not
  22338. */
  22339. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22340. /**
  22341. * Get a string representing the shaders built by the current node graph
  22342. */
  22343. get compiledShaders(): string;
  22344. /**
  22345. * Binds the world matrix to the material
  22346. * @param world defines the world transformation matrix
  22347. */
  22348. bindOnlyWorldMatrix(world: Matrix): void;
  22349. /**
  22350. * Binds the submesh to this material by preparing the effect and shader to draw
  22351. * @param world defines the world transformation matrix
  22352. * @param mesh defines the mesh containing the submesh
  22353. * @param subMesh defines the submesh to bind the material to
  22354. */
  22355. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22356. /**
  22357. * Gets the active textures from the material
  22358. * @returns an array of textures
  22359. */
  22360. getActiveTextures(): BaseTexture[];
  22361. /**
  22362. * Gets the list of texture blocks
  22363. * @returns an array of texture blocks
  22364. */
  22365. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22366. /**
  22367. * Specifies if the material uses a texture
  22368. * @param texture defines the texture to check against the material
  22369. * @returns a boolean specifying if the material uses the texture
  22370. */
  22371. hasTexture(texture: BaseTexture): boolean;
  22372. /**
  22373. * Disposes the material
  22374. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22375. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22376. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22377. */
  22378. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22379. /** Creates the node editor window. */
  22380. private _createNodeEditor;
  22381. /**
  22382. * Launch the node material editor
  22383. * @param config Define the configuration of the editor
  22384. * @return a promise fulfilled when the node editor is visible
  22385. */
  22386. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22387. /**
  22388. * Clear the current material
  22389. */
  22390. clear(): void;
  22391. /**
  22392. * Clear the current material and set it to a default state
  22393. */
  22394. setToDefault(): void;
  22395. /**
  22396. * Clear the current material and set it to a default state for post process
  22397. */
  22398. setToDefaultPostProcess(): void;
  22399. /**
  22400. * Clear the current material and set it to a default state for particle
  22401. */
  22402. setToDefaultParticle(): void;
  22403. /**
  22404. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22405. * @param url defines the url to load from
  22406. * @returns a promise that will fullfil when the material is fully loaded
  22407. */
  22408. loadAsync(url: string): Promise<void>;
  22409. private _gatherBlocks;
  22410. /**
  22411. * Generate a string containing the code declaration required to create an equivalent of this material
  22412. * @returns a string
  22413. */
  22414. generateCode(): string;
  22415. /**
  22416. * Serializes this material in a JSON representation
  22417. * @returns the serialized material object
  22418. */
  22419. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22420. private _restoreConnections;
  22421. /**
  22422. * Clear the current graph and load a new one from a serialization object
  22423. * @param source defines the JSON representation of the material
  22424. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22425. * @param merge defines whether or not the source must be merged or replace the current content
  22426. */
  22427. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  22428. /**
  22429. * Makes a duplicate of the current material.
  22430. * @param name - name to use for the new material.
  22431. */
  22432. clone(name: string): NodeMaterial;
  22433. /**
  22434. * Creates a node material from parsed material data
  22435. * @param source defines the JSON representation of the material
  22436. * @param scene defines the hosting scene
  22437. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22438. * @returns a new node material
  22439. */
  22440. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22441. /**
  22442. * Creates a node material from a snippet saved in a remote file
  22443. * @param name defines the name of the material to create
  22444. * @param url defines the url to load from
  22445. * @param scene defines the hosting scene
  22446. * @returns a promise that will resolve to the new node material
  22447. */
  22448. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22449. /**
  22450. * Creates a node material from a snippet saved by the node material editor
  22451. * @param snippetId defines the snippet to load
  22452. * @param scene defines the hosting scene
  22453. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22454. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22455. * @returns a promise that will resolve to the new node material
  22456. */
  22457. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22458. /**
  22459. * Creates a new node material set to default basic configuration
  22460. * @param name defines the name of the material
  22461. * @param scene defines the hosting scene
  22462. * @returns a new NodeMaterial
  22463. */
  22464. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22465. }
  22466. }
  22467. declare module BABYLON {
  22468. /**
  22469. * Size options for a post process
  22470. */
  22471. export type PostProcessOptions = {
  22472. width: number;
  22473. height: number;
  22474. };
  22475. /**
  22476. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22477. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22478. */
  22479. export class PostProcess {
  22480. /** Name of the PostProcess. */
  22481. name: string;
  22482. /**
  22483. * Gets or sets the unique id of the post process
  22484. */
  22485. uniqueId: number;
  22486. /**
  22487. * Width of the texture to apply the post process on
  22488. */
  22489. width: number;
  22490. /**
  22491. * Height of the texture to apply the post process on
  22492. */
  22493. height: number;
  22494. /**
  22495. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22496. */
  22497. nodeMaterialSource: Nullable<NodeMaterial>;
  22498. /**
  22499. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22500. * @hidden
  22501. */
  22502. _outputTexture: Nullable<InternalTexture>;
  22503. /**
  22504. * Sampling mode used by the shader
  22505. * See https://doc.babylonjs.com/classes/3.1/texture
  22506. */
  22507. renderTargetSamplingMode: number;
  22508. /**
  22509. * Clear color to use when screen clearing
  22510. */
  22511. clearColor: Color4;
  22512. /**
  22513. * If the buffer needs to be cleared before applying the post process. (default: true)
  22514. * Should be set to false if shader will overwrite all previous pixels.
  22515. */
  22516. autoClear: boolean;
  22517. /**
  22518. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22519. */
  22520. alphaMode: number;
  22521. /**
  22522. * Sets the setAlphaBlendConstants of the babylon engine
  22523. */
  22524. alphaConstants: Color4;
  22525. /**
  22526. * Animations to be used for the post processing
  22527. */
  22528. animations: Animation[];
  22529. /**
  22530. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22531. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22532. */
  22533. enablePixelPerfectMode: boolean;
  22534. /**
  22535. * Force the postprocess to be applied without taking in account viewport
  22536. */
  22537. forceFullscreenViewport: boolean;
  22538. /**
  22539. * List of inspectable custom properties (used by the Inspector)
  22540. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22541. */
  22542. inspectableCustomProperties: IInspectable[];
  22543. /**
  22544. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22545. *
  22546. * | Value | Type | Description |
  22547. * | ----- | ----------------------------------- | ----------- |
  22548. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22549. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22550. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22551. *
  22552. */
  22553. scaleMode: number;
  22554. /**
  22555. * Force textures to be a power of two (default: false)
  22556. */
  22557. alwaysForcePOT: boolean;
  22558. private _samples;
  22559. /**
  22560. * Number of sample textures (default: 1)
  22561. */
  22562. get samples(): number;
  22563. set samples(n: number);
  22564. /**
  22565. * Modify the scale of the post process to be the same as the viewport (default: false)
  22566. */
  22567. adaptScaleToCurrentViewport: boolean;
  22568. private _camera;
  22569. protected _scene: Scene;
  22570. private _engine;
  22571. private _options;
  22572. private _reusable;
  22573. private _textureType;
  22574. private _textureFormat;
  22575. /**
  22576. * Smart array of input and output textures for the post process.
  22577. * @hidden
  22578. */
  22579. _textures: SmartArray<InternalTexture>;
  22580. /**
  22581. * The index in _textures that corresponds to the output texture.
  22582. * @hidden
  22583. */
  22584. _currentRenderTextureInd: number;
  22585. private _effect;
  22586. private _samplers;
  22587. private _fragmentUrl;
  22588. private _vertexUrl;
  22589. private _parameters;
  22590. private _scaleRatio;
  22591. protected _indexParameters: any;
  22592. private _shareOutputWithPostProcess;
  22593. private _texelSize;
  22594. private _forcedOutputTexture;
  22595. /**
  22596. * Returns the fragment url or shader name used in the post process.
  22597. * @returns the fragment url or name in the shader store.
  22598. */
  22599. getEffectName(): string;
  22600. /**
  22601. * An event triggered when the postprocess is activated.
  22602. */
  22603. onActivateObservable: Observable<Camera>;
  22604. private _onActivateObserver;
  22605. /**
  22606. * A function that is added to the onActivateObservable
  22607. */
  22608. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22609. /**
  22610. * An event triggered when the postprocess changes its size.
  22611. */
  22612. onSizeChangedObservable: Observable<PostProcess>;
  22613. private _onSizeChangedObserver;
  22614. /**
  22615. * A function that is added to the onSizeChangedObservable
  22616. */
  22617. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22618. /**
  22619. * An event triggered when the postprocess applies its effect.
  22620. */
  22621. onApplyObservable: Observable<Effect>;
  22622. private _onApplyObserver;
  22623. /**
  22624. * A function that is added to the onApplyObservable
  22625. */
  22626. set onApply(callback: (effect: Effect) => void);
  22627. /**
  22628. * An event triggered before rendering the postprocess
  22629. */
  22630. onBeforeRenderObservable: Observable<Effect>;
  22631. private _onBeforeRenderObserver;
  22632. /**
  22633. * A function that is added to the onBeforeRenderObservable
  22634. */
  22635. set onBeforeRender(callback: (effect: Effect) => void);
  22636. /**
  22637. * An event triggered after rendering the postprocess
  22638. */
  22639. onAfterRenderObservable: Observable<Effect>;
  22640. private _onAfterRenderObserver;
  22641. /**
  22642. * A function that is added to the onAfterRenderObservable
  22643. */
  22644. set onAfterRender(callback: (efect: Effect) => void);
  22645. /**
  22646. * 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
  22647. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22648. */
  22649. get inputTexture(): InternalTexture;
  22650. set inputTexture(value: InternalTexture);
  22651. /**
  22652. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  22653. * the only way to unset it is to use this function to restore its internal state
  22654. */
  22655. restoreDefaultInputTexture(): void;
  22656. /**
  22657. * Gets the camera which post process is applied to.
  22658. * @returns The camera the post process is applied to.
  22659. */
  22660. getCamera(): Camera;
  22661. /**
  22662. * Gets the texel size of the postprocess.
  22663. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22664. */
  22665. get texelSize(): Vector2;
  22666. /**
  22667. * Creates a new instance PostProcess
  22668. * @param name The name of the PostProcess.
  22669. * @param fragmentUrl The url of the fragment shader to be used.
  22670. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22671. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22672. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22673. * @param camera The camera to apply the render pass to.
  22674. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22675. * @param engine The engine which the post process will be applied. (default: current engine)
  22676. * @param reusable If the post process can be reused on the same frame. (default: false)
  22677. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22678. * @param textureType Type of textures used when performing the post process. (default: 0)
  22679. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22680. * @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
  22681. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  22682. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22683. */
  22684. constructor(
  22685. /** Name of the PostProcess. */
  22686. 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);
  22687. /**
  22688. * Gets a string idenfifying the name of the class
  22689. * @returns "PostProcess" string
  22690. */
  22691. getClassName(): string;
  22692. /**
  22693. * Gets the engine which this post process belongs to.
  22694. * @returns The engine the post process was enabled with.
  22695. */
  22696. getEngine(): Engine;
  22697. /**
  22698. * The effect that is created when initializing the post process.
  22699. * @returns The created effect corresponding the the postprocess.
  22700. */
  22701. getEffect(): Effect;
  22702. /**
  22703. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22704. * @param postProcess The post process to share the output with.
  22705. * @returns This post process.
  22706. */
  22707. shareOutputWith(postProcess: PostProcess): PostProcess;
  22708. /**
  22709. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  22710. * This should be called if the post process that shares output with this post process is disabled/disposed.
  22711. */
  22712. useOwnOutput(): void;
  22713. /**
  22714. * Updates the effect with the current post process compile time values and recompiles the shader.
  22715. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22716. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22717. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22718. * @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
  22719. * @param onCompiled Called when the shader has been compiled.
  22720. * @param onError Called if there is an error when compiling a shader.
  22721. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  22722. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  22723. */
  22724. 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;
  22725. /**
  22726. * The post process is reusable if it can be used multiple times within one frame.
  22727. * @returns If the post process is reusable
  22728. */
  22729. isReusable(): boolean;
  22730. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  22731. markTextureDirty(): void;
  22732. /**
  22733. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  22734. * 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.
  22735. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  22736. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  22737. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  22738. * @returns The target texture that was bound to be written to.
  22739. */
  22740. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  22741. /**
  22742. * If the post process is supported.
  22743. */
  22744. get isSupported(): boolean;
  22745. /**
  22746. * The aspect ratio of the output texture.
  22747. */
  22748. get aspectRatio(): number;
  22749. /**
  22750. * Get a value indicating if the post-process is ready to be used
  22751. * @returns true if the post-process is ready (shader is compiled)
  22752. */
  22753. isReady(): boolean;
  22754. /**
  22755. * Binds all textures and uniforms to the shader, this will be run on every pass.
  22756. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  22757. */
  22758. apply(): Nullable<Effect>;
  22759. private _disposeTextures;
  22760. /**
  22761. * Disposes the post process.
  22762. * @param camera The camera to dispose the post process on.
  22763. */
  22764. dispose(camera?: Camera): void;
  22765. }
  22766. }
  22767. declare module BABYLON {
  22768. /** @hidden */
  22769. export var kernelBlurVaryingDeclaration: {
  22770. name: string;
  22771. shader: string;
  22772. };
  22773. }
  22774. declare module BABYLON {
  22775. /** @hidden */
  22776. export var kernelBlurFragment: {
  22777. name: string;
  22778. shader: string;
  22779. };
  22780. }
  22781. declare module BABYLON {
  22782. /** @hidden */
  22783. export var kernelBlurFragment2: {
  22784. name: string;
  22785. shader: string;
  22786. };
  22787. }
  22788. declare module BABYLON {
  22789. /** @hidden */
  22790. export var kernelBlurPixelShader: {
  22791. name: string;
  22792. shader: string;
  22793. };
  22794. }
  22795. declare module BABYLON {
  22796. /** @hidden */
  22797. export var kernelBlurVertex: {
  22798. name: string;
  22799. shader: string;
  22800. };
  22801. }
  22802. declare module BABYLON {
  22803. /** @hidden */
  22804. export var kernelBlurVertexShader: {
  22805. name: string;
  22806. shader: string;
  22807. };
  22808. }
  22809. declare module BABYLON {
  22810. /**
  22811. * The Blur Post Process which blurs an image based on a kernel and direction.
  22812. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  22813. */
  22814. export class BlurPostProcess extends PostProcess {
  22815. /** The direction in which to blur the image. */
  22816. direction: Vector2;
  22817. private blockCompilation;
  22818. protected _kernel: number;
  22819. protected _idealKernel: number;
  22820. protected _packedFloat: boolean;
  22821. private _staticDefines;
  22822. /**
  22823. * Sets the length in pixels of the blur sample region
  22824. */
  22825. set kernel(v: number);
  22826. /**
  22827. * Gets the length in pixels of the blur sample region
  22828. */
  22829. get kernel(): number;
  22830. /**
  22831. * Sets wether or not the blur needs to unpack/repack floats
  22832. */
  22833. set packedFloat(v: boolean);
  22834. /**
  22835. * Gets wether or not the blur is unpacking/repacking floats
  22836. */
  22837. get packedFloat(): boolean;
  22838. /**
  22839. * Creates a new instance BlurPostProcess
  22840. * @param name The name of the effect.
  22841. * @param direction The direction in which to blur the image.
  22842. * @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.
  22843. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22844. * @param camera The camera to apply the render pass to.
  22845. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22846. * @param engine The engine which the post process will be applied. (default: current engine)
  22847. * @param reusable If the post process can be reused on the same frame. (default: false)
  22848. * @param textureType Type of textures used when performing the post process. (default: 0)
  22849. * @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)
  22850. */
  22851. constructor(name: string,
  22852. /** The direction in which to blur the image. */
  22853. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  22854. /**
  22855. * Updates the effect with the current post process compile time values and recompiles the shader.
  22856. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22857. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22858. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22859. * @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
  22860. * @param onCompiled Called when the shader has been compiled.
  22861. * @param onError Called if there is an error when compiling a shader.
  22862. */
  22863. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22864. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22865. /**
  22866. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  22867. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  22868. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  22869. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  22870. * The gaps between physical kernels are compensated for in the weighting of the samples
  22871. * @param idealKernel Ideal blur kernel.
  22872. * @return Nearest best kernel.
  22873. */
  22874. protected _nearestBestKernel(idealKernel: number): number;
  22875. /**
  22876. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  22877. * @param x The point on the Gaussian distribution to sample.
  22878. * @return the value of the Gaussian function at x.
  22879. */
  22880. protected _gaussianWeight(x: number): number;
  22881. /**
  22882. * Generates a string that can be used as a floating point number in GLSL.
  22883. * @param x Value to print.
  22884. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  22885. * @return GLSL float string.
  22886. */
  22887. protected _glslFloat(x: number, decimalFigures?: number): string;
  22888. }
  22889. }
  22890. declare module BABYLON {
  22891. /**
  22892. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22893. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22894. * You can then easily use it as a reflectionTexture on a flat surface.
  22895. * In case the surface is not a plane, please consider relying on reflection probes.
  22896. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22897. */
  22898. export class MirrorTexture extends RenderTargetTexture {
  22899. private scene;
  22900. /**
  22901. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  22902. * 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.
  22903. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22904. */
  22905. mirrorPlane: Plane;
  22906. /**
  22907. * Define the blur ratio used to blur the reflection if needed.
  22908. */
  22909. set blurRatio(value: number);
  22910. get blurRatio(): number;
  22911. /**
  22912. * Define the adaptive blur kernel used to blur the reflection if needed.
  22913. * This will autocompute the closest best match for the `blurKernel`
  22914. */
  22915. set adaptiveBlurKernel(value: number);
  22916. /**
  22917. * Define the blur kernel used to blur the reflection if needed.
  22918. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22919. */
  22920. set blurKernel(value: number);
  22921. /**
  22922. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  22923. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22924. */
  22925. set blurKernelX(value: number);
  22926. get blurKernelX(): number;
  22927. /**
  22928. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  22929. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22930. */
  22931. set blurKernelY(value: number);
  22932. get blurKernelY(): number;
  22933. private _autoComputeBlurKernel;
  22934. protected _onRatioRescale(): void;
  22935. private _updateGammaSpace;
  22936. private _imageProcessingConfigChangeObserver;
  22937. private _transformMatrix;
  22938. private _mirrorMatrix;
  22939. private _savedViewMatrix;
  22940. private _blurX;
  22941. private _blurY;
  22942. private _adaptiveBlurKernel;
  22943. private _blurKernelX;
  22944. private _blurKernelY;
  22945. private _blurRatio;
  22946. /**
  22947. * Instantiates a Mirror Texture.
  22948. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22949. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22950. * You can then easily use it as a reflectionTexture on a flat surface.
  22951. * In case the surface is not a plane, please consider relying on reflection probes.
  22952. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22953. * @param name
  22954. * @param size
  22955. * @param scene
  22956. * @param generateMipMaps
  22957. * @param type
  22958. * @param samplingMode
  22959. * @param generateDepthBuffer
  22960. */
  22961. constructor(name: string, size: number | {
  22962. width: number;
  22963. height: number;
  22964. } | {
  22965. ratio: number;
  22966. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  22967. private _preparePostProcesses;
  22968. /**
  22969. * Clone the mirror texture.
  22970. * @returns the cloned texture
  22971. */
  22972. clone(): MirrorTexture;
  22973. /**
  22974. * Serialize the texture to a JSON representation you could use in Parse later on
  22975. * @returns the serialized JSON representation
  22976. */
  22977. serialize(): any;
  22978. /**
  22979. * Dispose the texture and release its associated resources.
  22980. */
  22981. dispose(): void;
  22982. }
  22983. }
  22984. declare module BABYLON {
  22985. /**
  22986. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  22987. * @see https://doc.babylonjs.com/babylon101/materials#texture
  22988. */
  22989. export class Texture extends BaseTexture {
  22990. /**
  22991. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  22992. */
  22993. static SerializeBuffers: boolean;
  22994. /** @hidden */
  22995. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  22996. /** @hidden */
  22997. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  22998. /** @hidden */
  22999. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23000. /** nearest is mag = nearest and min = nearest and mip = linear */
  23001. static readonly NEAREST_SAMPLINGMODE: number;
  23002. /** nearest is mag = nearest and min = nearest and mip = linear */
  23003. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23004. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23005. static readonly BILINEAR_SAMPLINGMODE: number;
  23006. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23007. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23008. /** Trilinear is mag = linear and min = linear and mip = linear */
  23009. static readonly TRILINEAR_SAMPLINGMODE: number;
  23010. /** Trilinear is mag = linear and min = linear and mip = linear */
  23011. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23012. /** mag = nearest and min = nearest and mip = nearest */
  23013. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23014. /** mag = nearest and min = linear and mip = nearest */
  23015. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23016. /** mag = nearest and min = linear and mip = linear */
  23017. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23018. /** mag = nearest and min = linear and mip = none */
  23019. static readonly NEAREST_LINEAR: number;
  23020. /** mag = nearest and min = nearest and mip = none */
  23021. static readonly NEAREST_NEAREST: number;
  23022. /** mag = linear and min = nearest and mip = nearest */
  23023. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23024. /** mag = linear and min = nearest and mip = linear */
  23025. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23026. /** mag = linear and min = linear and mip = none */
  23027. static readonly LINEAR_LINEAR: number;
  23028. /** mag = linear and min = nearest and mip = none */
  23029. static readonly LINEAR_NEAREST: number;
  23030. /** Explicit coordinates mode */
  23031. static readonly EXPLICIT_MODE: number;
  23032. /** Spherical coordinates mode */
  23033. static readonly SPHERICAL_MODE: number;
  23034. /** Planar coordinates mode */
  23035. static readonly PLANAR_MODE: number;
  23036. /** Cubic coordinates mode */
  23037. static readonly CUBIC_MODE: number;
  23038. /** Projection coordinates mode */
  23039. static readonly PROJECTION_MODE: number;
  23040. /** Inverse Cubic coordinates mode */
  23041. static readonly SKYBOX_MODE: number;
  23042. /** Inverse Cubic coordinates mode */
  23043. static readonly INVCUBIC_MODE: number;
  23044. /** Equirectangular coordinates mode */
  23045. static readonly EQUIRECTANGULAR_MODE: number;
  23046. /** Equirectangular Fixed coordinates mode */
  23047. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23048. /** Equirectangular Fixed Mirrored coordinates mode */
  23049. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23050. /** Texture is not repeating outside of 0..1 UVs */
  23051. static readonly CLAMP_ADDRESSMODE: number;
  23052. /** Texture is repeating outside of 0..1 UVs */
  23053. static readonly WRAP_ADDRESSMODE: number;
  23054. /** Texture is repeating and mirrored */
  23055. static readonly MIRROR_ADDRESSMODE: number;
  23056. /**
  23057. * 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
  23058. */
  23059. static UseSerializedUrlIfAny: boolean;
  23060. /**
  23061. * Define the url of the texture.
  23062. */
  23063. url: Nullable<string>;
  23064. /**
  23065. * Define an offset on the texture to offset the u coordinates of the UVs
  23066. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23067. */
  23068. uOffset: number;
  23069. /**
  23070. * Define an offset on the texture to offset the v coordinates of the UVs
  23071. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23072. */
  23073. vOffset: number;
  23074. /**
  23075. * Define an offset on the texture to scale the u coordinates of the UVs
  23076. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23077. */
  23078. uScale: number;
  23079. /**
  23080. * Define an offset on the texture to scale the v coordinates of the UVs
  23081. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23082. */
  23083. vScale: number;
  23084. /**
  23085. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23086. * @see https://doc.babylonjs.com/how_to/more_materials
  23087. */
  23088. uAng: number;
  23089. /**
  23090. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23091. * @see https://doc.babylonjs.com/how_to/more_materials
  23092. */
  23093. vAng: number;
  23094. /**
  23095. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23096. * @see https://doc.babylonjs.com/how_to/more_materials
  23097. */
  23098. wAng: number;
  23099. /**
  23100. * Defines the center of rotation (U)
  23101. */
  23102. uRotationCenter: number;
  23103. /**
  23104. * Defines the center of rotation (V)
  23105. */
  23106. vRotationCenter: number;
  23107. /**
  23108. * Defines the center of rotation (W)
  23109. */
  23110. wRotationCenter: number;
  23111. /**
  23112. * Are mip maps generated for this texture or not.
  23113. */
  23114. get noMipmap(): boolean;
  23115. /**
  23116. * List of inspectable custom properties (used by the Inspector)
  23117. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23118. */
  23119. inspectableCustomProperties: Nullable<IInspectable[]>;
  23120. private _noMipmap;
  23121. /** @hidden */
  23122. _invertY: boolean;
  23123. private _rowGenerationMatrix;
  23124. private _cachedTextureMatrix;
  23125. private _projectionModeMatrix;
  23126. private _t0;
  23127. private _t1;
  23128. private _t2;
  23129. private _cachedUOffset;
  23130. private _cachedVOffset;
  23131. private _cachedUScale;
  23132. private _cachedVScale;
  23133. private _cachedUAng;
  23134. private _cachedVAng;
  23135. private _cachedWAng;
  23136. private _cachedProjectionMatrixId;
  23137. private _cachedCoordinatesMode;
  23138. /** @hidden */
  23139. protected _initialSamplingMode: number;
  23140. /** @hidden */
  23141. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23142. private _deleteBuffer;
  23143. protected _format: Nullable<number>;
  23144. private _delayedOnLoad;
  23145. private _delayedOnError;
  23146. private _mimeType?;
  23147. /**
  23148. * Observable triggered once the texture has been loaded.
  23149. */
  23150. onLoadObservable: Observable<Texture>;
  23151. protected _isBlocking: boolean;
  23152. /**
  23153. * Is the texture preventing material to render while loading.
  23154. * If false, a default texture will be used instead of the loading one during the preparation step.
  23155. */
  23156. set isBlocking(value: boolean);
  23157. get isBlocking(): boolean;
  23158. /**
  23159. * Get the current sampling mode associated with the texture.
  23160. */
  23161. get samplingMode(): number;
  23162. /**
  23163. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23164. */
  23165. get invertY(): boolean;
  23166. /**
  23167. * Instantiates a new texture.
  23168. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23169. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23170. * @param url defines the url of the picture to load as a texture
  23171. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23172. * @param noMipmap defines if the texture will require mip maps or not
  23173. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23174. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23175. * @param onLoad defines a callback triggered when the texture has been loaded
  23176. * @param onError defines a callback triggered when an error occurred during the loading session
  23177. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23178. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23179. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23180. * @param mimeType defines an optional mime type information
  23181. */
  23182. 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);
  23183. /**
  23184. * Update the url (and optional buffer) of this texture if url was null during construction.
  23185. * @param url the url of the texture
  23186. * @param buffer the buffer of the texture (defaults to null)
  23187. * @param onLoad callback called when the texture is loaded (defaults to null)
  23188. */
  23189. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23190. /**
  23191. * Finish the loading sequence of a texture flagged as delayed load.
  23192. * @hidden
  23193. */
  23194. delayLoad(): void;
  23195. private _prepareRowForTextureGeneration;
  23196. /**
  23197. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23198. * @returns the transform matrix of the texture.
  23199. */
  23200. getTextureMatrix(uBase?: number): Matrix;
  23201. /**
  23202. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23203. * @returns The reflection texture transform
  23204. */
  23205. getReflectionTextureMatrix(): Matrix;
  23206. /**
  23207. * Clones the texture.
  23208. * @returns the cloned texture
  23209. */
  23210. clone(): Texture;
  23211. /**
  23212. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23213. * @returns The JSON representation of the texture
  23214. */
  23215. serialize(): any;
  23216. /**
  23217. * Get the current class name of the texture useful for serialization or dynamic coding.
  23218. * @returns "Texture"
  23219. */
  23220. getClassName(): string;
  23221. /**
  23222. * Dispose the texture and release its associated resources.
  23223. */
  23224. dispose(): void;
  23225. /**
  23226. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23227. * @param parsedTexture Define the JSON representation of the texture
  23228. * @param scene Define the scene the parsed texture should be instantiated in
  23229. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23230. * @returns The parsed texture if successful
  23231. */
  23232. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23233. /**
  23234. * Creates a texture from its base 64 representation.
  23235. * @param data Define the base64 payload without the data: prefix
  23236. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23237. * @param scene Define the scene the texture should belong to
  23238. * @param noMipmap Forces the texture to not create mip map information if true
  23239. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23240. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23241. * @param onLoad define a callback triggered when the texture has been loaded
  23242. * @param onError define a callback triggered when an error occurred during the loading session
  23243. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23244. * @returns the created texture
  23245. */
  23246. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23247. /**
  23248. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23249. * @param data Define the base64 payload without the data: prefix
  23250. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23251. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23252. * @param scene Define the scene the texture should belong to
  23253. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23254. * @param noMipmap Forces the texture to not create mip map information if true
  23255. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23256. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23257. * @param onLoad define a callback triggered when the texture has been loaded
  23258. * @param onError define a callback triggered when an error occurred during the loading session
  23259. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23260. * @returns the created texture
  23261. */
  23262. 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;
  23263. }
  23264. }
  23265. declare module BABYLON {
  23266. /**
  23267. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23268. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23269. */
  23270. export class PostProcessManager {
  23271. private _scene;
  23272. private _indexBuffer;
  23273. private _vertexBuffers;
  23274. /**
  23275. * Creates a new instance PostProcess
  23276. * @param scene The scene that the post process is associated with.
  23277. */
  23278. constructor(scene: Scene);
  23279. private _prepareBuffers;
  23280. private _buildIndexBuffer;
  23281. /**
  23282. * Rebuilds the vertex buffers of the manager.
  23283. * @hidden
  23284. */
  23285. _rebuild(): void;
  23286. /**
  23287. * Prepares a frame to be run through a post process.
  23288. * @param sourceTexture The input texture to the post procesess. (default: null)
  23289. * @param postProcesses An array of post processes to be run. (default: null)
  23290. * @returns True if the post processes were able to be run.
  23291. * @hidden
  23292. */
  23293. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23294. /**
  23295. * Manually render a set of post processes to a texture.
  23296. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23297. * @param postProcesses An array of post processes to be run.
  23298. * @param targetTexture The target texture to render to.
  23299. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23300. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23301. * @param lodLevel defines which lod of the texture to render to
  23302. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  23303. */
  23304. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  23305. /**
  23306. * Finalize the result of the output of the postprocesses.
  23307. * @param doNotPresent If true the result will not be displayed to the screen.
  23308. * @param targetTexture The target texture to render to.
  23309. * @param faceIndex The index of the face to bind the target texture to.
  23310. * @param postProcesses The array of post processes to render.
  23311. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23312. * @hidden
  23313. */
  23314. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23315. /**
  23316. * Disposes of the post process manager.
  23317. */
  23318. dispose(): void;
  23319. }
  23320. }
  23321. declare module BABYLON {
  23322. /**
  23323. * This Helps creating a texture that will be created from a camera in your scene.
  23324. * It is basically a dynamic texture that could be used to create special effects for instance.
  23325. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23326. */
  23327. export class RenderTargetTexture extends Texture {
  23328. isCube: boolean;
  23329. /**
  23330. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23331. */
  23332. static readonly REFRESHRATE_RENDER_ONCE: number;
  23333. /**
  23334. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23335. */
  23336. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23337. /**
  23338. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23339. * the central point of your effect and can save a lot of performances.
  23340. */
  23341. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23342. /**
  23343. * Use this predicate to dynamically define the list of mesh you want to render.
  23344. * If set, the renderList property will be overwritten.
  23345. */
  23346. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23347. private _renderList;
  23348. /**
  23349. * Use this list to define the list of mesh you want to render.
  23350. */
  23351. get renderList(): Nullable<Array<AbstractMesh>>;
  23352. set renderList(value: Nullable<Array<AbstractMesh>>);
  23353. /**
  23354. * Use this function to overload the renderList array at rendering time.
  23355. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  23356. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  23357. * the cube (if the RTT is a cube, else layerOrFace=0).
  23358. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  23359. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  23360. * hold dummy elements!
  23361. */
  23362. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  23363. private _hookArray;
  23364. /**
  23365. * Define if particles should be rendered in your texture.
  23366. */
  23367. renderParticles: boolean;
  23368. /**
  23369. * Define if sprites should be rendered in your texture.
  23370. */
  23371. renderSprites: boolean;
  23372. /**
  23373. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  23374. */
  23375. coordinatesMode: number;
  23376. /**
  23377. * Define the camera used to render the texture.
  23378. */
  23379. activeCamera: Nullable<Camera>;
  23380. /**
  23381. * Override the mesh isReady function with your own one.
  23382. */
  23383. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  23384. /**
  23385. * Override the render function of the texture with your own one.
  23386. */
  23387. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  23388. /**
  23389. * Define if camera post processes should be use while rendering the texture.
  23390. */
  23391. useCameraPostProcesses: boolean;
  23392. /**
  23393. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  23394. */
  23395. ignoreCameraViewport: boolean;
  23396. private _postProcessManager;
  23397. private _postProcesses;
  23398. private _resizeObserver;
  23399. /**
  23400. * An event triggered when the texture is unbind.
  23401. */
  23402. onBeforeBindObservable: Observable<RenderTargetTexture>;
  23403. /**
  23404. * An event triggered when the texture is unbind.
  23405. */
  23406. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  23407. private _onAfterUnbindObserver;
  23408. /**
  23409. * Set a after unbind callback in the texture.
  23410. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  23411. */
  23412. set onAfterUnbind(callback: () => void);
  23413. /**
  23414. * An event triggered before rendering the texture
  23415. */
  23416. onBeforeRenderObservable: Observable<number>;
  23417. private _onBeforeRenderObserver;
  23418. /**
  23419. * Set a before render callback in the texture.
  23420. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  23421. */
  23422. set onBeforeRender(callback: (faceIndex: number) => void);
  23423. /**
  23424. * An event triggered after rendering the texture
  23425. */
  23426. onAfterRenderObservable: Observable<number>;
  23427. private _onAfterRenderObserver;
  23428. /**
  23429. * Set a after render callback in the texture.
  23430. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  23431. */
  23432. set onAfterRender(callback: (faceIndex: number) => void);
  23433. /**
  23434. * An event triggered after the texture clear
  23435. */
  23436. onClearObservable: Observable<Engine>;
  23437. private _onClearObserver;
  23438. /**
  23439. * Set a clear callback in the texture.
  23440. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  23441. */
  23442. set onClear(callback: (Engine: Engine) => void);
  23443. /**
  23444. * An event triggered when the texture is resized.
  23445. */
  23446. onResizeObservable: Observable<RenderTargetTexture>;
  23447. /**
  23448. * Define the clear color of the Render Target if it should be different from the scene.
  23449. */
  23450. clearColor: Color4;
  23451. protected _size: number | {
  23452. width: number;
  23453. height: number;
  23454. layers?: number;
  23455. };
  23456. protected _initialSizeParameter: number | {
  23457. width: number;
  23458. height: number;
  23459. } | {
  23460. ratio: number;
  23461. };
  23462. protected _sizeRatio: Nullable<number>;
  23463. /** @hidden */
  23464. _generateMipMaps: boolean;
  23465. protected _renderingManager: RenderingManager;
  23466. /** @hidden */
  23467. _waitingRenderList: string[];
  23468. protected _doNotChangeAspectRatio: boolean;
  23469. protected _currentRefreshId: number;
  23470. protected _refreshRate: number;
  23471. protected _textureMatrix: Matrix;
  23472. protected _samples: number;
  23473. protected _renderTargetOptions: RenderTargetCreationOptions;
  23474. /**
  23475. * Gets render target creation options that were used.
  23476. */
  23477. get renderTargetOptions(): RenderTargetCreationOptions;
  23478. protected _onRatioRescale(): void;
  23479. /**
  23480. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  23481. * It must define where the camera used to render the texture is set
  23482. */
  23483. boundingBoxPosition: Vector3;
  23484. private _boundingBoxSize;
  23485. /**
  23486. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  23487. * When defined, the cubemap will switch to local mode
  23488. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  23489. * @example https://www.babylonjs-playground.com/#RNASML
  23490. */
  23491. set boundingBoxSize(value: Vector3);
  23492. get boundingBoxSize(): Vector3;
  23493. /**
  23494. * In case the RTT has been created with a depth texture, get the associated
  23495. * depth texture.
  23496. * Otherwise, return null.
  23497. */
  23498. get depthStencilTexture(): Nullable<InternalTexture>;
  23499. /**
  23500. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  23501. * or used a shadow, depth texture...
  23502. * @param name The friendly name of the texture
  23503. * @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)
  23504. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  23505. * @param generateMipMaps True if mip maps need to be generated after render.
  23506. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  23507. * @param type The type of the buffer in the RTT (int, half float, float...)
  23508. * @param isCube True if a cube texture needs to be created
  23509. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  23510. * @param generateDepthBuffer True to generate a depth buffer
  23511. * @param generateStencilBuffer True to generate a stencil buffer
  23512. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  23513. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  23514. * @param delayAllocation if the texture allocation should be delayed (default: false)
  23515. */
  23516. constructor(name: string, size: number | {
  23517. width: number;
  23518. height: number;
  23519. layers?: number;
  23520. } | {
  23521. ratio: number;
  23522. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  23523. /**
  23524. * Creates a depth stencil texture.
  23525. * This is only available in WebGL 2 or with the depth texture extension available.
  23526. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  23527. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  23528. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  23529. */
  23530. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  23531. private _processSizeParameter;
  23532. /**
  23533. * Define the number of samples to use in case of MSAA.
  23534. * It defaults to one meaning no MSAA has been enabled.
  23535. */
  23536. get samples(): number;
  23537. set samples(value: number);
  23538. /**
  23539. * Resets the refresh counter of the texture and start bak from scratch.
  23540. * Could be useful to regenerate the texture if it is setup to render only once.
  23541. */
  23542. resetRefreshCounter(): void;
  23543. /**
  23544. * Define the refresh rate of the texture or the rendering frequency.
  23545. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  23546. */
  23547. get refreshRate(): number;
  23548. set refreshRate(value: number);
  23549. /**
  23550. * Adds a post process to the render target rendering passes.
  23551. * @param postProcess define the post process to add
  23552. */
  23553. addPostProcess(postProcess: PostProcess): void;
  23554. /**
  23555. * Clear all the post processes attached to the render target
  23556. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  23557. */
  23558. clearPostProcesses(dispose?: boolean): void;
  23559. /**
  23560. * Remove one of the post process from the list of attached post processes to the texture
  23561. * @param postProcess define the post process to remove from the list
  23562. */
  23563. removePostProcess(postProcess: PostProcess): void;
  23564. /** @hidden */
  23565. _shouldRender(): boolean;
  23566. /**
  23567. * Gets the actual render size of the texture.
  23568. * @returns the width of the render size
  23569. */
  23570. getRenderSize(): number;
  23571. /**
  23572. * Gets the actual render width of the texture.
  23573. * @returns the width of the render size
  23574. */
  23575. getRenderWidth(): number;
  23576. /**
  23577. * Gets the actual render height of the texture.
  23578. * @returns the height of the render size
  23579. */
  23580. getRenderHeight(): number;
  23581. /**
  23582. * Gets the actual number of layers of the texture.
  23583. * @returns the number of layers
  23584. */
  23585. getRenderLayers(): number;
  23586. /**
  23587. * Get if the texture can be rescaled or not.
  23588. */
  23589. get canRescale(): boolean;
  23590. /**
  23591. * Resize the texture using a ratio.
  23592. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  23593. */
  23594. scale(ratio: number): void;
  23595. /**
  23596. * Get the texture reflection matrix used to rotate/transform the reflection.
  23597. * @returns the reflection matrix
  23598. */
  23599. getReflectionTextureMatrix(): Matrix;
  23600. /**
  23601. * Resize the texture to a new desired size.
  23602. * Be carrefull as it will recreate all the data in the new texture.
  23603. * @param size Define the new size. It can be:
  23604. * - a number for squared texture,
  23605. * - an object containing { width: number, height: number }
  23606. * - or an object containing a ratio { ratio: number }
  23607. */
  23608. resize(size: number | {
  23609. width: number;
  23610. height: number;
  23611. } | {
  23612. ratio: number;
  23613. }): void;
  23614. private _defaultRenderListPrepared;
  23615. /**
  23616. * Renders all the objects from the render list into the texture.
  23617. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  23618. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  23619. */
  23620. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  23621. private _bestReflectionRenderTargetDimension;
  23622. private _prepareRenderingManager;
  23623. /**
  23624. * @hidden
  23625. * @param faceIndex face index to bind to if this is a cubetexture
  23626. * @param layer defines the index of the texture to bind in the array
  23627. */
  23628. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  23629. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23630. private renderToTarget;
  23631. /**
  23632. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  23633. * This allowed control for front to back rendering or reversly depending of the special needs.
  23634. *
  23635. * @param renderingGroupId The rendering group id corresponding to its index
  23636. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  23637. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  23638. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  23639. */
  23640. 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;
  23641. /**
  23642. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  23643. *
  23644. * @param renderingGroupId The rendering group id corresponding to its index
  23645. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  23646. */
  23647. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  23648. /**
  23649. * Clones the texture.
  23650. * @returns the cloned texture
  23651. */
  23652. clone(): RenderTargetTexture;
  23653. /**
  23654. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23655. * @returns The JSON representation of the texture
  23656. */
  23657. serialize(): any;
  23658. /**
  23659. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  23660. */
  23661. disposeFramebufferObjects(): void;
  23662. /**
  23663. * Dispose the texture and release its associated resources.
  23664. */
  23665. dispose(): void;
  23666. /** @hidden */
  23667. _rebuild(): void;
  23668. /**
  23669. * Clear the info related to rendering groups preventing retention point in material dispose.
  23670. */
  23671. freeRenderingGroups(): void;
  23672. /**
  23673. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  23674. * @returns the view count
  23675. */
  23676. getViewCount(): number;
  23677. }
  23678. }
  23679. declare module BABYLON {
  23680. /**
  23681. * Class used to manipulate GUIDs
  23682. */
  23683. export class GUID {
  23684. /**
  23685. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23686. * Be aware Math.random() could cause collisions, but:
  23687. * "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"
  23688. * @returns a pseudo random id
  23689. */
  23690. static RandomId(): string;
  23691. }
  23692. }
  23693. declare module BABYLON {
  23694. /**
  23695. * Options to be used when creating a shadow depth material
  23696. */
  23697. export interface IIOptionShadowDepthMaterial {
  23698. /** Variables in the vertex shader code that need to have their names remapped.
  23699. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  23700. * "var_name" should be either: worldPos or vNormalW
  23701. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  23702. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  23703. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  23704. */
  23705. remappedVariables?: string[];
  23706. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  23707. standalone?: boolean;
  23708. }
  23709. /**
  23710. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  23711. */
  23712. export class ShadowDepthWrapper {
  23713. private _scene;
  23714. private _options?;
  23715. private _baseMaterial;
  23716. private _onEffectCreatedObserver;
  23717. private _subMeshToEffect;
  23718. private _subMeshToDepthEffect;
  23719. private _meshes;
  23720. /** @hidden */
  23721. _matriceNames: any;
  23722. /** Gets the standalone status of the wrapper */
  23723. get standalone(): boolean;
  23724. /** Gets the base material the wrapper is built upon */
  23725. get baseMaterial(): Material;
  23726. /**
  23727. * Instantiate a new shadow depth wrapper.
  23728. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  23729. * generate the shadow depth map. For more information, please refer to the documentation:
  23730. * https://doc.babylonjs.com/babylon101/shadows
  23731. * @param baseMaterial Material to wrap
  23732. * @param scene Define the scene the material belongs to
  23733. * @param options Options used to create the wrapper
  23734. */
  23735. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  23736. /**
  23737. * Gets the effect to use to generate the depth map
  23738. * @param subMesh subMesh to get the effect for
  23739. * @param shadowGenerator shadow generator to get the effect for
  23740. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  23741. */
  23742. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  23743. /**
  23744. * Specifies that the submesh is ready to be used for depth rendering
  23745. * @param subMesh submesh to check
  23746. * @param defines the list of defines to take into account when checking the effect
  23747. * @param shadowGenerator combined with subMesh, it defines the effect to check
  23748. * @param useInstances specifies that instances should be used
  23749. * @returns a boolean indicating that the submesh is ready or not
  23750. */
  23751. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  23752. /**
  23753. * Disposes the resources
  23754. */
  23755. dispose(): void;
  23756. private _makeEffect;
  23757. }
  23758. }
  23759. declare module BABYLON {
  23760. interface ThinEngine {
  23761. /**
  23762. * Unbind a list of render target textures from the webGL context
  23763. * This is used only when drawBuffer extension or webGL2 are active
  23764. * @param textures defines the render target textures to unbind
  23765. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  23766. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  23767. */
  23768. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  23769. /**
  23770. * Create a multi render target texture
  23771. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  23772. * @param size defines the size of the texture
  23773. * @param options defines the creation options
  23774. * @returns the cube texture as an InternalTexture
  23775. */
  23776. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  23777. /**
  23778. * Update the sample count for a given multiple render target texture
  23779. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  23780. * @param textures defines the textures to update
  23781. * @param samples defines the sample count to set
  23782. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  23783. */
  23784. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  23785. /**
  23786. * Select a subsets of attachments to draw to.
  23787. * @param attachments gl attachments
  23788. */
  23789. bindAttachments(attachments: number[]): void;
  23790. }
  23791. }
  23792. declare module BABYLON {
  23793. /**
  23794. * Creation options of the multi render target texture.
  23795. */
  23796. export interface IMultiRenderTargetOptions {
  23797. /**
  23798. * Define if the texture needs to create mip maps after render.
  23799. */
  23800. generateMipMaps?: boolean;
  23801. /**
  23802. * Define the types of all the draw buffers we want to create
  23803. */
  23804. types?: number[];
  23805. /**
  23806. * Define the sampling modes of all the draw buffers we want to create
  23807. */
  23808. samplingModes?: number[];
  23809. /**
  23810. * Define if a depth buffer is required
  23811. */
  23812. generateDepthBuffer?: boolean;
  23813. /**
  23814. * Define if a stencil buffer is required
  23815. */
  23816. generateStencilBuffer?: boolean;
  23817. /**
  23818. * Define if a depth texture is required instead of a depth buffer
  23819. */
  23820. generateDepthTexture?: boolean;
  23821. /**
  23822. * Define the number of desired draw buffers
  23823. */
  23824. textureCount?: number;
  23825. /**
  23826. * Define if aspect ratio should be adapted to the texture or stay the scene one
  23827. */
  23828. doNotChangeAspectRatio?: boolean;
  23829. /**
  23830. * Define the default type of the buffers we are creating
  23831. */
  23832. defaultType?: number;
  23833. }
  23834. /**
  23835. * A multi render target, like a render target provides the ability to render to a texture.
  23836. * Unlike the render target, it can render to several draw buffers in one draw.
  23837. * This is specially interesting in deferred rendering or for any effects requiring more than
  23838. * just one color from a single pass.
  23839. */
  23840. export class MultiRenderTarget extends RenderTargetTexture {
  23841. private _internalTextures;
  23842. private _textures;
  23843. private _multiRenderTargetOptions;
  23844. private _count;
  23845. /**
  23846. * Get if draw buffers are currently supported by the used hardware and browser.
  23847. */
  23848. get isSupported(): boolean;
  23849. /**
  23850. * Get the list of textures generated by the multi render target.
  23851. */
  23852. get textures(): Texture[];
  23853. /**
  23854. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  23855. */
  23856. get count(): number;
  23857. /**
  23858. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  23859. */
  23860. get depthTexture(): Texture;
  23861. /**
  23862. * Set the wrapping mode on U of all the textures we are rendering to.
  23863. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23864. */
  23865. set wrapU(wrap: number);
  23866. /**
  23867. * Set the wrapping mode on V of all the textures we are rendering to.
  23868. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23869. */
  23870. set wrapV(wrap: number);
  23871. /**
  23872. * Instantiate a new multi render target texture.
  23873. * A multi render target, like a render target provides the ability to render to a texture.
  23874. * Unlike the render target, it can render to several draw buffers in one draw.
  23875. * This is specially interesting in deferred rendering or for any effects requiring more than
  23876. * just one color from a single pass.
  23877. * @param name Define the name of the texture
  23878. * @param size Define the size of the buffers to render to
  23879. * @param count Define the number of target we are rendering into
  23880. * @param scene Define the scene the texture belongs to
  23881. * @param options Define the options used to create the multi render target
  23882. */
  23883. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  23884. /** @hidden */
  23885. _rebuild(): void;
  23886. private _createInternalTextures;
  23887. private _createTextures;
  23888. /**
  23889. * Define the number of samples used if MSAA is enabled.
  23890. */
  23891. get samples(): number;
  23892. set samples(value: number);
  23893. /**
  23894. * Resize all the textures in the multi render target.
  23895. * Be carrefull as it will recreate all the data in the new texture.
  23896. * @param size Define the new size
  23897. */
  23898. resize(size: any): void;
  23899. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23900. /**
  23901. * Dispose the render targets and their associated resources
  23902. */
  23903. dispose(): void;
  23904. /**
  23905. * Release all the underlying texture used as draw buffers.
  23906. */
  23907. releaseInternalTextures(): void;
  23908. }
  23909. }
  23910. declare module BABYLON {
  23911. /** @hidden */
  23912. export var imageProcessingPixelShader: {
  23913. name: string;
  23914. shader: string;
  23915. };
  23916. }
  23917. declare module BABYLON {
  23918. /**
  23919. * ImageProcessingPostProcess
  23920. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  23921. */
  23922. export class ImageProcessingPostProcess extends PostProcess {
  23923. /**
  23924. * Default configuration related to image processing available in the PBR Material.
  23925. */
  23926. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23927. /**
  23928. * Gets the image processing configuration used either in this material.
  23929. */
  23930. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23931. /**
  23932. * Sets the Default image processing configuration used either in the this material.
  23933. *
  23934. * If sets to null, the scene one is in use.
  23935. */
  23936. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23937. /**
  23938. * Keep track of the image processing observer to allow dispose and replace.
  23939. */
  23940. private _imageProcessingObserver;
  23941. /**
  23942. * Attaches a new image processing configuration to the PBR Material.
  23943. * @param configuration
  23944. */
  23945. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  23946. /**
  23947. * If the post process is supported.
  23948. */
  23949. get isSupported(): boolean;
  23950. /**
  23951. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23952. */
  23953. get colorCurves(): Nullable<ColorCurves>;
  23954. /**
  23955. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23956. */
  23957. set colorCurves(value: Nullable<ColorCurves>);
  23958. /**
  23959. * Gets wether the color curves effect is enabled.
  23960. */
  23961. get colorCurvesEnabled(): boolean;
  23962. /**
  23963. * Sets wether the color curves effect is enabled.
  23964. */
  23965. set colorCurvesEnabled(value: boolean);
  23966. /**
  23967. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23968. */
  23969. get colorGradingTexture(): Nullable<BaseTexture>;
  23970. /**
  23971. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23972. */
  23973. set colorGradingTexture(value: Nullable<BaseTexture>);
  23974. /**
  23975. * Gets wether the color grading effect is enabled.
  23976. */
  23977. get colorGradingEnabled(): boolean;
  23978. /**
  23979. * Gets wether the color grading effect is enabled.
  23980. */
  23981. set colorGradingEnabled(value: boolean);
  23982. /**
  23983. * Gets exposure used in the effect.
  23984. */
  23985. get exposure(): number;
  23986. /**
  23987. * Sets exposure used in the effect.
  23988. */
  23989. set exposure(value: number);
  23990. /**
  23991. * Gets wether tonemapping is enabled or not.
  23992. */
  23993. get toneMappingEnabled(): boolean;
  23994. /**
  23995. * Sets wether tonemapping is enabled or not
  23996. */
  23997. set toneMappingEnabled(value: boolean);
  23998. /**
  23999. * Gets the type of tone mapping effect.
  24000. */
  24001. get toneMappingType(): number;
  24002. /**
  24003. * Sets the type of tone mapping effect.
  24004. */
  24005. set toneMappingType(value: number);
  24006. /**
  24007. * Gets contrast used in the effect.
  24008. */
  24009. get contrast(): number;
  24010. /**
  24011. * Sets contrast used in the effect.
  24012. */
  24013. set contrast(value: number);
  24014. /**
  24015. * Gets Vignette stretch size.
  24016. */
  24017. get vignetteStretch(): number;
  24018. /**
  24019. * Sets Vignette stretch size.
  24020. */
  24021. set vignetteStretch(value: number);
  24022. /**
  24023. * Gets Vignette centre X Offset.
  24024. */
  24025. get vignetteCentreX(): number;
  24026. /**
  24027. * Sets Vignette centre X Offset.
  24028. */
  24029. set vignetteCentreX(value: number);
  24030. /**
  24031. * Gets Vignette centre Y Offset.
  24032. */
  24033. get vignetteCentreY(): number;
  24034. /**
  24035. * Sets Vignette centre Y Offset.
  24036. */
  24037. set vignetteCentreY(value: number);
  24038. /**
  24039. * Gets Vignette weight or intensity of the vignette effect.
  24040. */
  24041. get vignetteWeight(): number;
  24042. /**
  24043. * Sets Vignette weight or intensity of the vignette effect.
  24044. */
  24045. set vignetteWeight(value: number);
  24046. /**
  24047. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24048. * if vignetteEnabled is set to true.
  24049. */
  24050. get vignetteColor(): Color4;
  24051. /**
  24052. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24053. * if vignetteEnabled is set to true.
  24054. */
  24055. set vignetteColor(value: Color4);
  24056. /**
  24057. * Gets Camera field of view used by the Vignette effect.
  24058. */
  24059. get vignetteCameraFov(): number;
  24060. /**
  24061. * Sets Camera field of view used by the Vignette effect.
  24062. */
  24063. set vignetteCameraFov(value: number);
  24064. /**
  24065. * Gets the vignette blend mode allowing different kind of effect.
  24066. */
  24067. get vignetteBlendMode(): number;
  24068. /**
  24069. * Sets the vignette blend mode allowing different kind of effect.
  24070. */
  24071. set vignetteBlendMode(value: number);
  24072. /**
  24073. * Gets wether the vignette effect is enabled.
  24074. */
  24075. get vignetteEnabled(): boolean;
  24076. /**
  24077. * Sets wether the vignette effect is enabled.
  24078. */
  24079. set vignetteEnabled(value: boolean);
  24080. private _fromLinearSpace;
  24081. /**
  24082. * Gets wether the input of the processing is in Gamma or Linear Space.
  24083. */
  24084. get fromLinearSpace(): boolean;
  24085. /**
  24086. * Sets wether the input of the processing is in Gamma or Linear Space.
  24087. */
  24088. set fromLinearSpace(value: boolean);
  24089. /**
  24090. * Defines cache preventing GC.
  24091. */
  24092. private _defines;
  24093. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  24094. /**
  24095. * "ImageProcessingPostProcess"
  24096. * @returns "ImageProcessingPostProcess"
  24097. */
  24098. getClassName(): string;
  24099. /**
  24100. * @hidden
  24101. */
  24102. _updateParameters(): void;
  24103. dispose(camera?: Camera): void;
  24104. }
  24105. }
  24106. declare module BABYLON {
  24107. /** @hidden */
  24108. export var fibonacci: {
  24109. name: string;
  24110. shader: string;
  24111. };
  24112. }
  24113. declare module BABYLON {
  24114. /** @hidden */
  24115. export var subSurfaceScatteringFunctions: {
  24116. name: string;
  24117. shader: string;
  24118. };
  24119. }
  24120. declare module BABYLON {
  24121. /** @hidden */
  24122. export var diffusionProfile: {
  24123. name: string;
  24124. shader: string;
  24125. };
  24126. }
  24127. declare module BABYLON {
  24128. /** @hidden */
  24129. export var subSurfaceScatteringPixelShader: {
  24130. name: string;
  24131. shader: string;
  24132. };
  24133. }
  24134. declare module BABYLON {
  24135. /**
  24136. * Sub surface scattering post process
  24137. */
  24138. export class SubSurfaceScatteringPostProcess extends PostProcess {
  24139. /** @hidden */
  24140. texelWidth: number;
  24141. /** @hidden */
  24142. texelHeight: number;
  24143. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  24144. }
  24145. }
  24146. declare module BABYLON {
  24147. /**
  24148. * Interface for defining prepass effects in the prepass post-process pipeline
  24149. */
  24150. export interface PrePassEffectConfiguration {
  24151. /**
  24152. * Post process to attach for this effect
  24153. */
  24154. postProcess: PostProcess;
  24155. /**
  24156. * Is the effect enabled
  24157. */
  24158. enabled: boolean;
  24159. /**
  24160. * Disposes the effect configuration
  24161. */
  24162. dispose(): void;
  24163. /**
  24164. * Disposes the effect configuration
  24165. */
  24166. createPostProcess: () => PostProcess;
  24167. }
  24168. }
  24169. declare module BABYLON {
  24170. /**
  24171. * Contains all parameters needed for the prepass to perform
  24172. * screen space subsurface scattering
  24173. */
  24174. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  24175. private _ssDiffusionS;
  24176. private _ssFilterRadii;
  24177. private _ssDiffusionD;
  24178. /**
  24179. * Post process to attach for screen space subsurface scattering
  24180. */
  24181. postProcess: SubSurfaceScatteringPostProcess;
  24182. /**
  24183. * Diffusion profile color for subsurface scattering
  24184. */
  24185. get ssDiffusionS(): number[];
  24186. /**
  24187. * Diffusion profile max color channel value for subsurface scattering
  24188. */
  24189. get ssDiffusionD(): number[];
  24190. /**
  24191. * Diffusion profile filter radius for subsurface scattering
  24192. */
  24193. get ssFilterRadii(): number[];
  24194. /**
  24195. * Is subsurface enabled
  24196. */
  24197. enabled: boolean;
  24198. /**
  24199. * Diffusion profile colors for subsurface scattering
  24200. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  24201. * See ...
  24202. * Note that you can only store up to 5 of them
  24203. */
  24204. ssDiffusionProfileColors: Color3[];
  24205. /**
  24206. * Defines the ratio real world => scene units.
  24207. * Used for subsurface scattering
  24208. */
  24209. metersPerUnit: number;
  24210. private _scene;
  24211. /**
  24212. * Builds a subsurface configuration object
  24213. * @param scene The scene
  24214. */
  24215. constructor(scene: Scene);
  24216. /**
  24217. * Adds a new diffusion profile.
  24218. * Useful for more realistic subsurface scattering on diverse materials.
  24219. * @param color The color of the diffusion profile. Should be the average color of the material.
  24220. * @return The index of the diffusion profile for the material subsurface configuration
  24221. */
  24222. addDiffusionProfile(color: Color3): number;
  24223. /**
  24224. * Creates the sss post process
  24225. * @return The created post process
  24226. */
  24227. createPostProcess(): SubSurfaceScatteringPostProcess;
  24228. /**
  24229. * Deletes all diffusion profiles.
  24230. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  24231. */
  24232. clearAllDiffusionProfiles(): void;
  24233. /**
  24234. * Disposes this object
  24235. */
  24236. dispose(): void;
  24237. /**
  24238. * @hidden
  24239. * https://zero-radiance.github.io/post/sampling-diffusion/
  24240. *
  24241. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  24242. * ------------------------------------------------------------------------------------
  24243. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  24244. * PDF[r, phi, s] = r * R[r, phi, s]
  24245. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  24246. * ------------------------------------------------------------------------------------
  24247. * We importance sample the color channel with the widest scattering distance.
  24248. */
  24249. getDiffusionProfileParameters(color: Color3): number;
  24250. /**
  24251. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  24252. * 'u' is the random number (the value of the CDF): [0, 1).
  24253. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  24254. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  24255. */
  24256. private _sampleBurleyDiffusionProfile;
  24257. }
  24258. }
  24259. declare module BABYLON {
  24260. /**
  24261. * Renders a pre pass of the scene
  24262. * This means every mesh in the scene will be rendered to a render target texture
  24263. * And then this texture will be composited to the rendering canvas with post processes
  24264. * It is necessary for effects like subsurface scattering or deferred shading
  24265. */
  24266. export class PrePassRenderer {
  24267. /** @hidden */
  24268. static _SceneComponentInitialization: (scene: Scene) => void;
  24269. private _scene;
  24270. private _engine;
  24271. private _isDirty;
  24272. /**
  24273. * Number of textures in the multi render target texture where the scene is directly rendered
  24274. */
  24275. readonly mrtCount: number;
  24276. /**
  24277. * The render target where the scene is directly rendered
  24278. */
  24279. prePassRT: MultiRenderTarget;
  24280. private _mrtTypes;
  24281. private _multiRenderAttachments;
  24282. private _defaultAttachments;
  24283. private _clearAttachments;
  24284. private _postProcesses;
  24285. private readonly _clearColor;
  24286. /**
  24287. * Image processing post process for composition
  24288. */
  24289. imageProcessingPostProcess: ImageProcessingPostProcess;
  24290. /**
  24291. * Configuration for sub surface scattering post process
  24292. */
  24293. subSurfaceConfiguration: SubSurfaceConfiguration;
  24294. /**
  24295. * Should materials render their geometry on the MRT
  24296. */
  24297. materialsShouldRenderGeometry: boolean;
  24298. /**
  24299. * Should materials render the irradiance information on the MRT
  24300. */
  24301. materialsShouldRenderIrradiance: boolean;
  24302. private _enabled;
  24303. /**
  24304. * Indicates if the prepass is enabled
  24305. */
  24306. get enabled(): boolean;
  24307. /**
  24308. * How many samples are used for MSAA of the scene render target
  24309. */
  24310. get samples(): number;
  24311. set samples(n: number);
  24312. /**
  24313. * Instanciates a prepass renderer
  24314. * @param scene The scene
  24315. */
  24316. constructor(scene: Scene);
  24317. private _initializeAttachments;
  24318. private _createCompositionEffect;
  24319. /**
  24320. * Indicates if rendering a prepass is supported
  24321. */
  24322. get isSupported(): boolean;
  24323. /**
  24324. * Sets the proper output textures to draw in the engine.
  24325. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  24326. */
  24327. bindAttachmentsForEffect(effect: Effect): void;
  24328. /**
  24329. * @hidden
  24330. */
  24331. _beforeCameraDraw(): void;
  24332. /**
  24333. * @hidden
  24334. */
  24335. _afterCameraDraw(): void;
  24336. private _checkRTSize;
  24337. private _bindFrameBuffer;
  24338. /**
  24339. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  24340. */
  24341. clear(): void;
  24342. private _setState;
  24343. private _enable;
  24344. private _disable;
  24345. private _resetPostProcessChain;
  24346. private _bindPostProcessChain;
  24347. /**
  24348. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  24349. */
  24350. markAsDirty(): void;
  24351. private _update;
  24352. /**
  24353. * Disposes the prepass renderer.
  24354. */
  24355. dispose(): void;
  24356. }
  24357. }
  24358. declare module BABYLON {
  24359. /**
  24360. * Options for compiling materials.
  24361. */
  24362. export interface IMaterialCompilationOptions {
  24363. /**
  24364. * Defines whether clip planes are enabled.
  24365. */
  24366. clipPlane: boolean;
  24367. /**
  24368. * Defines whether instances are enabled.
  24369. */
  24370. useInstances: boolean;
  24371. }
  24372. /**
  24373. * Options passed when calling customShaderNameResolve
  24374. */
  24375. export interface ICustomShaderNameResolveOptions {
  24376. /**
  24377. * 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
  24378. */
  24379. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  24380. }
  24381. /**
  24382. * Base class for the main features of a material in Babylon.js
  24383. */
  24384. export class Material implements IAnimatable {
  24385. /**
  24386. * Returns the triangle fill mode
  24387. */
  24388. static readonly TriangleFillMode: number;
  24389. /**
  24390. * Returns the wireframe mode
  24391. */
  24392. static readonly WireFrameFillMode: number;
  24393. /**
  24394. * Returns the point fill mode
  24395. */
  24396. static readonly PointFillMode: number;
  24397. /**
  24398. * Returns the point list draw mode
  24399. */
  24400. static readonly PointListDrawMode: number;
  24401. /**
  24402. * Returns the line list draw mode
  24403. */
  24404. static readonly LineListDrawMode: number;
  24405. /**
  24406. * Returns the line loop draw mode
  24407. */
  24408. static readonly LineLoopDrawMode: number;
  24409. /**
  24410. * Returns the line strip draw mode
  24411. */
  24412. static readonly LineStripDrawMode: number;
  24413. /**
  24414. * Returns the triangle strip draw mode
  24415. */
  24416. static readonly TriangleStripDrawMode: number;
  24417. /**
  24418. * Returns the triangle fan draw mode
  24419. */
  24420. static readonly TriangleFanDrawMode: number;
  24421. /**
  24422. * Stores the clock-wise side orientation
  24423. */
  24424. static readonly ClockWiseSideOrientation: number;
  24425. /**
  24426. * Stores the counter clock-wise side orientation
  24427. */
  24428. static readonly CounterClockWiseSideOrientation: number;
  24429. /**
  24430. * The dirty texture flag value
  24431. */
  24432. static readonly TextureDirtyFlag: number;
  24433. /**
  24434. * The dirty light flag value
  24435. */
  24436. static readonly LightDirtyFlag: number;
  24437. /**
  24438. * The dirty fresnel flag value
  24439. */
  24440. static readonly FresnelDirtyFlag: number;
  24441. /**
  24442. * The dirty attribute flag value
  24443. */
  24444. static readonly AttributesDirtyFlag: number;
  24445. /**
  24446. * The dirty misc flag value
  24447. */
  24448. static readonly MiscDirtyFlag: number;
  24449. /**
  24450. * The all dirty flag value
  24451. */
  24452. static readonly AllDirtyFlag: number;
  24453. /**
  24454. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  24455. */
  24456. static readonly MATERIAL_OPAQUE: number;
  24457. /**
  24458. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  24459. */
  24460. static readonly MATERIAL_ALPHATEST: number;
  24461. /**
  24462. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24463. */
  24464. static readonly MATERIAL_ALPHABLEND: number;
  24465. /**
  24466. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24467. * They are also discarded below the alpha cutoff threshold to improve performances.
  24468. */
  24469. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  24470. /**
  24471. * The Whiteout method is used to blend normals.
  24472. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24473. */
  24474. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  24475. /**
  24476. * The Reoriented Normal Mapping method is used to blend normals.
  24477. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24478. */
  24479. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  24480. /**
  24481. * Custom callback helping to override the default shader used in the material.
  24482. */
  24483. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  24484. /**
  24485. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  24486. */
  24487. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  24488. /**
  24489. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  24490. * This means that the material can keep using a previous shader while a new one is being compiled.
  24491. * This is mostly used when shader parallel compilation is supported (true by default)
  24492. */
  24493. allowShaderHotSwapping: boolean;
  24494. /**
  24495. * The ID of the material
  24496. */
  24497. id: string;
  24498. /**
  24499. * Gets or sets the unique id of the material
  24500. */
  24501. uniqueId: number;
  24502. /**
  24503. * The name of the material
  24504. */
  24505. name: string;
  24506. /**
  24507. * Gets or sets user defined metadata
  24508. */
  24509. metadata: any;
  24510. /**
  24511. * For internal use only. Please do not use.
  24512. */
  24513. reservedDataStore: any;
  24514. /**
  24515. * Specifies if the ready state should be checked on each call
  24516. */
  24517. checkReadyOnEveryCall: boolean;
  24518. /**
  24519. * Specifies if the ready state should be checked once
  24520. */
  24521. checkReadyOnlyOnce: boolean;
  24522. /**
  24523. * The state of the material
  24524. */
  24525. state: string;
  24526. /**
  24527. * If the material can be rendered to several textures with MRT extension
  24528. */
  24529. get canRenderToMRT(): boolean;
  24530. /**
  24531. * The alpha value of the material
  24532. */
  24533. protected _alpha: number;
  24534. /**
  24535. * List of inspectable custom properties (used by the Inspector)
  24536. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24537. */
  24538. inspectableCustomProperties: IInspectable[];
  24539. /**
  24540. * Sets the alpha value of the material
  24541. */
  24542. set alpha(value: number);
  24543. /**
  24544. * Gets the alpha value of the material
  24545. */
  24546. get alpha(): number;
  24547. /**
  24548. * Specifies if back face culling is enabled
  24549. */
  24550. protected _backFaceCulling: boolean;
  24551. /**
  24552. * Sets the back-face culling state
  24553. */
  24554. set backFaceCulling(value: boolean);
  24555. /**
  24556. * Gets the back-face culling state
  24557. */
  24558. get backFaceCulling(): boolean;
  24559. /**
  24560. * Stores the value for side orientation
  24561. */
  24562. sideOrientation: number;
  24563. /**
  24564. * Callback triggered when the material is compiled
  24565. */
  24566. onCompiled: Nullable<(effect: Effect) => void>;
  24567. /**
  24568. * Callback triggered when an error occurs
  24569. */
  24570. onError: Nullable<(effect: Effect, errors: string) => void>;
  24571. /**
  24572. * Callback triggered to get the render target textures
  24573. */
  24574. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  24575. /**
  24576. * Gets a boolean indicating that current material needs to register RTT
  24577. */
  24578. get hasRenderTargetTextures(): boolean;
  24579. /**
  24580. * Specifies if the material should be serialized
  24581. */
  24582. doNotSerialize: boolean;
  24583. /**
  24584. * @hidden
  24585. */
  24586. _storeEffectOnSubMeshes: boolean;
  24587. /**
  24588. * Stores the animations for the material
  24589. */
  24590. animations: Nullable<Array<Animation>>;
  24591. /**
  24592. * An event triggered when the material is disposed
  24593. */
  24594. onDisposeObservable: Observable<Material>;
  24595. /**
  24596. * An observer which watches for dispose events
  24597. */
  24598. private _onDisposeObserver;
  24599. private _onUnBindObservable;
  24600. /**
  24601. * Called during a dispose event
  24602. */
  24603. set onDispose(callback: () => void);
  24604. private _onBindObservable;
  24605. /**
  24606. * An event triggered when the material is bound
  24607. */
  24608. get onBindObservable(): Observable<AbstractMesh>;
  24609. /**
  24610. * An observer which watches for bind events
  24611. */
  24612. private _onBindObserver;
  24613. /**
  24614. * Called during a bind event
  24615. */
  24616. set onBind(callback: (Mesh: AbstractMesh) => void);
  24617. /**
  24618. * An event triggered when the material is unbound
  24619. */
  24620. get onUnBindObservable(): Observable<Material>;
  24621. protected _onEffectCreatedObservable: Nullable<Observable<{
  24622. effect: Effect;
  24623. subMesh: Nullable<SubMesh>;
  24624. }>>;
  24625. /**
  24626. * An event triggered when the effect is (re)created
  24627. */
  24628. get onEffectCreatedObservable(): Observable<{
  24629. effect: Effect;
  24630. subMesh: Nullable<SubMesh>;
  24631. }>;
  24632. /**
  24633. * Stores the value of the alpha mode
  24634. */
  24635. private _alphaMode;
  24636. /**
  24637. * Sets the value of the alpha mode.
  24638. *
  24639. * | Value | Type | Description |
  24640. * | --- | --- | --- |
  24641. * | 0 | ALPHA_DISABLE | |
  24642. * | 1 | ALPHA_ADD | |
  24643. * | 2 | ALPHA_COMBINE | |
  24644. * | 3 | ALPHA_SUBTRACT | |
  24645. * | 4 | ALPHA_MULTIPLY | |
  24646. * | 5 | ALPHA_MAXIMIZED | |
  24647. * | 6 | ALPHA_ONEONE | |
  24648. * | 7 | ALPHA_PREMULTIPLIED | |
  24649. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  24650. * | 9 | ALPHA_INTERPOLATE | |
  24651. * | 10 | ALPHA_SCREENMODE | |
  24652. *
  24653. */
  24654. set alphaMode(value: number);
  24655. /**
  24656. * Gets the value of the alpha mode
  24657. */
  24658. get alphaMode(): number;
  24659. /**
  24660. * Stores the state of the need depth pre-pass value
  24661. */
  24662. private _needDepthPrePass;
  24663. /**
  24664. * Sets the need depth pre-pass value
  24665. */
  24666. set needDepthPrePass(value: boolean);
  24667. /**
  24668. * Gets the depth pre-pass value
  24669. */
  24670. get needDepthPrePass(): boolean;
  24671. /**
  24672. * Specifies if depth writing should be disabled
  24673. */
  24674. disableDepthWrite: boolean;
  24675. /**
  24676. * Specifies if color writing should be disabled
  24677. */
  24678. disableColorWrite: boolean;
  24679. /**
  24680. * Specifies if depth writing should be forced
  24681. */
  24682. forceDepthWrite: boolean;
  24683. /**
  24684. * Specifies the depth function that should be used. 0 means the default engine function
  24685. */
  24686. depthFunction: number;
  24687. /**
  24688. * Specifies if there should be a separate pass for culling
  24689. */
  24690. separateCullingPass: boolean;
  24691. /**
  24692. * Stores the state specifing if fog should be enabled
  24693. */
  24694. private _fogEnabled;
  24695. /**
  24696. * Sets the state for enabling fog
  24697. */
  24698. set fogEnabled(value: boolean);
  24699. /**
  24700. * Gets the value of the fog enabled state
  24701. */
  24702. get fogEnabled(): boolean;
  24703. /**
  24704. * Stores the size of points
  24705. */
  24706. pointSize: number;
  24707. /**
  24708. * Stores the z offset value
  24709. */
  24710. zOffset: number;
  24711. get wireframe(): boolean;
  24712. /**
  24713. * Sets the state of wireframe mode
  24714. */
  24715. set wireframe(value: boolean);
  24716. /**
  24717. * Gets the value specifying if point clouds are enabled
  24718. */
  24719. get pointsCloud(): boolean;
  24720. /**
  24721. * Sets the state of point cloud mode
  24722. */
  24723. set pointsCloud(value: boolean);
  24724. /**
  24725. * Gets the material fill mode
  24726. */
  24727. get fillMode(): number;
  24728. /**
  24729. * Sets the material fill mode
  24730. */
  24731. set fillMode(value: number);
  24732. /**
  24733. * @hidden
  24734. * Stores the effects for the material
  24735. */
  24736. _effect: Nullable<Effect>;
  24737. /**
  24738. * Specifies if uniform buffers should be used
  24739. */
  24740. private _useUBO;
  24741. /**
  24742. * Stores a reference to the scene
  24743. */
  24744. private _scene;
  24745. /**
  24746. * Stores the fill mode state
  24747. */
  24748. private _fillMode;
  24749. /**
  24750. * Specifies if the depth write state should be cached
  24751. */
  24752. private _cachedDepthWriteState;
  24753. /**
  24754. * Specifies if the color write state should be cached
  24755. */
  24756. private _cachedColorWriteState;
  24757. /**
  24758. * Specifies if the depth function state should be cached
  24759. */
  24760. private _cachedDepthFunctionState;
  24761. /**
  24762. * Stores the uniform buffer
  24763. */
  24764. protected _uniformBuffer: UniformBuffer;
  24765. /** @hidden */
  24766. _indexInSceneMaterialArray: number;
  24767. /** @hidden */
  24768. meshMap: Nullable<{
  24769. [id: string]: AbstractMesh | undefined;
  24770. }>;
  24771. /**
  24772. * Creates a material instance
  24773. * @param name defines the name of the material
  24774. * @param scene defines the scene to reference
  24775. * @param doNotAdd specifies if the material should be added to the scene
  24776. */
  24777. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24778. /**
  24779. * Returns a string representation of the current material
  24780. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24781. * @returns a string with material information
  24782. */
  24783. toString(fullDetails?: boolean): string;
  24784. /**
  24785. * Gets the class name of the material
  24786. * @returns a string with the class name of the material
  24787. */
  24788. getClassName(): string;
  24789. /**
  24790. * Specifies if updates for the material been locked
  24791. */
  24792. get isFrozen(): boolean;
  24793. /**
  24794. * Locks updates for the material
  24795. */
  24796. freeze(): void;
  24797. /**
  24798. * Unlocks updates for the material
  24799. */
  24800. unfreeze(): void;
  24801. /**
  24802. * Specifies if the material is ready to be used
  24803. * @param mesh defines the mesh to check
  24804. * @param useInstances specifies if instances should be used
  24805. * @returns a boolean indicating if the material is ready to be used
  24806. */
  24807. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24808. /**
  24809. * Specifies that the submesh is ready to be used
  24810. * @param mesh defines the mesh to check
  24811. * @param subMesh defines which submesh to check
  24812. * @param useInstances specifies that instances should be used
  24813. * @returns a boolean indicating that the submesh is ready or not
  24814. */
  24815. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24816. /**
  24817. * Returns the material effect
  24818. * @returns the effect associated with the material
  24819. */
  24820. getEffect(): Nullable<Effect>;
  24821. /**
  24822. * Returns the current scene
  24823. * @returns a Scene
  24824. */
  24825. getScene(): Scene;
  24826. /**
  24827. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24828. */
  24829. protected _forceAlphaTest: boolean;
  24830. /**
  24831. * The transparency mode of the material.
  24832. */
  24833. protected _transparencyMode: Nullable<number>;
  24834. /**
  24835. * Gets the current transparency mode.
  24836. */
  24837. get transparencyMode(): Nullable<number>;
  24838. /**
  24839. * Sets the transparency mode of the material.
  24840. *
  24841. * | Value | Type | Description |
  24842. * | ----- | ----------------------------------- | ----------- |
  24843. * | 0 | OPAQUE | |
  24844. * | 1 | ALPHATEST | |
  24845. * | 2 | ALPHABLEND | |
  24846. * | 3 | ALPHATESTANDBLEND | |
  24847. *
  24848. */
  24849. set transparencyMode(value: Nullable<number>);
  24850. /**
  24851. * Returns true if alpha blending should be disabled.
  24852. */
  24853. protected get _disableAlphaBlending(): boolean;
  24854. /**
  24855. * Specifies whether or not this material should be rendered in alpha blend mode.
  24856. * @returns a boolean specifying if alpha blending is needed
  24857. */
  24858. needAlphaBlending(): boolean;
  24859. /**
  24860. * Specifies if the mesh will require alpha blending
  24861. * @param mesh defines the mesh to check
  24862. * @returns a boolean specifying if alpha blending is needed for the mesh
  24863. */
  24864. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  24865. /**
  24866. * Specifies whether or not this material should be rendered in alpha test mode.
  24867. * @returns a boolean specifying if an alpha test is needed.
  24868. */
  24869. needAlphaTesting(): boolean;
  24870. /**
  24871. * Specifies if material alpha testing should be turned on for the mesh
  24872. * @param mesh defines the mesh to check
  24873. */
  24874. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  24875. /**
  24876. * Gets the texture used for the alpha test
  24877. * @returns the texture to use for alpha testing
  24878. */
  24879. getAlphaTestTexture(): Nullable<BaseTexture>;
  24880. /**
  24881. * Marks the material to indicate that it needs to be re-calculated
  24882. */
  24883. markDirty(): void;
  24884. /** @hidden */
  24885. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  24886. /**
  24887. * Binds the material to the mesh
  24888. * @param world defines the world transformation matrix
  24889. * @param mesh defines the mesh to bind the material to
  24890. */
  24891. bind(world: Matrix, mesh?: Mesh): void;
  24892. /**
  24893. * Binds the submesh to the material
  24894. * @param world defines the world transformation matrix
  24895. * @param mesh defines the mesh containing the submesh
  24896. * @param subMesh defines the submesh to bind the material to
  24897. */
  24898. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24899. /**
  24900. * Binds the world matrix to the material
  24901. * @param world defines the world transformation matrix
  24902. */
  24903. bindOnlyWorldMatrix(world: Matrix): void;
  24904. /**
  24905. * Binds the scene's uniform buffer to the effect.
  24906. * @param effect defines the effect to bind to the scene uniform buffer
  24907. * @param sceneUbo defines the uniform buffer storing scene data
  24908. */
  24909. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  24910. /**
  24911. * Binds the view matrix to the effect
  24912. * @param effect defines the effect to bind the view matrix to
  24913. */
  24914. bindView(effect: Effect): void;
  24915. /**
  24916. * Binds the view projection matrix to the effect
  24917. * @param effect defines the effect to bind the view projection matrix to
  24918. */
  24919. bindViewProjection(effect: Effect): void;
  24920. /**
  24921. * Processes to execute after binding the material to a mesh
  24922. * @param mesh defines the rendered mesh
  24923. */
  24924. protected _afterBind(mesh?: Mesh): void;
  24925. /**
  24926. * Unbinds the material from the mesh
  24927. */
  24928. unbind(): void;
  24929. /**
  24930. * Gets the active textures from the material
  24931. * @returns an array of textures
  24932. */
  24933. getActiveTextures(): BaseTexture[];
  24934. /**
  24935. * Specifies if the material uses a texture
  24936. * @param texture defines the texture to check against the material
  24937. * @returns a boolean specifying if the material uses the texture
  24938. */
  24939. hasTexture(texture: BaseTexture): boolean;
  24940. /**
  24941. * Makes a duplicate of the material, and gives it a new name
  24942. * @param name defines the new name for the duplicated material
  24943. * @returns the cloned material
  24944. */
  24945. clone(name: string): Nullable<Material>;
  24946. /**
  24947. * Gets the meshes bound to the material
  24948. * @returns an array of meshes bound to the material
  24949. */
  24950. getBindedMeshes(): AbstractMesh[];
  24951. /**
  24952. * Force shader compilation
  24953. * @param mesh defines the mesh associated with this material
  24954. * @param onCompiled defines a function to execute once the material is compiled
  24955. * @param options defines the options to configure the compilation
  24956. * @param onError defines a function to execute if the material fails compiling
  24957. */
  24958. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  24959. /**
  24960. * Force shader compilation
  24961. * @param mesh defines the mesh that will use this material
  24962. * @param options defines additional options for compiling the shaders
  24963. * @returns a promise that resolves when the compilation completes
  24964. */
  24965. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  24966. private static readonly _AllDirtyCallBack;
  24967. private static readonly _ImageProcessingDirtyCallBack;
  24968. private static readonly _TextureDirtyCallBack;
  24969. private static readonly _FresnelDirtyCallBack;
  24970. private static readonly _MiscDirtyCallBack;
  24971. private static readonly _LightsDirtyCallBack;
  24972. private static readonly _AttributeDirtyCallBack;
  24973. private static _FresnelAndMiscDirtyCallBack;
  24974. private static _TextureAndMiscDirtyCallBack;
  24975. private static readonly _DirtyCallbackArray;
  24976. private static readonly _RunDirtyCallBacks;
  24977. /**
  24978. * Marks a define in the material to indicate that it needs to be re-computed
  24979. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  24980. */
  24981. markAsDirty(flag: number): void;
  24982. /**
  24983. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  24984. * @param func defines a function which checks material defines against the submeshes
  24985. */
  24986. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  24987. /**
  24988. * Indicates that the scene should check if the rendering now needs a prepass
  24989. */
  24990. protected _markScenePrePassDirty(): void;
  24991. /**
  24992. * Indicates that we need to re-calculated for all submeshes
  24993. */
  24994. protected _markAllSubMeshesAsAllDirty(): void;
  24995. /**
  24996. * Indicates that image processing needs to be re-calculated for all submeshes
  24997. */
  24998. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  24999. /**
  25000. * Indicates that textures need to be re-calculated for all submeshes
  25001. */
  25002. protected _markAllSubMeshesAsTexturesDirty(): void;
  25003. /**
  25004. * Indicates that fresnel needs to be re-calculated for all submeshes
  25005. */
  25006. protected _markAllSubMeshesAsFresnelDirty(): void;
  25007. /**
  25008. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  25009. */
  25010. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  25011. /**
  25012. * Indicates that lights need to be re-calculated for all submeshes
  25013. */
  25014. protected _markAllSubMeshesAsLightsDirty(): void;
  25015. /**
  25016. * Indicates that attributes need to be re-calculated for all submeshes
  25017. */
  25018. protected _markAllSubMeshesAsAttributesDirty(): void;
  25019. /**
  25020. * Indicates that misc needs to be re-calculated for all submeshes
  25021. */
  25022. protected _markAllSubMeshesAsMiscDirty(): void;
  25023. /**
  25024. * Indicates that textures and misc need to be re-calculated for all submeshes
  25025. */
  25026. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  25027. /**
  25028. * Sets the required values to the prepass renderer.
  25029. * @param prePassRenderer defines the prepass renderer to setup.
  25030. * @returns true if the pre pass is needed.
  25031. */
  25032. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  25033. /**
  25034. * Disposes the material
  25035. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25036. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25037. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  25038. */
  25039. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  25040. /** @hidden */
  25041. private releaseVertexArrayObject;
  25042. /**
  25043. * Serializes this material
  25044. * @returns the serialized material object
  25045. */
  25046. serialize(): any;
  25047. /**
  25048. * Creates a material from parsed material data
  25049. * @param parsedMaterial defines parsed material data
  25050. * @param scene defines the hosting scene
  25051. * @param rootUrl defines the root URL to use to load textures
  25052. * @returns a new material
  25053. */
  25054. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  25055. }
  25056. }
  25057. declare module BABYLON {
  25058. /**
  25059. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25060. * separate meshes. This can be use to improve performances.
  25061. * @see https://doc.babylonjs.com/how_to/multi_materials
  25062. */
  25063. export class MultiMaterial extends Material {
  25064. private _subMaterials;
  25065. /**
  25066. * Gets or Sets the list of Materials used within the multi material.
  25067. * They need to be ordered according to the submeshes order in the associated mesh
  25068. */
  25069. get subMaterials(): Nullable<Material>[];
  25070. set subMaterials(value: Nullable<Material>[]);
  25071. /**
  25072. * Function used to align with Node.getChildren()
  25073. * @returns the list of Materials used within the multi material
  25074. */
  25075. getChildren(): Nullable<Material>[];
  25076. /**
  25077. * Instantiates a new Multi Material
  25078. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25079. * separate meshes. This can be use to improve performances.
  25080. * @see https://doc.babylonjs.com/how_to/multi_materials
  25081. * @param name Define the name in the scene
  25082. * @param scene Define the scene the material belongs to
  25083. */
  25084. constructor(name: string, scene: Scene);
  25085. private _hookArray;
  25086. /**
  25087. * Get one of the submaterial by its index in the submaterials array
  25088. * @param index The index to look the sub material at
  25089. * @returns The Material if the index has been defined
  25090. */
  25091. getSubMaterial(index: number): Nullable<Material>;
  25092. /**
  25093. * Get the list of active textures for the whole sub materials list.
  25094. * @returns All the textures that will be used during the rendering
  25095. */
  25096. getActiveTextures(): BaseTexture[];
  25097. /**
  25098. * Gets the current class name of the material e.g. "MultiMaterial"
  25099. * Mainly use in serialization.
  25100. * @returns the class name
  25101. */
  25102. getClassName(): string;
  25103. /**
  25104. * Checks if the material is ready to render the requested sub mesh
  25105. * @param mesh Define the mesh the submesh belongs to
  25106. * @param subMesh Define the sub mesh to look readyness for
  25107. * @param useInstances Define whether or not the material is used with instances
  25108. * @returns true if ready, otherwise false
  25109. */
  25110. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25111. /**
  25112. * Clones the current material and its related sub materials
  25113. * @param name Define the name of the newly cloned material
  25114. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  25115. * @returns the cloned material
  25116. */
  25117. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  25118. /**
  25119. * Serializes the materials into a JSON representation.
  25120. * @returns the JSON representation
  25121. */
  25122. serialize(): any;
  25123. /**
  25124. * Dispose the material and release its associated resources
  25125. * @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)
  25126. * @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)
  25127. * @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)
  25128. */
  25129. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  25130. /**
  25131. * Creates a MultiMaterial from parsed MultiMaterial data.
  25132. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  25133. * @param scene defines the hosting scene
  25134. * @returns a new MultiMaterial
  25135. */
  25136. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  25137. }
  25138. }
  25139. declare module BABYLON {
  25140. /**
  25141. * Defines a subdivision inside a mesh
  25142. */
  25143. export class SubMesh implements ICullable {
  25144. /** the material index to use */
  25145. materialIndex: number;
  25146. /** vertex index start */
  25147. verticesStart: number;
  25148. /** vertices count */
  25149. verticesCount: number;
  25150. /** index start */
  25151. indexStart: number;
  25152. /** indices count */
  25153. indexCount: number;
  25154. /** @hidden */
  25155. _materialDefines: Nullable<MaterialDefines>;
  25156. /** @hidden */
  25157. _materialEffect: Nullable<Effect>;
  25158. /** @hidden */
  25159. _effectOverride: Nullable<Effect>;
  25160. /**
  25161. * Gets material defines used by the effect associated to the sub mesh
  25162. */
  25163. get materialDefines(): Nullable<MaterialDefines>;
  25164. /**
  25165. * Sets material defines used by the effect associated to the sub mesh
  25166. */
  25167. set materialDefines(defines: Nullable<MaterialDefines>);
  25168. /**
  25169. * Gets associated effect
  25170. */
  25171. get effect(): Nullable<Effect>;
  25172. /**
  25173. * Sets associated effect (effect used to render this submesh)
  25174. * @param effect defines the effect to associate with
  25175. * @param defines defines the set of defines used to compile this effect
  25176. */
  25177. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  25178. /** @hidden */
  25179. _linesIndexCount: number;
  25180. private _mesh;
  25181. private _renderingMesh;
  25182. private _boundingInfo;
  25183. private _linesIndexBuffer;
  25184. /** @hidden */
  25185. _lastColliderWorldVertices: Nullable<Vector3[]>;
  25186. /** @hidden */
  25187. _trianglePlanes: Plane[];
  25188. /** @hidden */
  25189. _lastColliderTransformMatrix: Nullable<Matrix>;
  25190. /** @hidden */
  25191. _renderId: number;
  25192. /** @hidden */
  25193. _alphaIndex: number;
  25194. /** @hidden */
  25195. _distanceToCamera: number;
  25196. /** @hidden */
  25197. _id: number;
  25198. private _currentMaterial;
  25199. /**
  25200. * Add a new submesh to a mesh
  25201. * @param materialIndex defines the material index to use
  25202. * @param verticesStart defines vertex index start
  25203. * @param verticesCount defines vertices count
  25204. * @param indexStart defines index start
  25205. * @param indexCount defines indices count
  25206. * @param mesh defines the parent mesh
  25207. * @param renderingMesh defines an optional rendering mesh
  25208. * @param createBoundingBox defines if bounding box should be created for this submesh
  25209. * @returns the new submesh
  25210. */
  25211. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  25212. /**
  25213. * Creates a new submesh
  25214. * @param materialIndex defines the material index to use
  25215. * @param verticesStart defines vertex index start
  25216. * @param verticesCount defines vertices count
  25217. * @param indexStart defines index start
  25218. * @param indexCount defines indices count
  25219. * @param mesh defines the parent mesh
  25220. * @param renderingMesh defines an optional rendering mesh
  25221. * @param createBoundingBox defines if bounding box should be created for this submesh
  25222. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  25223. */
  25224. constructor(
  25225. /** the material index to use */
  25226. materialIndex: number,
  25227. /** vertex index start */
  25228. verticesStart: number,
  25229. /** vertices count */
  25230. verticesCount: number,
  25231. /** index start */
  25232. indexStart: number,
  25233. /** indices count */
  25234. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  25235. /**
  25236. * Returns true if this submesh covers the entire parent mesh
  25237. * @ignorenaming
  25238. */
  25239. get IsGlobal(): boolean;
  25240. /**
  25241. * Returns the submesh BoudingInfo object
  25242. * @returns current bounding info (or mesh's one if the submesh is global)
  25243. */
  25244. getBoundingInfo(): BoundingInfo;
  25245. /**
  25246. * Sets the submesh BoundingInfo
  25247. * @param boundingInfo defines the new bounding info to use
  25248. * @returns the SubMesh
  25249. */
  25250. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  25251. /**
  25252. * Returns the mesh of the current submesh
  25253. * @return the parent mesh
  25254. */
  25255. getMesh(): AbstractMesh;
  25256. /**
  25257. * Returns the rendering mesh of the submesh
  25258. * @returns the rendering mesh (could be different from parent mesh)
  25259. */
  25260. getRenderingMesh(): Mesh;
  25261. /**
  25262. * Returns the replacement mesh of the submesh
  25263. * @returns the replacement mesh (could be different from parent mesh)
  25264. */
  25265. getReplacementMesh(): Nullable<AbstractMesh>;
  25266. /**
  25267. * Returns the effective mesh of the submesh
  25268. * @returns the effective mesh (could be different from parent mesh)
  25269. */
  25270. getEffectiveMesh(): AbstractMesh;
  25271. /**
  25272. * Returns the submesh material
  25273. * @returns null or the current material
  25274. */
  25275. getMaterial(): Nullable<Material>;
  25276. private _IsMultiMaterial;
  25277. /**
  25278. * Sets a new updated BoundingInfo object to the submesh
  25279. * @param data defines an optional position array to use to determine the bounding info
  25280. * @returns the SubMesh
  25281. */
  25282. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  25283. /** @hidden */
  25284. _checkCollision(collider: Collider): boolean;
  25285. /**
  25286. * Updates the submesh BoundingInfo
  25287. * @param world defines the world matrix to use to update the bounding info
  25288. * @returns the submesh
  25289. */
  25290. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  25291. /**
  25292. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  25293. * @param frustumPlanes defines the frustum planes
  25294. * @returns true if the submesh is intersecting with the frustum
  25295. */
  25296. isInFrustum(frustumPlanes: Plane[]): boolean;
  25297. /**
  25298. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  25299. * @param frustumPlanes defines the frustum planes
  25300. * @returns true if the submesh is inside the frustum
  25301. */
  25302. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25303. /**
  25304. * Renders the submesh
  25305. * @param enableAlphaMode defines if alpha needs to be used
  25306. * @returns the submesh
  25307. */
  25308. render(enableAlphaMode: boolean): SubMesh;
  25309. /**
  25310. * @hidden
  25311. */
  25312. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  25313. /**
  25314. * Checks if the submesh intersects with a ray
  25315. * @param ray defines the ray to test
  25316. * @returns true is the passed ray intersects the submesh bounding box
  25317. */
  25318. canIntersects(ray: Ray): boolean;
  25319. /**
  25320. * Intersects current submesh with a ray
  25321. * @param ray defines the ray to test
  25322. * @param positions defines mesh's positions array
  25323. * @param indices defines mesh's indices array
  25324. * @param fastCheck defines if the first intersection will be used (and not the closest)
  25325. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25326. * @returns intersection info or null if no intersection
  25327. */
  25328. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  25329. /** @hidden */
  25330. private _intersectLines;
  25331. /** @hidden */
  25332. private _intersectUnIndexedLines;
  25333. /** @hidden */
  25334. private _intersectTriangles;
  25335. /** @hidden */
  25336. private _intersectUnIndexedTriangles;
  25337. /** @hidden */
  25338. _rebuild(): void;
  25339. /**
  25340. * Creates a new submesh from the passed mesh
  25341. * @param newMesh defines the new hosting mesh
  25342. * @param newRenderingMesh defines an optional rendering mesh
  25343. * @returns the new submesh
  25344. */
  25345. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  25346. /**
  25347. * Release associated resources
  25348. */
  25349. dispose(): void;
  25350. /**
  25351. * Gets the class name
  25352. * @returns the string "SubMesh".
  25353. */
  25354. getClassName(): string;
  25355. /**
  25356. * Creates a new submesh from indices data
  25357. * @param materialIndex the index of the main mesh material
  25358. * @param startIndex the index where to start the copy in the mesh indices array
  25359. * @param indexCount the number of indices to copy then from the startIndex
  25360. * @param mesh the main mesh to create the submesh from
  25361. * @param renderingMesh the optional rendering mesh
  25362. * @returns a new submesh
  25363. */
  25364. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  25365. }
  25366. }
  25367. declare module BABYLON {
  25368. /**
  25369. * Class used to represent data loading progression
  25370. */
  25371. export class SceneLoaderFlags {
  25372. private static _ForceFullSceneLoadingForIncremental;
  25373. private static _ShowLoadingScreen;
  25374. private static _CleanBoneMatrixWeights;
  25375. private static _loggingLevel;
  25376. /**
  25377. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  25378. */
  25379. static get ForceFullSceneLoadingForIncremental(): boolean;
  25380. static set ForceFullSceneLoadingForIncremental(value: boolean);
  25381. /**
  25382. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  25383. */
  25384. static get ShowLoadingScreen(): boolean;
  25385. static set ShowLoadingScreen(value: boolean);
  25386. /**
  25387. * Defines the current logging level (while loading the scene)
  25388. * @ignorenaming
  25389. */
  25390. static get loggingLevel(): number;
  25391. static set loggingLevel(value: number);
  25392. /**
  25393. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  25394. */
  25395. static get CleanBoneMatrixWeights(): boolean;
  25396. static set CleanBoneMatrixWeights(value: boolean);
  25397. }
  25398. }
  25399. declare module BABYLON {
  25400. /**
  25401. * Class used to store geometry data (vertex buffers + index buffer)
  25402. */
  25403. export class Geometry implements IGetSetVerticesData {
  25404. /**
  25405. * Gets or sets the ID of the geometry
  25406. */
  25407. id: string;
  25408. /**
  25409. * Gets or sets the unique ID of the geometry
  25410. */
  25411. uniqueId: number;
  25412. /**
  25413. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25414. */
  25415. delayLoadState: number;
  25416. /**
  25417. * Gets the file containing the data to load when running in delay load state
  25418. */
  25419. delayLoadingFile: Nullable<string>;
  25420. /**
  25421. * Callback called when the geometry is updated
  25422. */
  25423. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25424. private _scene;
  25425. private _engine;
  25426. private _meshes;
  25427. private _totalVertices;
  25428. /** @hidden */
  25429. _indices: IndicesArray;
  25430. /** @hidden */
  25431. _vertexBuffers: {
  25432. [key: string]: VertexBuffer;
  25433. };
  25434. private _isDisposed;
  25435. private _extend;
  25436. private _boundingBias;
  25437. /** @hidden */
  25438. _delayInfo: Array<string>;
  25439. private _indexBuffer;
  25440. private _indexBufferIsUpdatable;
  25441. /** @hidden */
  25442. _boundingInfo: Nullable<BoundingInfo>;
  25443. /** @hidden */
  25444. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25445. /** @hidden */
  25446. _softwareSkinningFrameId: number;
  25447. private _vertexArrayObjects;
  25448. private _updatable;
  25449. /** @hidden */
  25450. _positions: Nullable<Vector3[]>;
  25451. /**
  25452. * 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
  25453. */
  25454. get boundingBias(): Vector2;
  25455. /**
  25456. * 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
  25457. */
  25458. set boundingBias(value: Vector2);
  25459. /**
  25460. * Static function used to attach a new empty geometry to a mesh
  25461. * @param mesh defines the mesh to attach the geometry to
  25462. * @returns the new Geometry
  25463. */
  25464. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25465. /** Get the list of meshes using this geometry */
  25466. get meshes(): Mesh[];
  25467. /**
  25468. * 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
  25469. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  25470. */
  25471. useBoundingInfoFromGeometry: boolean;
  25472. /**
  25473. * Creates a new geometry
  25474. * @param id defines the unique ID
  25475. * @param scene defines the hosting scene
  25476. * @param vertexData defines the VertexData used to get geometry data
  25477. * @param updatable defines if geometry must be updatable (false by default)
  25478. * @param mesh defines the mesh that will be associated with the geometry
  25479. */
  25480. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25481. /**
  25482. * Gets the current extend of the geometry
  25483. */
  25484. get extend(): {
  25485. minimum: Vector3;
  25486. maximum: Vector3;
  25487. };
  25488. /**
  25489. * Gets the hosting scene
  25490. * @returns the hosting Scene
  25491. */
  25492. getScene(): Scene;
  25493. /**
  25494. * Gets the hosting engine
  25495. * @returns the hosting Engine
  25496. */
  25497. getEngine(): Engine;
  25498. /**
  25499. * Defines if the geometry is ready to use
  25500. * @returns true if the geometry is ready to be used
  25501. */
  25502. isReady(): boolean;
  25503. /**
  25504. * Gets a value indicating that the geometry should not be serialized
  25505. */
  25506. get doNotSerialize(): boolean;
  25507. /** @hidden */
  25508. _rebuild(): void;
  25509. /**
  25510. * Affects all geometry data in one call
  25511. * @param vertexData defines the geometry data
  25512. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25513. */
  25514. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25515. /**
  25516. * Set specific vertex data
  25517. * @param kind defines the data kind (Position, normal, etc...)
  25518. * @param data defines the vertex data to use
  25519. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25520. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25521. */
  25522. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25523. /**
  25524. * Removes a specific vertex data
  25525. * @param kind defines the data kind (Position, normal, etc...)
  25526. */
  25527. removeVerticesData(kind: string): void;
  25528. /**
  25529. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25530. * @param buffer defines the vertex buffer to use
  25531. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25532. */
  25533. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25534. /**
  25535. * Update a specific vertex buffer
  25536. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  25537. * It will do nothing if the buffer is not updatable
  25538. * @param kind defines the data kind (Position, normal, etc...)
  25539. * @param data defines the data to use
  25540. * @param offset defines the offset in the target buffer where to store the data
  25541. * @param useBytes set to true if the offset is in bytes
  25542. */
  25543. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25544. /**
  25545. * Update a specific vertex buffer
  25546. * This function will create a new buffer if the current one is not updatable
  25547. * @param kind defines the data kind (Position, normal, etc...)
  25548. * @param data defines the data to use
  25549. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25550. */
  25551. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25552. private _updateBoundingInfo;
  25553. /** @hidden */
  25554. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  25555. /**
  25556. * Gets total number of vertices
  25557. * @returns the total number of vertices
  25558. */
  25559. getTotalVertices(): number;
  25560. /**
  25561. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25562. * @param kind defines the data kind (Position, normal, etc...)
  25563. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25564. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25565. * @returns a float array containing vertex data
  25566. */
  25567. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25568. /**
  25569. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25570. * @param kind defines the data kind (Position, normal, etc...)
  25571. * @returns true if the vertex buffer with the specified kind is updatable
  25572. */
  25573. isVertexBufferUpdatable(kind: string): boolean;
  25574. /**
  25575. * Gets a specific vertex buffer
  25576. * @param kind defines the data kind (Position, normal, etc...)
  25577. * @returns a VertexBuffer
  25578. */
  25579. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25580. /**
  25581. * Returns all vertex buffers
  25582. * @return an object holding all vertex buffers indexed by kind
  25583. */
  25584. getVertexBuffers(): Nullable<{
  25585. [key: string]: VertexBuffer;
  25586. }>;
  25587. /**
  25588. * Gets a boolean indicating if specific vertex buffer is present
  25589. * @param kind defines the data kind (Position, normal, etc...)
  25590. * @returns true if data is present
  25591. */
  25592. isVerticesDataPresent(kind: string): boolean;
  25593. /**
  25594. * Gets a list of all attached data kinds (Position, normal, etc...)
  25595. * @returns a list of string containing all kinds
  25596. */
  25597. getVerticesDataKinds(): string[];
  25598. /**
  25599. * Update index buffer
  25600. * @param indices defines the indices to store in the index buffer
  25601. * @param offset defines the offset in the target buffer where to store the data
  25602. * @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)
  25603. */
  25604. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  25605. /**
  25606. * Creates a new index buffer
  25607. * @param indices defines the indices to store in the index buffer
  25608. * @param totalVertices defines the total number of vertices (could be null)
  25609. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25610. */
  25611. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25612. /**
  25613. * Return the total number of indices
  25614. * @returns the total number of indices
  25615. */
  25616. getTotalIndices(): number;
  25617. /**
  25618. * Gets the index buffer array
  25619. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25620. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25621. * @returns the index buffer array
  25622. */
  25623. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25624. /**
  25625. * Gets the index buffer
  25626. * @return the index buffer
  25627. */
  25628. getIndexBuffer(): Nullable<DataBuffer>;
  25629. /** @hidden */
  25630. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25631. /**
  25632. * Release the associated resources for a specific mesh
  25633. * @param mesh defines the source mesh
  25634. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25635. */
  25636. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25637. /**
  25638. * Apply current geometry to a given mesh
  25639. * @param mesh defines the mesh to apply geometry to
  25640. */
  25641. applyToMesh(mesh: Mesh): void;
  25642. private _updateExtend;
  25643. private _applyToMesh;
  25644. private notifyUpdate;
  25645. /**
  25646. * Load the geometry if it was flagged as delay loaded
  25647. * @param scene defines the hosting scene
  25648. * @param onLoaded defines a callback called when the geometry is loaded
  25649. */
  25650. load(scene: Scene, onLoaded?: () => void): void;
  25651. private _queueLoad;
  25652. /**
  25653. * Invert the geometry to move from a right handed system to a left handed one.
  25654. */
  25655. toLeftHanded(): void;
  25656. /** @hidden */
  25657. _resetPointsArrayCache(): void;
  25658. /** @hidden */
  25659. _generatePointsArray(): boolean;
  25660. /**
  25661. * Gets a value indicating if the geometry is disposed
  25662. * @returns true if the geometry was disposed
  25663. */
  25664. isDisposed(): boolean;
  25665. private _disposeVertexArrayObjects;
  25666. /**
  25667. * Free all associated resources
  25668. */
  25669. dispose(): void;
  25670. /**
  25671. * Clone the current geometry into a new geometry
  25672. * @param id defines the unique ID of the new geometry
  25673. * @returns a new geometry object
  25674. */
  25675. copy(id: string): Geometry;
  25676. /**
  25677. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25678. * @return a JSON representation of the current geometry data (without the vertices data)
  25679. */
  25680. serialize(): any;
  25681. private toNumberArray;
  25682. /**
  25683. * Serialize all vertices data into a JSON oject
  25684. * @returns a JSON representation of the current geometry data
  25685. */
  25686. serializeVerticeData(): any;
  25687. /**
  25688. * Extracts a clone of a mesh geometry
  25689. * @param mesh defines the source mesh
  25690. * @param id defines the unique ID of the new geometry object
  25691. * @returns the new geometry object
  25692. */
  25693. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25694. /**
  25695. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25696. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25697. * Be aware Math.random() could cause collisions, but:
  25698. * "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"
  25699. * @returns a string containing a new GUID
  25700. */
  25701. static RandomId(): string;
  25702. /** @hidden */
  25703. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25704. private static _CleanMatricesWeights;
  25705. /**
  25706. * Create a new geometry from persisted data (Using .babylon file format)
  25707. * @param parsedVertexData defines the persisted data
  25708. * @param scene defines the hosting scene
  25709. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25710. * @returns the new geometry object
  25711. */
  25712. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25713. }
  25714. }
  25715. declare module BABYLON {
  25716. /**
  25717. * Define an interface for all classes that will get and set the data on vertices
  25718. */
  25719. export interface IGetSetVerticesData {
  25720. /**
  25721. * Gets a boolean indicating if specific vertex data is present
  25722. * @param kind defines the vertex data kind to use
  25723. * @returns true is data kind is present
  25724. */
  25725. isVerticesDataPresent(kind: string): boolean;
  25726. /**
  25727. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25728. * @param kind defines the data kind (Position, normal, etc...)
  25729. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25730. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25731. * @returns a float array containing vertex data
  25732. */
  25733. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25734. /**
  25735. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25736. * @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.
  25737. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25738. * @returns the indices array or an empty array if the mesh has no geometry
  25739. */
  25740. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25741. /**
  25742. * Set specific vertex data
  25743. * @param kind defines the data kind (Position, normal, etc...)
  25744. * @param data defines the vertex data to use
  25745. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25746. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25747. */
  25748. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  25749. /**
  25750. * Update a specific associated vertex buffer
  25751. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25752. * - VertexBuffer.PositionKind
  25753. * - VertexBuffer.UVKind
  25754. * - VertexBuffer.UV2Kind
  25755. * - VertexBuffer.UV3Kind
  25756. * - VertexBuffer.UV4Kind
  25757. * - VertexBuffer.UV5Kind
  25758. * - VertexBuffer.UV6Kind
  25759. * - VertexBuffer.ColorKind
  25760. * - VertexBuffer.MatricesIndicesKind
  25761. * - VertexBuffer.MatricesIndicesExtraKind
  25762. * - VertexBuffer.MatricesWeightsKind
  25763. * - VertexBuffer.MatricesWeightsExtraKind
  25764. * @param data defines the data source
  25765. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25766. * @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)
  25767. */
  25768. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  25769. /**
  25770. * Creates a new index buffer
  25771. * @param indices defines the indices to store in the index buffer
  25772. * @param totalVertices defines the total number of vertices (could be null)
  25773. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25774. */
  25775. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25776. }
  25777. /**
  25778. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25779. */
  25780. export class VertexData {
  25781. /**
  25782. * Mesh side orientation : usually the external or front surface
  25783. */
  25784. static readonly FRONTSIDE: number;
  25785. /**
  25786. * Mesh side orientation : usually the internal or back surface
  25787. */
  25788. static readonly BACKSIDE: number;
  25789. /**
  25790. * Mesh side orientation : both internal and external or front and back surfaces
  25791. */
  25792. static readonly DOUBLESIDE: number;
  25793. /**
  25794. * Mesh side orientation : by default, `FRONTSIDE`
  25795. */
  25796. static readonly DEFAULTSIDE: number;
  25797. /**
  25798. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25799. */
  25800. positions: Nullable<FloatArray>;
  25801. /**
  25802. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25803. */
  25804. normals: Nullable<FloatArray>;
  25805. /**
  25806. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25807. */
  25808. tangents: Nullable<FloatArray>;
  25809. /**
  25810. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25811. */
  25812. uvs: Nullable<FloatArray>;
  25813. /**
  25814. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25815. */
  25816. uvs2: Nullable<FloatArray>;
  25817. /**
  25818. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25819. */
  25820. uvs3: Nullable<FloatArray>;
  25821. /**
  25822. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25823. */
  25824. uvs4: Nullable<FloatArray>;
  25825. /**
  25826. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25827. */
  25828. uvs5: Nullable<FloatArray>;
  25829. /**
  25830. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25831. */
  25832. uvs6: Nullable<FloatArray>;
  25833. /**
  25834. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25835. */
  25836. colors: Nullable<FloatArray>;
  25837. /**
  25838. * 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).
  25839. */
  25840. matricesIndices: Nullable<FloatArray>;
  25841. /**
  25842. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25843. */
  25844. matricesWeights: Nullable<FloatArray>;
  25845. /**
  25846. * An array extending the number of possible indices
  25847. */
  25848. matricesIndicesExtra: Nullable<FloatArray>;
  25849. /**
  25850. * An array extending the number of possible weights when the number of indices is extended
  25851. */
  25852. matricesWeightsExtra: Nullable<FloatArray>;
  25853. /**
  25854. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25855. */
  25856. indices: Nullable<IndicesArray>;
  25857. /**
  25858. * Uses the passed data array to set the set the values for the specified kind of data
  25859. * @param data a linear array of floating numbers
  25860. * @param kind the type of data that is being set, eg positions, colors etc
  25861. */
  25862. set(data: FloatArray, kind: string): void;
  25863. /**
  25864. * Associates the vertexData to the passed Mesh.
  25865. * Sets it as updatable or not (default `false`)
  25866. * @param mesh the mesh the vertexData is applied to
  25867. * @param updatable when used and having the value true allows new data to update the vertexData
  25868. * @returns the VertexData
  25869. */
  25870. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  25871. /**
  25872. * Associates the vertexData to the passed Geometry.
  25873. * Sets it as updatable or not (default `false`)
  25874. * @param geometry the geometry the vertexData is applied to
  25875. * @param updatable when used and having the value true allows new data to update the vertexData
  25876. * @returns VertexData
  25877. */
  25878. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  25879. /**
  25880. * Updates the associated mesh
  25881. * @param mesh the mesh to be updated
  25882. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25883. * @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
  25884. * @returns VertexData
  25885. */
  25886. updateMesh(mesh: Mesh): VertexData;
  25887. /**
  25888. * Updates the associated geometry
  25889. * @param geometry the geometry to be updated
  25890. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25891. * @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
  25892. * @returns VertexData.
  25893. */
  25894. updateGeometry(geometry: Geometry): VertexData;
  25895. private _applyTo;
  25896. private _update;
  25897. /**
  25898. * Transforms each position and each normal of the vertexData according to the passed Matrix
  25899. * @param matrix the transforming matrix
  25900. * @returns the VertexData
  25901. */
  25902. transform(matrix: Matrix): VertexData;
  25903. /**
  25904. * Merges the passed VertexData into the current one
  25905. * @param other the VertexData to be merged into the current one
  25906. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  25907. * @returns the modified VertexData
  25908. */
  25909. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  25910. private _mergeElement;
  25911. private _validate;
  25912. /**
  25913. * Serializes the VertexData
  25914. * @returns a serialized object
  25915. */
  25916. serialize(): any;
  25917. /**
  25918. * Extracts the vertexData from a mesh
  25919. * @param mesh the mesh from which to extract the VertexData
  25920. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  25921. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25922. * @returns the object VertexData associated to the passed mesh
  25923. */
  25924. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25925. /**
  25926. * Extracts the vertexData from the geometry
  25927. * @param geometry the geometry from which to extract the VertexData
  25928. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  25929. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25930. * @returns the object VertexData associated to the passed mesh
  25931. */
  25932. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25933. private static _ExtractFrom;
  25934. /**
  25935. * Creates the VertexData for a Ribbon
  25936. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  25937. * * pathArray array of paths, each of which an array of successive Vector3
  25938. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  25939. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  25940. * * 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
  25941. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25942. * * 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)
  25943. * * 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)
  25944. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  25945. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  25946. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  25947. * @returns the VertexData of the ribbon
  25948. */
  25949. static CreateRibbon(options: {
  25950. pathArray: Vector3[][];
  25951. closeArray?: boolean;
  25952. closePath?: boolean;
  25953. offset?: number;
  25954. sideOrientation?: number;
  25955. frontUVs?: Vector4;
  25956. backUVs?: Vector4;
  25957. invertUV?: boolean;
  25958. uvs?: Vector2[];
  25959. colors?: Color4[];
  25960. }): VertexData;
  25961. /**
  25962. * Creates the VertexData for a box
  25963. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25964. * * size sets the width, height and depth of the box to the value of size, optional default 1
  25965. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  25966. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  25967. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  25968. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25969. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25970. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25971. * * 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)
  25972. * * 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)
  25973. * @returns the VertexData of the box
  25974. */
  25975. static CreateBox(options: {
  25976. size?: number;
  25977. width?: number;
  25978. height?: number;
  25979. depth?: number;
  25980. faceUV?: Vector4[];
  25981. faceColors?: Color4[];
  25982. sideOrientation?: number;
  25983. frontUVs?: Vector4;
  25984. backUVs?: Vector4;
  25985. }): VertexData;
  25986. /**
  25987. * Creates the VertexData for a tiled box
  25988. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25989. * * faceTiles sets the pattern, tile size and number of tiles for a face
  25990. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25991. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25992. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25993. * @returns the VertexData of the box
  25994. */
  25995. static CreateTiledBox(options: {
  25996. pattern?: number;
  25997. width?: number;
  25998. height?: number;
  25999. depth?: number;
  26000. tileSize?: number;
  26001. tileWidth?: number;
  26002. tileHeight?: number;
  26003. alignHorizontal?: number;
  26004. alignVertical?: number;
  26005. faceUV?: Vector4[];
  26006. faceColors?: Color4[];
  26007. sideOrientation?: number;
  26008. }): VertexData;
  26009. /**
  26010. * Creates the VertexData for a tiled plane
  26011. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26012. * * pattern a limited pattern arrangement depending on the number
  26013. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  26014. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  26015. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  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 tiled plane
  26020. */
  26021. static CreateTiledPlane(options: {
  26022. pattern?: number;
  26023. tileSize?: number;
  26024. tileWidth?: number;
  26025. tileHeight?: number;
  26026. size?: number;
  26027. width?: number;
  26028. height?: number;
  26029. alignHorizontal?: number;
  26030. alignVertical?: number;
  26031. sideOrientation?: number;
  26032. frontUVs?: Vector4;
  26033. backUVs?: Vector4;
  26034. }): VertexData;
  26035. /**
  26036. * Creates the VertexData for an ellipsoid, defaults to a sphere
  26037. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26038. * * segments sets the number of horizontal strips optional, default 32
  26039. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  26040. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  26041. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  26042. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  26043. * * 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
  26044. * * 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
  26045. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26046. * * 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)
  26047. * * 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)
  26048. * @returns the VertexData of the ellipsoid
  26049. */
  26050. static CreateSphere(options: {
  26051. segments?: number;
  26052. diameter?: number;
  26053. diameterX?: number;
  26054. diameterY?: number;
  26055. diameterZ?: number;
  26056. arc?: number;
  26057. slice?: number;
  26058. sideOrientation?: number;
  26059. frontUVs?: Vector4;
  26060. backUVs?: Vector4;
  26061. }): VertexData;
  26062. /**
  26063. * Creates the VertexData for a cylinder, cone or prism
  26064. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26065. * * height sets the height (y direction) of the cylinder, optional, default 2
  26066. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  26067. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  26068. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  26069. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26070. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  26071. * * 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
  26072. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26073. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26074. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  26075. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  26076. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26077. * * 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)
  26078. * * 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)
  26079. * @returns the VertexData of the cylinder, cone or prism
  26080. */
  26081. static CreateCylinder(options: {
  26082. height?: number;
  26083. diameterTop?: number;
  26084. diameterBottom?: number;
  26085. diameter?: number;
  26086. tessellation?: number;
  26087. subdivisions?: number;
  26088. arc?: number;
  26089. faceColors?: Color4[];
  26090. faceUV?: Vector4[];
  26091. hasRings?: boolean;
  26092. enclose?: boolean;
  26093. sideOrientation?: number;
  26094. frontUVs?: Vector4;
  26095. backUVs?: Vector4;
  26096. }): VertexData;
  26097. /**
  26098. * Creates the VertexData for a torus
  26099. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26100. * * diameter the diameter of the torus, optional default 1
  26101. * * thickness the diameter of the tube forming the torus, optional default 0.5
  26102. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26103. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26104. * * 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)
  26105. * * 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)
  26106. * @returns the VertexData of the torus
  26107. */
  26108. static CreateTorus(options: {
  26109. diameter?: number;
  26110. thickness?: number;
  26111. tessellation?: number;
  26112. sideOrientation?: number;
  26113. frontUVs?: Vector4;
  26114. backUVs?: Vector4;
  26115. }): VertexData;
  26116. /**
  26117. * Creates the VertexData of the LineSystem
  26118. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  26119. * - lines an array of lines, each line being an array of successive Vector3
  26120. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  26121. * @returns the VertexData of the LineSystem
  26122. */
  26123. static CreateLineSystem(options: {
  26124. lines: Vector3[][];
  26125. colors?: Nullable<Color4[][]>;
  26126. }): VertexData;
  26127. /**
  26128. * Create the VertexData for a DashedLines
  26129. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  26130. * - points an array successive Vector3
  26131. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  26132. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  26133. * - dashNb the intended total number of dashes, optional, default 200
  26134. * @returns the VertexData for the DashedLines
  26135. */
  26136. static CreateDashedLines(options: {
  26137. points: Vector3[];
  26138. dashSize?: number;
  26139. gapSize?: number;
  26140. dashNb?: number;
  26141. }): VertexData;
  26142. /**
  26143. * Creates the VertexData for a Ground
  26144. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26145. * - width the width (x direction) of the ground, optional, default 1
  26146. * - height the height (z direction) of the ground, optional, default 1
  26147. * - subdivisions the number of subdivisions per side, optional, default 1
  26148. * @returns the VertexData of the Ground
  26149. */
  26150. static CreateGround(options: {
  26151. width?: number;
  26152. height?: number;
  26153. subdivisions?: number;
  26154. subdivisionsX?: number;
  26155. subdivisionsY?: number;
  26156. }): VertexData;
  26157. /**
  26158. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  26159. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26160. * * xmin the ground minimum X coordinate, optional, default -1
  26161. * * zmin the ground minimum Z coordinate, optional, default -1
  26162. * * xmax the ground maximum X coordinate, optional, default 1
  26163. * * zmax the ground maximum Z coordinate, optional, default 1
  26164. * * 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}
  26165. * * 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}
  26166. * @returns the VertexData of the TiledGround
  26167. */
  26168. static CreateTiledGround(options: {
  26169. xmin: number;
  26170. zmin: number;
  26171. xmax: number;
  26172. zmax: number;
  26173. subdivisions?: {
  26174. w: number;
  26175. h: number;
  26176. };
  26177. precision?: {
  26178. w: number;
  26179. h: number;
  26180. };
  26181. }): VertexData;
  26182. /**
  26183. * Creates the VertexData of the Ground designed from a heightmap
  26184. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  26185. * * width the width (x direction) of the ground
  26186. * * height the height (z direction) of the ground
  26187. * * subdivisions the number of subdivisions per side
  26188. * * minHeight the minimum altitude on the ground, optional, default 0
  26189. * * maxHeight the maximum altitude on the ground, optional default 1
  26190. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  26191. * * buffer the array holding the image color data
  26192. * * bufferWidth the width of image
  26193. * * bufferHeight the height of image
  26194. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  26195. * @returns the VertexData of the Ground designed from a heightmap
  26196. */
  26197. static CreateGroundFromHeightMap(options: {
  26198. width: number;
  26199. height: number;
  26200. subdivisions: number;
  26201. minHeight: number;
  26202. maxHeight: number;
  26203. colorFilter: Color3;
  26204. buffer: Uint8Array;
  26205. bufferWidth: number;
  26206. bufferHeight: number;
  26207. alphaFilter: number;
  26208. }): VertexData;
  26209. /**
  26210. * Creates the VertexData for a Plane
  26211. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  26212. * * size sets the width and height of the plane to the value of size, optional default 1
  26213. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  26214. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  26215. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26216. * * 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)
  26217. * * 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)
  26218. * @returns the VertexData of the box
  26219. */
  26220. static CreatePlane(options: {
  26221. size?: number;
  26222. width?: number;
  26223. height?: number;
  26224. sideOrientation?: number;
  26225. frontUVs?: Vector4;
  26226. backUVs?: Vector4;
  26227. }): VertexData;
  26228. /**
  26229. * Creates the VertexData of the Disc or regular Polygon
  26230. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  26231. * * radius the radius of the disc, optional default 0.5
  26232. * * tessellation the number of polygon sides, optional, default 64
  26233. * * 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
  26234. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26235. * * 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)
  26236. * * 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)
  26237. * @returns the VertexData of the box
  26238. */
  26239. static CreateDisc(options: {
  26240. radius?: number;
  26241. tessellation?: number;
  26242. arc?: number;
  26243. sideOrientation?: number;
  26244. frontUVs?: Vector4;
  26245. backUVs?: Vector4;
  26246. }): VertexData;
  26247. /**
  26248. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  26249. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  26250. * @param polygon a mesh built from polygonTriangulation.build()
  26251. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26252. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26253. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26254. * @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)
  26255. * @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)
  26256. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  26257. * @returns the VertexData of the Polygon
  26258. */
  26259. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  26260. /**
  26261. * Creates the VertexData of the IcoSphere
  26262. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  26263. * * radius the radius of the IcoSphere, optional default 1
  26264. * * radiusX allows stretching in the x direction, optional, default radius
  26265. * * radiusY allows stretching in the y direction, optional, default radius
  26266. * * radiusZ allows stretching in the z direction, optional, default radius
  26267. * * flat when true creates a flat shaded mesh, optional, default true
  26268. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26269. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26270. * * 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)
  26271. * * 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)
  26272. * @returns the VertexData of the IcoSphere
  26273. */
  26274. static CreateIcoSphere(options: {
  26275. radius?: number;
  26276. radiusX?: number;
  26277. radiusY?: number;
  26278. radiusZ?: number;
  26279. flat?: boolean;
  26280. subdivisions?: number;
  26281. sideOrientation?: number;
  26282. frontUVs?: Vector4;
  26283. backUVs?: Vector4;
  26284. }): VertexData;
  26285. /**
  26286. * Creates the VertexData for a Polyhedron
  26287. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  26288. * * type provided types are:
  26289. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  26290. * * 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)
  26291. * * size the size of the IcoSphere, optional default 1
  26292. * * sizeX allows stretching in the x direction, optional, default size
  26293. * * sizeY allows stretching in the y direction, optional, default size
  26294. * * sizeZ allows stretching in the z direction, optional, default size
  26295. * * 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
  26296. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26297. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26298. * * flat when true creates a flat shaded mesh, optional, default true
  26299. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26300. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26301. * * 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)
  26302. * * 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)
  26303. * @returns the VertexData of the Polyhedron
  26304. */
  26305. static CreatePolyhedron(options: {
  26306. type?: number;
  26307. size?: number;
  26308. sizeX?: number;
  26309. sizeY?: number;
  26310. sizeZ?: number;
  26311. custom?: any;
  26312. faceUV?: Vector4[];
  26313. faceColors?: Color4[];
  26314. flat?: boolean;
  26315. sideOrientation?: number;
  26316. frontUVs?: Vector4;
  26317. backUVs?: Vector4;
  26318. }): VertexData;
  26319. /**
  26320. * Creates the VertexData for a TorusKnot
  26321. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  26322. * * radius the radius of the torus knot, optional, default 2
  26323. * * tube the thickness of the tube, optional, default 0.5
  26324. * * radialSegments the number of sides on each tube segments, optional, default 32
  26325. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  26326. * * p the number of windings around the z axis, optional, default 2
  26327. * * q the number of windings around the x axis, optional, default 3
  26328. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26329. * * 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)
  26330. * * 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)
  26331. * @returns the VertexData of the Torus Knot
  26332. */
  26333. static CreateTorusKnot(options: {
  26334. radius?: number;
  26335. tube?: number;
  26336. radialSegments?: number;
  26337. tubularSegments?: number;
  26338. p?: number;
  26339. q?: number;
  26340. sideOrientation?: number;
  26341. frontUVs?: Vector4;
  26342. backUVs?: Vector4;
  26343. }): VertexData;
  26344. /**
  26345. * Compute normals for given positions and indices
  26346. * @param positions an array of vertex positions, [...., x, y, z, ......]
  26347. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  26348. * @param normals an array of vertex normals, [...., x, y, z, ......]
  26349. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  26350. * * facetNormals : optional array of facet normals (vector3)
  26351. * * facetPositions : optional array of facet positions (vector3)
  26352. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  26353. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  26354. * * bInfo : optional bounding info, required for facetPartitioning computation
  26355. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  26356. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  26357. * * useRightHandedSystem: optional boolean to for right handed system computation
  26358. * * depthSort : optional boolean to enable the facet depth sort computation
  26359. * * distanceTo : optional Vector3 to compute the facet depth from this location
  26360. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  26361. */
  26362. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  26363. facetNormals?: any;
  26364. facetPositions?: any;
  26365. facetPartitioning?: any;
  26366. ratio?: number;
  26367. bInfo?: any;
  26368. bbSize?: Vector3;
  26369. subDiv?: any;
  26370. useRightHandedSystem?: boolean;
  26371. depthSort?: boolean;
  26372. distanceTo?: Vector3;
  26373. depthSortedFacets?: any;
  26374. }): void;
  26375. /** @hidden */
  26376. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  26377. /**
  26378. * Applies VertexData created from the imported parameters to the geometry
  26379. * @param parsedVertexData the parsed data from an imported file
  26380. * @param geometry the geometry to apply the VertexData to
  26381. */
  26382. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  26383. }
  26384. }
  26385. declare module BABYLON {
  26386. /**
  26387. * Defines a target to use with MorphTargetManager
  26388. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26389. */
  26390. export class MorphTarget implements IAnimatable {
  26391. /** defines the name of the target */
  26392. name: string;
  26393. /**
  26394. * Gets or sets the list of animations
  26395. */
  26396. animations: Animation[];
  26397. private _scene;
  26398. private _positions;
  26399. private _normals;
  26400. private _tangents;
  26401. private _uvs;
  26402. private _influence;
  26403. private _uniqueId;
  26404. /**
  26405. * Observable raised when the influence changes
  26406. */
  26407. onInfluenceChanged: Observable<boolean>;
  26408. /** @hidden */
  26409. _onDataLayoutChanged: Observable<void>;
  26410. /**
  26411. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  26412. */
  26413. get influence(): number;
  26414. set influence(influence: number);
  26415. /**
  26416. * Gets or sets the id of the morph Target
  26417. */
  26418. id: string;
  26419. private _animationPropertiesOverride;
  26420. /**
  26421. * Gets or sets the animation properties override
  26422. */
  26423. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26424. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26425. /**
  26426. * Creates a new MorphTarget
  26427. * @param name defines the name of the target
  26428. * @param influence defines the influence to use
  26429. * @param scene defines the scene the morphtarget belongs to
  26430. */
  26431. constructor(
  26432. /** defines the name of the target */
  26433. name: string, influence?: number, scene?: Nullable<Scene>);
  26434. /**
  26435. * Gets the unique ID of this manager
  26436. */
  26437. get uniqueId(): number;
  26438. /**
  26439. * Gets a boolean defining if the target contains position data
  26440. */
  26441. get hasPositions(): boolean;
  26442. /**
  26443. * Gets a boolean defining if the target contains normal data
  26444. */
  26445. get hasNormals(): boolean;
  26446. /**
  26447. * Gets a boolean defining if the target contains tangent data
  26448. */
  26449. get hasTangents(): boolean;
  26450. /**
  26451. * Gets a boolean defining if the target contains texture coordinates data
  26452. */
  26453. get hasUVs(): boolean;
  26454. /**
  26455. * Affects position data to this target
  26456. * @param data defines the position data to use
  26457. */
  26458. setPositions(data: Nullable<FloatArray>): void;
  26459. /**
  26460. * Gets the position data stored in this target
  26461. * @returns a FloatArray containing the position data (or null if not present)
  26462. */
  26463. getPositions(): Nullable<FloatArray>;
  26464. /**
  26465. * Affects normal data to this target
  26466. * @param data defines the normal data to use
  26467. */
  26468. setNormals(data: Nullable<FloatArray>): void;
  26469. /**
  26470. * Gets the normal data stored in this target
  26471. * @returns a FloatArray containing the normal data (or null if not present)
  26472. */
  26473. getNormals(): Nullable<FloatArray>;
  26474. /**
  26475. * Affects tangent data to this target
  26476. * @param data defines the tangent data to use
  26477. */
  26478. setTangents(data: Nullable<FloatArray>): void;
  26479. /**
  26480. * Gets the tangent data stored in this target
  26481. * @returns a FloatArray containing the tangent data (or null if not present)
  26482. */
  26483. getTangents(): Nullable<FloatArray>;
  26484. /**
  26485. * Affects texture coordinates data to this target
  26486. * @param data defines the texture coordinates data to use
  26487. */
  26488. setUVs(data: Nullable<FloatArray>): void;
  26489. /**
  26490. * Gets the texture coordinates data stored in this target
  26491. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  26492. */
  26493. getUVs(): Nullable<FloatArray>;
  26494. /**
  26495. * Clone the current target
  26496. * @returns a new MorphTarget
  26497. */
  26498. clone(): MorphTarget;
  26499. /**
  26500. * Serializes the current target into a Serialization object
  26501. * @returns the serialized object
  26502. */
  26503. serialize(): any;
  26504. /**
  26505. * Returns the string "MorphTarget"
  26506. * @returns "MorphTarget"
  26507. */
  26508. getClassName(): string;
  26509. /**
  26510. * Creates a new target from serialized data
  26511. * @param serializationObject defines the serialized data to use
  26512. * @returns a new MorphTarget
  26513. */
  26514. static Parse(serializationObject: any): MorphTarget;
  26515. /**
  26516. * Creates a MorphTarget from mesh data
  26517. * @param mesh defines the source mesh
  26518. * @param name defines the name to use for the new target
  26519. * @param influence defines the influence to attach to the target
  26520. * @returns a new MorphTarget
  26521. */
  26522. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  26523. }
  26524. }
  26525. declare module BABYLON {
  26526. /**
  26527. * This class is used to deform meshes using morphing between different targets
  26528. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26529. */
  26530. export class MorphTargetManager {
  26531. private _targets;
  26532. private _targetInfluenceChangedObservers;
  26533. private _targetDataLayoutChangedObservers;
  26534. private _activeTargets;
  26535. private _scene;
  26536. private _influences;
  26537. private _supportsNormals;
  26538. private _supportsTangents;
  26539. private _supportsUVs;
  26540. private _vertexCount;
  26541. private _uniqueId;
  26542. private _tempInfluences;
  26543. /**
  26544. * Gets or sets a boolean indicating if normals must be morphed
  26545. */
  26546. enableNormalMorphing: boolean;
  26547. /**
  26548. * Gets or sets a boolean indicating if tangents must be morphed
  26549. */
  26550. enableTangentMorphing: boolean;
  26551. /**
  26552. * Gets or sets a boolean indicating if UV must be morphed
  26553. */
  26554. enableUVMorphing: boolean;
  26555. /**
  26556. * Creates a new MorphTargetManager
  26557. * @param scene defines the current scene
  26558. */
  26559. constructor(scene?: Nullable<Scene>);
  26560. /**
  26561. * Gets the unique ID of this manager
  26562. */
  26563. get uniqueId(): number;
  26564. /**
  26565. * Gets the number of vertices handled by this manager
  26566. */
  26567. get vertexCount(): number;
  26568. /**
  26569. * Gets a boolean indicating if this manager supports morphing of normals
  26570. */
  26571. get supportsNormals(): boolean;
  26572. /**
  26573. * Gets a boolean indicating if this manager supports morphing of tangents
  26574. */
  26575. get supportsTangents(): boolean;
  26576. /**
  26577. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  26578. */
  26579. get supportsUVs(): boolean;
  26580. /**
  26581. * Gets the number of targets stored in this manager
  26582. */
  26583. get numTargets(): number;
  26584. /**
  26585. * Gets the number of influencers (ie. the number of targets with influences > 0)
  26586. */
  26587. get numInfluencers(): number;
  26588. /**
  26589. * Gets the list of influences (one per target)
  26590. */
  26591. get influences(): Float32Array;
  26592. /**
  26593. * Gets the active target at specified index. An active target is a target with an influence > 0
  26594. * @param index defines the index to check
  26595. * @returns the requested target
  26596. */
  26597. getActiveTarget(index: number): MorphTarget;
  26598. /**
  26599. * Gets the target at specified index
  26600. * @param index defines the index to check
  26601. * @returns the requested target
  26602. */
  26603. getTarget(index: number): MorphTarget;
  26604. /**
  26605. * Add a new target to this manager
  26606. * @param target defines the target to add
  26607. */
  26608. addTarget(target: MorphTarget): void;
  26609. /**
  26610. * Removes a target from the manager
  26611. * @param target defines the target to remove
  26612. */
  26613. removeTarget(target: MorphTarget): void;
  26614. /**
  26615. * Clone the current manager
  26616. * @returns a new MorphTargetManager
  26617. */
  26618. clone(): MorphTargetManager;
  26619. /**
  26620. * Serializes the current manager into a Serialization object
  26621. * @returns the serialized object
  26622. */
  26623. serialize(): any;
  26624. private _syncActiveTargets;
  26625. /**
  26626. * Syncrhonize the targets with all the meshes using this morph target manager
  26627. */
  26628. synchronize(): void;
  26629. /**
  26630. * Creates a new MorphTargetManager from serialized data
  26631. * @param serializationObject defines the serialized data
  26632. * @param scene defines the hosting scene
  26633. * @returns the new MorphTargetManager
  26634. */
  26635. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  26636. }
  26637. }
  26638. declare module BABYLON {
  26639. /**
  26640. * Class used to represent a specific level of detail of a mesh
  26641. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26642. */
  26643. export class MeshLODLevel {
  26644. /** Defines the distance where this level should start being displayed */
  26645. distance: number;
  26646. /** Defines the mesh to use to render this level */
  26647. mesh: Nullable<Mesh>;
  26648. /**
  26649. * Creates a new LOD level
  26650. * @param distance defines the distance where this level should star being displayed
  26651. * @param mesh defines the mesh to use to render this level
  26652. */
  26653. constructor(
  26654. /** Defines the distance where this level should start being displayed */
  26655. distance: number,
  26656. /** Defines the mesh to use to render this level */
  26657. mesh: Nullable<Mesh>);
  26658. }
  26659. }
  26660. declare module BABYLON {
  26661. /**
  26662. * Helper class used to generate a canvas to manipulate images
  26663. */
  26664. export class CanvasGenerator {
  26665. /**
  26666. * Create a new canvas (or offscreen canvas depending on the context)
  26667. * @param width defines the expected width
  26668. * @param height defines the expected height
  26669. * @return a new canvas or offscreen canvas
  26670. */
  26671. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  26672. }
  26673. }
  26674. declare module BABYLON {
  26675. /**
  26676. * Mesh representing the gorund
  26677. */
  26678. export class GroundMesh extends Mesh {
  26679. /** If octree should be generated */
  26680. generateOctree: boolean;
  26681. private _heightQuads;
  26682. /** @hidden */
  26683. _subdivisionsX: number;
  26684. /** @hidden */
  26685. _subdivisionsY: number;
  26686. /** @hidden */
  26687. _width: number;
  26688. /** @hidden */
  26689. _height: number;
  26690. /** @hidden */
  26691. _minX: number;
  26692. /** @hidden */
  26693. _maxX: number;
  26694. /** @hidden */
  26695. _minZ: number;
  26696. /** @hidden */
  26697. _maxZ: number;
  26698. constructor(name: string, scene: Scene);
  26699. /**
  26700. * "GroundMesh"
  26701. * @returns "GroundMesh"
  26702. */
  26703. getClassName(): string;
  26704. /**
  26705. * The minimum of x and y subdivisions
  26706. */
  26707. get subdivisions(): number;
  26708. /**
  26709. * X subdivisions
  26710. */
  26711. get subdivisionsX(): number;
  26712. /**
  26713. * Y subdivisions
  26714. */
  26715. get subdivisionsY(): number;
  26716. /**
  26717. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26718. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26719. * @param chunksCount the number of subdivisions for x and y
  26720. * @param octreeBlocksSize (Default: 32)
  26721. */
  26722. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26723. /**
  26724. * Returns a height (y) value in the Worl system :
  26725. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26726. * @param x x coordinate
  26727. * @param z z coordinate
  26728. * @returns the ground y position if (x, z) are outside the ground surface.
  26729. */
  26730. getHeightAtCoordinates(x: number, z: number): number;
  26731. /**
  26732. * Returns a normalized vector (Vector3) orthogonal to the ground
  26733. * at the ground coordinates (x, z) expressed in the World system.
  26734. * @param x x coordinate
  26735. * @param z z coordinate
  26736. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26737. */
  26738. getNormalAtCoordinates(x: number, z: number): Vector3;
  26739. /**
  26740. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26741. * at the ground coordinates (x, z) expressed in the World system.
  26742. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26743. * @param x x coordinate
  26744. * @param z z coordinate
  26745. * @param ref vector to store the result
  26746. * @returns the GroundMesh.
  26747. */
  26748. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26749. /**
  26750. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26751. * if the ground has been updated.
  26752. * This can be used in the render loop.
  26753. * @returns the GroundMesh.
  26754. */
  26755. updateCoordinateHeights(): GroundMesh;
  26756. private _getFacetAt;
  26757. private _initHeightQuads;
  26758. private _computeHeightQuads;
  26759. /**
  26760. * Serializes this ground mesh
  26761. * @param serializationObject object to write serialization to
  26762. */
  26763. serialize(serializationObject: any): void;
  26764. /**
  26765. * Parses a serialized ground mesh
  26766. * @param parsedMesh the serialized mesh
  26767. * @param scene the scene to create the ground mesh in
  26768. * @returns the created ground mesh
  26769. */
  26770. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26771. }
  26772. }
  26773. declare module BABYLON {
  26774. /**
  26775. * Interface for Physics-Joint data
  26776. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26777. */
  26778. export interface PhysicsJointData {
  26779. /**
  26780. * The main pivot of the joint
  26781. */
  26782. mainPivot?: Vector3;
  26783. /**
  26784. * The connected pivot of the joint
  26785. */
  26786. connectedPivot?: Vector3;
  26787. /**
  26788. * The main axis of the joint
  26789. */
  26790. mainAxis?: Vector3;
  26791. /**
  26792. * The connected axis of the joint
  26793. */
  26794. connectedAxis?: Vector3;
  26795. /**
  26796. * The collision of the joint
  26797. */
  26798. collision?: boolean;
  26799. /**
  26800. * Native Oimo/Cannon/Energy data
  26801. */
  26802. nativeParams?: any;
  26803. }
  26804. /**
  26805. * This is a holder class for the physics joint created by the physics plugin
  26806. * It holds a set of functions to control the underlying joint
  26807. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26808. */
  26809. export class PhysicsJoint {
  26810. /**
  26811. * The type of the physics joint
  26812. */
  26813. type: number;
  26814. /**
  26815. * The data for the physics joint
  26816. */
  26817. jointData: PhysicsJointData;
  26818. private _physicsJoint;
  26819. protected _physicsPlugin: IPhysicsEnginePlugin;
  26820. /**
  26821. * Initializes the physics joint
  26822. * @param type The type of the physics joint
  26823. * @param jointData The data for the physics joint
  26824. */
  26825. constructor(
  26826. /**
  26827. * The type of the physics joint
  26828. */
  26829. type: number,
  26830. /**
  26831. * The data for the physics joint
  26832. */
  26833. jointData: PhysicsJointData);
  26834. /**
  26835. * Gets the physics joint
  26836. */
  26837. get physicsJoint(): any;
  26838. /**
  26839. * Sets the physics joint
  26840. */
  26841. set physicsJoint(newJoint: any);
  26842. /**
  26843. * Sets the physics plugin
  26844. */
  26845. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  26846. /**
  26847. * Execute a function that is physics-plugin specific.
  26848. * @param {Function} func the function that will be executed.
  26849. * It accepts two parameters: the physics world and the physics joint
  26850. */
  26851. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26852. /**
  26853. * Distance-Joint type
  26854. */
  26855. static DistanceJoint: number;
  26856. /**
  26857. * Hinge-Joint type
  26858. */
  26859. static HingeJoint: number;
  26860. /**
  26861. * Ball-and-Socket joint type
  26862. */
  26863. static BallAndSocketJoint: number;
  26864. /**
  26865. * Wheel-Joint type
  26866. */
  26867. static WheelJoint: number;
  26868. /**
  26869. * Slider-Joint type
  26870. */
  26871. static SliderJoint: number;
  26872. /**
  26873. * Prismatic-Joint type
  26874. */
  26875. static PrismaticJoint: number;
  26876. /**
  26877. * Universal-Joint type
  26878. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  26879. */
  26880. static UniversalJoint: number;
  26881. /**
  26882. * Hinge-Joint 2 type
  26883. */
  26884. static Hinge2Joint: number;
  26885. /**
  26886. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  26887. */
  26888. static PointToPointJoint: number;
  26889. /**
  26890. * Spring-Joint type
  26891. */
  26892. static SpringJoint: number;
  26893. /**
  26894. * Lock-Joint type
  26895. */
  26896. static LockJoint: number;
  26897. }
  26898. /**
  26899. * A class representing a physics distance joint
  26900. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26901. */
  26902. export class DistanceJoint extends PhysicsJoint {
  26903. /**
  26904. *
  26905. * @param jointData The data for the Distance-Joint
  26906. */
  26907. constructor(jointData: DistanceJointData);
  26908. /**
  26909. * Update the predefined distance.
  26910. * @param maxDistance The maximum preferred distance
  26911. * @param minDistance The minimum preferred distance
  26912. */
  26913. updateDistance(maxDistance: number, minDistance?: number): void;
  26914. }
  26915. /**
  26916. * Represents a Motor-Enabled Joint
  26917. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26918. */
  26919. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  26920. /**
  26921. * Initializes the Motor-Enabled Joint
  26922. * @param type The type of the joint
  26923. * @param jointData The physica joint data for the joint
  26924. */
  26925. constructor(type: number, jointData: PhysicsJointData);
  26926. /**
  26927. * Set the motor values.
  26928. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26929. * @param force the force to apply
  26930. * @param maxForce max force for this motor.
  26931. */
  26932. setMotor(force?: number, maxForce?: number): void;
  26933. /**
  26934. * Set the motor's limits.
  26935. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26936. * @param upperLimit The upper limit of the motor
  26937. * @param lowerLimit The lower limit of the motor
  26938. */
  26939. setLimit(upperLimit: number, lowerLimit?: number): void;
  26940. }
  26941. /**
  26942. * This class represents a single physics Hinge-Joint
  26943. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26944. */
  26945. export class HingeJoint extends MotorEnabledJoint {
  26946. /**
  26947. * Initializes the Hinge-Joint
  26948. * @param jointData The joint data for the Hinge-Joint
  26949. */
  26950. constructor(jointData: PhysicsJointData);
  26951. /**
  26952. * Set the motor values.
  26953. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26954. * @param {number} force the force to apply
  26955. * @param {number} maxForce max force for this motor.
  26956. */
  26957. setMotor(force?: number, maxForce?: number): void;
  26958. /**
  26959. * Set the motor's limits.
  26960. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26961. * @param upperLimit The upper limit of the motor
  26962. * @param lowerLimit The lower limit of the motor
  26963. */
  26964. setLimit(upperLimit: number, lowerLimit?: number): void;
  26965. }
  26966. /**
  26967. * This class represents a dual hinge physics joint (same as wheel joint)
  26968. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26969. */
  26970. export class Hinge2Joint extends MotorEnabledJoint {
  26971. /**
  26972. * Initializes the Hinge2-Joint
  26973. * @param jointData The joint data for the Hinge2-Joint
  26974. */
  26975. constructor(jointData: PhysicsJointData);
  26976. /**
  26977. * Set the motor values.
  26978. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26979. * @param {number} targetSpeed the speed the motor is to reach
  26980. * @param {number} maxForce max force for this motor.
  26981. * @param {motorIndex} the motor's index, 0 or 1.
  26982. */
  26983. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  26984. /**
  26985. * Set the motor limits.
  26986. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26987. * @param {number} upperLimit the upper limit
  26988. * @param {number} lowerLimit lower limit
  26989. * @param {motorIndex} the motor's index, 0 or 1.
  26990. */
  26991. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26992. }
  26993. /**
  26994. * Interface for a motor enabled joint
  26995. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26996. */
  26997. export interface IMotorEnabledJoint {
  26998. /**
  26999. * Physics joint
  27000. */
  27001. physicsJoint: any;
  27002. /**
  27003. * Sets the motor of the motor-enabled joint
  27004. * @param force The force of the motor
  27005. * @param maxForce The maximum force of the motor
  27006. * @param motorIndex The index of the motor
  27007. */
  27008. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27009. /**
  27010. * Sets the limit of the motor
  27011. * @param upperLimit The upper limit of the motor
  27012. * @param lowerLimit The lower limit of the motor
  27013. * @param motorIndex The index of the motor
  27014. */
  27015. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27016. }
  27017. /**
  27018. * Joint data for a Distance-Joint
  27019. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27020. */
  27021. export interface DistanceJointData extends PhysicsJointData {
  27022. /**
  27023. * Max distance the 2 joint objects can be apart
  27024. */
  27025. maxDistance: number;
  27026. }
  27027. /**
  27028. * Joint data from a spring joint
  27029. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27030. */
  27031. export interface SpringJointData extends PhysicsJointData {
  27032. /**
  27033. * Length of the spring
  27034. */
  27035. length: number;
  27036. /**
  27037. * Stiffness of the spring
  27038. */
  27039. stiffness: number;
  27040. /**
  27041. * Damping of the spring
  27042. */
  27043. damping: number;
  27044. /** this callback will be called when applying the force to the impostors. */
  27045. forceApplicationCallback: () => void;
  27046. }
  27047. }
  27048. declare module BABYLON {
  27049. /**
  27050. * Holds the data for the raycast result
  27051. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27052. */
  27053. export class PhysicsRaycastResult {
  27054. private _hasHit;
  27055. private _hitDistance;
  27056. private _hitNormalWorld;
  27057. private _hitPointWorld;
  27058. private _rayFromWorld;
  27059. private _rayToWorld;
  27060. /**
  27061. * Gets if there was a hit
  27062. */
  27063. get hasHit(): boolean;
  27064. /**
  27065. * Gets the distance from the hit
  27066. */
  27067. get hitDistance(): number;
  27068. /**
  27069. * Gets the hit normal/direction in the world
  27070. */
  27071. get hitNormalWorld(): Vector3;
  27072. /**
  27073. * Gets the hit point in the world
  27074. */
  27075. get hitPointWorld(): Vector3;
  27076. /**
  27077. * Gets the ray "start point" of the ray in the world
  27078. */
  27079. get rayFromWorld(): Vector3;
  27080. /**
  27081. * Gets the ray "end point" of the ray in the world
  27082. */
  27083. get rayToWorld(): Vector3;
  27084. /**
  27085. * Sets the hit data (normal & point in world space)
  27086. * @param hitNormalWorld defines the normal in world space
  27087. * @param hitPointWorld defines the point in world space
  27088. */
  27089. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  27090. /**
  27091. * Sets the distance from the start point to the hit point
  27092. * @param distance
  27093. */
  27094. setHitDistance(distance: number): void;
  27095. /**
  27096. * Calculates the distance manually
  27097. */
  27098. calculateHitDistance(): void;
  27099. /**
  27100. * Resets all the values to default
  27101. * @param from The from point on world space
  27102. * @param to The to point on world space
  27103. */
  27104. reset(from?: Vector3, to?: Vector3): void;
  27105. }
  27106. /**
  27107. * Interface for the size containing width and height
  27108. */
  27109. interface IXYZ {
  27110. /**
  27111. * X
  27112. */
  27113. x: number;
  27114. /**
  27115. * Y
  27116. */
  27117. y: number;
  27118. /**
  27119. * Z
  27120. */
  27121. z: number;
  27122. }
  27123. }
  27124. declare module BABYLON {
  27125. /**
  27126. * Interface used to describe a physics joint
  27127. */
  27128. export interface PhysicsImpostorJoint {
  27129. /** Defines the main impostor to which the joint is linked */
  27130. mainImpostor: PhysicsImpostor;
  27131. /** Defines the impostor that is connected to the main impostor using this joint */
  27132. connectedImpostor: PhysicsImpostor;
  27133. /** Defines the joint itself */
  27134. joint: PhysicsJoint;
  27135. }
  27136. /** @hidden */
  27137. export interface IPhysicsEnginePlugin {
  27138. world: any;
  27139. name: string;
  27140. setGravity(gravity: Vector3): void;
  27141. setTimeStep(timeStep: number): void;
  27142. getTimeStep(): number;
  27143. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  27144. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27145. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27146. generatePhysicsBody(impostor: PhysicsImpostor): void;
  27147. removePhysicsBody(impostor: PhysicsImpostor): void;
  27148. generateJoint(joint: PhysicsImpostorJoint): void;
  27149. removeJoint(joint: PhysicsImpostorJoint): void;
  27150. isSupported(): boolean;
  27151. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  27152. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  27153. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27154. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27155. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27156. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27157. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  27158. getBodyMass(impostor: PhysicsImpostor): number;
  27159. getBodyFriction(impostor: PhysicsImpostor): number;
  27160. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  27161. getBodyRestitution(impostor: PhysicsImpostor): number;
  27162. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  27163. getBodyPressure?(impostor: PhysicsImpostor): number;
  27164. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  27165. getBodyStiffness?(impostor: PhysicsImpostor): number;
  27166. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  27167. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  27168. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  27169. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  27170. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  27171. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27172. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27173. sleepBody(impostor: PhysicsImpostor): void;
  27174. wakeUpBody(impostor: PhysicsImpostor): void;
  27175. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27176. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  27177. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  27178. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27179. getRadius(impostor: PhysicsImpostor): number;
  27180. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  27181. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  27182. dispose(): void;
  27183. }
  27184. /**
  27185. * Interface used to define a physics engine
  27186. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27187. */
  27188. export interface IPhysicsEngine {
  27189. /**
  27190. * Gets the gravity vector used by the simulation
  27191. */
  27192. gravity: Vector3;
  27193. /**
  27194. * Sets the gravity vector used by the simulation
  27195. * @param gravity defines the gravity vector to use
  27196. */
  27197. setGravity(gravity: Vector3): void;
  27198. /**
  27199. * Set the time step of the physics engine.
  27200. * Default is 1/60.
  27201. * To slow it down, enter 1/600 for example.
  27202. * To speed it up, 1/30
  27203. * @param newTimeStep the new timestep to apply to this world.
  27204. */
  27205. setTimeStep(newTimeStep: number): void;
  27206. /**
  27207. * Get the time step of the physics engine.
  27208. * @returns the current time step
  27209. */
  27210. getTimeStep(): number;
  27211. /**
  27212. * Set the sub time step of the physics engine.
  27213. * Default is 0 meaning there is no sub steps
  27214. * To increase physics resolution precision, set a small value (like 1 ms)
  27215. * @param subTimeStep defines the new sub timestep used for physics resolution.
  27216. */
  27217. setSubTimeStep(subTimeStep: number): void;
  27218. /**
  27219. * Get the sub time step of the physics engine.
  27220. * @returns the current sub time step
  27221. */
  27222. getSubTimeStep(): number;
  27223. /**
  27224. * Release all resources
  27225. */
  27226. dispose(): void;
  27227. /**
  27228. * Gets the name of the current physics plugin
  27229. * @returns the name of the plugin
  27230. */
  27231. getPhysicsPluginName(): string;
  27232. /**
  27233. * Adding a new impostor for the impostor tracking.
  27234. * This will be done by the impostor itself.
  27235. * @param impostor the impostor to add
  27236. */
  27237. addImpostor(impostor: PhysicsImpostor): void;
  27238. /**
  27239. * Remove an impostor from the engine.
  27240. * This impostor and its mesh will not longer be updated by the physics engine.
  27241. * @param impostor the impostor to remove
  27242. */
  27243. removeImpostor(impostor: PhysicsImpostor): void;
  27244. /**
  27245. * Add a joint to the physics engine
  27246. * @param mainImpostor defines the main impostor to which the joint is added.
  27247. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  27248. * @param joint defines the joint that will connect both impostors.
  27249. */
  27250. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27251. /**
  27252. * Removes a joint from the simulation
  27253. * @param mainImpostor defines the impostor used with the joint
  27254. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  27255. * @param joint defines the joint to remove
  27256. */
  27257. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27258. /**
  27259. * Gets the current plugin used to run the simulation
  27260. * @returns current plugin
  27261. */
  27262. getPhysicsPlugin(): IPhysicsEnginePlugin;
  27263. /**
  27264. * Gets the list of physic impostors
  27265. * @returns an array of PhysicsImpostor
  27266. */
  27267. getImpostors(): Array<PhysicsImpostor>;
  27268. /**
  27269. * Gets the impostor for a physics enabled object
  27270. * @param object defines the object impersonated by the impostor
  27271. * @returns the PhysicsImpostor or null if not found
  27272. */
  27273. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27274. /**
  27275. * Gets the impostor for a physics body object
  27276. * @param body defines physics body used by the impostor
  27277. * @returns the PhysicsImpostor or null if not found
  27278. */
  27279. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  27280. /**
  27281. * Does a raycast in the physics world
  27282. * @param from when should the ray start?
  27283. * @param to when should the ray end?
  27284. * @returns PhysicsRaycastResult
  27285. */
  27286. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27287. /**
  27288. * Called by the scene. No need to call it.
  27289. * @param delta defines the timespam between frames
  27290. */
  27291. _step(delta: number): void;
  27292. }
  27293. }
  27294. declare module BABYLON {
  27295. /**
  27296. * The interface for the physics imposter parameters
  27297. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27298. */
  27299. export interface PhysicsImpostorParameters {
  27300. /**
  27301. * The mass of the physics imposter
  27302. */
  27303. mass: number;
  27304. /**
  27305. * The friction of the physics imposter
  27306. */
  27307. friction?: number;
  27308. /**
  27309. * The coefficient of restitution of the physics imposter
  27310. */
  27311. restitution?: number;
  27312. /**
  27313. * The native options of the physics imposter
  27314. */
  27315. nativeOptions?: any;
  27316. /**
  27317. * Specifies if the parent should be ignored
  27318. */
  27319. ignoreParent?: boolean;
  27320. /**
  27321. * Specifies if bi-directional transformations should be disabled
  27322. */
  27323. disableBidirectionalTransformation?: boolean;
  27324. /**
  27325. * The pressure inside the physics imposter, soft object only
  27326. */
  27327. pressure?: number;
  27328. /**
  27329. * The stiffness the physics imposter, soft object only
  27330. */
  27331. stiffness?: number;
  27332. /**
  27333. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  27334. */
  27335. velocityIterations?: number;
  27336. /**
  27337. * The number of iterations used in maintaining consistent vertex positions, soft object only
  27338. */
  27339. positionIterations?: number;
  27340. /**
  27341. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  27342. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  27343. * Add to fix multiple points
  27344. */
  27345. fixedPoints?: number;
  27346. /**
  27347. * The collision margin around a soft object
  27348. */
  27349. margin?: number;
  27350. /**
  27351. * The collision margin around a soft object
  27352. */
  27353. damping?: number;
  27354. /**
  27355. * The path for a rope based on an extrusion
  27356. */
  27357. path?: any;
  27358. /**
  27359. * The shape of an extrusion used for a rope based on an extrusion
  27360. */
  27361. shape?: any;
  27362. }
  27363. /**
  27364. * Interface for a physics-enabled object
  27365. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27366. */
  27367. export interface IPhysicsEnabledObject {
  27368. /**
  27369. * The position of the physics-enabled object
  27370. */
  27371. position: Vector3;
  27372. /**
  27373. * The rotation of the physics-enabled object
  27374. */
  27375. rotationQuaternion: Nullable<Quaternion>;
  27376. /**
  27377. * The scale of the physics-enabled object
  27378. */
  27379. scaling: Vector3;
  27380. /**
  27381. * The rotation of the physics-enabled object
  27382. */
  27383. rotation?: Vector3;
  27384. /**
  27385. * The parent of the physics-enabled object
  27386. */
  27387. parent?: any;
  27388. /**
  27389. * The bounding info of the physics-enabled object
  27390. * @returns The bounding info of the physics-enabled object
  27391. */
  27392. getBoundingInfo(): BoundingInfo;
  27393. /**
  27394. * Computes the world matrix
  27395. * @param force Specifies if the world matrix should be computed by force
  27396. * @returns A world matrix
  27397. */
  27398. computeWorldMatrix(force: boolean): Matrix;
  27399. /**
  27400. * Gets the world matrix
  27401. * @returns A world matrix
  27402. */
  27403. getWorldMatrix?(): Matrix;
  27404. /**
  27405. * Gets the child meshes
  27406. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  27407. * @returns An array of abstract meshes
  27408. */
  27409. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  27410. /**
  27411. * Gets the vertex data
  27412. * @param kind The type of vertex data
  27413. * @returns A nullable array of numbers, or a float32 array
  27414. */
  27415. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  27416. /**
  27417. * Gets the indices from the mesh
  27418. * @returns A nullable array of index arrays
  27419. */
  27420. getIndices?(): Nullable<IndicesArray>;
  27421. /**
  27422. * Gets the scene from the mesh
  27423. * @returns the indices array or null
  27424. */
  27425. getScene?(): Scene;
  27426. /**
  27427. * Gets the absolute position from the mesh
  27428. * @returns the absolute position
  27429. */
  27430. getAbsolutePosition(): Vector3;
  27431. /**
  27432. * Gets the absolute pivot point from the mesh
  27433. * @returns the absolute pivot point
  27434. */
  27435. getAbsolutePivotPoint(): Vector3;
  27436. /**
  27437. * Rotates the mesh
  27438. * @param axis The axis of rotation
  27439. * @param amount The amount of rotation
  27440. * @param space The space of the rotation
  27441. * @returns The rotation transform node
  27442. */
  27443. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27444. /**
  27445. * Translates the mesh
  27446. * @param axis The axis of translation
  27447. * @param distance The distance of translation
  27448. * @param space The space of the translation
  27449. * @returns The transform node
  27450. */
  27451. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27452. /**
  27453. * Sets the absolute position of the mesh
  27454. * @param absolutePosition The absolute position of the mesh
  27455. * @returns The transform node
  27456. */
  27457. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27458. /**
  27459. * Gets the class name of the mesh
  27460. * @returns The class name
  27461. */
  27462. getClassName(): string;
  27463. }
  27464. /**
  27465. * Represents a physics imposter
  27466. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27467. */
  27468. export class PhysicsImpostor {
  27469. /**
  27470. * The physics-enabled object used as the physics imposter
  27471. */
  27472. object: IPhysicsEnabledObject;
  27473. /**
  27474. * The type of the physics imposter
  27475. */
  27476. type: number;
  27477. private _options;
  27478. private _scene?;
  27479. /**
  27480. * The default object size of the imposter
  27481. */
  27482. static DEFAULT_OBJECT_SIZE: Vector3;
  27483. /**
  27484. * The identity quaternion of the imposter
  27485. */
  27486. static IDENTITY_QUATERNION: Quaternion;
  27487. /** @hidden */
  27488. _pluginData: any;
  27489. private _physicsEngine;
  27490. private _physicsBody;
  27491. private _bodyUpdateRequired;
  27492. private _onBeforePhysicsStepCallbacks;
  27493. private _onAfterPhysicsStepCallbacks;
  27494. /** @hidden */
  27495. _onPhysicsCollideCallbacks: Array<{
  27496. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  27497. otherImpostors: Array<PhysicsImpostor>;
  27498. }>;
  27499. private _deltaPosition;
  27500. private _deltaRotation;
  27501. private _deltaRotationConjugated;
  27502. /** @hidden */
  27503. _isFromLine: boolean;
  27504. private _parent;
  27505. private _isDisposed;
  27506. private static _tmpVecs;
  27507. private static _tmpQuat;
  27508. /**
  27509. * Specifies if the physics imposter is disposed
  27510. */
  27511. get isDisposed(): boolean;
  27512. /**
  27513. * Gets the mass of the physics imposter
  27514. */
  27515. get mass(): number;
  27516. set mass(value: number);
  27517. /**
  27518. * Gets the coefficient of friction
  27519. */
  27520. get friction(): number;
  27521. /**
  27522. * Sets the coefficient of friction
  27523. */
  27524. set friction(value: number);
  27525. /**
  27526. * Gets the coefficient of restitution
  27527. */
  27528. get restitution(): number;
  27529. /**
  27530. * Sets the coefficient of restitution
  27531. */
  27532. set restitution(value: number);
  27533. /**
  27534. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  27535. */
  27536. get pressure(): number;
  27537. /**
  27538. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  27539. */
  27540. set pressure(value: number);
  27541. /**
  27542. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27543. */
  27544. get stiffness(): number;
  27545. /**
  27546. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27547. */
  27548. set stiffness(value: number);
  27549. /**
  27550. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27551. */
  27552. get velocityIterations(): number;
  27553. /**
  27554. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27555. */
  27556. set velocityIterations(value: number);
  27557. /**
  27558. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27559. */
  27560. get positionIterations(): number;
  27561. /**
  27562. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27563. */
  27564. set positionIterations(value: number);
  27565. /**
  27566. * The unique id of the physics imposter
  27567. * set by the physics engine when adding this impostor to the array
  27568. */
  27569. uniqueId: number;
  27570. /**
  27571. * @hidden
  27572. */
  27573. soft: boolean;
  27574. /**
  27575. * @hidden
  27576. */
  27577. segments: number;
  27578. private _joints;
  27579. /**
  27580. * Initializes the physics imposter
  27581. * @param object The physics-enabled object used as the physics imposter
  27582. * @param type The type of the physics imposter
  27583. * @param _options The options for the physics imposter
  27584. * @param _scene The Babylon scene
  27585. */
  27586. constructor(
  27587. /**
  27588. * The physics-enabled object used as the physics imposter
  27589. */
  27590. object: IPhysicsEnabledObject,
  27591. /**
  27592. * The type of the physics imposter
  27593. */
  27594. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  27595. /**
  27596. * This function will completly initialize this impostor.
  27597. * It will create a new body - but only if this mesh has no parent.
  27598. * If it has, this impostor will not be used other than to define the impostor
  27599. * of the child mesh.
  27600. * @hidden
  27601. */
  27602. _init(): void;
  27603. private _getPhysicsParent;
  27604. /**
  27605. * Should a new body be generated.
  27606. * @returns boolean specifying if body initialization is required
  27607. */
  27608. isBodyInitRequired(): boolean;
  27609. /**
  27610. * Sets the updated scaling
  27611. * @param updated Specifies if the scaling is updated
  27612. */
  27613. setScalingUpdated(): void;
  27614. /**
  27615. * Force a regeneration of this or the parent's impostor's body.
  27616. * Use under cautious - This will remove all joints already implemented.
  27617. */
  27618. forceUpdate(): void;
  27619. /**
  27620. * Gets the body that holds this impostor. Either its own, or its parent.
  27621. */
  27622. get physicsBody(): any;
  27623. /**
  27624. * Get the parent of the physics imposter
  27625. * @returns Physics imposter or null
  27626. */
  27627. get parent(): Nullable<PhysicsImpostor>;
  27628. /**
  27629. * Sets the parent of the physics imposter
  27630. */
  27631. set parent(value: Nullable<PhysicsImpostor>);
  27632. /**
  27633. * Set the physics body. Used mainly by the physics engine/plugin
  27634. */
  27635. set physicsBody(physicsBody: any);
  27636. /**
  27637. * Resets the update flags
  27638. */
  27639. resetUpdateFlags(): void;
  27640. /**
  27641. * Gets the object extend size
  27642. * @returns the object extend size
  27643. */
  27644. getObjectExtendSize(): Vector3;
  27645. /**
  27646. * Gets the object center
  27647. * @returns The object center
  27648. */
  27649. getObjectCenter(): Vector3;
  27650. /**
  27651. * Get a specific parameter from the options parameters
  27652. * @param paramName The object parameter name
  27653. * @returns The object parameter
  27654. */
  27655. getParam(paramName: string): any;
  27656. /**
  27657. * Sets a specific parameter in the options given to the physics plugin
  27658. * @param paramName The parameter name
  27659. * @param value The value of the parameter
  27660. */
  27661. setParam(paramName: string, value: number): void;
  27662. /**
  27663. * Specifically change the body's mass option. Won't recreate the physics body object
  27664. * @param mass The mass of the physics imposter
  27665. */
  27666. setMass(mass: number): void;
  27667. /**
  27668. * Gets the linear velocity
  27669. * @returns linear velocity or null
  27670. */
  27671. getLinearVelocity(): Nullable<Vector3>;
  27672. /**
  27673. * Sets the linear velocity
  27674. * @param velocity linear velocity or null
  27675. */
  27676. setLinearVelocity(velocity: Nullable<Vector3>): void;
  27677. /**
  27678. * Gets the angular velocity
  27679. * @returns angular velocity or null
  27680. */
  27681. getAngularVelocity(): Nullable<Vector3>;
  27682. /**
  27683. * Sets the angular velocity
  27684. * @param velocity The velocity or null
  27685. */
  27686. setAngularVelocity(velocity: Nullable<Vector3>): void;
  27687. /**
  27688. * Execute a function with the physics plugin native code
  27689. * Provide a function the will have two variables - the world object and the physics body object
  27690. * @param func The function to execute with the physics plugin native code
  27691. */
  27692. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  27693. /**
  27694. * Register a function that will be executed before the physics world is stepping forward
  27695. * @param func The function to execute before the physics world is stepped forward
  27696. */
  27697. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27698. /**
  27699. * Unregister a function that will be executed before the physics world is stepping forward
  27700. * @param func The function to execute before the physics world is stepped forward
  27701. */
  27702. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27703. /**
  27704. * Register a function that will be executed after the physics step
  27705. * @param func The function to execute after physics step
  27706. */
  27707. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27708. /**
  27709. * Unregisters a function that will be executed after the physics step
  27710. * @param func The function to execute after physics step
  27711. */
  27712. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27713. /**
  27714. * register a function that will be executed when this impostor collides against a different body
  27715. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  27716. * @param func Callback that is executed on collision
  27717. */
  27718. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  27719. /**
  27720. * Unregisters the physics imposter on contact
  27721. * @param collideAgainst The physics object to collide against
  27722. * @param func Callback to execute on collision
  27723. */
  27724. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  27725. private _tmpQuat;
  27726. private _tmpQuat2;
  27727. /**
  27728. * Get the parent rotation
  27729. * @returns The parent rotation
  27730. */
  27731. getParentsRotation(): Quaternion;
  27732. /**
  27733. * this function is executed by the physics engine.
  27734. */
  27735. beforeStep: () => void;
  27736. /**
  27737. * this function is executed by the physics engine
  27738. */
  27739. afterStep: () => void;
  27740. /**
  27741. * Legacy collision detection event support
  27742. */
  27743. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  27744. /**
  27745. * event and body object due to cannon's event-based architecture.
  27746. */
  27747. onCollide: (e: {
  27748. body: any;
  27749. }) => void;
  27750. /**
  27751. * Apply a force
  27752. * @param force The force to apply
  27753. * @param contactPoint The contact point for the force
  27754. * @returns The physics imposter
  27755. */
  27756. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27757. /**
  27758. * Apply an impulse
  27759. * @param force The impulse force
  27760. * @param contactPoint The contact point for the impulse force
  27761. * @returns The physics imposter
  27762. */
  27763. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27764. /**
  27765. * A help function to create a joint
  27766. * @param otherImpostor A physics imposter used to create a joint
  27767. * @param jointType The type of joint
  27768. * @param jointData The data for the joint
  27769. * @returns The physics imposter
  27770. */
  27771. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  27772. /**
  27773. * Add a joint to this impostor with a different impostor
  27774. * @param otherImpostor A physics imposter used to add a joint
  27775. * @param joint The joint to add
  27776. * @returns The physics imposter
  27777. */
  27778. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  27779. /**
  27780. * Add an anchor to a cloth impostor
  27781. * @param otherImpostor rigid impostor to anchor to
  27782. * @param width ratio across width from 0 to 1
  27783. * @param height ratio up height from 0 to 1
  27784. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  27785. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  27786. * @returns impostor the soft imposter
  27787. */
  27788. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27789. /**
  27790. * Add a hook to a rope impostor
  27791. * @param otherImpostor rigid impostor to anchor to
  27792. * @param length ratio across rope from 0 to 1
  27793. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  27794. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  27795. * @returns impostor the rope imposter
  27796. */
  27797. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27798. /**
  27799. * Will keep this body still, in a sleep mode.
  27800. * @returns the physics imposter
  27801. */
  27802. sleep(): PhysicsImpostor;
  27803. /**
  27804. * Wake the body up.
  27805. * @returns The physics imposter
  27806. */
  27807. wakeUp(): PhysicsImpostor;
  27808. /**
  27809. * Clones the physics imposter
  27810. * @param newObject The physics imposter clones to this physics-enabled object
  27811. * @returns A nullable physics imposter
  27812. */
  27813. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27814. /**
  27815. * Disposes the physics imposter
  27816. */
  27817. dispose(): void;
  27818. /**
  27819. * Sets the delta position
  27820. * @param position The delta position amount
  27821. */
  27822. setDeltaPosition(position: Vector3): void;
  27823. /**
  27824. * Sets the delta rotation
  27825. * @param rotation The delta rotation amount
  27826. */
  27827. setDeltaRotation(rotation: Quaternion): void;
  27828. /**
  27829. * Gets the box size of the physics imposter and stores the result in the input parameter
  27830. * @param result Stores the box size
  27831. * @returns The physics imposter
  27832. */
  27833. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27834. /**
  27835. * Gets the radius of the physics imposter
  27836. * @returns Radius of the physics imposter
  27837. */
  27838. getRadius(): number;
  27839. /**
  27840. * Sync a bone with this impostor
  27841. * @param bone The bone to sync to the impostor.
  27842. * @param boneMesh The mesh that the bone is influencing.
  27843. * @param jointPivot The pivot of the joint / bone in local space.
  27844. * @param distToJoint Optional distance from the impostor to the joint.
  27845. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27846. */
  27847. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27848. /**
  27849. * Sync impostor to a bone
  27850. * @param bone The bone that the impostor will be synced to.
  27851. * @param boneMesh The mesh that the bone is influencing.
  27852. * @param jointPivot The pivot of the joint / bone in local space.
  27853. * @param distToJoint Optional distance from the impostor to the joint.
  27854. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27855. * @param boneAxis Optional vector3 axis the bone is aligned with
  27856. */
  27857. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  27858. /**
  27859. * No-Imposter type
  27860. */
  27861. static NoImpostor: number;
  27862. /**
  27863. * Sphere-Imposter type
  27864. */
  27865. static SphereImpostor: number;
  27866. /**
  27867. * Box-Imposter type
  27868. */
  27869. static BoxImpostor: number;
  27870. /**
  27871. * Plane-Imposter type
  27872. */
  27873. static PlaneImpostor: number;
  27874. /**
  27875. * Mesh-imposter type
  27876. */
  27877. static MeshImpostor: number;
  27878. /**
  27879. * Capsule-Impostor type (Ammo.js plugin only)
  27880. */
  27881. static CapsuleImpostor: number;
  27882. /**
  27883. * Cylinder-Imposter type
  27884. */
  27885. static CylinderImpostor: number;
  27886. /**
  27887. * Particle-Imposter type
  27888. */
  27889. static ParticleImpostor: number;
  27890. /**
  27891. * Heightmap-Imposter type
  27892. */
  27893. static HeightmapImpostor: number;
  27894. /**
  27895. * ConvexHull-Impostor type (Ammo.js plugin only)
  27896. */
  27897. static ConvexHullImpostor: number;
  27898. /**
  27899. * Custom-Imposter type (Ammo.js plugin only)
  27900. */
  27901. static CustomImpostor: number;
  27902. /**
  27903. * Rope-Imposter type
  27904. */
  27905. static RopeImpostor: number;
  27906. /**
  27907. * Cloth-Imposter type
  27908. */
  27909. static ClothImpostor: number;
  27910. /**
  27911. * Softbody-Imposter type
  27912. */
  27913. static SoftbodyImpostor: number;
  27914. }
  27915. }
  27916. declare module BABYLON {
  27917. /**
  27918. * @hidden
  27919. **/
  27920. export class _CreationDataStorage {
  27921. closePath?: boolean;
  27922. closeArray?: boolean;
  27923. idx: number[];
  27924. dashSize: number;
  27925. gapSize: number;
  27926. path3D: Path3D;
  27927. pathArray: Vector3[][];
  27928. arc: number;
  27929. radius: number;
  27930. cap: number;
  27931. tessellation: number;
  27932. }
  27933. /**
  27934. * @hidden
  27935. **/
  27936. class _InstanceDataStorage {
  27937. visibleInstances: any;
  27938. batchCache: _InstancesBatch;
  27939. instancesBufferSize: number;
  27940. instancesBuffer: Nullable<Buffer>;
  27941. instancesData: Float32Array;
  27942. overridenInstanceCount: number;
  27943. isFrozen: boolean;
  27944. previousBatch: Nullable<_InstancesBatch>;
  27945. hardwareInstancedRendering: boolean;
  27946. sideOrientation: number;
  27947. manualUpdate: boolean;
  27948. }
  27949. /**
  27950. * @hidden
  27951. **/
  27952. export class _InstancesBatch {
  27953. mustReturn: boolean;
  27954. visibleInstances: Nullable<InstancedMesh[]>[];
  27955. renderSelf: boolean[];
  27956. hardwareInstancedRendering: boolean[];
  27957. }
  27958. /**
  27959. * @hidden
  27960. **/
  27961. class _ThinInstanceDataStorage {
  27962. instancesCount: number;
  27963. matrixBuffer: Nullable<Buffer>;
  27964. matrixBufferSize: number;
  27965. matrixData: Nullable<Float32Array>;
  27966. boundingVectors: Array<Vector3>;
  27967. worldMatrices: Nullable<Matrix[]>;
  27968. }
  27969. /**
  27970. * Class used to represent renderable models
  27971. */
  27972. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  27973. /**
  27974. * Mesh side orientation : usually the external or front surface
  27975. */
  27976. static readonly FRONTSIDE: number;
  27977. /**
  27978. * Mesh side orientation : usually the internal or back surface
  27979. */
  27980. static readonly BACKSIDE: number;
  27981. /**
  27982. * Mesh side orientation : both internal and external or front and back surfaces
  27983. */
  27984. static readonly DOUBLESIDE: number;
  27985. /**
  27986. * Mesh side orientation : by default, `FRONTSIDE`
  27987. */
  27988. static readonly DEFAULTSIDE: number;
  27989. /**
  27990. * Mesh cap setting : no cap
  27991. */
  27992. static readonly NO_CAP: number;
  27993. /**
  27994. * Mesh cap setting : one cap at the beginning of the mesh
  27995. */
  27996. static readonly CAP_START: number;
  27997. /**
  27998. * Mesh cap setting : one cap at the end of the mesh
  27999. */
  28000. static readonly CAP_END: number;
  28001. /**
  28002. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  28003. */
  28004. static readonly CAP_ALL: number;
  28005. /**
  28006. * Mesh pattern setting : no flip or rotate
  28007. */
  28008. static readonly NO_FLIP: number;
  28009. /**
  28010. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  28011. */
  28012. static readonly FLIP_TILE: number;
  28013. /**
  28014. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  28015. */
  28016. static readonly ROTATE_TILE: number;
  28017. /**
  28018. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  28019. */
  28020. static readonly FLIP_ROW: number;
  28021. /**
  28022. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  28023. */
  28024. static readonly ROTATE_ROW: number;
  28025. /**
  28026. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  28027. */
  28028. static readonly FLIP_N_ROTATE_TILE: number;
  28029. /**
  28030. * Mesh pattern setting : rotate pattern and rotate
  28031. */
  28032. static readonly FLIP_N_ROTATE_ROW: number;
  28033. /**
  28034. * Mesh tile positioning : part tiles same on left/right or top/bottom
  28035. */
  28036. static readonly CENTER: number;
  28037. /**
  28038. * Mesh tile positioning : part tiles on left
  28039. */
  28040. static readonly LEFT: number;
  28041. /**
  28042. * Mesh tile positioning : part tiles on right
  28043. */
  28044. static readonly RIGHT: number;
  28045. /**
  28046. * Mesh tile positioning : part tiles on top
  28047. */
  28048. static readonly TOP: number;
  28049. /**
  28050. * Mesh tile positioning : part tiles on bottom
  28051. */
  28052. static readonly BOTTOM: number;
  28053. /**
  28054. * Gets the default side orientation.
  28055. * @param orientation the orientation to value to attempt to get
  28056. * @returns the default orientation
  28057. * @hidden
  28058. */
  28059. static _GetDefaultSideOrientation(orientation?: number): number;
  28060. private _internalMeshDataInfo;
  28061. get computeBonesUsingShaders(): boolean;
  28062. set computeBonesUsingShaders(value: boolean);
  28063. /**
  28064. * An event triggered before rendering the mesh
  28065. */
  28066. get onBeforeRenderObservable(): Observable<Mesh>;
  28067. /**
  28068. * An event triggered before binding the mesh
  28069. */
  28070. get onBeforeBindObservable(): Observable<Mesh>;
  28071. /**
  28072. * An event triggered after rendering the mesh
  28073. */
  28074. get onAfterRenderObservable(): Observable<Mesh>;
  28075. /**
  28076. * An event triggered before drawing the mesh
  28077. */
  28078. get onBeforeDrawObservable(): Observable<Mesh>;
  28079. private _onBeforeDrawObserver;
  28080. /**
  28081. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  28082. */
  28083. set onBeforeDraw(callback: () => void);
  28084. get hasInstances(): boolean;
  28085. get hasThinInstances(): boolean;
  28086. /**
  28087. * Gets the delay loading state of the mesh (when delay loading is turned on)
  28088. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  28089. */
  28090. delayLoadState: number;
  28091. /**
  28092. * Gets the list of instances created from this mesh
  28093. * it is not supposed to be modified manually.
  28094. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  28095. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28096. */
  28097. instances: InstancedMesh[];
  28098. /**
  28099. * Gets the file containing delay loading data for this mesh
  28100. */
  28101. delayLoadingFile: string;
  28102. /** @hidden */
  28103. _binaryInfo: any;
  28104. /**
  28105. * User defined function used to change how LOD level selection is done
  28106. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28107. */
  28108. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  28109. /**
  28110. * Gets or sets the morph target manager
  28111. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  28112. */
  28113. get morphTargetManager(): Nullable<MorphTargetManager>;
  28114. set morphTargetManager(value: Nullable<MorphTargetManager>);
  28115. /** @hidden */
  28116. _creationDataStorage: Nullable<_CreationDataStorage>;
  28117. /** @hidden */
  28118. _geometry: Nullable<Geometry>;
  28119. /** @hidden */
  28120. _delayInfo: Array<string>;
  28121. /** @hidden */
  28122. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  28123. /** @hidden */
  28124. _instanceDataStorage: _InstanceDataStorage;
  28125. /** @hidden */
  28126. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  28127. private _effectiveMaterial;
  28128. /** @hidden */
  28129. _shouldGenerateFlatShading: boolean;
  28130. /** @hidden */
  28131. _originalBuilderSideOrientation: number;
  28132. /**
  28133. * Use this property to change the original side orientation defined at construction time
  28134. */
  28135. overrideMaterialSideOrientation: Nullable<number>;
  28136. /**
  28137. * Gets the source mesh (the one used to clone this one from)
  28138. */
  28139. get source(): Nullable<Mesh>;
  28140. /**
  28141. * Gets or sets a boolean indicating that this mesh does not use index buffer
  28142. */
  28143. get isUnIndexed(): boolean;
  28144. set isUnIndexed(value: boolean);
  28145. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  28146. get worldMatrixInstancedBuffer(): Float32Array;
  28147. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  28148. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  28149. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  28150. /**
  28151. * @constructor
  28152. * @param name The value used by scene.getMeshByName() to do a lookup.
  28153. * @param scene The scene to add this mesh to.
  28154. * @param parent The parent of this mesh, if it has one
  28155. * @param source An optional Mesh from which geometry is shared, cloned.
  28156. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28157. * When false, achieved by calling a clone(), also passing False.
  28158. * This will make creation of children, recursive.
  28159. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  28160. */
  28161. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  28162. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  28163. doNotInstantiate: boolean;
  28164. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  28165. /**
  28166. * Gets the class name
  28167. * @returns the string "Mesh".
  28168. */
  28169. getClassName(): string;
  28170. /** @hidden */
  28171. get _isMesh(): boolean;
  28172. /**
  28173. * Returns a description of this mesh
  28174. * @param fullDetails define if full details about this mesh must be used
  28175. * @returns a descriptive string representing this mesh
  28176. */
  28177. toString(fullDetails?: boolean): string;
  28178. /** @hidden */
  28179. _unBindEffect(): void;
  28180. /**
  28181. * Gets a boolean indicating if this mesh has LOD
  28182. */
  28183. get hasLODLevels(): boolean;
  28184. /**
  28185. * Gets the list of MeshLODLevel associated with the current mesh
  28186. * @returns an array of MeshLODLevel
  28187. */
  28188. getLODLevels(): MeshLODLevel[];
  28189. private _sortLODLevels;
  28190. /**
  28191. * Add a mesh as LOD level triggered at the given distance.
  28192. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28193. * @param distance The distance from the center of the object to show this level
  28194. * @param mesh The mesh to be added as LOD level (can be null)
  28195. * @return This mesh (for chaining)
  28196. */
  28197. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  28198. /**
  28199. * Returns the LOD level mesh at the passed distance or null if not found.
  28200. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28201. * @param distance The distance from the center of the object to show this level
  28202. * @returns a Mesh or `null`
  28203. */
  28204. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  28205. /**
  28206. * Remove a mesh from the LOD array
  28207. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28208. * @param mesh defines the mesh to be removed
  28209. * @return This mesh (for chaining)
  28210. */
  28211. removeLODLevel(mesh: Mesh): Mesh;
  28212. /**
  28213. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  28214. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28215. * @param camera defines the camera to use to compute distance
  28216. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  28217. * @return This mesh (for chaining)
  28218. */
  28219. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  28220. /**
  28221. * Gets the mesh internal Geometry object
  28222. */
  28223. get geometry(): Nullable<Geometry>;
  28224. /**
  28225. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  28226. * @returns the total number of vertices
  28227. */
  28228. getTotalVertices(): number;
  28229. /**
  28230. * Returns the content of an associated vertex buffer
  28231. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28232. * - VertexBuffer.PositionKind
  28233. * - VertexBuffer.UVKind
  28234. * - VertexBuffer.UV2Kind
  28235. * - VertexBuffer.UV3Kind
  28236. * - VertexBuffer.UV4Kind
  28237. * - VertexBuffer.UV5Kind
  28238. * - VertexBuffer.UV6Kind
  28239. * - VertexBuffer.ColorKind
  28240. * - VertexBuffer.MatricesIndicesKind
  28241. * - VertexBuffer.MatricesIndicesExtraKind
  28242. * - VertexBuffer.MatricesWeightsKind
  28243. * - VertexBuffer.MatricesWeightsExtraKind
  28244. * @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
  28245. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  28246. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  28247. */
  28248. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  28249. /**
  28250. * Returns the mesh VertexBuffer object from the requested `kind`
  28251. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28252. * - VertexBuffer.PositionKind
  28253. * - VertexBuffer.NormalKind
  28254. * - VertexBuffer.UVKind
  28255. * - VertexBuffer.UV2Kind
  28256. * - VertexBuffer.UV3Kind
  28257. * - VertexBuffer.UV4Kind
  28258. * - VertexBuffer.UV5Kind
  28259. * - VertexBuffer.UV6Kind
  28260. * - VertexBuffer.ColorKind
  28261. * - VertexBuffer.MatricesIndicesKind
  28262. * - VertexBuffer.MatricesIndicesExtraKind
  28263. * - VertexBuffer.MatricesWeightsKind
  28264. * - VertexBuffer.MatricesWeightsExtraKind
  28265. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  28266. */
  28267. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  28268. /**
  28269. * Tests if a specific vertex buffer is associated with this mesh
  28270. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28271. * - VertexBuffer.PositionKind
  28272. * - VertexBuffer.NormalKind
  28273. * - VertexBuffer.UVKind
  28274. * - VertexBuffer.UV2Kind
  28275. * - VertexBuffer.UV3Kind
  28276. * - VertexBuffer.UV4Kind
  28277. * - VertexBuffer.UV5Kind
  28278. * - VertexBuffer.UV6Kind
  28279. * - VertexBuffer.ColorKind
  28280. * - VertexBuffer.MatricesIndicesKind
  28281. * - VertexBuffer.MatricesIndicesExtraKind
  28282. * - VertexBuffer.MatricesWeightsKind
  28283. * - VertexBuffer.MatricesWeightsExtraKind
  28284. * @returns a boolean
  28285. */
  28286. isVerticesDataPresent(kind: string): boolean;
  28287. /**
  28288. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  28289. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28290. * - VertexBuffer.PositionKind
  28291. * - VertexBuffer.UVKind
  28292. * - VertexBuffer.UV2Kind
  28293. * - VertexBuffer.UV3Kind
  28294. * - VertexBuffer.UV4Kind
  28295. * - VertexBuffer.UV5Kind
  28296. * - VertexBuffer.UV6Kind
  28297. * - VertexBuffer.ColorKind
  28298. * - VertexBuffer.MatricesIndicesKind
  28299. * - VertexBuffer.MatricesIndicesExtraKind
  28300. * - VertexBuffer.MatricesWeightsKind
  28301. * - VertexBuffer.MatricesWeightsExtraKind
  28302. * @returns a boolean
  28303. */
  28304. isVertexBufferUpdatable(kind: string): boolean;
  28305. /**
  28306. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  28307. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28308. * - VertexBuffer.PositionKind
  28309. * - VertexBuffer.NormalKind
  28310. * - VertexBuffer.UVKind
  28311. * - VertexBuffer.UV2Kind
  28312. * - VertexBuffer.UV3Kind
  28313. * - VertexBuffer.UV4Kind
  28314. * - VertexBuffer.UV5Kind
  28315. * - VertexBuffer.UV6Kind
  28316. * - VertexBuffer.ColorKind
  28317. * - VertexBuffer.MatricesIndicesKind
  28318. * - VertexBuffer.MatricesIndicesExtraKind
  28319. * - VertexBuffer.MatricesWeightsKind
  28320. * - VertexBuffer.MatricesWeightsExtraKind
  28321. * @returns an array of strings
  28322. */
  28323. getVerticesDataKinds(): string[];
  28324. /**
  28325. * Returns a positive integer : the total number of indices in this mesh geometry.
  28326. * @returns the numner of indices or zero if the mesh has no geometry.
  28327. */
  28328. getTotalIndices(): number;
  28329. /**
  28330. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28331. * @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.
  28332. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  28333. * @returns the indices array or an empty array if the mesh has no geometry
  28334. */
  28335. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  28336. get isBlocked(): boolean;
  28337. /**
  28338. * Determine if the current mesh is ready to be rendered
  28339. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28340. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  28341. * @returns true if all associated assets are ready (material, textures, shaders)
  28342. */
  28343. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  28344. /**
  28345. * 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.
  28346. */
  28347. get areNormalsFrozen(): boolean;
  28348. /**
  28349. * 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.
  28350. * @returns the current mesh
  28351. */
  28352. freezeNormals(): Mesh;
  28353. /**
  28354. * 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
  28355. * @returns the current mesh
  28356. */
  28357. unfreezeNormals(): Mesh;
  28358. /**
  28359. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  28360. */
  28361. set overridenInstanceCount(count: number);
  28362. /** @hidden */
  28363. _preActivate(): Mesh;
  28364. /** @hidden */
  28365. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28366. /** @hidden */
  28367. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  28368. protected _afterComputeWorldMatrix(): void;
  28369. /** @hidden */
  28370. _postActivate(): void;
  28371. /**
  28372. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28373. * This means the mesh underlying bounding box and sphere are recomputed.
  28374. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28375. * @returns the current mesh
  28376. */
  28377. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  28378. /** @hidden */
  28379. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  28380. /**
  28381. * This function will subdivide the mesh into multiple submeshes
  28382. * @param count defines the expected number of submeshes
  28383. */
  28384. subdivide(count: number): void;
  28385. /**
  28386. * Copy a FloatArray into a specific associated vertex buffer
  28387. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28388. * - VertexBuffer.PositionKind
  28389. * - VertexBuffer.UVKind
  28390. * - VertexBuffer.UV2Kind
  28391. * - VertexBuffer.UV3Kind
  28392. * - VertexBuffer.UV4Kind
  28393. * - VertexBuffer.UV5Kind
  28394. * - VertexBuffer.UV6Kind
  28395. * - VertexBuffer.ColorKind
  28396. * - VertexBuffer.MatricesIndicesKind
  28397. * - VertexBuffer.MatricesIndicesExtraKind
  28398. * - VertexBuffer.MatricesWeightsKind
  28399. * - VertexBuffer.MatricesWeightsExtraKind
  28400. * @param data defines the data source
  28401. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28402. * @param stride defines the data stride size (can be null)
  28403. * @returns the current mesh
  28404. */
  28405. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28406. /**
  28407. * Delete a vertex buffer associated with this mesh
  28408. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  28409. * - VertexBuffer.PositionKind
  28410. * - VertexBuffer.UVKind
  28411. * - VertexBuffer.UV2Kind
  28412. * - VertexBuffer.UV3Kind
  28413. * - VertexBuffer.UV4Kind
  28414. * - VertexBuffer.UV5Kind
  28415. * - VertexBuffer.UV6Kind
  28416. * - VertexBuffer.ColorKind
  28417. * - VertexBuffer.MatricesIndicesKind
  28418. * - VertexBuffer.MatricesIndicesExtraKind
  28419. * - VertexBuffer.MatricesWeightsKind
  28420. * - VertexBuffer.MatricesWeightsExtraKind
  28421. */
  28422. removeVerticesData(kind: string): void;
  28423. /**
  28424. * Flags an associated vertex buffer as updatable
  28425. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  28426. * - VertexBuffer.PositionKind
  28427. * - VertexBuffer.UVKind
  28428. * - VertexBuffer.UV2Kind
  28429. * - VertexBuffer.UV3Kind
  28430. * - VertexBuffer.UV4Kind
  28431. * - VertexBuffer.UV5Kind
  28432. * - VertexBuffer.UV6Kind
  28433. * - VertexBuffer.ColorKind
  28434. * - VertexBuffer.MatricesIndicesKind
  28435. * - VertexBuffer.MatricesIndicesExtraKind
  28436. * - VertexBuffer.MatricesWeightsKind
  28437. * - VertexBuffer.MatricesWeightsExtraKind
  28438. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28439. */
  28440. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  28441. /**
  28442. * Sets the mesh global Vertex Buffer
  28443. * @param buffer defines the buffer to use
  28444. * @returns the current mesh
  28445. */
  28446. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  28447. /**
  28448. * Update a specific associated vertex buffer
  28449. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28450. * - VertexBuffer.PositionKind
  28451. * - VertexBuffer.UVKind
  28452. * - VertexBuffer.UV2Kind
  28453. * - VertexBuffer.UV3Kind
  28454. * - VertexBuffer.UV4Kind
  28455. * - VertexBuffer.UV5Kind
  28456. * - VertexBuffer.UV6Kind
  28457. * - VertexBuffer.ColorKind
  28458. * - VertexBuffer.MatricesIndicesKind
  28459. * - VertexBuffer.MatricesIndicesExtraKind
  28460. * - VertexBuffer.MatricesWeightsKind
  28461. * - VertexBuffer.MatricesWeightsExtraKind
  28462. * @param data defines the data source
  28463. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  28464. * @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)
  28465. * @returns the current mesh
  28466. */
  28467. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28468. /**
  28469. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  28470. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  28471. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  28472. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  28473. * @returns the current mesh
  28474. */
  28475. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  28476. /**
  28477. * Creates a un-shared specific occurence of the geometry for the mesh.
  28478. * @returns the current mesh
  28479. */
  28480. makeGeometryUnique(): Mesh;
  28481. /**
  28482. * Set the index buffer of this mesh
  28483. * @param indices defines the source data
  28484. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  28485. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  28486. * @returns the current mesh
  28487. */
  28488. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  28489. /**
  28490. * Update the current index buffer
  28491. * @param indices defines the source data
  28492. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28493. * @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)
  28494. * @returns the current mesh
  28495. */
  28496. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28497. /**
  28498. * Invert the geometry to move from a right handed system to a left handed one.
  28499. * @returns the current mesh
  28500. */
  28501. toLeftHanded(): Mesh;
  28502. /** @hidden */
  28503. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28504. /** @hidden */
  28505. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28506. /**
  28507. * Registers for this mesh a javascript function called just before the rendering process
  28508. * @param func defines the function to call before rendering this mesh
  28509. * @returns the current mesh
  28510. */
  28511. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28512. /**
  28513. * Disposes a previously registered javascript function called before the rendering
  28514. * @param func defines the function to remove
  28515. * @returns the current mesh
  28516. */
  28517. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28518. /**
  28519. * Registers for this mesh a javascript function called just after the rendering is complete
  28520. * @param func defines the function to call after rendering this mesh
  28521. * @returns the current mesh
  28522. */
  28523. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28524. /**
  28525. * Disposes a previously registered javascript function called after the rendering.
  28526. * @param func defines the function to remove
  28527. * @returns the current mesh
  28528. */
  28529. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28530. /** @hidden */
  28531. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  28532. /** @hidden */
  28533. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  28534. /** @hidden */
  28535. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  28536. /** @hidden */
  28537. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  28538. /** @hidden */
  28539. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  28540. /** @hidden */
  28541. _rebuild(): void;
  28542. /** @hidden */
  28543. _freeze(): void;
  28544. /** @hidden */
  28545. _unFreeze(): void;
  28546. /**
  28547. * 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
  28548. * @param subMesh defines the subMesh to render
  28549. * @param enableAlphaMode defines if alpha mode can be changed
  28550. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  28551. * @returns the current mesh
  28552. */
  28553. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  28554. private _onBeforeDraw;
  28555. /**
  28556. * Renormalize the mesh and patch it up if there are no weights
  28557. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  28558. * However in the case of zero weights then we set just a single influence to 1.
  28559. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  28560. */
  28561. cleanMatrixWeights(): void;
  28562. private normalizeSkinFourWeights;
  28563. private normalizeSkinWeightsAndExtra;
  28564. /**
  28565. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  28566. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  28567. * the user know there was an issue with importing the mesh
  28568. * @returns a validation object with skinned, valid and report string
  28569. */
  28570. validateSkinning(): {
  28571. skinned: boolean;
  28572. valid: boolean;
  28573. report: string;
  28574. };
  28575. /** @hidden */
  28576. _checkDelayState(): Mesh;
  28577. private _queueLoad;
  28578. /**
  28579. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28580. * A mesh is in the frustum if its bounding box intersects the frustum
  28581. * @param frustumPlanes defines the frustum to test
  28582. * @returns true if the mesh is in the frustum planes
  28583. */
  28584. isInFrustum(frustumPlanes: Plane[]): boolean;
  28585. /**
  28586. * Sets the mesh material by the material or multiMaterial `id` property
  28587. * @param id is a string identifying the material or the multiMaterial
  28588. * @returns the current mesh
  28589. */
  28590. setMaterialByID(id: string): Mesh;
  28591. /**
  28592. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  28593. * @returns an array of IAnimatable
  28594. */
  28595. getAnimatables(): IAnimatable[];
  28596. /**
  28597. * Modifies the mesh geometry according to the passed transformation matrix.
  28598. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  28599. * The mesh normals are modified using the same transformation.
  28600. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28601. * @param transform defines the transform matrix to use
  28602. * @see https://doc.babylonjs.com/resources/baking_transformations
  28603. * @returns the current mesh
  28604. */
  28605. bakeTransformIntoVertices(transform: Matrix): Mesh;
  28606. /**
  28607. * Modifies the mesh geometry according to its own current World Matrix.
  28608. * The mesh World Matrix is then reset.
  28609. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  28610. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28611. * @see https://doc.babylonjs.com/resources/baking_transformations
  28612. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  28613. * @returns the current mesh
  28614. */
  28615. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  28616. /** @hidden */
  28617. get _positions(): Nullable<Vector3[]>;
  28618. /** @hidden */
  28619. _resetPointsArrayCache(): Mesh;
  28620. /** @hidden */
  28621. _generatePointsArray(): boolean;
  28622. /**
  28623. * Returns a new Mesh object generated from the current mesh properties.
  28624. * This method must not get confused with createInstance()
  28625. * @param name is a string, the name given to the new mesh
  28626. * @param newParent can be any Node object (default `null`)
  28627. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  28628. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  28629. * @returns a new mesh
  28630. */
  28631. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  28632. /**
  28633. * Releases resources associated with this mesh.
  28634. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28635. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28636. */
  28637. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28638. /** @hidden */
  28639. _disposeInstanceSpecificData(): void;
  28640. /** @hidden */
  28641. _disposeThinInstanceSpecificData(): void;
  28642. /**
  28643. * Modifies the mesh geometry according to a displacement map.
  28644. * 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.
  28645. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28646. * @param url is a string, the URL from the image file is to be downloaded.
  28647. * @param minHeight is the lower limit of the displacement.
  28648. * @param maxHeight is the upper limit of the displacement.
  28649. * @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.
  28650. * @param uvOffset is an optional vector2 used to offset UV.
  28651. * @param uvScale is an optional vector2 used to scale UV.
  28652. * @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.
  28653. * @returns the Mesh.
  28654. */
  28655. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28656. /**
  28657. * Modifies the mesh geometry according to a displacementMap buffer.
  28658. * 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.
  28659. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28660. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  28661. * @param heightMapWidth is the width of the buffer image.
  28662. * @param heightMapHeight is the height of the buffer image.
  28663. * @param minHeight is the lower limit of the displacement.
  28664. * @param maxHeight is the upper limit of the displacement.
  28665. * @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.
  28666. * @param uvOffset is an optional vector2 used to offset UV.
  28667. * @param uvScale is an optional vector2 used to scale UV.
  28668. * @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.
  28669. * @returns the Mesh.
  28670. */
  28671. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28672. /**
  28673. * Modify the mesh to get a flat shading rendering.
  28674. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  28675. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  28676. * @returns current mesh
  28677. */
  28678. convertToFlatShadedMesh(): Mesh;
  28679. /**
  28680. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  28681. * In other words, more vertices, no more indices and a single bigger VBO.
  28682. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  28683. * @returns current mesh
  28684. */
  28685. convertToUnIndexedMesh(): Mesh;
  28686. /**
  28687. * Inverses facet orientations.
  28688. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28689. * @param flipNormals will also inverts the normals
  28690. * @returns current mesh
  28691. */
  28692. flipFaces(flipNormals?: boolean): Mesh;
  28693. /**
  28694. * Increase the number of facets and hence vertices in a mesh
  28695. * Vertex normals are interpolated from existing vertex normals
  28696. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28697. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  28698. */
  28699. increaseVertices(numberPerEdge: number): void;
  28700. /**
  28701. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  28702. * This will undo any application of covertToFlatShadedMesh
  28703. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28704. */
  28705. forceSharedVertices(): void;
  28706. /** @hidden */
  28707. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  28708. /** @hidden */
  28709. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  28710. /**
  28711. * Creates a new InstancedMesh object from the mesh model.
  28712. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28713. * @param name defines the name of the new instance
  28714. * @returns a new InstancedMesh
  28715. */
  28716. createInstance(name: string): InstancedMesh;
  28717. /**
  28718. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  28719. * After this call, all the mesh instances have the same submeshes than the current mesh.
  28720. * @returns the current mesh
  28721. */
  28722. synchronizeInstances(): Mesh;
  28723. /**
  28724. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  28725. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  28726. * This should be used together with the simplification to avoid disappearing triangles.
  28727. * @param successCallback an optional success callback to be called after the optimization finished.
  28728. * @returns the current mesh
  28729. */
  28730. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  28731. /**
  28732. * Serialize current mesh
  28733. * @param serializationObject defines the object which will receive the serialization data
  28734. */
  28735. serialize(serializationObject: any): void;
  28736. /** @hidden */
  28737. _syncGeometryWithMorphTargetManager(): void;
  28738. /** @hidden */
  28739. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  28740. /**
  28741. * Returns a new Mesh object parsed from the source provided.
  28742. * @param parsedMesh is the source
  28743. * @param scene defines the hosting scene
  28744. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  28745. * @returns a new Mesh
  28746. */
  28747. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  28748. /**
  28749. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  28750. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28751. * @param name defines the name of the mesh to create
  28752. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  28753. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  28754. * @param closePath creates a seam between the first and the last points of each path of the path array
  28755. * @param offset is taken in account only if the `pathArray` is containing a single path
  28756. * @param scene defines the hosting scene
  28757. * @param updatable defines if the mesh must be flagged as updatable
  28758. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28759. * @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)
  28760. * @returns a new Mesh
  28761. */
  28762. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28763. /**
  28764. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  28765. * @param name defines the name of the mesh to create
  28766. * @param radius sets the radius size (float) of the polygon (default 0.5)
  28767. * @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
  28768. * @param scene defines the hosting scene
  28769. * @param updatable defines if the mesh must be flagged as updatable
  28770. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28771. * @returns a new Mesh
  28772. */
  28773. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28774. /**
  28775. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  28776. * @param name defines the name of the mesh to create
  28777. * @param size sets the size (float) of each box side (default 1)
  28778. * @param scene defines the hosting scene
  28779. * @param updatable defines if the mesh must be flagged as updatable
  28780. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28781. * @returns a new Mesh
  28782. */
  28783. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28784. /**
  28785. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  28786. * @param name defines the name of the mesh to create
  28787. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28788. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28789. * @param scene defines the hosting scene
  28790. * @param updatable defines if the mesh must be flagged as updatable
  28791. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28792. * @returns a new Mesh
  28793. */
  28794. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28795. /**
  28796. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  28797. * @param name defines the name of the mesh to create
  28798. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28799. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28800. * @param scene defines the hosting scene
  28801. * @returns a new Mesh
  28802. */
  28803. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  28804. /**
  28805. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  28806. * @param name defines the name of the mesh to create
  28807. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  28808. * @param diameterTop set the top cap diameter (floats, default 1)
  28809. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  28810. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  28811. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  28812. * @param scene defines the hosting scene
  28813. * @param updatable defines if the mesh must be flagged as updatable
  28814. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28815. * @returns a new Mesh
  28816. */
  28817. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  28818. /**
  28819. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  28820. * @param name defines the name of the mesh to create
  28821. * @param diameter sets the diameter size (float) of the torus (default 1)
  28822. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  28823. * @param tessellation sets the number of torus sides (postive integer, default 16)
  28824. * @param scene defines the hosting scene
  28825. * @param updatable defines if the mesh must be flagged as updatable
  28826. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28827. * @returns a new Mesh
  28828. */
  28829. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28830. /**
  28831. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  28832. * @param name defines the name of the mesh to create
  28833. * @param radius sets the global radius size (float) of the torus knot (default 2)
  28834. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  28835. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  28836. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  28837. * @param p the number of windings on X axis (positive integers, default 2)
  28838. * @param q the number of windings on Y axis (positive integers, default 3)
  28839. * @param scene defines the hosting scene
  28840. * @param updatable defines if the mesh must be flagged as updatable
  28841. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28842. * @returns a new Mesh
  28843. */
  28844. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28845. /**
  28846. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  28847. * @param name defines the name of the mesh to create
  28848. * @param points is an array successive Vector3
  28849. * @param scene defines the hosting scene
  28850. * @param updatable defines if the mesh must be flagged as updatable
  28851. * @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).
  28852. * @returns a new Mesh
  28853. */
  28854. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  28855. /**
  28856. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  28857. * @param name defines the name of the mesh to create
  28858. * @param points is an array successive Vector3
  28859. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  28860. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28861. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  28862. * @param scene defines the hosting scene
  28863. * @param updatable defines if the mesh must be flagged as updatable
  28864. * @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)
  28865. * @returns a new Mesh
  28866. */
  28867. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  28868. /**
  28869. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  28870. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  28871. * 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.
  28872. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28873. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28874. * Remember you can only change the shape positions, not their number when updating a polygon.
  28875. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  28876. * @param name defines the name of the mesh to create
  28877. * @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
  28878. * @param scene defines the hosting scene
  28879. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28880. * @param updatable defines if the mesh must be flagged as updatable
  28881. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28882. * @param earcutInjection can be used to inject your own earcut reference
  28883. * @returns a new Mesh
  28884. */
  28885. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28886. /**
  28887. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  28888. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  28889. * @param name defines the name of the mesh to create
  28890. * @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
  28891. * @param depth defines the height of extrusion
  28892. * @param scene defines the hosting scene
  28893. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28894. * @param updatable defines if the mesh must be flagged as updatable
  28895. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28896. * @param earcutInjection can be used to inject your own earcut reference
  28897. * @returns a new Mesh
  28898. */
  28899. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28900. /**
  28901. * Creates an extruded shape mesh.
  28902. * 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
  28903. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28904. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28905. * @param name defines the name of the mesh to create
  28906. * @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
  28907. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28908. * @param scale is the value to scale the shape
  28909. * @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
  28910. * @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
  28911. * @param scene defines the hosting scene
  28912. * @param updatable defines if the mesh must be flagged as updatable
  28913. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28914. * @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)
  28915. * @returns a new Mesh
  28916. */
  28917. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28918. /**
  28919. * Creates an custom extruded shape mesh.
  28920. * The custom extrusion is a parametric shape.
  28921. * It has no predefined shape. Its final shape will depend on the input parameters.
  28922. * Please consider using the same method from the MeshBuilder class instead
  28923. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28924. * @param name defines the name of the mesh to create
  28925. * @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
  28926. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28927. * @param scaleFunction is a custom Javascript function called on each path point
  28928. * @param rotationFunction is a custom Javascript function called on each path point
  28929. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28930. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  28931. * @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
  28932. * @param scene defines the hosting scene
  28933. * @param updatable defines if the mesh must be flagged as updatable
  28934. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28935. * @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)
  28936. * @returns a new Mesh
  28937. */
  28938. 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;
  28939. /**
  28940. * Creates lathe mesh.
  28941. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  28942. * Please consider using the same method from the MeshBuilder class instead
  28943. * @param name defines the name of the mesh to create
  28944. * @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
  28945. * @param radius is the radius value of the lathe
  28946. * @param tessellation is the side number of the lathe.
  28947. * @param scene defines the hosting scene
  28948. * @param updatable defines if the mesh must be flagged as updatable
  28949. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28950. * @returns a new Mesh
  28951. */
  28952. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28953. /**
  28954. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  28955. * @param name defines the name of the mesh to create
  28956. * @param size sets the size (float) of both sides of the plane at once (default 1)
  28957. * @param scene defines the hosting scene
  28958. * @param updatable defines if the mesh must be flagged as updatable
  28959. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28960. * @returns a new Mesh
  28961. */
  28962. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28963. /**
  28964. * Creates a ground mesh.
  28965. * Please consider using the same method from the MeshBuilder class instead
  28966. * @param name defines the name of the mesh to create
  28967. * @param width set the width of the ground
  28968. * @param height set the height of the ground
  28969. * @param subdivisions sets the number of subdivisions per side
  28970. * @param scene defines the hosting scene
  28971. * @param updatable defines if the mesh must be flagged as updatable
  28972. * @returns a new Mesh
  28973. */
  28974. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  28975. /**
  28976. * Creates a tiled ground mesh.
  28977. * Please consider using the same method from the MeshBuilder class instead
  28978. * @param name defines the name of the mesh to create
  28979. * @param xmin set the ground minimum X coordinate
  28980. * @param zmin set the ground minimum Y coordinate
  28981. * @param xmax set the ground maximum X coordinate
  28982. * @param zmax set the ground maximum Z coordinate
  28983. * @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
  28984. * @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
  28985. * @param scene defines the hosting scene
  28986. * @param updatable defines if the mesh must be flagged as updatable
  28987. * @returns a new Mesh
  28988. */
  28989. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  28990. w: number;
  28991. h: number;
  28992. }, precision: {
  28993. w: number;
  28994. h: number;
  28995. }, scene: Scene, updatable?: boolean): Mesh;
  28996. /**
  28997. * Creates a ground mesh from a height map.
  28998. * Please consider using the same method from the MeshBuilder class instead
  28999. * @see https://doc.babylonjs.com/babylon101/height_map
  29000. * @param name defines the name of the mesh to create
  29001. * @param url sets the URL of the height map image resource
  29002. * @param width set the ground width size
  29003. * @param height set the ground height size
  29004. * @param subdivisions sets the number of subdivision per side
  29005. * @param minHeight is the minimum altitude on the ground
  29006. * @param maxHeight is the maximum altitude on the ground
  29007. * @param scene defines the hosting scene
  29008. * @param updatable defines if the mesh must be flagged as updatable
  29009. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  29010. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  29011. * @returns a new Mesh
  29012. */
  29013. 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;
  29014. /**
  29015. * Creates a tube mesh.
  29016. * The tube is a parametric shape.
  29017. * It has no predefined shape. Its final shape will depend on the input parameters.
  29018. * Please consider using the same method from the MeshBuilder class instead
  29019. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29020. * @param name defines the name of the mesh to create
  29021. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  29022. * @param radius sets the tube radius size
  29023. * @param tessellation is the number of sides on the tubular surface
  29024. * @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
  29025. * @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
  29026. * @param scene defines the hosting scene
  29027. * @param updatable defines if the mesh must be flagged as updatable
  29028. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29029. * @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)
  29030. * @returns a new Mesh
  29031. */
  29032. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  29033. (i: number, distance: number): number;
  29034. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29035. /**
  29036. * Creates a polyhedron mesh.
  29037. * Please consider using the same method from the MeshBuilder class instead.
  29038. * * 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
  29039. * * The parameter `size` (positive float, default 1) sets the polygon size
  29040. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  29041. * * 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`
  29042. * * 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
  29043. * * 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)`)
  29044. * * 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
  29045. * * 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
  29046. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29047. * * 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
  29048. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29049. * @param name defines the name of the mesh to create
  29050. * @param options defines the options used to create the mesh
  29051. * @param scene defines the hosting scene
  29052. * @returns a new Mesh
  29053. */
  29054. static CreatePolyhedron(name: string, options: {
  29055. type?: number;
  29056. size?: number;
  29057. sizeX?: number;
  29058. sizeY?: number;
  29059. sizeZ?: number;
  29060. custom?: any;
  29061. faceUV?: Vector4[];
  29062. faceColors?: Color4[];
  29063. updatable?: boolean;
  29064. sideOrientation?: number;
  29065. }, scene: Scene): Mesh;
  29066. /**
  29067. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  29068. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  29069. * * 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`)
  29070. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  29071. * * 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
  29072. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29073. * * 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
  29074. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29075. * @param name defines the name of the mesh
  29076. * @param options defines the options used to create the mesh
  29077. * @param scene defines the hosting scene
  29078. * @returns a new Mesh
  29079. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  29080. */
  29081. static CreateIcoSphere(name: string, options: {
  29082. radius?: number;
  29083. flat?: boolean;
  29084. subdivisions?: number;
  29085. sideOrientation?: number;
  29086. updatable?: boolean;
  29087. }, scene: Scene): Mesh;
  29088. /**
  29089. * Creates a decal mesh.
  29090. * Please consider using the same method from the MeshBuilder class instead.
  29091. * A decal is a mesh usually applied as a model onto the surface of another mesh
  29092. * @param name defines the name of the mesh
  29093. * @param sourceMesh defines the mesh receiving the decal
  29094. * @param position sets the position of the decal in world coordinates
  29095. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  29096. * @param size sets the decal scaling
  29097. * @param angle sets the angle to rotate the decal
  29098. * @returns a new Mesh
  29099. */
  29100. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  29101. /**
  29102. * Prepare internal position array for software CPU skinning
  29103. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  29104. */
  29105. setPositionsForCPUSkinning(): Float32Array;
  29106. /**
  29107. * Prepare internal normal array for software CPU skinning
  29108. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  29109. */
  29110. setNormalsForCPUSkinning(): Float32Array;
  29111. /**
  29112. * Updates the vertex buffer by applying transformation from the bones
  29113. * @param skeleton defines the skeleton to apply to current mesh
  29114. * @returns the current mesh
  29115. */
  29116. applySkeleton(skeleton: Skeleton): Mesh;
  29117. /**
  29118. * 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
  29119. * @param meshes defines the list of meshes to scan
  29120. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  29121. */
  29122. static MinMax(meshes: AbstractMesh[]): {
  29123. min: Vector3;
  29124. max: Vector3;
  29125. };
  29126. /**
  29127. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  29128. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  29129. * @returns a vector3
  29130. */
  29131. static Center(meshesOrMinMaxVector: {
  29132. min: Vector3;
  29133. max: Vector3;
  29134. } | AbstractMesh[]): Vector3;
  29135. /**
  29136. * Merge the array of meshes into a single mesh for performance reasons.
  29137. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  29138. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  29139. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  29140. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  29141. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  29142. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  29143. * @returns a new mesh
  29144. */
  29145. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  29146. /** @hidden */
  29147. addInstance(instance: InstancedMesh): void;
  29148. /** @hidden */
  29149. removeInstance(instance: InstancedMesh): void;
  29150. }
  29151. }
  29152. declare module BABYLON {
  29153. /**
  29154. * This is the base class of all the camera used in the application.
  29155. * @see https://doc.babylonjs.com/features/cameras
  29156. */
  29157. export class Camera extends Node {
  29158. /** @hidden */
  29159. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29160. /**
  29161. * This is the default projection mode used by the cameras.
  29162. * It helps recreating a feeling of perspective and better appreciate depth.
  29163. * This is the best way to simulate real life cameras.
  29164. */
  29165. static readonly PERSPECTIVE_CAMERA: number;
  29166. /**
  29167. * This helps creating camera with an orthographic mode.
  29168. * 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.
  29169. */
  29170. static readonly ORTHOGRAPHIC_CAMERA: number;
  29171. /**
  29172. * This is the default FOV mode for perspective cameras.
  29173. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29174. */
  29175. static readonly FOVMODE_VERTICAL_FIXED: number;
  29176. /**
  29177. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29178. */
  29179. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29180. /**
  29181. * This specifies ther is no need for a camera rig.
  29182. * Basically only one eye is rendered corresponding to the camera.
  29183. */
  29184. static readonly RIG_MODE_NONE: number;
  29185. /**
  29186. * Simulates a camera Rig with one blue eye and one red eye.
  29187. * This can be use with 3d blue and red glasses.
  29188. */
  29189. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29190. /**
  29191. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29192. */
  29193. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29194. /**
  29195. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29196. */
  29197. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29198. /**
  29199. * Defines that both eyes of the camera will be rendered over under each other.
  29200. */
  29201. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29202. /**
  29203. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  29204. */
  29205. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  29206. /**
  29207. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29208. */
  29209. static readonly RIG_MODE_VR: number;
  29210. /**
  29211. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29212. */
  29213. static readonly RIG_MODE_WEBVR: number;
  29214. /**
  29215. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29216. */
  29217. static readonly RIG_MODE_CUSTOM: number;
  29218. /**
  29219. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29220. */
  29221. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29222. /**
  29223. * Define the input manager associated with the camera.
  29224. */
  29225. inputs: CameraInputsManager<Camera>;
  29226. /** @hidden */
  29227. _position: Vector3;
  29228. /**
  29229. * Define the current local position of the camera in the scene
  29230. */
  29231. get position(): Vector3;
  29232. set position(newPosition: Vector3);
  29233. /**
  29234. * The vector the camera should consider as up.
  29235. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29236. */
  29237. upVector: Vector3;
  29238. /**
  29239. * Define the current limit on the left side for an orthographic camera
  29240. * In scene unit
  29241. */
  29242. orthoLeft: Nullable<number>;
  29243. /**
  29244. * Define the current limit on the right side for an orthographic camera
  29245. * In scene unit
  29246. */
  29247. orthoRight: Nullable<number>;
  29248. /**
  29249. * Define the current limit on the bottom side for an orthographic camera
  29250. * In scene unit
  29251. */
  29252. orthoBottom: Nullable<number>;
  29253. /**
  29254. * Define the current limit on the top side for an orthographic camera
  29255. * In scene unit
  29256. */
  29257. orthoTop: Nullable<number>;
  29258. /**
  29259. * Field Of View is set in Radians. (default is 0.8)
  29260. */
  29261. fov: number;
  29262. /**
  29263. * Define the minimum distance the camera can see from.
  29264. * This is important to note that the depth buffer are not infinite and the closer it starts
  29265. * the more your scene might encounter depth fighting issue.
  29266. */
  29267. minZ: number;
  29268. /**
  29269. * Define the maximum distance the camera can see to.
  29270. * This is important to note that the depth buffer are not infinite and the further it end
  29271. * the more your scene might encounter depth fighting issue.
  29272. */
  29273. maxZ: number;
  29274. /**
  29275. * Define the default inertia of the camera.
  29276. * This helps giving a smooth feeling to the camera movement.
  29277. */
  29278. inertia: number;
  29279. /**
  29280. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  29281. */
  29282. mode: number;
  29283. /**
  29284. * Define whether the camera is intermediate.
  29285. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29286. */
  29287. isIntermediate: boolean;
  29288. /**
  29289. * Define the viewport of the camera.
  29290. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29291. */
  29292. viewport: Viewport;
  29293. /**
  29294. * Restricts the camera to viewing objects with the same layerMask.
  29295. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29296. */
  29297. layerMask: number;
  29298. /**
  29299. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29300. */
  29301. fovMode: number;
  29302. /**
  29303. * Rig mode of the camera.
  29304. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29305. * This is normally controlled byt the camera themselves as internal use.
  29306. */
  29307. cameraRigMode: number;
  29308. /**
  29309. * Defines the distance between both "eyes" in case of a RIG
  29310. */
  29311. interaxialDistance: number;
  29312. /**
  29313. * Defines if stereoscopic rendering is done side by side or over under.
  29314. */
  29315. isStereoscopicSideBySide: boolean;
  29316. /**
  29317. * 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
  29318. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29319. * else in the scene. (Eg. security camera)
  29320. *
  29321. * 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)
  29322. */
  29323. customRenderTargets: RenderTargetTexture[];
  29324. /**
  29325. * When set, the camera will render to this render target instead of the default canvas
  29326. *
  29327. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  29328. */
  29329. outputRenderTarget: Nullable<RenderTargetTexture>;
  29330. /**
  29331. * Observable triggered when the camera view matrix has changed.
  29332. */
  29333. onViewMatrixChangedObservable: Observable<Camera>;
  29334. /**
  29335. * Observable triggered when the camera Projection matrix has changed.
  29336. */
  29337. onProjectionMatrixChangedObservable: Observable<Camera>;
  29338. /**
  29339. * Observable triggered when the inputs have been processed.
  29340. */
  29341. onAfterCheckInputsObservable: Observable<Camera>;
  29342. /**
  29343. * Observable triggered when reset has been called and applied to the camera.
  29344. */
  29345. onRestoreStateObservable: Observable<Camera>;
  29346. /**
  29347. * Is this camera a part of a rig system?
  29348. */
  29349. isRigCamera: boolean;
  29350. /**
  29351. * If isRigCamera set to true this will be set with the parent camera.
  29352. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  29353. */
  29354. rigParent?: Camera;
  29355. /** @hidden */
  29356. _cameraRigParams: any;
  29357. /** @hidden */
  29358. _rigCameras: Camera[];
  29359. /** @hidden */
  29360. _rigPostProcess: Nullable<PostProcess>;
  29361. protected _webvrViewMatrix: Matrix;
  29362. /** @hidden */
  29363. _skipRendering: boolean;
  29364. /** @hidden */
  29365. _projectionMatrix: Matrix;
  29366. /** @hidden */
  29367. _postProcesses: Nullable<PostProcess>[];
  29368. /** @hidden */
  29369. _activeMeshes: SmartArray<AbstractMesh>;
  29370. protected _globalPosition: Vector3;
  29371. /** @hidden */
  29372. _computedViewMatrix: Matrix;
  29373. private _doNotComputeProjectionMatrix;
  29374. private _transformMatrix;
  29375. private _frustumPlanes;
  29376. private _refreshFrustumPlanes;
  29377. private _storedFov;
  29378. private _stateStored;
  29379. /**
  29380. * Instantiates a new camera object.
  29381. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29382. * @see https://doc.babylonjs.com/features/cameras
  29383. * @param name Defines the name of the camera in the scene
  29384. * @param position Defines the position of the camera
  29385. * @param scene Defines the scene the camera belongs too
  29386. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29387. */
  29388. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29389. /**
  29390. * Store current camera state (fov, position, etc..)
  29391. * @returns the camera
  29392. */
  29393. storeState(): Camera;
  29394. /**
  29395. * Restores the camera state values if it has been stored. You must call storeState() first
  29396. */
  29397. protected _restoreStateValues(): boolean;
  29398. /**
  29399. * Restored camera state. You must call storeState() first.
  29400. * @returns true if restored and false otherwise
  29401. */
  29402. restoreState(): boolean;
  29403. /**
  29404. * Gets the class name of the camera.
  29405. * @returns the class name
  29406. */
  29407. getClassName(): string;
  29408. /** @hidden */
  29409. readonly _isCamera: boolean;
  29410. /**
  29411. * Gets a string representation of the camera useful for debug purpose.
  29412. * @param fullDetails Defines that a more verboe level of logging is required
  29413. * @returns the string representation
  29414. */
  29415. toString(fullDetails?: boolean): string;
  29416. /**
  29417. * Gets the current world space position of the camera.
  29418. */
  29419. get globalPosition(): Vector3;
  29420. /**
  29421. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29422. * @returns the active meshe list
  29423. */
  29424. getActiveMeshes(): SmartArray<AbstractMesh>;
  29425. /**
  29426. * Check whether a mesh is part of the current active mesh list of the camera
  29427. * @param mesh Defines the mesh to check
  29428. * @returns true if active, false otherwise
  29429. */
  29430. isActiveMesh(mesh: Mesh): boolean;
  29431. /**
  29432. * Is this camera ready to be used/rendered
  29433. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29434. * @return true if the camera is ready
  29435. */
  29436. isReady(completeCheck?: boolean): boolean;
  29437. /** @hidden */
  29438. _initCache(): void;
  29439. /** @hidden */
  29440. _updateCache(ignoreParentClass?: boolean): void;
  29441. /** @hidden */
  29442. _isSynchronized(): boolean;
  29443. /** @hidden */
  29444. _isSynchronizedViewMatrix(): boolean;
  29445. /** @hidden */
  29446. _isSynchronizedProjectionMatrix(): boolean;
  29447. /**
  29448. * Attach the input controls to a specific dom element to get the input from.
  29449. * @param element Defines the element the controls should be listened from
  29450. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29451. */
  29452. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29453. /**
  29454. * Detach the current controls from the specified dom element.
  29455. * @param element Defines the element to stop listening the inputs from
  29456. */
  29457. detachControl(element: HTMLElement): void;
  29458. /**
  29459. * Update the camera state according to the different inputs gathered during the frame.
  29460. */
  29461. update(): void;
  29462. /** @hidden */
  29463. _checkInputs(): void;
  29464. /** @hidden */
  29465. get rigCameras(): Camera[];
  29466. /**
  29467. * Gets the post process used by the rig cameras
  29468. */
  29469. get rigPostProcess(): Nullable<PostProcess>;
  29470. /**
  29471. * Internal, gets the first post proces.
  29472. * @returns the first post process to be run on this camera.
  29473. */
  29474. _getFirstPostProcess(): Nullable<PostProcess>;
  29475. private _cascadePostProcessesToRigCams;
  29476. /**
  29477. * Attach a post process to the camera.
  29478. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29479. * @param postProcess The post process to attach to the camera
  29480. * @param insertAt The position of the post process in case several of them are in use in the scene
  29481. * @returns the position the post process has been inserted at
  29482. */
  29483. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29484. /**
  29485. * Detach a post process to the camera.
  29486. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29487. * @param postProcess The post process to detach from the camera
  29488. */
  29489. detachPostProcess(postProcess: PostProcess): void;
  29490. /**
  29491. * Gets the current world matrix of the camera
  29492. */
  29493. getWorldMatrix(): Matrix;
  29494. /** @hidden */
  29495. _getViewMatrix(): Matrix;
  29496. /**
  29497. * Gets the current view matrix of the camera.
  29498. * @param force forces the camera to recompute the matrix without looking at the cached state
  29499. * @returns the view matrix
  29500. */
  29501. getViewMatrix(force?: boolean): Matrix;
  29502. /**
  29503. * Freeze the projection matrix.
  29504. * It will prevent the cache check of the camera projection compute and can speed up perf
  29505. * if no parameter of the camera are meant to change
  29506. * @param projection Defines manually a projection if necessary
  29507. */
  29508. freezeProjectionMatrix(projection?: Matrix): void;
  29509. /**
  29510. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29511. */
  29512. unfreezeProjectionMatrix(): void;
  29513. /**
  29514. * Gets the current projection matrix of the camera.
  29515. * @param force forces the camera to recompute the matrix without looking at the cached state
  29516. * @returns the projection matrix
  29517. */
  29518. getProjectionMatrix(force?: boolean): Matrix;
  29519. /**
  29520. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29521. * @returns a Matrix
  29522. */
  29523. getTransformationMatrix(): Matrix;
  29524. private _updateFrustumPlanes;
  29525. /**
  29526. * Checks if a cullable object (mesh...) is in the camera frustum
  29527. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29528. * @param target The object to check
  29529. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  29530. * @returns true if the object is in frustum otherwise false
  29531. */
  29532. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  29533. /**
  29534. * Checks if a cullable object (mesh...) is in the camera frustum
  29535. * Unlike isInFrustum this cheks the full bounding box
  29536. * @param target The object to check
  29537. * @returns true if the object is in frustum otherwise false
  29538. */
  29539. isCompletelyInFrustum(target: ICullable): boolean;
  29540. /**
  29541. * Gets a ray in the forward direction from the camera.
  29542. * @param length Defines the length of the ray to create
  29543. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29544. * @param origin Defines the start point of the ray which defaults to the camera position
  29545. * @returns the forward ray
  29546. */
  29547. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29548. /**
  29549. * Gets a ray in the forward direction from the camera.
  29550. * @param refRay the ray to (re)use when setting the values
  29551. * @param length Defines the length of the ray to create
  29552. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29553. * @param origin Defines the start point of the ray which defaults to the camera position
  29554. * @returns the forward ray
  29555. */
  29556. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29557. /**
  29558. * Releases resources associated with this node.
  29559. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29560. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29561. */
  29562. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29563. /** @hidden */
  29564. _isLeftCamera: boolean;
  29565. /**
  29566. * Gets the left camera of a rig setup in case of Rigged Camera
  29567. */
  29568. get isLeftCamera(): boolean;
  29569. /** @hidden */
  29570. _isRightCamera: boolean;
  29571. /**
  29572. * Gets the right camera of a rig setup in case of Rigged Camera
  29573. */
  29574. get isRightCamera(): boolean;
  29575. /**
  29576. * Gets the left camera of a rig setup in case of Rigged Camera
  29577. */
  29578. get leftCamera(): Nullable<FreeCamera>;
  29579. /**
  29580. * Gets the right camera of a rig setup in case of Rigged Camera
  29581. */
  29582. get rightCamera(): Nullable<FreeCamera>;
  29583. /**
  29584. * Gets the left camera target of a rig setup in case of Rigged Camera
  29585. * @returns the target position
  29586. */
  29587. getLeftTarget(): Nullable<Vector3>;
  29588. /**
  29589. * Gets the right camera target of a rig setup in case of Rigged Camera
  29590. * @returns the target position
  29591. */
  29592. getRightTarget(): Nullable<Vector3>;
  29593. /**
  29594. * @hidden
  29595. */
  29596. setCameraRigMode(mode: number, rigParams: any): void;
  29597. /** @hidden */
  29598. static _setStereoscopicRigMode(camera: Camera): void;
  29599. /** @hidden */
  29600. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29601. /** @hidden */
  29602. static _setVRRigMode(camera: Camera, rigParams: any): void;
  29603. /** @hidden */
  29604. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29605. /** @hidden */
  29606. _getVRProjectionMatrix(): Matrix;
  29607. protected _updateCameraRotationMatrix(): void;
  29608. protected _updateWebVRCameraRotationMatrix(): void;
  29609. /**
  29610. * This function MUST be overwritten by the different WebVR cameras available.
  29611. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29612. * @hidden
  29613. */
  29614. _getWebVRProjectionMatrix(): Matrix;
  29615. /**
  29616. * This function MUST be overwritten by the different WebVR cameras available.
  29617. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29618. * @hidden
  29619. */
  29620. _getWebVRViewMatrix(): Matrix;
  29621. /** @hidden */
  29622. setCameraRigParameter(name: string, value: any): void;
  29623. /**
  29624. * needs to be overridden by children so sub has required properties to be copied
  29625. * @hidden
  29626. */
  29627. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29628. /**
  29629. * May need to be overridden by children
  29630. * @hidden
  29631. */
  29632. _updateRigCameras(): void;
  29633. /** @hidden */
  29634. _setupInputs(): void;
  29635. /**
  29636. * Serialiaze the camera setup to a json represention
  29637. * @returns the JSON representation
  29638. */
  29639. serialize(): any;
  29640. /**
  29641. * Clones the current camera.
  29642. * @param name The cloned camera name
  29643. * @returns the cloned camera
  29644. */
  29645. clone(name: string): Camera;
  29646. /**
  29647. * Gets the direction of the camera relative to a given local axis.
  29648. * @param localAxis Defines the reference axis to provide a relative direction.
  29649. * @return the direction
  29650. */
  29651. getDirection(localAxis: Vector3): Vector3;
  29652. /**
  29653. * Returns the current camera absolute rotation
  29654. */
  29655. get absoluteRotation(): Quaternion;
  29656. /**
  29657. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29658. * @param localAxis Defines the reference axis to provide a relative direction.
  29659. * @param result Defines the vector to store the result in
  29660. */
  29661. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29662. /**
  29663. * Gets a camera constructor for a given camera type
  29664. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29665. * @param name The name of the camera the result will be able to instantiate
  29666. * @param scene The scene the result will construct the camera in
  29667. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29668. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29669. * @returns a factory method to construc the camera
  29670. */
  29671. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29672. /**
  29673. * Compute the world matrix of the camera.
  29674. * @returns the camera world matrix
  29675. */
  29676. computeWorldMatrix(): Matrix;
  29677. /**
  29678. * Parse a JSON and creates the camera from the parsed information
  29679. * @param parsedCamera The JSON to parse
  29680. * @param scene The scene to instantiate the camera in
  29681. * @returns the newly constructed camera
  29682. */
  29683. static Parse(parsedCamera: any, scene: Scene): Camera;
  29684. }
  29685. }
  29686. declare module BABYLON {
  29687. /**
  29688. * Class containing static functions to help procedurally build meshes
  29689. */
  29690. export class DiscBuilder {
  29691. /**
  29692. * Creates a plane polygonal mesh. By default, this is a disc
  29693. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  29694. * * 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
  29695. * * 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
  29696. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29697. * * 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
  29698. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29699. * @param name defines the name of the mesh
  29700. * @param options defines the options used to create the mesh
  29701. * @param scene defines the hosting scene
  29702. * @returns the plane polygonal mesh
  29703. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  29704. */
  29705. static CreateDisc(name: string, options: {
  29706. radius?: number;
  29707. tessellation?: number;
  29708. arc?: number;
  29709. updatable?: boolean;
  29710. sideOrientation?: number;
  29711. frontUVs?: Vector4;
  29712. backUVs?: Vector4;
  29713. }, scene?: Nullable<Scene>): Mesh;
  29714. }
  29715. }
  29716. declare module BABYLON {
  29717. /**
  29718. * Options to be used when creating a FresnelParameters.
  29719. */
  29720. export type IFresnelParametersCreationOptions = {
  29721. /**
  29722. * Define the color used on edges (grazing angle)
  29723. */
  29724. leftColor?: Color3;
  29725. /**
  29726. * Define the color used on center
  29727. */
  29728. rightColor?: Color3;
  29729. /**
  29730. * Define bias applied to computed fresnel term
  29731. */
  29732. bias?: number;
  29733. /**
  29734. * Defined the power exponent applied to fresnel term
  29735. */
  29736. power?: number;
  29737. /**
  29738. * Define if the fresnel effect is enable or not.
  29739. */
  29740. isEnabled?: boolean;
  29741. };
  29742. /**
  29743. * Serialized format for FresnelParameters.
  29744. */
  29745. export type IFresnelParametersSerialized = {
  29746. /**
  29747. * Define the color used on edges (grazing angle) [as an array]
  29748. */
  29749. leftColor: number[];
  29750. /**
  29751. * Define the color used on center [as an array]
  29752. */
  29753. rightColor: number[];
  29754. /**
  29755. * Define bias applied to computed fresnel term
  29756. */
  29757. bias: number;
  29758. /**
  29759. * Defined the power exponent applied to fresnel term
  29760. */
  29761. power?: number;
  29762. /**
  29763. * Define if the fresnel effect is enable or not.
  29764. */
  29765. isEnabled: boolean;
  29766. };
  29767. /**
  29768. * This represents all the required information to add a fresnel effect on a material:
  29769. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29770. */
  29771. export class FresnelParameters {
  29772. private _isEnabled;
  29773. /**
  29774. * Define if the fresnel effect is enable or not.
  29775. */
  29776. get isEnabled(): boolean;
  29777. set isEnabled(value: boolean);
  29778. /**
  29779. * Define the color used on edges (grazing angle)
  29780. */
  29781. leftColor: Color3;
  29782. /**
  29783. * Define the color used on center
  29784. */
  29785. rightColor: Color3;
  29786. /**
  29787. * Define bias applied to computed fresnel term
  29788. */
  29789. bias: number;
  29790. /**
  29791. * Defined the power exponent applied to fresnel term
  29792. */
  29793. power: number;
  29794. /**
  29795. * Creates a new FresnelParameters object.
  29796. *
  29797. * @param options provide your own settings to optionally to override defaults
  29798. */
  29799. constructor(options?: IFresnelParametersCreationOptions);
  29800. /**
  29801. * Clones the current fresnel and its valuues
  29802. * @returns a clone fresnel configuration
  29803. */
  29804. clone(): FresnelParameters;
  29805. /**
  29806. * Determines equality between FresnelParameters objects
  29807. * @param otherFresnelParameters defines the second operand
  29808. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  29809. */
  29810. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  29811. /**
  29812. * Serializes the current fresnel parameters to a JSON representation.
  29813. * @return the JSON serialization
  29814. */
  29815. serialize(): IFresnelParametersSerialized;
  29816. /**
  29817. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29818. * @param parsedFresnelParameters Define the JSON representation
  29819. * @returns the parsed parameters
  29820. */
  29821. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  29822. }
  29823. }
  29824. declare module BABYLON {
  29825. /**
  29826. * This groups all the flags used to control the materials channel.
  29827. */
  29828. export class MaterialFlags {
  29829. private static _DiffuseTextureEnabled;
  29830. /**
  29831. * Are diffuse textures enabled in the application.
  29832. */
  29833. static get DiffuseTextureEnabled(): boolean;
  29834. static set DiffuseTextureEnabled(value: boolean);
  29835. private static _DetailTextureEnabled;
  29836. /**
  29837. * Are detail textures enabled in the application.
  29838. */
  29839. static get DetailTextureEnabled(): boolean;
  29840. static set DetailTextureEnabled(value: boolean);
  29841. private static _AmbientTextureEnabled;
  29842. /**
  29843. * Are ambient textures enabled in the application.
  29844. */
  29845. static get AmbientTextureEnabled(): boolean;
  29846. static set AmbientTextureEnabled(value: boolean);
  29847. private static _OpacityTextureEnabled;
  29848. /**
  29849. * Are opacity textures enabled in the application.
  29850. */
  29851. static get OpacityTextureEnabled(): boolean;
  29852. static set OpacityTextureEnabled(value: boolean);
  29853. private static _ReflectionTextureEnabled;
  29854. /**
  29855. * Are reflection textures enabled in the application.
  29856. */
  29857. static get ReflectionTextureEnabled(): boolean;
  29858. static set ReflectionTextureEnabled(value: boolean);
  29859. private static _EmissiveTextureEnabled;
  29860. /**
  29861. * Are emissive textures enabled in the application.
  29862. */
  29863. static get EmissiveTextureEnabled(): boolean;
  29864. static set EmissiveTextureEnabled(value: boolean);
  29865. private static _SpecularTextureEnabled;
  29866. /**
  29867. * Are specular textures enabled in the application.
  29868. */
  29869. static get SpecularTextureEnabled(): boolean;
  29870. static set SpecularTextureEnabled(value: boolean);
  29871. private static _BumpTextureEnabled;
  29872. /**
  29873. * Are bump textures enabled in the application.
  29874. */
  29875. static get BumpTextureEnabled(): boolean;
  29876. static set BumpTextureEnabled(value: boolean);
  29877. private static _LightmapTextureEnabled;
  29878. /**
  29879. * Are lightmap textures enabled in the application.
  29880. */
  29881. static get LightmapTextureEnabled(): boolean;
  29882. static set LightmapTextureEnabled(value: boolean);
  29883. private static _RefractionTextureEnabled;
  29884. /**
  29885. * Are refraction textures enabled in the application.
  29886. */
  29887. static get RefractionTextureEnabled(): boolean;
  29888. static set RefractionTextureEnabled(value: boolean);
  29889. private static _ColorGradingTextureEnabled;
  29890. /**
  29891. * Are color grading textures enabled in the application.
  29892. */
  29893. static get ColorGradingTextureEnabled(): boolean;
  29894. static set ColorGradingTextureEnabled(value: boolean);
  29895. private static _FresnelEnabled;
  29896. /**
  29897. * Are fresnels enabled in the application.
  29898. */
  29899. static get FresnelEnabled(): boolean;
  29900. static set FresnelEnabled(value: boolean);
  29901. private static _ClearCoatTextureEnabled;
  29902. /**
  29903. * Are clear coat textures enabled in the application.
  29904. */
  29905. static get ClearCoatTextureEnabled(): boolean;
  29906. static set ClearCoatTextureEnabled(value: boolean);
  29907. private static _ClearCoatBumpTextureEnabled;
  29908. /**
  29909. * Are clear coat bump textures enabled in the application.
  29910. */
  29911. static get ClearCoatBumpTextureEnabled(): boolean;
  29912. static set ClearCoatBumpTextureEnabled(value: boolean);
  29913. private static _ClearCoatTintTextureEnabled;
  29914. /**
  29915. * Are clear coat tint textures enabled in the application.
  29916. */
  29917. static get ClearCoatTintTextureEnabled(): boolean;
  29918. static set ClearCoatTintTextureEnabled(value: boolean);
  29919. private static _SheenTextureEnabled;
  29920. /**
  29921. * Are sheen textures enabled in the application.
  29922. */
  29923. static get SheenTextureEnabled(): boolean;
  29924. static set SheenTextureEnabled(value: boolean);
  29925. private static _AnisotropicTextureEnabled;
  29926. /**
  29927. * Are anisotropic textures enabled in the application.
  29928. */
  29929. static get AnisotropicTextureEnabled(): boolean;
  29930. static set AnisotropicTextureEnabled(value: boolean);
  29931. private static _ThicknessTextureEnabled;
  29932. /**
  29933. * Are thickness textures enabled in the application.
  29934. */
  29935. static get ThicknessTextureEnabled(): boolean;
  29936. static set ThicknessTextureEnabled(value: boolean);
  29937. }
  29938. }
  29939. declare module BABYLON {
  29940. /** @hidden */
  29941. export var defaultFragmentDeclaration: {
  29942. name: string;
  29943. shader: string;
  29944. };
  29945. }
  29946. declare module BABYLON {
  29947. /** @hidden */
  29948. export var defaultUboDeclaration: {
  29949. name: string;
  29950. shader: string;
  29951. };
  29952. }
  29953. declare module BABYLON {
  29954. /** @hidden */
  29955. export var prePassDeclaration: {
  29956. name: string;
  29957. shader: string;
  29958. };
  29959. }
  29960. declare module BABYLON {
  29961. /** @hidden */
  29962. export var lightFragmentDeclaration: {
  29963. name: string;
  29964. shader: string;
  29965. };
  29966. }
  29967. declare module BABYLON {
  29968. /** @hidden */
  29969. export var lightUboDeclaration: {
  29970. name: string;
  29971. shader: string;
  29972. };
  29973. }
  29974. declare module BABYLON {
  29975. /** @hidden */
  29976. export var lightsFragmentFunctions: {
  29977. name: string;
  29978. shader: string;
  29979. };
  29980. }
  29981. declare module BABYLON {
  29982. /** @hidden */
  29983. export var shadowsFragmentFunctions: {
  29984. name: string;
  29985. shader: string;
  29986. };
  29987. }
  29988. declare module BABYLON {
  29989. /** @hidden */
  29990. export var fresnelFunction: {
  29991. name: string;
  29992. shader: string;
  29993. };
  29994. }
  29995. declare module BABYLON {
  29996. /** @hidden */
  29997. export var bumpFragmentMainFunctions: {
  29998. name: string;
  29999. shader: string;
  30000. };
  30001. }
  30002. declare module BABYLON {
  30003. /** @hidden */
  30004. export var bumpFragmentFunctions: {
  30005. name: string;
  30006. shader: string;
  30007. };
  30008. }
  30009. declare module BABYLON {
  30010. /** @hidden */
  30011. export var logDepthDeclaration: {
  30012. name: string;
  30013. shader: string;
  30014. };
  30015. }
  30016. declare module BABYLON {
  30017. /** @hidden */
  30018. export var bumpFragment: {
  30019. name: string;
  30020. shader: string;
  30021. };
  30022. }
  30023. declare module BABYLON {
  30024. /** @hidden */
  30025. export var depthPrePass: {
  30026. name: string;
  30027. shader: string;
  30028. };
  30029. }
  30030. declare module BABYLON {
  30031. /** @hidden */
  30032. export var lightFragment: {
  30033. name: string;
  30034. shader: string;
  30035. };
  30036. }
  30037. declare module BABYLON {
  30038. /** @hidden */
  30039. export var logDepthFragment: {
  30040. name: string;
  30041. shader: string;
  30042. };
  30043. }
  30044. declare module BABYLON {
  30045. /** @hidden */
  30046. export var defaultPixelShader: {
  30047. name: string;
  30048. shader: string;
  30049. };
  30050. }
  30051. declare module BABYLON {
  30052. /** @hidden */
  30053. export var defaultVertexDeclaration: {
  30054. name: string;
  30055. shader: string;
  30056. };
  30057. }
  30058. declare module BABYLON {
  30059. /** @hidden */
  30060. export var bumpVertexDeclaration: {
  30061. name: string;
  30062. shader: string;
  30063. };
  30064. }
  30065. declare module BABYLON {
  30066. /** @hidden */
  30067. export var bumpVertex: {
  30068. name: string;
  30069. shader: string;
  30070. };
  30071. }
  30072. declare module BABYLON {
  30073. /** @hidden */
  30074. export var fogVertex: {
  30075. name: string;
  30076. shader: string;
  30077. };
  30078. }
  30079. declare module BABYLON {
  30080. /** @hidden */
  30081. export var shadowsVertex: {
  30082. name: string;
  30083. shader: string;
  30084. };
  30085. }
  30086. declare module BABYLON {
  30087. /** @hidden */
  30088. export var pointCloudVertex: {
  30089. name: string;
  30090. shader: string;
  30091. };
  30092. }
  30093. declare module BABYLON {
  30094. /** @hidden */
  30095. export var logDepthVertex: {
  30096. name: string;
  30097. shader: string;
  30098. };
  30099. }
  30100. declare module BABYLON {
  30101. /** @hidden */
  30102. export var defaultVertexShader: {
  30103. name: string;
  30104. shader: string;
  30105. };
  30106. }
  30107. declare module BABYLON {
  30108. /**
  30109. * @hidden
  30110. */
  30111. export interface IMaterialDetailMapDefines {
  30112. DETAIL: boolean;
  30113. DETAILDIRECTUV: number;
  30114. DETAIL_NORMALBLENDMETHOD: number;
  30115. /** @hidden */
  30116. _areTexturesDirty: boolean;
  30117. }
  30118. /**
  30119. * Define the code related to the detail map parameters of a material
  30120. *
  30121. * Inspired from:
  30122. * 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
  30123. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  30124. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  30125. */
  30126. export class DetailMapConfiguration {
  30127. private _texture;
  30128. /**
  30129. * The detail texture of the material.
  30130. */
  30131. texture: Nullable<BaseTexture>;
  30132. /**
  30133. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  30134. * Bigger values mean stronger blending
  30135. */
  30136. diffuseBlendLevel: number;
  30137. /**
  30138. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  30139. * Bigger values mean stronger blending. Only used with PBR materials
  30140. */
  30141. roughnessBlendLevel: number;
  30142. /**
  30143. * Defines how strong the bump effect from the detail map is
  30144. * Bigger values mean stronger effect
  30145. */
  30146. bumpLevel: number;
  30147. private _normalBlendMethod;
  30148. /**
  30149. * The method used to blend the bump and detail normals together
  30150. */
  30151. normalBlendMethod: number;
  30152. private _isEnabled;
  30153. /**
  30154. * Enable or disable the detail map on this material
  30155. */
  30156. isEnabled: boolean;
  30157. /** @hidden */
  30158. private _internalMarkAllSubMeshesAsTexturesDirty;
  30159. /** @hidden */
  30160. _markAllSubMeshesAsTexturesDirty(): void;
  30161. /**
  30162. * Instantiate a new detail map
  30163. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  30164. */
  30165. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  30166. /**
  30167. * Gets whether the submesh is ready to be used or not.
  30168. * @param defines the list of "defines" to update.
  30169. * @param scene defines the scene the material belongs to.
  30170. * @returns - boolean indicating that the submesh is ready or not.
  30171. */
  30172. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  30173. /**
  30174. * Update the defines for detail map usage
  30175. * @param defines the list of "defines" to update.
  30176. * @param scene defines the scene the material belongs to.
  30177. */
  30178. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  30179. /**
  30180. * Binds the material data.
  30181. * @param uniformBuffer defines the Uniform buffer to fill in.
  30182. * @param scene defines the scene the material belongs to.
  30183. * @param isFrozen defines whether the material is frozen or not.
  30184. */
  30185. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  30186. /**
  30187. * Checks to see if a texture is used in the material.
  30188. * @param texture - Base texture to use.
  30189. * @returns - Boolean specifying if a texture is used in the material.
  30190. */
  30191. hasTexture(texture: BaseTexture): boolean;
  30192. /**
  30193. * Returns an array of the actively used textures.
  30194. * @param activeTextures Array of BaseTextures
  30195. */
  30196. getActiveTextures(activeTextures: BaseTexture[]): void;
  30197. /**
  30198. * Returns the animatable textures.
  30199. * @param animatables Array of animatable textures.
  30200. */
  30201. getAnimatables(animatables: IAnimatable[]): void;
  30202. /**
  30203. * Disposes the resources of the material.
  30204. * @param forceDisposeTextures - Forces the disposal of all textures.
  30205. */
  30206. dispose(forceDisposeTextures?: boolean): void;
  30207. /**
  30208. * Get the current class name useful for serialization or dynamic coding.
  30209. * @returns "DetailMap"
  30210. */
  30211. getClassName(): string;
  30212. /**
  30213. * Add the required uniforms to the current list.
  30214. * @param uniforms defines the current uniform list.
  30215. */
  30216. static AddUniforms(uniforms: string[]): void;
  30217. /**
  30218. * Add the required samplers to the current list.
  30219. * @param samplers defines the current sampler list.
  30220. */
  30221. static AddSamplers(samplers: string[]): void;
  30222. /**
  30223. * Add the required uniforms to the current buffer.
  30224. * @param uniformBuffer defines the current uniform buffer.
  30225. */
  30226. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  30227. /**
  30228. * Makes a duplicate of the current instance into another one.
  30229. * @param detailMap define the instance where to copy the info
  30230. */
  30231. copyTo(detailMap: DetailMapConfiguration): void;
  30232. /**
  30233. * Serializes this detail map instance
  30234. * @returns - An object with the serialized instance.
  30235. */
  30236. serialize(): any;
  30237. /**
  30238. * Parses a detail map setting from a serialized object.
  30239. * @param source - Serialized object.
  30240. * @param scene Defines the scene we are parsing for
  30241. * @param rootUrl Defines the rootUrl to load from
  30242. */
  30243. parse(source: any, scene: Scene, rootUrl: string): void;
  30244. }
  30245. }
  30246. declare module BABYLON {
  30247. /** @hidden */
  30248. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  30249. MAINUV1: boolean;
  30250. MAINUV2: boolean;
  30251. DIFFUSE: boolean;
  30252. DIFFUSEDIRECTUV: number;
  30253. DETAIL: boolean;
  30254. DETAILDIRECTUV: number;
  30255. DETAIL_NORMALBLENDMETHOD: number;
  30256. AMBIENT: boolean;
  30257. AMBIENTDIRECTUV: number;
  30258. OPACITY: boolean;
  30259. OPACITYDIRECTUV: number;
  30260. OPACITYRGB: boolean;
  30261. REFLECTION: boolean;
  30262. EMISSIVE: boolean;
  30263. EMISSIVEDIRECTUV: number;
  30264. SPECULAR: boolean;
  30265. SPECULARDIRECTUV: number;
  30266. BUMP: boolean;
  30267. BUMPDIRECTUV: number;
  30268. PARALLAX: boolean;
  30269. PARALLAXOCCLUSION: boolean;
  30270. SPECULAROVERALPHA: boolean;
  30271. CLIPPLANE: boolean;
  30272. CLIPPLANE2: boolean;
  30273. CLIPPLANE3: boolean;
  30274. CLIPPLANE4: boolean;
  30275. CLIPPLANE5: boolean;
  30276. CLIPPLANE6: boolean;
  30277. ALPHATEST: boolean;
  30278. DEPTHPREPASS: boolean;
  30279. ALPHAFROMDIFFUSE: boolean;
  30280. POINTSIZE: boolean;
  30281. FOG: boolean;
  30282. SPECULARTERM: boolean;
  30283. DIFFUSEFRESNEL: boolean;
  30284. OPACITYFRESNEL: boolean;
  30285. REFLECTIONFRESNEL: boolean;
  30286. REFRACTIONFRESNEL: boolean;
  30287. EMISSIVEFRESNEL: boolean;
  30288. FRESNEL: boolean;
  30289. NORMAL: boolean;
  30290. UV1: boolean;
  30291. UV2: boolean;
  30292. VERTEXCOLOR: boolean;
  30293. VERTEXALPHA: boolean;
  30294. NUM_BONE_INFLUENCERS: number;
  30295. BonesPerMesh: number;
  30296. BONETEXTURE: boolean;
  30297. INSTANCES: boolean;
  30298. THIN_INSTANCES: boolean;
  30299. GLOSSINESS: boolean;
  30300. ROUGHNESS: boolean;
  30301. EMISSIVEASILLUMINATION: boolean;
  30302. LINKEMISSIVEWITHDIFFUSE: boolean;
  30303. REFLECTIONFRESNELFROMSPECULAR: boolean;
  30304. LIGHTMAP: boolean;
  30305. LIGHTMAPDIRECTUV: number;
  30306. OBJECTSPACE_NORMALMAP: boolean;
  30307. USELIGHTMAPASSHADOWMAP: boolean;
  30308. REFLECTIONMAP_3D: boolean;
  30309. REFLECTIONMAP_SPHERICAL: boolean;
  30310. REFLECTIONMAP_PLANAR: boolean;
  30311. REFLECTIONMAP_CUBIC: boolean;
  30312. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  30313. REFLECTIONMAP_PROJECTION: boolean;
  30314. REFLECTIONMAP_SKYBOX: boolean;
  30315. REFLECTIONMAP_EXPLICIT: boolean;
  30316. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  30317. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  30318. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  30319. INVERTCUBICMAP: boolean;
  30320. LOGARITHMICDEPTH: boolean;
  30321. REFRACTION: boolean;
  30322. REFRACTIONMAP_3D: boolean;
  30323. REFLECTIONOVERALPHA: boolean;
  30324. TWOSIDEDLIGHTING: boolean;
  30325. SHADOWFLOAT: boolean;
  30326. MORPHTARGETS: boolean;
  30327. MORPHTARGETS_NORMAL: boolean;
  30328. MORPHTARGETS_TANGENT: boolean;
  30329. MORPHTARGETS_UV: boolean;
  30330. NUM_MORPH_INFLUENCERS: number;
  30331. NONUNIFORMSCALING: boolean;
  30332. PREMULTIPLYALPHA: boolean;
  30333. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  30334. ALPHABLEND: boolean;
  30335. PREPASS: boolean;
  30336. SCENE_MRT_COUNT: number;
  30337. RGBDLIGHTMAP: boolean;
  30338. RGBDREFLECTION: boolean;
  30339. RGBDREFRACTION: boolean;
  30340. IMAGEPROCESSING: boolean;
  30341. VIGNETTE: boolean;
  30342. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30343. VIGNETTEBLENDMODEOPAQUE: boolean;
  30344. TONEMAPPING: boolean;
  30345. TONEMAPPING_ACES: boolean;
  30346. CONTRAST: boolean;
  30347. COLORCURVES: boolean;
  30348. COLORGRADING: boolean;
  30349. COLORGRADING3D: boolean;
  30350. SAMPLER3DGREENDEPTH: boolean;
  30351. SAMPLER3DBGRMAP: boolean;
  30352. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30353. MULTIVIEW: boolean;
  30354. /**
  30355. * If the reflection texture on this material is in linear color space
  30356. * @hidden
  30357. */
  30358. IS_REFLECTION_LINEAR: boolean;
  30359. /**
  30360. * If the refraction texture on this material is in linear color space
  30361. * @hidden
  30362. */
  30363. IS_REFRACTION_LINEAR: boolean;
  30364. EXPOSURE: boolean;
  30365. constructor();
  30366. setReflectionMode(modeToEnable: string): void;
  30367. }
  30368. /**
  30369. * This is the default material used in Babylon. It is the best trade off between quality
  30370. * and performances.
  30371. * @see https://doc.babylonjs.com/babylon101/materials
  30372. */
  30373. export class StandardMaterial extends PushMaterial {
  30374. private _diffuseTexture;
  30375. /**
  30376. * The basic texture of the material as viewed under a light.
  30377. */
  30378. diffuseTexture: Nullable<BaseTexture>;
  30379. private _ambientTexture;
  30380. /**
  30381. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  30382. */
  30383. ambientTexture: Nullable<BaseTexture>;
  30384. private _opacityTexture;
  30385. /**
  30386. * Define the transparency of the material from a texture.
  30387. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  30388. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  30389. */
  30390. opacityTexture: Nullable<BaseTexture>;
  30391. private _reflectionTexture;
  30392. /**
  30393. * Define the texture used to display the reflection.
  30394. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30395. */
  30396. reflectionTexture: Nullable<BaseTexture>;
  30397. private _emissiveTexture;
  30398. /**
  30399. * Define texture of the material as if self lit.
  30400. * This will be mixed in the final result even in the absence of light.
  30401. */
  30402. emissiveTexture: Nullable<BaseTexture>;
  30403. private _specularTexture;
  30404. /**
  30405. * Define how the color and intensity of the highlight given by the light in the material.
  30406. */
  30407. specularTexture: Nullable<BaseTexture>;
  30408. private _bumpTexture;
  30409. /**
  30410. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  30411. * 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.
  30412. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  30413. */
  30414. bumpTexture: Nullable<BaseTexture>;
  30415. private _lightmapTexture;
  30416. /**
  30417. * Complex lighting can be computationally expensive to compute at runtime.
  30418. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  30419. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  30420. */
  30421. lightmapTexture: Nullable<BaseTexture>;
  30422. private _refractionTexture;
  30423. /**
  30424. * Define the texture used to display the refraction.
  30425. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30426. */
  30427. refractionTexture: Nullable<BaseTexture>;
  30428. /**
  30429. * The color of the material lit by the environmental background lighting.
  30430. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  30431. */
  30432. ambientColor: Color3;
  30433. /**
  30434. * The basic color of the material as viewed under a light.
  30435. */
  30436. diffuseColor: Color3;
  30437. /**
  30438. * Define how the color and intensity of the highlight given by the light in the material.
  30439. */
  30440. specularColor: Color3;
  30441. /**
  30442. * Define the color of the material as if self lit.
  30443. * This will be mixed in the final result even in the absence of light.
  30444. */
  30445. emissiveColor: Color3;
  30446. /**
  30447. * Defines how sharp are the highlights in the material.
  30448. * The bigger the value the sharper giving a more glossy feeling to the result.
  30449. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  30450. */
  30451. specularPower: number;
  30452. private _useAlphaFromDiffuseTexture;
  30453. /**
  30454. * Does the transparency come from the diffuse texture alpha channel.
  30455. */
  30456. useAlphaFromDiffuseTexture: boolean;
  30457. private _useEmissiveAsIllumination;
  30458. /**
  30459. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  30460. */
  30461. useEmissiveAsIllumination: boolean;
  30462. private _linkEmissiveWithDiffuse;
  30463. /**
  30464. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  30465. * the emissive level when the final color is close to one.
  30466. */
  30467. linkEmissiveWithDiffuse: boolean;
  30468. private _useSpecularOverAlpha;
  30469. /**
  30470. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  30471. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  30472. */
  30473. useSpecularOverAlpha: boolean;
  30474. private _useReflectionOverAlpha;
  30475. /**
  30476. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  30477. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  30478. */
  30479. useReflectionOverAlpha: boolean;
  30480. private _disableLighting;
  30481. /**
  30482. * Does lights from the scene impacts this material.
  30483. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  30484. */
  30485. disableLighting: boolean;
  30486. private _useObjectSpaceNormalMap;
  30487. /**
  30488. * Allows using an object space normal map (instead of tangent space).
  30489. */
  30490. useObjectSpaceNormalMap: boolean;
  30491. private _useParallax;
  30492. /**
  30493. * Is parallax enabled or not.
  30494. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30495. */
  30496. useParallax: boolean;
  30497. private _useParallaxOcclusion;
  30498. /**
  30499. * Is parallax occlusion enabled or not.
  30500. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  30501. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30502. */
  30503. useParallaxOcclusion: boolean;
  30504. /**
  30505. * 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.
  30506. */
  30507. parallaxScaleBias: number;
  30508. private _roughness;
  30509. /**
  30510. * Helps to define how blurry the reflections should appears in the material.
  30511. */
  30512. roughness: number;
  30513. /**
  30514. * In case of refraction, define the value of the index of refraction.
  30515. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30516. */
  30517. indexOfRefraction: number;
  30518. /**
  30519. * Invert the refraction texture alongside the y axis.
  30520. * It can be useful with procedural textures or probe for instance.
  30521. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30522. */
  30523. invertRefractionY: boolean;
  30524. /**
  30525. * Defines the alpha limits in alpha test mode.
  30526. */
  30527. alphaCutOff: number;
  30528. private _useLightmapAsShadowmap;
  30529. /**
  30530. * In case of light mapping, define whether the map contains light or shadow informations.
  30531. */
  30532. useLightmapAsShadowmap: boolean;
  30533. private _diffuseFresnelParameters;
  30534. /**
  30535. * Define the diffuse fresnel parameters of the material.
  30536. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30537. */
  30538. diffuseFresnelParameters: FresnelParameters;
  30539. private _opacityFresnelParameters;
  30540. /**
  30541. * Define the opacity fresnel parameters of the material.
  30542. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30543. */
  30544. opacityFresnelParameters: FresnelParameters;
  30545. private _reflectionFresnelParameters;
  30546. /**
  30547. * Define the reflection fresnel parameters of the material.
  30548. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30549. */
  30550. reflectionFresnelParameters: FresnelParameters;
  30551. private _refractionFresnelParameters;
  30552. /**
  30553. * Define the refraction fresnel parameters of the material.
  30554. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30555. */
  30556. refractionFresnelParameters: FresnelParameters;
  30557. private _emissiveFresnelParameters;
  30558. /**
  30559. * Define the emissive fresnel parameters of the material.
  30560. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30561. */
  30562. emissiveFresnelParameters: FresnelParameters;
  30563. private _useReflectionFresnelFromSpecular;
  30564. /**
  30565. * If true automatically deducts the fresnels values from the material specularity.
  30566. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30567. */
  30568. useReflectionFresnelFromSpecular: boolean;
  30569. private _useGlossinessFromSpecularMapAlpha;
  30570. /**
  30571. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  30572. */
  30573. useGlossinessFromSpecularMapAlpha: boolean;
  30574. private _maxSimultaneousLights;
  30575. /**
  30576. * Defines the maximum number of lights that can be used in the material
  30577. */
  30578. maxSimultaneousLights: number;
  30579. private _invertNormalMapX;
  30580. /**
  30581. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  30582. */
  30583. invertNormalMapX: boolean;
  30584. private _invertNormalMapY;
  30585. /**
  30586. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  30587. */
  30588. invertNormalMapY: boolean;
  30589. private _twoSidedLighting;
  30590. /**
  30591. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  30592. */
  30593. twoSidedLighting: boolean;
  30594. /**
  30595. * Default configuration related to image processing available in the standard Material.
  30596. */
  30597. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30598. /**
  30599. * Gets the image processing configuration used either in this material.
  30600. */
  30601. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  30602. /**
  30603. * Sets the Default image processing configuration used either in the this material.
  30604. *
  30605. * If sets to null, the scene one is in use.
  30606. */
  30607. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  30608. /**
  30609. * Keep track of the image processing observer to allow dispose and replace.
  30610. */
  30611. private _imageProcessingObserver;
  30612. /**
  30613. * Attaches a new image processing configuration to the Standard Material.
  30614. * @param configuration
  30615. */
  30616. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30617. /**
  30618. * Gets wether the color curves effect is enabled.
  30619. */
  30620. get cameraColorCurvesEnabled(): boolean;
  30621. /**
  30622. * Sets wether the color curves effect is enabled.
  30623. */
  30624. set cameraColorCurvesEnabled(value: boolean);
  30625. /**
  30626. * Gets wether the color grading effect is enabled.
  30627. */
  30628. get cameraColorGradingEnabled(): boolean;
  30629. /**
  30630. * Gets wether the color grading effect is enabled.
  30631. */
  30632. set cameraColorGradingEnabled(value: boolean);
  30633. /**
  30634. * Gets wether tonemapping is enabled or not.
  30635. */
  30636. get cameraToneMappingEnabled(): boolean;
  30637. /**
  30638. * Sets wether tonemapping is enabled or not
  30639. */
  30640. set cameraToneMappingEnabled(value: boolean);
  30641. /**
  30642. * The camera exposure used on this material.
  30643. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30644. * This corresponds to a photographic exposure.
  30645. */
  30646. get cameraExposure(): number;
  30647. /**
  30648. * The camera exposure used on this material.
  30649. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30650. * This corresponds to a photographic exposure.
  30651. */
  30652. set cameraExposure(value: number);
  30653. /**
  30654. * Gets The camera contrast used on this material.
  30655. */
  30656. get cameraContrast(): number;
  30657. /**
  30658. * Sets The camera contrast used on this material.
  30659. */
  30660. set cameraContrast(value: number);
  30661. /**
  30662. * Gets the Color Grading 2D Lookup Texture.
  30663. */
  30664. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  30665. /**
  30666. * Sets the Color Grading 2D Lookup Texture.
  30667. */
  30668. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  30669. /**
  30670. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30671. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30672. * 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;
  30673. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30674. */
  30675. get cameraColorCurves(): Nullable<ColorCurves>;
  30676. /**
  30677. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30678. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30679. * 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;
  30680. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30681. */
  30682. set cameraColorCurves(value: Nullable<ColorCurves>);
  30683. /**
  30684. * Can this material render to several textures at once
  30685. */
  30686. get canRenderToMRT(): boolean;
  30687. /**
  30688. * Defines the detail map parameters for the material.
  30689. */
  30690. readonly detailMap: DetailMapConfiguration;
  30691. protected _renderTargets: SmartArray<RenderTargetTexture>;
  30692. protected _worldViewProjectionMatrix: Matrix;
  30693. protected _globalAmbientColor: Color3;
  30694. protected _useLogarithmicDepth: boolean;
  30695. protected _rebuildInParallel: boolean;
  30696. /**
  30697. * Instantiates a new standard material.
  30698. * This is the default material used in Babylon. It is the best trade off between quality
  30699. * and performances.
  30700. * @see https://doc.babylonjs.com/babylon101/materials
  30701. * @param name Define the name of the material in the scene
  30702. * @param scene Define the scene the material belong to
  30703. */
  30704. constructor(name: string, scene: Scene);
  30705. /**
  30706. * Gets a boolean indicating that current material needs to register RTT
  30707. */
  30708. get hasRenderTargetTextures(): boolean;
  30709. /**
  30710. * Gets the current class name of the material e.g. "StandardMaterial"
  30711. * Mainly use in serialization.
  30712. * @returns the class name
  30713. */
  30714. getClassName(): string;
  30715. /**
  30716. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  30717. * You can try switching to logarithmic depth.
  30718. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  30719. */
  30720. get useLogarithmicDepth(): boolean;
  30721. set useLogarithmicDepth(value: boolean);
  30722. /**
  30723. * Specifies if the material will require alpha blending
  30724. * @returns a boolean specifying if alpha blending is needed
  30725. */
  30726. needAlphaBlending(): boolean;
  30727. /**
  30728. * Specifies if this material should be rendered in alpha test mode
  30729. * @returns a boolean specifying if an alpha test is needed.
  30730. */
  30731. needAlphaTesting(): boolean;
  30732. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  30733. /**
  30734. * Get the texture used for alpha test purpose.
  30735. * @returns the diffuse texture in case of the standard material.
  30736. */
  30737. getAlphaTestTexture(): Nullable<BaseTexture>;
  30738. /**
  30739. * Get if the submesh is ready to be used and all its information available.
  30740. * Child classes can use it to update shaders
  30741. * @param mesh defines the mesh to check
  30742. * @param subMesh defines which submesh to check
  30743. * @param useInstances specifies that instances should be used
  30744. * @returns a boolean indicating that the submesh is ready or not
  30745. */
  30746. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30747. /**
  30748. * Builds the material UBO layouts.
  30749. * Used internally during the effect preparation.
  30750. */
  30751. buildUniformLayout(): void;
  30752. /**
  30753. * Unbinds the material from the mesh
  30754. */
  30755. unbind(): void;
  30756. /**
  30757. * Binds the submesh to this material by preparing the effect and shader to draw
  30758. * @param world defines the world transformation matrix
  30759. * @param mesh defines the mesh containing the submesh
  30760. * @param subMesh defines the submesh to bind the material to
  30761. */
  30762. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30763. /**
  30764. * Get the list of animatables in the material.
  30765. * @returns the list of animatables object used in the material
  30766. */
  30767. getAnimatables(): IAnimatable[];
  30768. /**
  30769. * Gets the active textures from the material
  30770. * @returns an array of textures
  30771. */
  30772. getActiveTextures(): BaseTexture[];
  30773. /**
  30774. * Specifies if the material uses a texture
  30775. * @param texture defines the texture to check against the material
  30776. * @returns a boolean specifying if the material uses the texture
  30777. */
  30778. hasTexture(texture: BaseTexture): boolean;
  30779. /**
  30780. * Disposes the material
  30781. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30782. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30783. */
  30784. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  30785. /**
  30786. * Makes a duplicate of the material, and gives it a new name
  30787. * @param name defines the new name for the duplicated material
  30788. * @returns the cloned material
  30789. */
  30790. clone(name: string): StandardMaterial;
  30791. /**
  30792. * Serializes this material in a JSON representation
  30793. * @returns the serialized material object
  30794. */
  30795. serialize(): any;
  30796. /**
  30797. * Creates a standard material from parsed material data
  30798. * @param source defines the JSON representation of the material
  30799. * @param scene defines the hosting scene
  30800. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  30801. * @returns a new standard material
  30802. */
  30803. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  30804. /**
  30805. * Are diffuse textures enabled in the application.
  30806. */
  30807. static get DiffuseTextureEnabled(): boolean;
  30808. static set DiffuseTextureEnabled(value: boolean);
  30809. /**
  30810. * Are detail textures enabled in the application.
  30811. */
  30812. static get DetailTextureEnabled(): boolean;
  30813. static set DetailTextureEnabled(value: boolean);
  30814. /**
  30815. * Are ambient textures enabled in the application.
  30816. */
  30817. static get AmbientTextureEnabled(): boolean;
  30818. static set AmbientTextureEnabled(value: boolean);
  30819. /**
  30820. * Are opacity textures enabled in the application.
  30821. */
  30822. static get OpacityTextureEnabled(): boolean;
  30823. static set OpacityTextureEnabled(value: boolean);
  30824. /**
  30825. * Are reflection textures enabled in the application.
  30826. */
  30827. static get ReflectionTextureEnabled(): boolean;
  30828. static set ReflectionTextureEnabled(value: boolean);
  30829. /**
  30830. * Are emissive textures enabled in the application.
  30831. */
  30832. static get EmissiveTextureEnabled(): boolean;
  30833. static set EmissiveTextureEnabled(value: boolean);
  30834. /**
  30835. * Are specular textures enabled in the application.
  30836. */
  30837. static get SpecularTextureEnabled(): boolean;
  30838. static set SpecularTextureEnabled(value: boolean);
  30839. /**
  30840. * Are bump textures enabled in the application.
  30841. */
  30842. static get BumpTextureEnabled(): boolean;
  30843. static set BumpTextureEnabled(value: boolean);
  30844. /**
  30845. * Are lightmap textures enabled in the application.
  30846. */
  30847. static get LightmapTextureEnabled(): boolean;
  30848. static set LightmapTextureEnabled(value: boolean);
  30849. /**
  30850. * Are refraction textures enabled in the application.
  30851. */
  30852. static get RefractionTextureEnabled(): boolean;
  30853. static set RefractionTextureEnabled(value: boolean);
  30854. /**
  30855. * Are color grading textures enabled in the application.
  30856. */
  30857. static get ColorGradingTextureEnabled(): boolean;
  30858. static set ColorGradingTextureEnabled(value: boolean);
  30859. /**
  30860. * Are fresnels enabled in the application.
  30861. */
  30862. static get FresnelEnabled(): boolean;
  30863. static set FresnelEnabled(value: boolean);
  30864. }
  30865. }
  30866. declare module BABYLON {
  30867. /**
  30868. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  30869. *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.
  30870. * The SPS is also a particle system. It provides some methods to manage the particles.
  30871. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  30872. *
  30873. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  30874. */
  30875. export class SolidParticleSystem implements IDisposable {
  30876. /**
  30877. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  30878. * Example : var p = SPS.particles[i];
  30879. */
  30880. particles: SolidParticle[];
  30881. /**
  30882. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  30883. */
  30884. nbParticles: number;
  30885. /**
  30886. * If the particles must ever face the camera (default false). Useful for planar particles.
  30887. */
  30888. billboard: boolean;
  30889. /**
  30890. * Recompute normals when adding a shape
  30891. */
  30892. recomputeNormals: boolean;
  30893. /**
  30894. * This a counter ofr your own usage. It's not set by any SPS functions.
  30895. */
  30896. counter: number;
  30897. /**
  30898. * The SPS name. This name is also given to the underlying mesh.
  30899. */
  30900. name: string;
  30901. /**
  30902. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  30903. */
  30904. mesh: Mesh;
  30905. /**
  30906. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  30907. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  30908. */
  30909. vars: any;
  30910. /**
  30911. * This array is populated when the SPS is set as 'pickable'.
  30912. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  30913. * Each element of this array is an object `{idx: int, faceId: int}`.
  30914. * `idx` is the picked particle index in the `SPS.particles` array
  30915. * `faceId` is the picked face index counted within this particle.
  30916. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  30917. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  30918. * Use the method SPS.pickedParticle(pickingInfo) instead.
  30919. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  30920. */
  30921. pickedParticles: {
  30922. idx: number;
  30923. faceId: number;
  30924. }[];
  30925. /**
  30926. * This array is populated when the SPS is set as 'pickable'
  30927. * Each key of this array is a submesh index.
  30928. * Each element of this array is a second array defined like this :
  30929. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  30930. * Each element of this second array is an object `{idx: int, faceId: int}`.
  30931. * `idx` is the picked particle index in the `SPS.particles` array
  30932. * `faceId` is the picked face index counted within this particle.
  30933. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  30934. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  30935. */
  30936. pickedBySubMesh: {
  30937. idx: number;
  30938. faceId: number;
  30939. }[][];
  30940. /**
  30941. * This array is populated when `enableDepthSort` is set to true.
  30942. * Each element of this array is an instance of the class DepthSortedParticle.
  30943. */
  30944. depthSortedParticles: DepthSortedParticle[];
  30945. /**
  30946. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  30947. * @hidden
  30948. */
  30949. _bSphereOnly: boolean;
  30950. /**
  30951. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  30952. * @hidden
  30953. */
  30954. _bSphereRadiusFactor: number;
  30955. private _scene;
  30956. private _positions;
  30957. private _indices;
  30958. private _normals;
  30959. private _colors;
  30960. private _uvs;
  30961. private _indices32;
  30962. private _positions32;
  30963. private _normals32;
  30964. private _fixedNormal32;
  30965. private _colors32;
  30966. private _uvs32;
  30967. private _index;
  30968. private _updatable;
  30969. private _pickable;
  30970. private _isVisibilityBoxLocked;
  30971. private _alwaysVisible;
  30972. private _depthSort;
  30973. private _expandable;
  30974. private _shapeCounter;
  30975. private _copy;
  30976. private _color;
  30977. private _computeParticleColor;
  30978. private _computeParticleTexture;
  30979. private _computeParticleRotation;
  30980. private _computeParticleVertex;
  30981. private _computeBoundingBox;
  30982. private _depthSortParticles;
  30983. private _camera;
  30984. private _mustUnrotateFixedNormals;
  30985. private _particlesIntersect;
  30986. private _needs32Bits;
  30987. private _isNotBuilt;
  30988. private _lastParticleId;
  30989. private _idxOfId;
  30990. private _multimaterialEnabled;
  30991. private _useModelMaterial;
  30992. private _indicesByMaterial;
  30993. private _materialIndexes;
  30994. private _depthSortFunction;
  30995. private _materialSortFunction;
  30996. private _materials;
  30997. private _multimaterial;
  30998. private _materialIndexesById;
  30999. private _defaultMaterial;
  31000. private _autoUpdateSubMeshes;
  31001. private _tmpVertex;
  31002. /**
  31003. * Creates a SPS (Solid Particle System) object.
  31004. * @param name (String) is the SPS name, this will be the underlying mesh name.
  31005. * @param scene (Scene) is the scene in which the SPS is added.
  31006. * @param options defines the options of the sps e.g.
  31007. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  31008. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  31009. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  31010. * * 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.
  31011. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  31012. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  31013. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  31014. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  31015. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  31016. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  31017. */
  31018. constructor(name: string, scene: Scene, options?: {
  31019. updatable?: boolean;
  31020. isPickable?: boolean;
  31021. enableDepthSort?: boolean;
  31022. particleIntersection?: boolean;
  31023. boundingSphereOnly?: boolean;
  31024. bSphereRadiusFactor?: number;
  31025. expandable?: boolean;
  31026. useModelMaterial?: boolean;
  31027. enableMultiMaterial?: boolean;
  31028. });
  31029. /**
  31030. * Builds the SPS underlying mesh. Returns a standard Mesh.
  31031. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  31032. * @returns the created mesh
  31033. */
  31034. buildMesh(): Mesh;
  31035. /**
  31036. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  31037. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  31038. * Thus the particles generated from `digest()` have their property `position` set yet.
  31039. * @param mesh ( Mesh ) is the mesh to be digested
  31040. * @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
  31041. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  31042. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  31043. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31044. * @returns the current SPS
  31045. */
  31046. digest(mesh: Mesh, options?: {
  31047. facetNb?: number;
  31048. number?: number;
  31049. delta?: number;
  31050. storage?: [];
  31051. }): SolidParticleSystem;
  31052. /**
  31053. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  31054. * @hidden
  31055. */
  31056. private _unrotateFixedNormals;
  31057. /**
  31058. * Resets the temporary working copy particle
  31059. * @hidden
  31060. */
  31061. private _resetCopy;
  31062. /**
  31063. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  31064. * @param p the current index in the positions array to be updated
  31065. * @param ind the current index in the indices array
  31066. * @param shape a Vector3 array, the shape geometry
  31067. * @param positions the positions array to be updated
  31068. * @param meshInd the shape indices array
  31069. * @param indices the indices array to be updated
  31070. * @param meshUV the shape uv array
  31071. * @param uvs the uv array to be updated
  31072. * @param meshCol the shape color array
  31073. * @param colors the color array to be updated
  31074. * @param meshNor the shape normals array
  31075. * @param normals the normals array to be updated
  31076. * @param idx the particle index
  31077. * @param idxInShape the particle index in its shape
  31078. * @param options the addShape() method passed options
  31079. * @model the particle model
  31080. * @hidden
  31081. */
  31082. private _meshBuilder;
  31083. /**
  31084. * Returns a shape Vector3 array from positions float array
  31085. * @param positions float array
  31086. * @returns a vector3 array
  31087. * @hidden
  31088. */
  31089. private _posToShape;
  31090. /**
  31091. * Returns a shapeUV array from a float uvs (array deep copy)
  31092. * @param uvs as a float array
  31093. * @returns a shapeUV array
  31094. * @hidden
  31095. */
  31096. private _uvsToShapeUV;
  31097. /**
  31098. * Adds a new particle object in the particles array
  31099. * @param idx particle index in particles array
  31100. * @param id particle id
  31101. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  31102. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  31103. * @param model particle ModelShape object
  31104. * @param shapeId model shape identifier
  31105. * @param idxInShape index of the particle in the current model
  31106. * @param bInfo model bounding info object
  31107. * @param storage target storage array, if any
  31108. * @hidden
  31109. */
  31110. private _addParticle;
  31111. /**
  31112. * Adds some particles to the SPS from the model shape. Returns the shape id.
  31113. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  31114. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  31115. * @param nb (positive integer) the number of particles to be created from this model
  31116. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  31117. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  31118. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31119. * @returns the number of shapes in the system
  31120. */
  31121. addShape(mesh: Mesh, nb: number, options?: {
  31122. positionFunction?: any;
  31123. vertexFunction?: any;
  31124. storage?: [];
  31125. }): number;
  31126. /**
  31127. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  31128. * @hidden
  31129. */
  31130. private _rebuildParticle;
  31131. /**
  31132. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  31133. * @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.
  31134. * @returns the SPS.
  31135. */
  31136. rebuildMesh(reset?: boolean): SolidParticleSystem;
  31137. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  31138. * Returns an array with the removed particles.
  31139. * 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.
  31140. * The SPS can't be empty so at least one particle needs to remain in place.
  31141. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  31142. * @param start index of the first particle to remove
  31143. * @param end index of the last particle to remove (included)
  31144. * @returns an array populated with the removed particles
  31145. */
  31146. removeParticles(start: number, end: number): SolidParticle[];
  31147. /**
  31148. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  31149. * @param solidParticleArray an array populated with Solid Particles objects
  31150. * @returns the SPS
  31151. */
  31152. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  31153. /**
  31154. * Creates a new particle and modifies the SPS mesh geometry :
  31155. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  31156. * - calls _addParticle() to populate the particle array
  31157. * factorized code from addShape() and insertParticlesFromArray()
  31158. * @param idx particle index in the particles array
  31159. * @param i particle index in its shape
  31160. * @param modelShape particle ModelShape object
  31161. * @param shape shape vertex array
  31162. * @param meshInd shape indices array
  31163. * @param meshUV shape uv array
  31164. * @param meshCol shape color array
  31165. * @param meshNor shape normals array
  31166. * @param bbInfo shape bounding info
  31167. * @param storage target particle storage
  31168. * @options addShape() passed options
  31169. * @hidden
  31170. */
  31171. private _insertNewParticle;
  31172. /**
  31173. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  31174. * This method calls `updateParticle()` for each particle of the SPS.
  31175. * For an animated SPS, it is usually called within the render loop.
  31176. * 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.
  31177. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  31178. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  31179. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  31180. * @returns the SPS.
  31181. */
  31182. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  31183. /**
  31184. * Disposes the SPS.
  31185. */
  31186. dispose(): void;
  31187. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  31188. * idx is the particle index in the SPS
  31189. * faceId is the picked face index counted within this particle.
  31190. * Returns null if the pickInfo can't identify a picked particle.
  31191. * @param pickingInfo (PickingInfo object)
  31192. * @returns {idx: number, faceId: number} or null
  31193. */
  31194. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  31195. idx: number;
  31196. faceId: number;
  31197. }>;
  31198. /**
  31199. * Returns a SolidParticle object from its identifier : particle.id
  31200. * @param id (integer) the particle Id
  31201. * @returns the searched particle or null if not found in the SPS.
  31202. */
  31203. getParticleById(id: number): Nullable<SolidParticle>;
  31204. /**
  31205. * Returns a new array populated with the particles having the passed shapeId.
  31206. * @param shapeId (integer) the shape identifier
  31207. * @returns a new solid particle array
  31208. */
  31209. getParticlesByShapeId(shapeId: number): SolidParticle[];
  31210. /**
  31211. * Populates the passed array "ref" with the particles having the passed shapeId.
  31212. * @param shapeId the shape identifier
  31213. * @returns the SPS
  31214. * @param ref
  31215. */
  31216. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  31217. /**
  31218. * Computes the required SubMeshes according the materials assigned to the particles.
  31219. * @returns the solid particle system.
  31220. * Does nothing if called before the SPS mesh is built.
  31221. */
  31222. computeSubMeshes(): SolidParticleSystem;
  31223. /**
  31224. * Sorts the solid particles by material when MultiMaterial is enabled.
  31225. * Updates the indices32 array.
  31226. * Updates the indicesByMaterial array.
  31227. * Updates the mesh indices array.
  31228. * @returns the SPS
  31229. * @hidden
  31230. */
  31231. private _sortParticlesByMaterial;
  31232. /**
  31233. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  31234. * @hidden
  31235. */
  31236. private _setMaterialIndexesById;
  31237. /**
  31238. * Returns an array with unique values of Materials from the passed array
  31239. * @param array the material array to be checked and filtered
  31240. * @hidden
  31241. */
  31242. private _filterUniqueMaterialId;
  31243. /**
  31244. * Sets a new Standard Material as _defaultMaterial if not already set.
  31245. * @hidden
  31246. */
  31247. private _setDefaultMaterial;
  31248. /**
  31249. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  31250. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31251. * @returns the SPS.
  31252. */
  31253. refreshVisibleSize(): SolidParticleSystem;
  31254. /**
  31255. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  31256. * @param size the size (float) of the visibility box
  31257. * note : this doesn't lock the SPS mesh bounding box.
  31258. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31259. */
  31260. setVisibilityBox(size: number): void;
  31261. /**
  31262. * Gets whether the SPS as always visible or not
  31263. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31264. */
  31265. get isAlwaysVisible(): boolean;
  31266. /**
  31267. * Sets the SPS as always visible or not
  31268. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31269. */
  31270. set isAlwaysVisible(val: boolean);
  31271. /**
  31272. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31273. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31274. */
  31275. set isVisibilityBoxLocked(val: boolean);
  31276. /**
  31277. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31278. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31279. */
  31280. get isVisibilityBoxLocked(): boolean;
  31281. /**
  31282. * Tells to `setParticles()` to compute the particle rotations or not.
  31283. * Default value : true. The SPS is faster when it's set to false.
  31284. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31285. */
  31286. set computeParticleRotation(val: boolean);
  31287. /**
  31288. * Tells to `setParticles()` to compute the particle colors or not.
  31289. * Default value : true. The SPS is faster when it's set to false.
  31290. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31291. */
  31292. set computeParticleColor(val: boolean);
  31293. set computeParticleTexture(val: boolean);
  31294. /**
  31295. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  31296. * Default value : false. The SPS is faster when it's set to false.
  31297. * Note : the particle custom vertex positions aren't stored values.
  31298. */
  31299. set computeParticleVertex(val: boolean);
  31300. /**
  31301. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  31302. */
  31303. set computeBoundingBox(val: boolean);
  31304. /**
  31305. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  31306. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31307. * Default : `true`
  31308. */
  31309. set depthSortParticles(val: boolean);
  31310. /**
  31311. * Gets if `setParticles()` computes the particle rotations or not.
  31312. * Default value : true. The SPS is faster when it's set to false.
  31313. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31314. */
  31315. get computeParticleRotation(): boolean;
  31316. /**
  31317. * Gets if `setParticles()` computes the particle colors or not.
  31318. * Default value : true. The SPS is faster when it's set to false.
  31319. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31320. */
  31321. get computeParticleColor(): boolean;
  31322. /**
  31323. * Gets if `setParticles()` computes the particle textures or not.
  31324. * Default value : true. The SPS is faster when it's set to false.
  31325. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  31326. */
  31327. get computeParticleTexture(): boolean;
  31328. /**
  31329. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  31330. * Default value : false. The SPS is faster when it's set to false.
  31331. * Note : the particle custom vertex positions aren't stored values.
  31332. */
  31333. get computeParticleVertex(): boolean;
  31334. /**
  31335. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  31336. */
  31337. get computeBoundingBox(): boolean;
  31338. /**
  31339. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  31340. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31341. * Default : `true`
  31342. */
  31343. get depthSortParticles(): boolean;
  31344. /**
  31345. * Gets if the SPS is created as expandable at construction time.
  31346. * Default : `false`
  31347. */
  31348. get expandable(): boolean;
  31349. /**
  31350. * Gets if the SPS supports the Multi Materials
  31351. */
  31352. get multimaterialEnabled(): boolean;
  31353. /**
  31354. * Gets if the SPS uses the model materials for its own multimaterial.
  31355. */
  31356. get useModelMaterial(): boolean;
  31357. /**
  31358. * The SPS used material array.
  31359. */
  31360. get materials(): Material[];
  31361. /**
  31362. * Sets the SPS MultiMaterial from the passed materials.
  31363. * Note : the passed array is internally copied and not used then by reference.
  31364. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  31365. */
  31366. setMultiMaterial(materials: Material[]): void;
  31367. /**
  31368. * The SPS computed multimaterial object
  31369. */
  31370. get multimaterial(): MultiMaterial;
  31371. set multimaterial(mm: MultiMaterial);
  31372. /**
  31373. * If the subMeshes must be updated on the next call to setParticles()
  31374. */
  31375. get autoUpdateSubMeshes(): boolean;
  31376. set autoUpdateSubMeshes(val: boolean);
  31377. /**
  31378. * This function does nothing. It may be overwritten to set all the particle first values.
  31379. * The SPS doesn't call this function, you may have to call it by your own.
  31380. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31381. */
  31382. initParticles(): void;
  31383. /**
  31384. * This function does nothing. It may be overwritten to recycle a particle.
  31385. * The SPS doesn't call this function, you may have to call it by your own.
  31386. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31387. * @param particle The particle to recycle
  31388. * @returns the recycled particle
  31389. */
  31390. recycleParticle(particle: SolidParticle): SolidParticle;
  31391. /**
  31392. * Updates a particle : this function should be overwritten by the user.
  31393. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  31394. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31395. * @example : just set a particle position or velocity and recycle conditions
  31396. * @param particle The particle to update
  31397. * @returns the updated particle
  31398. */
  31399. updateParticle(particle: SolidParticle): SolidParticle;
  31400. /**
  31401. * Updates a vertex of a particle : it can be overwritten by the user.
  31402. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  31403. * @param particle the current particle
  31404. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  31405. * @param pt the index of the current vertex in the particle shape
  31406. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  31407. * @example : just set a vertex particle position or color
  31408. * @returns the sps
  31409. */
  31410. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  31411. /**
  31412. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  31413. * This does nothing and may be overwritten by the user.
  31414. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31415. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31416. * @param update the boolean update value actually passed to setParticles()
  31417. */
  31418. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31419. /**
  31420. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  31421. * This will be passed three parameters.
  31422. * This does nothing and may be overwritten by the user.
  31423. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31424. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31425. * @param update the boolean update value actually passed to setParticles()
  31426. */
  31427. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31428. }
  31429. }
  31430. declare module BABYLON {
  31431. /**
  31432. * Represents one particle of a solid particle system.
  31433. */
  31434. export class SolidParticle {
  31435. /**
  31436. * particle global index
  31437. */
  31438. idx: number;
  31439. /**
  31440. * particle identifier
  31441. */
  31442. id: number;
  31443. /**
  31444. * The color of the particle
  31445. */
  31446. color: Nullable<Color4>;
  31447. /**
  31448. * The world space position of the particle.
  31449. */
  31450. position: Vector3;
  31451. /**
  31452. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  31453. */
  31454. rotation: Vector3;
  31455. /**
  31456. * The world space rotation quaternion of the particle.
  31457. */
  31458. rotationQuaternion: Nullable<Quaternion>;
  31459. /**
  31460. * The scaling of the particle.
  31461. */
  31462. scaling: Vector3;
  31463. /**
  31464. * The uvs of the particle.
  31465. */
  31466. uvs: Vector4;
  31467. /**
  31468. * The current speed of the particle.
  31469. */
  31470. velocity: Vector3;
  31471. /**
  31472. * The pivot point in the particle local space.
  31473. */
  31474. pivot: Vector3;
  31475. /**
  31476. * Must the particle be translated from its pivot point in its local space ?
  31477. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  31478. * Default : false
  31479. */
  31480. translateFromPivot: boolean;
  31481. /**
  31482. * Is the particle active or not ?
  31483. */
  31484. alive: boolean;
  31485. /**
  31486. * Is the particle visible or not ?
  31487. */
  31488. isVisible: boolean;
  31489. /**
  31490. * Index of this particle in the global "positions" array (Internal use)
  31491. * @hidden
  31492. */
  31493. _pos: number;
  31494. /**
  31495. * @hidden Index of this particle in the global "indices" array (Internal use)
  31496. */
  31497. _ind: number;
  31498. /**
  31499. * @hidden ModelShape of this particle (Internal use)
  31500. */
  31501. _model: ModelShape;
  31502. /**
  31503. * ModelShape id of this particle
  31504. */
  31505. shapeId: number;
  31506. /**
  31507. * Index of the particle in its shape id
  31508. */
  31509. idxInShape: number;
  31510. /**
  31511. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  31512. */
  31513. _modelBoundingInfo: BoundingInfo;
  31514. /**
  31515. * @hidden Particle BoundingInfo object (Internal use)
  31516. */
  31517. _boundingInfo: BoundingInfo;
  31518. /**
  31519. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  31520. */
  31521. _sps: SolidParticleSystem;
  31522. /**
  31523. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  31524. */
  31525. _stillInvisible: boolean;
  31526. /**
  31527. * @hidden Last computed particle rotation matrix
  31528. */
  31529. _rotationMatrix: number[];
  31530. /**
  31531. * Parent particle Id, if any.
  31532. * Default null.
  31533. */
  31534. parentId: Nullable<number>;
  31535. /**
  31536. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  31537. */
  31538. materialIndex: Nullable<number>;
  31539. /**
  31540. * Custom object or properties.
  31541. */
  31542. props: Nullable<any>;
  31543. /**
  31544. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  31545. * The possible values are :
  31546. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31547. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31548. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31549. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31550. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31551. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  31552. * */
  31553. cullingStrategy: number;
  31554. /**
  31555. * @hidden Internal global position in the SPS.
  31556. */
  31557. _globalPosition: Vector3;
  31558. /**
  31559. * Creates a Solid Particle object.
  31560. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  31561. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  31562. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  31563. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  31564. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  31565. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  31566. * @param shapeId (integer) is the model shape identifier in the SPS.
  31567. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  31568. * @param sps defines the sps it is associated to
  31569. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  31570. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  31571. */
  31572. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  31573. /**
  31574. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  31575. * @param target the particle target
  31576. * @returns the current particle
  31577. */
  31578. copyToRef(target: SolidParticle): SolidParticle;
  31579. /**
  31580. * Legacy support, changed scale to scaling
  31581. */
  31582. get scale(): Vector3;
  31583. /**
  31584. * Legacy support, changed scale to scaling
  31585. */
  31586. set scale(scale: Vector3);
  31587. /**
  31588. * Legacy support, changed quaternion to rotationQuaternion
  31589. */
  31590. get quaternion(): Nullable<Quaternion>;
  31591. /**
  31592. * Legacy support, changed quaternion to rotationQuaternion
  31593. */
  31594. set quaternion(q: Nullable<Quaternion>);
  31595. /**
  31596. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  31597. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  31598. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  31599. * @returns true if it intersects
  31600. */
  31601. intersectsMesh(target: Mesh | SolidParticle): boolean;
  31602. /**
  31603. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  31604. * A particle is in the frustum if its bounding box intersects the frustum
  31605. * @param frustumPlanes defines the frustum to test
  31606. * @returns true if the particle is in the frustum planes
  31607. */
  31608. isInFrustum(frustumPlanes: Plane[]): boolean;
  31609. /**
  31610. * get the rotation matrix of the particle
  31611. * @hidden
  31612. */
  31613. getRotationMatrix(m: Matrix): void;
  31614. }
  31615. /**
  31616. * Represents the shape of the model used by one particle of a solid particle system.
  31617. * SPS internal tool, don't use it manually.
  31618. */
  31619. export class ModelShape {
  31620. /**
  31621. * The shape id
  31622. * @hidden
  31623. */
  31624. shapeID: number;
  31625. /**
  31626. * flat array of model positions (internal use)
  31627. * @hidden
  31628. */
  31629. _shape: Vector3[];
  31630. /**
  31631. * flat array of model UVs (internal use)
  31632. * @hidden
  31633. */
  31634. _shapeUV: number[];
  31635. /**
  31636. * color array of the model
  31637. * @hidden
  31638. */
  31639. _shapeColors: number[];
  31640. /**
  31641. * indices array of the model
  31642. * @hidden
  31643. */
  31644. _indices: number[];
  31645. /**
  31646. * normals array of the model
  31647. * @hidden
  31648. */
  31649. _normals: number[];
  31650. /**
  31651. * length of the shape in the model indices array (internal use)
  31652. * @hidden
  31653. */
  31654. _indicesLength: number;
  31655. /**
  31656. * Custom position function (internal use)
  31657. * @hidden
  31658. */
  31659. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  31660. /**
  31661. * Custom vertex function (internal use)
  31662. * @hidden
  31663. */
  31664. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  31665. /**
  31666. * Model material (internal use)
  31667. * @hidden
  31668. */
  31669. _material: Nullable<Material>;
  31670. /**
  31671. * 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.
  31672. * SPS internal tool, don't use it manually.
  31673. * @hidden
  31674. */
  31675. 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>);
  31676. }
  31677. /**
  31678. * Represents a Depth Sorted Particle in the solid particle system.
  31679. * @hidden
  31680. */
  31681. export class DepthSortedParticle {
  31682. /**
  31683. * Particle index
  31684. */
  31685. idx: number;
  31686. /**
  31687. * Index of the particle in the "indices" array
  31688. */
  31689. ind: number;
  31690. /**
  31691. * Length of the particle shape in the "indices" array
  31692. */
  31693. indicesLength: number;
  31694. /**
  31695. * Squared distance from the particle to the camera
  31696. */
  31697. sqDistance: number;
  31698. /**
  31699. * Material index when used with MultiMaterials
  31700. */
  31701. materialIndex: number;
  31702. /**
  31703. * Creates a new sorted particle
  31704. * @param materialIndex
  31705. */
  31706. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  31707. }
  31708. /**
  31709. * Represents a solid particle vertex
  31710. */
  31711. export class SolidParticleVertex {
  31712. /**
  31713. * Vertex position
  31714. */
  31715. position: Vector3;
  31716. /**
  31717. * Vertex color
  31718. */
  31719. color: Color4;
  31720. /**
  31721. * Vertex UV
  31722. */
  31723. uv: Vector2;
  31724. /**
  31725. * Creates a new solid particle vertex
  31726. */
  31727. constructor();
  31728. /** Vertex x coordinate */
  31729. get x(): number;
  31730. set x(val: number);
  31731. /** Vertex y coordinate */
  31732. get y(): number;
  31733. set y(val: number);
  31734. /** Vertex z coordinate */
  31735. get z(): number;
  31736. set z(val: number);
  31737. }
  31738. }
  31739. declare module BABYLON {
  31740. /**
  31741. * @hidden
  31742. */
  31743. export class _MeshCollisionData {
  31744. _checkCollisions: boolean;
  31745. _collisionMask: number;
  31746. _collisionGroup: number;
  31747. _surroundingMeshes: Nullable<AbstractMesh[]>;
  31748. _collider: Nullable<Collider>;
  31749. _oldPositionForCollisions: Vector3;
  31750. _diffPositionForCollisions: Vector3;
  31751. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  31752. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  31753. }
  31754. }
  31755. declare module BABYLON {
  31756. /** @hidden */
  31757. class _FacetDataStorage {
  31758. facetPositions: Vector3[];
  31759. facetNormals: Vector3[];
  31760. facetPartitioning: number[][];
  31761. facetNb: number;
  31762. partitioningSubdivisions: number;
  31763. partitioningBBoxRatio: number;
  31764. facetDataEnabled: boolean;
  31765. facetParameters: any;
  31766. bbSize: Vector3;
  31767. subDiv: {
  31768. max: number;
  31769. X: number;
  31770. Y: number;
  31771. Z: number;
  31772. };
  31773. facetDepthSort: boolean;
  31774. facetDepthSortEnabled: boolean;
  31775. depthSortedIndices: IndicesArray;
  31776. depthSortedFacets: {
  31777. ind: number;
  31778. sqDistance: number;
  31779. }[];
  31780. facetDepthSortFunction: (f1: {
  31781. ind: number;
  31782. sqDistance: number;
  31783. }, f2: {
  31784. ind: number;
  31785. sqDistance: number;
  31786. }) => number;
  31787. facetDepthSortFrom: Vector3;
  31788. facetDepthSortOrigin: Vector3;
  31789. invertedMatrix: Matrix;
  31790. }
  31791. /**
  31792. * @hidden
  31793. **/
  31794. class _InternalAbstractMeshDataInfo {
  31795. _hasVertexAlpha: boolean;
  31796. _useVertexColors: boolean;
  31797. _numBoneInfluencers: number;
  31798. _applyFog: boolean;
  31799. _receiveShadows: boolean;
  31800. _facetData: _FacetDataStorage;
  31801. _visibility: number;
  31802. _skeleton: Nullable<Skeleton>;
  31803. _layerMask: number;
  31804. _computeBonesUsingShaders: boolean;
  31805. _isActive: boolean;
  31806. _onlyForInstances: boolean;
  31807. _isActiveIntermediate: boolean;
  31808. _onlyForInstancesIntermediate: boolean;
  31809. _actAsRegularMesh: boolean;
  31810. }
  31811. /**
  31812. * Class used to store all common mesh properties
  31813. */
  31814. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  31815. /** No occlusion */
  31816. static OCCLUSION_TYPE_NONE: number;
  31817. /** Occlusion set to optimisitic */
  31818. static OCCLUSION_TYPE_OPTIMISTIC: number;
  31819. /** Occlusion set to strict */
  31820. static OCCLUSION_TYPE_STRICT: number;
  31821. /** Use an accurante occlusion algorithm */
  31822. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  31823. /** Use a conservative occlusion algorithm */
  31824. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  31825. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  31826. * Test order :
  31827. * Is the bounding sphere outside the frustum ?
  31828. * If not, are the bounding box vertices outside the frustum ?
  31829. * It not, then the cullable object is in the frustum.
  31830. */
  31831. static readonly CULLINGSTRATEGY_STANDARD: number;
  31832. /** Culling strategy : Bounding Sphere Only.
  31833. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  31834. * It's also less accurate than the standard because some not visible objects can still be selected.
  31835. * Test : is the bounding sphere outside the frustum ?
  31836. * If not, then the cullable object is in the frustum.
  31837. */
  31838. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  31839. /** Culling strategy : Optimistic Inclusion.
  31840. * This in an inclusion test first, then the standard exclusion test.
  31841. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  31842. * 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.
  31843. * Anyway, it's as accurate as the standard strategy.
  31844. * Test :
  31845. * Is the cullable object bounding sphere center in the frustum ?
  31846. * If not, apply the default culling strategy.
  31847. */
  31848. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  31849. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  31850. * This in an inclusion test first, then the bounding sphere only exclusion test.
  31851. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  31852. * 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.
  31853. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  31854. * Test :
  31855. * Is the cullable object bounding sphere center in the frustum ?
  31856. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  31857. */
  31858. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  31859. /**
  31860. * No billboard
  31861. */
  31862. static get BILLBOARDMODE_NONE(): number;
  31863. /** Billboard on X axis */
  31864. static get BILLBOARDMODE_X(): number;
  31865. /** Billboard on Y axis */
  31866. static get BILLBOARDMODE_Y(): number;
  31867. /** Billboard on Z axis */
  31868. static get BILLBOARDMODE_Z(): number;
  31869. /** Billboard on all axes */
  31870. static get BILLBOARDMODE_ALL(): number;
  31871. /** Billboard on using position instead of orientation */
  31872. static get BILLBOARDMODE_USE_POSITION(): number;
  31873. /** @hidden */
  31874. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  31875. /**
  31876. * The culling strategy to use to check whether the mesh must be rendered or not.
  31877. * This value can be changed at any time and will be used on the next render mesh selection.
  31878. * The possible values are :
  31879. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31880. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31881. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31882. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31883. * Please read each static variable documentation to get details about the culling process.
  31884. * */
  31885. cullingStrategy: number;
  31886. /**
  31887. * Gets the number of facets in the mesh
  31888. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  31889. */
  31890. get facetNb(): number;
  31891. /**
  31892. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  31893. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  31894. */
  31895. get partitioningSubdivisions(): number;
  31896. set partitioningSubdivisions(nb: number);
  31897. /**
  31898. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  31899. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  31900. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  31901. */
  31902. get partitioningBBoxRatio(): number;
  31903. set partitioningBBoxRatio(ratio: number);
  31904. /**
  31905. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  31906. * Works only for updatable meshes.
  31907. * Doesn't work with multi-materials
  31908. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  31909. */
  31910. get mustDepthSortFacets(): boolean;
  31911. set mustDepthSortFacets(sort: boolean);
  31912. /**
  31913. * The location (Vector3) where the facet depth sort must be computed from.
  31914. * By default, the active camera position.
  31915. * Used only when facet depth sort is enabled
  31916. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  31917. */
  31918. get facetDepthSortFrom(): Vector3;
  31919. set facetDepthSortFrom(location: Vector3);
  31920. /**
  31921. * gets a boolean indicating if facetData is enabled
  31922. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  31923. */
  31924. get isFacetDataEnabled(): boolean;
  31925. /** @hidden */
  31926. _updateNonUniformScalingState(value: boolean): boolean;
  31927. /**
  31928. * An event triggered when this mesh collides with another one
  31929. */
  31930. onCollideObservable: Observable<AbstractMesh>;
  31931. /** Set a function to call when this mesh collides with another one */
  31932. set onCollide(callback: () => void);
  31933. /**
  31934. * An event triggered when the collision's position changes
  31935. */
  31936. onCollisionPositionChangeObservable: Observable<Vector3>;
  31937. /** Set a function to call when the collision's position changes */
  31938. set onCollisionPositionChange(callback: () => void);
  31939. /**
  31940. * An event triggered when material is changed
  31941. */
  31942. onMaterialChangedObservable: Observable<AbstractMesh>;
  31943. /**
  31944. * Gets or sets the orientation for POV movement & rotation
  31945. */
  31946. definedFacingForward: boolean;
  31947. /** @hidden */
  31948. _occlusionQuery: Nullable<WebGLQuery>;
  31949. /** @hidden */
  31950. _renderingGroup: Nullable<RenderingGroup>;
  31951. /**
  31952. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  31953. */
  31954. get visibility(): number;
  31955. /**
  31956. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  31957. */
  31958. set visibility(value: number);
  31959. /** Gets or sets the alpha index used to sort transparent meshes
  31960. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  31961. */
  31962. alphaIndex: number;
  31963. /**
  31964. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  31965. */
  31966. isVisible: boolean;
  31967. /**
  31968. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  31969. */
  31970. isPickable: boolean;
  31971. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  31972. showSubMeshesBoundingBox: boolean;
  31973. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  31974. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  31975. */
  31976. isBlocker: boolean;
  31977. /**
  31978. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  31979. */
  31980. enablePointerMoveEvents: boolean;
  31981. /**
  31982. * Specifies the rendering group id for this mesh (0 by default)
  31983. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  31984. */
  31985. renderingGroupId: number;
  31986. private _material;
  31987. /** Gets or sets current material */
  31988. get material(): Nullable<Material>;
  31989. set material(value: Nullable<Material>);
  31990. /**
  31991. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  31992. * @see https://doc.babylonjs.com/babylon101/shadows
  31993. */
  31994. get receiveShadows(): boolean;
  31995. set receiveShadows(value: boolean);
  31996. /** Defines color to use when rendering outline */
  31997. outlineColor: Color3;
  31998. /** Define width to use when rendering outline */
  31999. outlineWidth: number;
  32000. /** Defines color to use when rendering overlay */
  32001. overlayColor: Color3;
  32002. /** Defines alpha to use when rendering overlay */
  32003. overlayAlpha: number;
  32004. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  32005. get hasVertexAlpha(): boolean;
  32006. set hasVertexAlpha(value: boolean);
  32007. /** 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) */
  32008. get useVertexColors(): boolean;
  32009. set useVertexColors(value: boolean);
  32010. /**
  32011. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  32012. */
  32013. get computeBonesUsingShaders(): boolean;
  32014. set computeBonesUsingShaders(value: boolean);
  32015. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  32016. get numBoneInfluencers(): number;
  32017. set numBoneInfluencers(value: number);
  32018. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  32019. get applyFog(): boolean;
  32020. set applyFog(value: boolean);
  32021. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  32022. useOctreeForRenderingSelection: boolean;
  32023. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  32024. useOctreeForPicking: boolean;
  32025. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  32026. useOctreeForCollisions: boolean;
  32027. /**
  32028. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  32029. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  32030. */
  32031. get layerMask(): number;
  32032. set layerMask(value: number);
  32033. /**
  32034. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  32035. */
  32036. alwaysSelectAsActiveMesh: boolean;
  32037. /**
  32038. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  32039. */
  32040. doNotSyncBoundingInfo: boolean;
  32041. /**
  32042. * Gets or sets the current action manager
  32043. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  32044. */
  32045. actionManager: Nullable<AbstractActionManager>;
  32046. private _meshCollisionData;
  32047. /**
  32048. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  32049. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32050. */
  32051. ellipsoid: Vector3;
  32052. /**
  32053. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  32054. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32055. */
  32056. ellipsoidOffset: Vector3;
  32057. /**
  32058. * Gets or sets a collision mask used to mask collisions (default is -1).
  32059. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32060. */
  32061. get collisionMask(): number;
  32062. set collisionMask(mask: number);
  32063. /**
  32064. * Gets or sets the current collision group mask (-1 by default).
  32065. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32066. */
  32067. get collisionGroup(): number;
  32068. set collisionGroup(mask: number);
  32069. /**
  32070. * Gets or sets current surrounding meshes (null by default).
  32071. *
  32072. * By default collision detection is tested against every mesh in the scene.
  32073. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  32074. * meshes will be tested for the collision.
  32075. *
  32076. * Note: if set to an empty array no collision will happen when this mesh is moved.
  32077. */
  32078. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  32079. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  32080. /**
  32081. * Defines edge width used when edgesRenderer is enabled
  32082. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32083. */
  32084. edgesWidth: number;
  32085. /**
  32086. * Defines edge color used when edgesRenderer is enabled
  32087. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32088. */
  32089. edgesColor: Color4;
  32090. /** @hidden */
  32091. _edgesRenderer: Nullable<IEdgesRenderer>;
  32092. /** @hidden */
  32093. _masterMesh: Nullable<AbstractMesh>;
  32094. /** @hidden */
  32095. _boundingInfo: Nullable<BoundingInfo>;
  32096. /** @hidden */
  32097. _renderId: number;
  32098. /**
  32099. * Gets or sets the list of subMeshes
  32100. * @see https://doc.babylonjs.com/how_to/multi_materials
  32101. */
  32102. subMeshes: SubMesh[];
  32103. /** @hidden */
  32104. _intersectionsInProgress: AbstractMesh[];
  32105. /** @hidden */
  32106. _unIndexed: boolean;
  32107. /** @hidden */
  32108. _lightSources: Light[];
  32109. /** Gets the list of lights affecting that mesh */
  32110. get lightSources(): Light[];
  32111. /** @hidden */
  32112. get _positions(): Nullable<Vector3[]>;
  32113. /** @hidden */
  32114. _waitingData: {
  32115. lods: Nullable<any>;
  32116. actions: Nullable<any>;
  32117. freezeWorldMatrix: Nullable<boolean>;
  32118. };
  32119. /** @hidden */
  32120. _bonesTransformMatrices: Nullable<Float32Array>;
  32121. /** @hidden */
  32122. _transformMatrixTexture: Nullable<RawTexture>;
  32123. /**
  32124. * Gets or sets a skeleton to apply skining transformations
  32125. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32126. */
  32127. set skeleton(value: Nullable<Skeleton>);
  32128. get skeleton(): Nullable<Skeleton>;
  32129. /**
  32130. * An event triggered when the mesh is rebuilt.
  32131. */
  32132. onRebuildObservable: Observable<AbstractMesh>;
  32133. /**
  32134. * Creates a new AbstractMesh
  32135. * @param name defines the name of the mesh
  32136. * @param scene defines the hosting scene
  32137. */
  32138. constructor(name: string, scene?: Nullable<Scene>);
  32139. /**
  32140. * Returns the string "AbstractMesh"
  32141. * @returns "AbstractMesh"
  32142. */
  32143. getClassName(): string;
  32144. /**
  32145. * Gets a string representation of the current mesh
  32146. * @param fullDetails defines a boolean indicating if full details must be included
  32147. * @returns a string representation of the current mesh
  32148. */
  32149. toString(fullDetails?: boolean): string;
  32150. /**
  32151. * @hidden
  32152. */
  32153. protected _getEffectiveParent(): Nullable<Node>;
  32154. /** @hidden */
  32155. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32156. /** @hidden */
  32157. _rebuild(): void;
  32158. /** @hidden */
  32159. _resyncLightSources(): void;
  32160. /** @hidden */
  32161. _resyncLightSource(light: Light): void;
  32162. /** @hidden */
  32163. _unBindEffect(): void;
  32164. /** @hidden */
  32165. _removeLightSource(light: Light, dispose: boolean): void;
  32166. private _markSubMeshesAsDirty;
  32167. /** @hidden */
  32168. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  32169. /** @hidden */
  32170. _markSubMeshesAsAttributesDirty(): void;
  32171. /** @hidden */
  32172. _markSubMeshesAsMiscDirty(): void;
  32173. /**
  32174. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  32175. */
  32176. get scaling(): Vector3;
  32177. set scaling(newScaling: Vector3);
  32178. /**
  32179. * Returns true if the mesh is blocked. Implemented by child classes
  32180. */
  32181. get isBlocked(): boolean;
  32182. /**
  32183. * Returns the mesh itself by default. Implemented by child classes
  32184. * @param camera defines the camera to use to pick the right LOD level
  32185. * @returns the currentAbstractMesh
  32186. */
  32187. getLOD(camera: Camera): Nullable<AbstractMesh>;
  32188. /**
  32189. * Returns 0 by default. Implemented by child classes
  32190. * @returns an integer
  32191. */
  32192. getTotalVertices(): number;
  32193. /**
  32194. * Returns a positive integer : the total number of indices in this mesh geometry.
  32195. * @returns the numner of indices or zero if the mesh has no geometry.
  32196. */
  32197. getTotalIndices(): number;
  32198. /**
  32199. * Returns null by default. Implemented by child classes
  32200. * @returns null
  32201. */
  32202. getIndices(): Nullable<IndicesArray>;
  32203. /**
  32204. * Returns the array of the requested vertex data kind. Implemented by child classes
  32205. * @param kind defines the vertex data kind to use
  32206. * @returns null
  32207. */
  32208. getVerticesData(kind: string): Nullable<FloatArray>;
  32209. /**
  32210. * Sets the vertex data of the mesh geometry for the requested `kind`.
  32211. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  32212. * Note that a new underlying VertexBuffer object is created each call.
  32213. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  32214. * @param kind defines vertex data kind:
  32215. * * VertexBuffer.PositionKind
  32216. * * VertexBuffer.UVKind
  32217. * * VertexBuffer.UV2Kind
  32218. * * VertexBuffer.UV3Kind
  32219. * * VertexBuffer.UV4Kind
  32220. * * VertexBuffer.UV5Kind
  32221. * * VertexBuffer.UV6Kind
  32222. * * VertexBuffer.ColorKind
  32223. * * VertexBuffer.MatricesIndicesKind
  32224. * * VertexBuffer.MatricesIndicesExtraKind
  32225. * * VertexBuffer.MatricesWeightsKind
  32226. * * VertexBuffer.MatricesWeightsExtraKind
  32227. * @param data defines the data source
  32228. * @param updatable defines if the data must be flagged as updatable (or static)
  32229. * @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
  32230. * @returns the current mesh
  32231. */
  32232. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32233. /**
  32234. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  32235. * If the mesh has no geometry, it is simply returned as it is.
  32236. * @param kind defines vertex data kind:
  32237. * * VertexBuffer.PositionKind
  32238. * * VertexBuffer.UVKind
  32239. * * VertexBuffer.UV2Kind
  32240. * * VertexBuffer.UV3Kind
  32241. * * VertexBuffer.UV4Kind
  32242. * * VertexBuffer.UV5Kind
  32243. * * VertexBuffer.UV6Kind
  32244. * * VertexBuffer.ColorKind
  32245. * * VertexBuffer.MatricesIndicesKind
  32246. * * VertexBuffer.MatricesIndicesExtraKind
  32247. * * VertexBuffer.MatricesWeightsKind
  32248. * * VertexBuffer.MatricesWeightsExtraKind
  32249. * @param data defines the data source
  32250. * @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
  32251. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  32252. * @returns the current mesh
  32253. */
  32254. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32255. /**
  32256. * Sets the mesh indices,
  32257. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  32258. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  32259. * @param totalVertices Defines the total number of vertices
  32260. * @returns the current mesh
  32261. */
  32262. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  32263. /**
  32264. * Gets a boolean indicating if specific vertex data is present
  32265. * @param kind defines the vertex data kind to use
  32266. * @returns true is data kind is present
  32267. */
  32268. isVerticesDataPresent(kind: string): boolean;
  32269. /**
  32270. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  32271. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  32272. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  32273. * @returns a BoundingInfo
  32274. */
  32275. getBoundingInfo(): BoundingInfo;
  32276. /**
  32277. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  32278. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  32279. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  32280. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  32281. * @returns the current mesh
  32282. */
  32283. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  32284. /**
  32285. * Overwrite the current bounding info
  32286. * @param boundingInfo defines the new bounding info
  32287. * @returns the current mesh
  32288. */
  32289. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  32290. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  32291. get useBones(): boolean;
  32292. /** @hidden */
  32293. _preActivate(): void;
  32294. /** @hidden */
  32295. _preActivateForIntermediateRendering(renderId: number): void;
  32296. /** @hidden */
  32297. _activate(renderId: number, intermediateRendering: boolean): boolean;
  32298. /** @hidden */
  32299. _postActivate(): void;
  32300. /** @hidden */
  32301. _freeze(): void;
  32302. /** @hidden */
  32303. _unFreeze(): void;
  32304. /**
  32305. * Gets the current world matrix
  32306. * @returns a Matrix
  32307. */
  32308. getWorldMatrix(): Matrix;
  32309. /** @hidden */
  32310. _getWorldMatrixDeterminant(): number;
  32311. /**
  32312. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  32313. */
  32314. get isAnInstance(): boolean;
  32315. /**
  32316. * Gets a boolean indicating if this mesh has instances
  32317. */
  32318. get hasInstances(): boolean;
  32319. /**
  32320. * Gets a boolean indicating if this mesh has thin instances
  32321. */
  32322. get hasThinInstances(): boolean;
  32323. /**
  32324. * Perform relative position change from the point of view of behind the front of the mesh.
  32325. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32326. * Supports definition of mesh facing forward or backward
  32327. * @param amountRight defines the distance on the right axis
  32328. * @param amountUp defines the distance on the up axis
  32329. * @param amountForward defines the distance on the forward axis
  32330. * @returns the current mesh
  32331. */
  32332. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  32333. /**
  32334. * Calculate relative position change from the point of view of behind the front of the mesh.
  32335. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32336. * Supports definition of mesh facing forward or backward
  32337. * @param amountRight defines the distance on the right axis
  32338. * @param amountUp defines the distance on the up axis
  32339. * @param amountForward defines the distance on the forward axis
  32340. * @returns the new displacement vector
  32341. */
  32342. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  32343. /**
  32344. * Perform relative rotation change from the point of view of behind the front of the mesh.
  32345. * Supports definition of mesh facing forward or backward
  32346. * @param flipBack defines the flip
  32347. * @param twirlClockwise defines the twirl
  32348. * @param tiltRight defines the tilt
  32349. * @returns the current mesh
  32350. */
  32351. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  32352. /**
  32353. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  32354. * Supports definition of mesh facing forward or backward.
  32355. * @param flipBack defines the flip
  32356. * @param twirlClockwise defines the twirl
  32357. * @param tiltRight defines the tilt
  32358. * @returns the new rotation vector
  32359. */
  32360. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  32361. /**
  32362. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32363. * This means the mesh underlying bounding box and sphere are recomputed.
  32364. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32365. * @returns the current mesh
  32366. */
  32367. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  32368. /** @hidden */
  32369. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  32370. /** @hidden */
  32371. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  32372. /** @hidden */
  32373. _updateBoundingInfo(): AbstractMesh;
  32374. /** @hidden */
  32375. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  32376. /** @hidden */
  32377. protected _afterComputeWorldMatrix(): void;
  32378. /** @hidden */
  32379. get _effectiveMesh(): AbstractMesh;
  32380. /**
  32381. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32382. * A mesh is in the frustum if its bounding box intersects the frustum
  32383. * @param frustumPlanes defines the frustum to test
  32384. * @returns true if the mesh is in the frustum planes
  32385. */
  32386. isInFrustum(frustumPlanes: Plane[]): boolean;
  32387. /**
  32388. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  32389. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  32390. * @param frustumPlanes defines the frustum to test
  32391. * @returns true if the mesh is completely in the frustum planes
  32392. */
  32393. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  32394. /**
  32395. * True if the mesh intersects another mesh or a SolidParticle object
  32396. * @param mesh defines a target mesh or SolidParticle to test
  32397. * @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)
  32398. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  32399. * @returns true if there is an intersection
  32400. */
  32401. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  32402. /**
  32403. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  32404. * @param point defines the point to test
  32405. * @returns true if there is an intersection
  32406. */
  32407. intersectsPoint(point: Vector3): boolean;
  32408. /**
  32409. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  32410. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32411. */
  32412. get checkCollisions(): boolean;
  32413. set checkCollisions(collisionEnabled: boolean);
  32414. /**
  32415. * Gets Collider object used to compute collisions (not physics)
  32416. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32417. */
  32418. get collider(): Nullable<Collider>;
  32419. /**
  32420. * Move the mesh using collision engine
  32421. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32422. * @param displacement defines the requested displacement vector
  32423. * @returns the current mesh
  32424. */
  32425. moveWithCollisions(displacement: Vector3): AbstractMesh;
  32426. private _onCollisionPositionChange;
  32427. /** @hidden */
  32428. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  32429. /** @hidden */
  32430. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  32431. /** @hidden */
  32432. _checkCollision(collider: Collider): AbstractMesh;
  32433. /** @hidden */
  32434. _generatePointsArray(): boolean;
  32435. /**
  32436. * Checks if the passed Ray intersects with the mesh
  32437. * @param ray defines the ray to use
  32438. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  32439. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32440. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  32441. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  32442. * @returns the picking info
  32443. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  32444. */
  32445. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  32446. /**
  32447. * Clones the current mesh
  32448. * @param name defines the mesh name
  32449. * @param newParent defines the new mesh parent
  32450. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  32451. * @returns the new mesh
  32452. */
  32453. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  32454. /**
  32455. * Disposes all the submeshes of the current meshnp
  32456. * @returns the current mesh
  32457. */
  32458. releaseSubMeshes(): AbstractMesh;
  32459. /**
  32460. * Releases resources associated with this abstract mesh.
  32461. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32462. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32463. */
  32464. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32465. /**
  32466. * Adds the passed mesh as a child to the current mesh
  32467. * @param mesh defines the child mesh
  32468. * @returns the current mesh
  32469. */
  32470. addChild(mesh: AbstractMesh): AbstractMesh;
  32471. /**
  32472. * Removes the passed mesh from the current mesh children list
  32473. * @param mesh defines the child mesh
  32474. * @returns the current mesh
  32475. */
  32476. removeChild(mesh: AbstractMesh): AbstractMesh;
  32477. /** @hidden */
  32478. private _initFacetData;
  32479. /**
  32480. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  32481. * This method can be called within the render loop.
  32482. * 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
  32483. * @returns the current mesh
  32484. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32485. */
  32486. updateFacetData(): AbstractMesh;
  32487. /**
  32488. * Returns the facetLocalNormals array.
  32489. * The normals are expressed in the mesh local spac
  32490. * @returns an array of Vector3
  32491. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32492. */
  32493. getFacetLocalNormals(): Vector3[];
  32494. /**
  32495. * Returns the facetLocalPositions array.
  32496. * The facet positions are expressed in the mesh local space
  32497. * @returns an array of Vector3
  32498. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32499. */
  32500. getFacetLocalPositions(): Vector3[];
  32501. /**
  32502. * Returns the facetLocalPartioning array
  32503. * @returns an array of array of numbers
  32504. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32505. */
  32506. getFacetLocalPartitioning(): number[][];
  32507. /**
  32508. * Returns the i-th facet position in the world system.
  32509. * This method allocates a new Vector3 per call
  32510. * @param i defines the facet index
  32511. * @returns a new Vector3
  32512. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32513. */
  32514. getFacetPosition(i: number): Vector3;
  32515. /**
  32516. * Sets the reference Vector3 with the i-th facet position in the world system
  32517. * @param i defines the facet index
  32518. * @param ref defines the target vector
  32519. * @returns the current mesh
  32520. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32521. */
  32522. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  32523. /**
  32524. * Returns the i-th facet normal in the world system.
  32525. * This method allocates a new Vector3 per call
  32526. * @param i defines the facet index
  32527. * @returns a new Vector3
  32528. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32529. */
  32530. getFacetNormal(i: number): Vector3;
  32531. /**
  32532. * Sets the reference Vector3 with the i-th facet normal in the world system
  32533. * @param i defines the facet index
  32534. * @param ref defines the target vector
  32535. * @returns the current mesh
  32536. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32537. */
  32538. getFacetNormalToRef(i: number, ref: Vector3): this;
  32539. /**
  32540. * 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)
  32541. * @param x defines x coordinate
  32542. * @param y defines y coordinate
  32543. * @param z defines z coordinate
  32544. * @returns the array of facet indexes
  32545. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32546. */
  32547. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  32548. /**
  32549. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  32550. * @param projected sets as the (x,y,z) world projection on the facet
  32551. * @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
  32552. * @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
  32553. * @param x defines x coordinate
  32554. * @param y defines y coordinate
  32555. * @param z defines z coordinate
  32556. * @returns the face index if found (or null instead)
  32557. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32558. */
  32559. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32560. /**
  32561. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  32562. * @param projected sets as the (x,y,z) local projection on the facet
  32563. * @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
  32564. * @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
  32565. * @param x defines x coordinate
  32566. * @param y defines y coordinate
  32567. * @param z defines z coordinate
  32568. * @returns the face index if found (or null instead)
  32569. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32570. */
  32571. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32572. /**
  32573. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  32574. * @returns the parameters
  32575. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32576. */
  32577. getFacetDataParameters(): any;
  32578. /**
  32579. * Disables the feature FacetData and frees the related memory
  32580. * @returns the current mesh
  32581. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32582. */
  32583. disableFacetData(): AbstractMesh;
  32584. /**
  32585. * Updates the AbstractMesh indices array
  32586. * @param indices defines the data source
  32587. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32588. * @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)
  32589. * @returns the current mesh
  32590. */
  32591. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32592. /**
  32593. * Creates new normals data for the mesh
  32594. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  32595. * @returns the current mesh
  32596. */
  32597. createNormals(updatable: boolean): AbstractMesh;
  32598. /**
  32599. * Align the mesh with a normal
  32600. * @param normal defines the normal to use
  32601. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  32602. * @returns the current mesh
  32603. */
  32604. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  32605. /** @hidden */
  32606. _checkOcclusionQuery(): boolean;
  32607. /**
  32608. * Disables the mesh edge rendering mode
  32609. * @returns the currentAbstractMesh
  32610. */
  32611. disableEdgesRendering(): AbstractMesh;
  32612. /**
  32613. * Enables the edge rendering mode on the mesh.
  32614. * This mode makes the mesh edges visible
  32615. * @param epsilon defines the maximal distance between two angles to detect a face
  32616. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  32617. * @returns the currentAbstractMesh
  32618. * @see https://www.babylonjs-playground.com/#19O9TU#0
  32619. */
  32620. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  32621. /**
  32622. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  32623. * @returns an array of particle systems in the scene that use the mesh as an emitter
  32624. */
  32625. getConnectedParticleSystems(): IParticleSystem[];
  32626. }
  32627. }
  32628. declare module BABYLON {
  32629. /**
  32630. * Interface used to define ActionEvent
  32631. */
  32632. export interface IActionEvent {
  32633. /** The mesh or sprite that triggered the action */
  32634. source: any;
  32635. /** The X mouse cursor position at the time of the event */
  32636. pointerX: number;
  32637. /** The Y mouse cursor position at the time of the event */
  32638. pointerY: number;
  32639. /** The mesh that is currently pointed at (can be null) */
  32640. meshUnderPointer: Nullable<AbstractMesh>;
  32641. /** the original (browser) event that triggered the ActionEvent */
  32642. sourceEvent?: any;
  32643. /** additional data for the event */
  32644. additionalData?: any;
  32645. }
  32646. /**
  32647. * ActionEvent is the event being sent when an action is triggered.
  32648. */
  32649. export class ActionEvent implements IActionEvent {
  32650. /** The mesh or sprite that triggered the action */
  32651. source: any;
  32652. /** The X mouse cursor position at the time of the event */
  32653. pointerX: number;
  32654. /** The Y mouse cursor position at the time of the event */
  32655. pointerY: number;
  32656. /** The mesh that is currently pointed at (can be null) */
  32657. meshUnderPointer: Nullable<AbstractMesh>;
  32658. /** the original (browser) event that triggered the ActionEvent */
  32659. sourceEvent?: any;
  32660. /** additional data for the event */
  32661. additionalData?: any;
  32662. /**
  32663. * Creates a new ActionEvent
  32664. * @param source The mesh or sprite that triggered the action
  32665. * @param pointerX The X mouse cursor position at the time of the event
  32666. * @param pointerY The Y mouse cursor position at the time of the event
  32667. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  32668. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  32669. * @param additionalData additional data for the event
  32670. */
  32671. constructor(
  32672. /** The mesh or sprite that triggered the action */
  32673. source: any,
  32674. /** The X mouse cursor position at the time of the event */
  32675. pointerX: number,
  32676. /** The Y mouse cursor position at the time of the event */
  32677. pointerY: number,
  32678. /** The mesh that is currently pointed at (can be null) */
  32679. meshUnderPointer: Nullable<AbstractMesh>,
  32680. /** the original (browser) event that triggered the ActionEvent */
  32681. sourceEvent?: any,
  32682. /** additional data for the event */
  32683. additionalData?: any);
  32684. /**
  32685. * Helper function to auto-create an ActionEvent from a source mesh.
  32686. * @param source The source mesh that triggered the event
  32687. * @param evt The original (browser) event
  32688. * @param additionalData additional data for the event
  32689. * @returns the new ActionEvent
  32690. */
  32691. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  32692. /**
  32693. * Helper function to auto-create an ActionEvent from a source sprite
  32694. * @param source The source sprite that triggered the event
  32695. * @param scene Scene associated with the sprite
  32696. * @param evt The original (browser) event
  32697. * @param additionalData additional data for the event
  32698. * @returns the new ActionEvent
  32699. */
  32700. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  32701. /**
  32702. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  32703. * @param scene the scene where the event occurred
  32704. * @param evt The original (browser) event
  32705. * @returns the new ActionEvent
  32706. */
  32707. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  32708. /**
  32709. * Helper function to auto-create an ActionEvent from a primitive
  32710. * @param prim defines the target primitive
  32711. * @param pointerPos defines the pointer position
  32712. * @param evt The original (browser) event
  32713. * @param additionalData additional data for the event
  32714. * @returns the new ActionEvent
  32715. */
  32716. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  32717. }
  32718. }
  32719. declare module BABYLON {
  32720. /**
  32721. * Abstract class used to decouple action Manager from scene and meshes.
  32722. * Do not instantiate.
  32723. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  32724. */
  32725. export abstract class AbstractActionManager implements IDisposable {
  32726. /** Gets the list of active triggers */
  32727. static Triggers: {
  32728. [key: string]: number;
  32729. };
  32730. /** Gets the cursor to use when hovering items */
  32731. hoverCursor: string;
  32732. /** Gets the list of actions */
  32733. actions: IAction[];
  32734. /**
  32735. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  32736. */
  32737. isRecursive: boolean;
  32738. /**
  32739. * Releases all associated resources
  32740. */
  32741. abstract dispose(): void;
  32742. /**
  32743. * Does this action manager has pointer triggers
  32744. */
  32745. abstract get hasPointerTriggers(): boolean;
  32746. /**
  32747. * Does this action manager has pick triggers
  32748. */
  32749. abstract get hasPickTriggers(): boolean;
  32750. /**
  32751. * Process a specific trigger
  32752. * @param trigger defines the trigger to process
  32753. * @param evt defines the event details to be processed
  32754. */
  32755. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  32756. /**
  32757. * Does this action manager handles actions of any of the given triggers
  32758. * @param triggers defines the triggers to be tested
  32759. * @return a boolean indicating whether one (or more) of the triggers is handled
  32760. */
  32761. abstract hasSpecificTriggers(triggers: number[]): boolean;
  32762. /**
  32763. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  32764. * speed.
  32765. * @param triggerA defines the trigger to be tested
  32766. * @param triggerB defines the trigger to be tested
  32767. * @return a boolean indicating whether one (or more) of the triggers is handled
  32768. */
  32769. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  32770. /**
  32771. * Does this action manager handles actions of a given trigger
  32772. * @param trigger defines the trigger to be tested
  32773. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  32774. * @return whether the trigger is handled
  32775. */
  32776. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  32777. /**
  32778. * Serialize this manager to a JSON object
  32779. * @param name defines the property name to store this manager
  32780. * @returns a JSON representation of this manager
  32781. */
  32782. abstract serialize(name: string): any;
  32783. /**
  32784. * Registers an action to this action manager
  32785. * @param action defines the action to be registered
  32786. * @return the action amended (prepared) after registration
  32787. */
  32788. abstract registerAction(action: IAction): Nullable<IAction>;
  32789. /**
  32790. * Unregisters an action to this action manager
  32791. * @param action defines the action to be unregistered
  32792. * @return a boolean indicating whether the action has been unregistered
  32793. */
  32794. abstract unregisterAction(action: IAction): Boolean;
  32795. /**
  32796. * Does exist one action manager with at least one trigger
  32797. **/
  32798. static get HasTriggers(): boolean;
  32799. /**
  32800. * Does exist one action manager with at least one pick trigger
  32801. **/
  32802. static get HasPickTriggers(): boolean;
  32803. /**
  32804. * Does exist one action manager that handles actions of a given trigger
  32805. * @param trigger defines the trigger to be tested
  32806. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  32807. **/
  32808. static HasSpecificTrigger(trigger: number): boolean;
  32809. }
  32810. }
  32811. declare module BABYLON {
  32812. /**
  32813. * Defines how a node can be built from a string name.
  32814. */
  32815. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  32816. /**
  32817. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  32818. */
  32819. export class Node implements IBehaviorAware<Node> {
  32820. /** @hidden */
  32821. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  32822. private static _NodeConstructors;
  32823. /**
  32824. * Add a new node constructor
  32825. * @param type defines the type name of the node to construct
  32826. * @param constructorFunc defines the constructor function
  32827. */
  32828. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  32829. /**
  32830. * Returns a node constructor based on type name
  32831. * @param type defines the type name
  32832. * @param name defines the new node name
  32833. * @param scene defines the hosting scene
  32834. * @param options defines optional options to transmit to constructors
  32835. * @returns the new constructor or null
  32836. */
  32837. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  32838. /**
  32839. * Gets or sets the name of the node
  32840. */
  32841. name: string;
  32842. /**
  32843. * Gets or sets the id of the node
  32844. */
  32845. id: string;
  32846. /**
  32847. * Gets or sets the unique id of the node
  32848. */
  32849. uniqueId: number;
  32850. /**
  32851. * Gets or sets a string used to store user defined state for the node
  32852. */
  32853. state: string;
  32854. /**
  32855. * Gets or sets an object used to store user defined information for the node
  32856. */
  32857. metadata: any;
  32858. /**
  32859. * For internal use only. Please do not use.
  32860. */
  32861. reservedDataStore: any;
  32862. /**
  32863. * List of inspectable custom properties (used by the Inspector)
  32864. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  32865. */
  32866. inspectableCustomProperties: IInspectable[];
  32867. private _doNotSerialize;
  32868. /**
  32869. * Gets or sets a boolean used to define if the node must be serialized
  32870. */
  32871. get doNotSerialize(): boolean;
  32872. set doNotSerialize(value: boolean);
  32873. /** @hidden */
  32874. _isDisposed: boolean;
  32875. /**
  32876. * Gets a list of Animations associated with the node
  32877. */
  32878. animations: Animation[];
  32879. protected _ranges: {
  32880. [name: string]: Nullable<AnimationRange>;
  32881. };
  32882. /**
  32883. * Callback raised when the node is ready to be used
  32884. */
  32885. onReady: Nullable<(node: Node) => void>;
  32886. private _isEnabled;
  32887. private _isParentEnabled;
  32888. private _isReady;
  32889. /** @hidden */
  32890. _currentRenderId: number;
  32891. private _parentUpdateId;
  32892. /** @hidden */
  32893. _childUpdateId: number;
  32894. /** @hidden */
  32895. _waitingParentId: Nullable<string>;
  32896. /** @hidden */
  32897. _scene: Scene;
  32898. /** @hidden */
  32899. _cache: any;
  32900. private _parentNode;
  32901. private _children;
  32902. /** @hidden */
  32903. _worldMatrix: Matrix;
  32904. /** @hidden */
  32905. _worldMatrixDeterminant: number;
  32906. /** @hidden */
  32907. _worldMatrixDeterminantIsDirty: boolean;
  32908. /** @hidden */
  32909. private _sceneRootNodesIndex;
  32910. /**
  32911. * Gets a boolean indicating if the node has been disposed
  32912. * @returns true if the node was disposed
  32913. */
  32914. isDisposed(): boolean;
  32915. /**
  32916. * Gets or sets the parent of the node (without keeping the current position in the scene)
  32917. * @see https://doc.babylonjs.com/how_to/parenting
  32918. */
  32919. set parent(parent: Nullable<Node>);
  32920. get parent(): Nullable<Node>;
  32921. /** @hidden */
  32922. _addToSceneRootNodes(): void;
  32923. /** @hidden */
  32924. _removeFromSceneRootNodes(): void;
  32925. private _animationPropertiesOverride;
  32926. /**
  32927. * Gets or sets the animation properties override
  32928. */
  32929. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  32930. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  32931. /**
  32932. * Gets a string idenfifying the name of the class
  32933. * @returns "Node" string
  32934. */
  32935. getClassName(): string;
  32936. /** @hidden */
  32937. readonly _isNode: boolean;
  32938. /**
  32939. * An event triggered when the mesh is disposed
  32940. */
  32941. onDisposeObservable: Observable<Node>;
  32942. private _onDisposeObserver;
  32943. /**
  32944. * Sets a callback that will be raised when the node will be disposed
  32945. */
  32946. set onDispose(callback: () => void);
  32947. /**
  32948. * Creates a new Node
  32949. * @param name the name and id to be given to this node
  32950. * @param scene the scene this node will be added to
  32951. */
  32952. constructor(name: string, scene?: Nullable<Scene>);
  32953. /**
  32954. * Gets the scene of the node
  32955. * @returns a scene
  32956. */
  32957. getScene(): Scene;
  32958. /**
  32959. * Gets the engine of the node
  32960. * @returns a Engine
  32961. */
  32962. getEngine(): Engine;
  32963. private _behaviors;
  32964. /**
  32965. * Attach a behavior to the node
  32966. * @see https://doc.babylonjs.com/features/behaviour
  32967. * @param behavior defines the behavior to attach
  32968. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  32969. * @returns the current Node
  32970. */
  32971. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  32972. /**
  32973. * Remove an attached behavior
  32974. * @see https://doc.babylonjs.com/features/behaviour
  32975. * @param behavior defines the behavior to attach
  32976. * @returns the current Node
  32977. */
  32978. removeBehavior(behavior: Behavior<Node>): Node;
  32979. /**
  32980. * Gets the list of attached behaviors
  32981. * @see https://doc.babylonjs.com/features/behaviour
  32982. */
  32983. get behaviors(): Behavior<Node>[];
  32984. /**
  32985. * Gets an attached behavior by name
  32986. * @param name defines the name of the behavior to look for
  32987. * @see https://doc.babylonjs.com/features/behaviour
  32988. * @returns null if behavior was not found else the requested behavior
  32989. */
  32990. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  32991. /**
  32992. * Returns the latest update of the World matrix
  32993. * @returns a Matrix
  32994. */
  32995. getWorldMatrix(): Matrix;
  32996. /** @hidden */
  32997. _getWorldMatrixDeterminant(): number;
  32998. /**
  32999. * Returns directly the latest state of the mesh World matrix.
  33000. * A Matrix is returned.
  33001. */
  33002. get worldMatrixFromCache(): Matrix;
  33003. /** @hidden */
  33004. _initCache(): void;
  33005. /** @hidden */
  33006. updateCache(force?: boolean): void;
  33007. /** @hidden */
  33008. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33009. /** @hidden */
  33010. _updateCache(ignoreParentClass?: boolean): void;
  33011. /** @hidden */
  33012. _isSynchronized(): boolean;
  33013. /** @hidden */
  33014. _markSyncedWithParent(): void;
  33015. /** @hidden */
  33016. isSynchronizedWithParent(): boolean;
  33017. /** @hidden */
  33018. isSynchronized(): boolean;
  33019. /**
  33020. * Is this node ready to be used/rendered
  33021. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33022. * @return true if the node is ready
  33023. */
  33024. isReady(completeCheck?: boolean): boolean;
  33025. /**
  33026. * Is this node enabled?
  33027. * 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
  33028. * @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
  33029. * @return whether this node (and its parent) is enabled
  33030. */
  33031. isEnabled(checkAncestors?: boolean): boolean;
  33032. /** @hidden */
  33033. protected _syncParentEnabledState(): void;
  33034. /**
  33035. * Set the enabled state of this node
  33036. * @param value defines the new enabled state
  33037. */
  33038. setEnabled(value: boolean): void;
  33039. /**
  33040. * Is this node a descendant of the given node?
  33041. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  33042. * @param ancestor defines the parent node to inspect
  33043. * @returns a boolean indicating if this node is a descendant of the given node
  33044. */
  33045. isDescendantOf(ancestor: Node): boolean;
  33046. /** @hidden */
  33047. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  33048. /**
  33049. * Will return all nodes that have this node as ascendant
  33050. * @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
  33051. * @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
  33052. * @return all children nodes of all types
  33053. */
  33054. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  33055. /**
  33056. * Get all child-meshes of this node
  33057. * @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)
  33058. * @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
  33059. * @returns an array of AbstractMesh
  33060. */
  33061. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  33062. /**
  33063. * Get all direct children of this node
  33064. * @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
  33065. * @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)
  33066. * @returns an array of Node
  33067. */
  33068. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  33069. /** @hidden */
  33070. _setReady(state: boolean): void;
  33071. /**
  33072. * Get an animation by name
  33073. * @param name defines the name of the animation to look for
  33074. * @returns null if not found else the requested animation
  33075. */
  33076. getAnimationByName(name: string): Nullable<Animation>;
  33077. /**
  33078. * Creates an animation range for this node
  33079. * @param name defines the name of the range
  33080. * @param from defines the starting key
  33081. * @param to defines the end key
  33082. */
  33083. createAnimationRange(name: string, from: number, to: number): void;
  33084. /**
  33085. * Delete a specific animation range
  33086. * @param name defines the name of the range to delete
  33087. * @param deleteFrames defines if animation frames from the range must be deleted as well
  33088. */
  33089. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  33090. /**
  33091. * Get an animation range by name
  33092. * @param name defines the name of the animation range to look for
  33093. * @returns null if not found else the requested animation range
  33094. */
  33095. getAnimationRange(name: string): Nullable<AnimationRange>;
  33096. /**
  33097. * Gets the list of all animation ranges defined on this node
  33098. * @returns an array
  33099. */
  33100. getAnimationRanges(): Nullable<AnimationRange>[];
  33101. /**
  33102. * Will start the animation sequence
  33103. * @param name defines the range frames for animation sequence
  33104. * @param loop defines if the animation should loop (false by default)
  33105. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  33106. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  33107. * @returns the object created for this animation. If range does not exist, it will return null
  33108. */
  33109. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  33110. /**
  33111. * Serialize animation ranges into a JSON compatible object
  33112. * @returns serialization object
  33113. */
  33114. serializeAnimationRanges(): any;
  33115. /**
  33116. * Computes the world matrix of the node
  33117. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  33118. * @returns the world matrix
  33119. */
  33120. computeWorldMatrix(force?: boolean): Matrix;
  33121. /**
  33122. * Releases resources associated with this node.
  33123. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33124. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33125. */
  33126. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33127. /**
  33128. * Parse animation range data from a serialization object and store them into a given node
  33129. * @param node defines where to store the animation ranges
  33130. * @param parsedNode defines the serialization object to read data from
  33131. * @param scene defines the hosting scene
  33132. */
  33133. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  33134. /**
  33135. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  33136. * @param includeDescendants Include bounding info from descendants as well (true by default)
  33137. * @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
  33138. * @returns the new bounding vectors
  33139. */
  33140. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  33141. min: Vector3;
  33142. max: Vector3;
  33143. };
  33144. }
  33145. }
  33146. declare module BABYLON {
  33147. /**
  33148. * @hidden
  33149. */
  33150. export class _IAnimationState {
  33151. key: number;
  33152. repeatCount: number;
  33153. workValue?: any;
  33154. loopMode?: number;
  33155. offsetValue?: any;
  33156. highLimitValue?: any;
  33157. }
  33158. /**
  33159. * Class used to store any kind of animation
  33160. */
  33161. export class Animation {
  33162. /**Name of the animation */
  33163. name: string;
  33164. /**Property to animate */
  33165. targetProperty: string;
  33166. /**The frames per second of the animation */
  33167. framePerSecond: number;
  33168. /**The data type of the animation */
  33169. dataType: number;
  33170. /**The loop mode of the animation */
  33171. loopMode?: number | undefined;
  33172. /**Specifies if blending should be enabled */
  33173. enableBlending?: boolean | undefined;
  33174. /**
  33175. * Use matrix interpolation instead of using direct key value when animating matrices
  33176. */
  33177. static AllowMatricesInterpolation: boolean;
  33178. /**
  33179. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  33180. */
  33181. static AllowMatrixDecomposeForInterpolation: boolean;
  33182. /** Define the Url to load snippets */
  33183. static SnippetUrl: string;
  33184. /** Snippet ID if the animation was created from the snippet server */
  33185. snippetId: string;
  33186. /**
  33187. * Stores the key frames of the animation
  33188. */
  33189. private _keys;
  33190. /**
  33191. * Stores the easing function of the animation
  33192. */
  33193. private _easingFunction;
  33194. /**
  33195. * @hidden Internal use only
  33196. */
  33197. _runtimeAnimations: RuntimeAnimation[];
  33198. /**
  33199. * The set of event that will be linked to this animation
  33200. */
  33201. private _events;
  33202. /**
  33203. * Stores an array of target property paths
  33204. */
  33205. targetPropertyPath: string[];
  33206. /**
  33207. * Stores the blending speed of the animation
  33208. */
  33209. blendingSpeed: number;
  33210. /**
  33211. * Stores the animation ranges for the animation
  33212. */
  33213. private _ranges;
  33214. /**
  33215. * @hidden Internal use
  33216. */
  33217. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  33218. /**
  33219. * Sets up an animation
  33220. * @param property The property to animate
  33221. * @param animationType The animation type to apply
  33222. * @param framePerSecond The frames per second of the animation
  33223. * @param easingFunction The easing function used in the animation
  33224. * @returns The created animation
  33225. */
  33226. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  33227. /**
  33228. * Create and start an animation on a node
  33229. * @param name defines the name of the global animation that will be run on all nodes
  33230. * @param node defines the root node where the animation will take place
  33231. * @param targetProperty defines property to animate
  33232. * @param framePerSecond defines the number of frame per second yo use
  33233. * @param totalFrame defines the number of frames in total
  33234. * @param from defines the initial value
  33235. * @param to defines the final value
  33236. * @param loopMode defines which loop mode you want to use (off by default)
  33237. * @param easingFunction defines the easing function to use (linear by default)
  33238. * @param onAnimationEnd defines the callback to call when animation end
  33239. * @returns the animatable created for this animation
  33240. */
  33241. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33242. /**
  33243. * Create and start an animation on a node and its descendants
  33244. * @param name defines the name of the global animation that will be run on all nodes
  33245. * @param node defines the root node where the animation will take place
  33246. * @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
  33247. * @param targetProperty defines property to animate
  33248. * @param framePerSecond defines the number of frame per second to use
  33249. * @param totalFrame defines the number of frames in total
  33250. * @param from defines the initial value
  33251. * @param to defines the final value
  33252. * @param loopMode defines which loop mode you want to use (off by default)
  33253. * @param easingFunction defines the easing function to use (linear by default)
  33254. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33255. * @returns the list of animatables created for all nodes
  33256. * @example https://www.babylonjs-playground.com/#MH0VLI
  33257. */
  33258. 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[]>;
  33259. /**
  33260. * Creates a new animation, merges it with the existing animations and starts it
  33261. * @param name Name of the animation
  33262. * @param node Node which contains the scene that begins the animations
  33263. * @param targetProperty Specifies which property to animate
  33264. * @param framePerSecond The frames per second of the animation
  33265. * @param totalFrame The total number of frames
  33266. * @param from The frame at the beginning of the animation
  33267. * @param to The frame at the end of the animation
  33268. * @param loopMode Specifies the loop mode of the animation
  33269. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  33270. * @param onAnimationEnd Callback to run once the animation is complete
  33271. * @returns Nullable animation
  33272. */
  33273. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33274. /**
  33275. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  33276. * @param sourceAnimation defines the Animation containing keyframes to convert
  33277. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  33278. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  33279. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  33280. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  33281. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  33282. */
  33283. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  33284. /**
  33285. * Transition property of an host to the target Value
  33286. * @param property The property to transition
  33287. * @param targetValue The target Value of the property
  33288. * @param host The object where the property to animate belongs
  33289. * @param scene Scene used to run the animation
  33290. * @param frameRate Framerate (in frame/s) to use
  33291. * @param transition The transition type we want to use
  33292. * @param duration The duration of the animation, in milliseconds
  33293. * @param onAnimationEnd Callback trigger at the end of the animation
  33294. * @returns Nullable animation
  33295. */
  33296. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  33297. /**
  33298. * Return the array of runtime animations currently using this animation
  33299. */
  33300. get runtimeAnimations(): RuntimeAnimation[];
  33301. /**
  33302. * Specifies if any of the runtime animations are currently running
  33303. */
  33304. get hasRunningRuntimeAnimations(): boolean;
  33305. /**
  33306. * Initializes the animation
  33307. * @param name Name of the animation
  33308. * @param targetProperty Property to animate
  33309. * @param framePerSecond The frames per second of the animation
  33310. * @param dataType The data type of the animation
  33311. * @param loopMode The loop mode of the animation
  33312. * @param enableBlending Specifies if blending should be enabled
  33313. */
  33314. constructor(
  33315. /**Name of the animation */
  33316. name: string,
  33317. /**Property to animate */
  33318. targetProperty: string,
  33319. /**The frames per second of the animation */
  33320. framePerSecond: number,
  33321. /**The data type of the animation */
  33322. dataType: number,
  33323. /**The loop mode of the animation */
  33324. loopMode?: number | undefined,
  33325. /**Specifies if blending should be enabled */
  33326. enableBlending?: boolean | undefined);
  33327. /**
  33328. * Converts the animation to a string
  33329. * @param fullDetails support for multiple levels of logging within scene loading
  33330. * @returns String form of the animation
  33331. */
  33332. toString(fullDetails?: boolean): string;
  33333. /**
  33334. * Add an event to this animation
  33335. * @param event Event to add
  33336. */
  33337. addEvent(event: AnimationEvent): void;
  33338. /**
  33339. * Remove all events found at the given frame
  33340. * @param frame The frame to remove events from
  33341. */
  33342. removeEvents(frame: number): void;
  33343. /**
  33344. * Retrieves all the events from the animation
  33345. * @returns Events from the animation
  33346. */
  33347. getEvents(): AnimationEvent[];
  33348. /**
  33349. * Creates an animation range
  33350. * @param name Name of the animation range
  33351. * @param from Starting frame of the animation range
  33352. * @param to Ending frame of the animation
  33353. */
  33354. createRange(name: string, from: number, to: number): void;
  33355. /**
  33356. * Deletes an animation range by name
  33357. * @param name Name of the animation range to delete
  33358. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  33359. */
  33360. deleteRange(name: string, deleteFrames?: boolean): void;
  33361. /**
  33362. * Gets the animation range by name, or null if not defined
  33363. * @param name Name of the animation range
  33364. * @returns Nullable animation range
  33365. */
  33366. getRange(name: string): Nullable<AnimationRange>;
  33367. /**
  33368. * Gets the key frames from the animation
  33369. * @returns The key frames of the animation
  33370. */
  33371. getKeys(): Array<IAnimationKey>;
  33372. /**
  33373. * Gets the highest frame rate of the animation
  33374. * @returns Highest frame rate of the animation
  33375. */
  33376. getHighestFrame(): number;
  33377. /**
  33378. * Gets the easing function of the animation
  33379. * @returns Easing function of the animation
  33380. */
  33381. getEasingFunction(): IEasingFunction;
  33382. /**
  33383. * Sets the easing function of the animation
  33384. * @param easingFunction A custom mathematical formula for animation
  33385. */
  33386. setEasingFunction(easingFunction: EasingFunction): void;
  33387. /**
  33388. * Interpolates a scalar linearly
  33389. * @param startValue Start value of the animation curve
  33390. * @param endValue End value of the animation curve
  33391. * @param gradient Scalar amount to interpolate
  33392. * @returns Interpolated scalar value
  33393. */
  33394. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  33395. /**
  33396. * Interpolates a scalar cubically
  33397. * @param startValue Start value of the animation curve
  33398. * @param outTangent End tangent of the animation
  33399. * @param endValue End value of the animation curve
  33400. * @param inTangent Start tangent of the animation curve
  33401. * @param gradient Scalar amount to interpolate
  33402. * @returns Interpolated scalar value
  33403. */
  33404. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  33405. /**
  33406. * Interpolates a quaternion using a spherical linear interpolation
  33407. * @param startValue Start value of the animation curve
  33408. * @param endValue End value of the animation curve
  33409. * @param gradient Scalar amount to interpolate
  33410. * @returns Interpolated quaternion value
  33411. */
  33412. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  33413. /**
  33414. * Interpolates a quaternion cubically
  33415. * @param startValue Start value of the animation curve
  33416. * @param outTangent End tangent of the animation curve
  33417. * @param endValue End value of the animation curve
  33418. * @param inTangent Start tangent of the animation curve
  33419. * @param gradient Scalar amount to interpolate
  33420. * @returns Interpolated quaternion value
  33421. */
  33422. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  33423. /**
  33424. * Interpolates a Vector3 linearl
  33425. * @param startValue Start value of the animation curve
  33426. * @param endValue End value of the animation curve
  33427. * @param gradient Scalar amount to interpolate
  33428. * @returns Interpolated scalar value
  33429. */
  33430. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  33431. /**
  33432. * Interpolates a Vector3 cubically
  33433. * @param startValue Start value of the animation curve
  33434. * @param outTangent End tangent of the animation
  33435. * @param endValue End value of the animation curve
  33436. * @param inTangent Start tangent of the animation curve
  33437. * @param gradient Scalar amount to interpolate
  33438. * @returns InterpolatedVector3 value
  33439. */
  33440. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  33441. /**
  33442. * Interpolates a Vector2 linearly
  33443. * @param startValue Start value of the animation curve
  33444. * @param endValue End value of the animation curve
  33445. * @param gradient Scalar amount to interpolate
  33446. * @returns Interpolated Vector2 value
  33447. */
  33448. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  33449. /**
  33450. * Interpolates a Vector2 cubically
  33451. * @param startValue Start value of the animation curve
  33452. * @param outTangent End tangent of the animation
  33453. * @param endValue End value of the animation curve
  33454. * @param inTangent Start tangent of the animation curve
  33455. * @param gradient Scalar amount to interpolate
  33456. * @returns Interpolated Vector2 value
  33457. */
  33458. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  33459. /**
  33460. * Interpolates a size linearly
  33461. * @param startValue Start value of the animation curve
  33462. * @param endValue End value of the animation curve
  33463. * @param gradient Scalar amount to interpolate
  33464. * @returns Interpolated Size value
  33465. */
  33466. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  33467. /**
  33468. * Interpolates a Color3 linearly
  33469. * @param startValue Start value of the animation curve
  33470. * @param endValue End value of the animation curve
  33471. * @param gradient Scalar amount to interpolate
  33472. * @returns Interpolated Color3 value
  33473. */
  33474. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  33475. /**
  33476. * Interpolates a Color4 linearly
  33477. * @param startValue Start value of the animation curve
  33478. * @param endValue End value of the animation curve
  33479. * @param gradient Scalar amount to interpolate
  33480. * @returns Interpolated Color3 value
  33481. */
  33482. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  33483. /**
  33484. * @hidden Internal use only
  33485. */
  33486. _getKeyValue(value: any): any;
  33487. /**
  33488. * @hidden Internal use only
  33489. */
  33490. _interpolate(currentFrame: number, state: _IAnimationState): any;
  33491. /**
  33492. * Defines the function to use to interpolate matrices
  33493. * @param startValue defines the start matrix
  33494. * @param endValue defines the end matrix
  33495. * @param gradient defines the gradient between both matrices
  33496. * @param result defines an optional target matrix where to store the interpolation
  33497. * @returns the interpolated matrix
  33498. */
  33499. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  33500. /**
  33501. * Makes a copy of the animation
  33502. * @returns Cloned animation
  33503. */
  33504. clone(): Animation;
  33505. /**
  33506. * Sets the key frames of the animation
  33507. * @param values The animation key frames to set
  33508. */
  33509. setKeys(values: Array<IAnimationKey>): void;
  33510. /**
  33511. * Serializes the animation to an object
  33512. * @returns Serialized object
  33513. */
  33514. serialize(): any;
  33515. /**
  33516. * Float animation type
  33517. */
  33518. static readonly ANIMATIONTYPE_FLOAT: number;
  33519. /**
  33520. * Vector3 animation type
  33521. */
  33522. static readonly ANIMATIONTYPE_VECTOR3: number;
  33523. /**
  33524. * Quaternion animation type
  33525. */
  33526. static readonly ANIMATIONTYPE_QUATERNION: number;
  33527. /**
  33528. * Matrix animation type
  33529. */
  33530. static readonly ANIMATIONTYPE_MATRIX: number;
  33531. /**
  33532. * Color3 animation type
  33533. */
  33534. static readonly ANIMATIONTYPE_COLOR3: number;
  33535. /**
  33536. * Color3 animation type
  33537. */
  33538. static readonly ANIMATIONTYPE_COLOR4: number;
  33539. /**
  33540. * Vector2 animation type
  33541. */
  33542. static readonly ANIMATIONTYPE_VECTOR2: number;
  33543. /**
  33544. * Size animation type
  33545. */
  33546. static readonly ANIMATIONTYPE_SIZE: number;
  33547. /**
  33548. * Relative Loop Mode
  33549. */
  33550. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  33551. /**
  33552. * Cycle Loop Mode
  33553. */
  33554. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  33555. /**
  33556. * Constant Loop Mode
  33557. */
  33558. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  33559. /** @hidden */
  33560. static _UniversalLerp(left: any, right: any, amount: number): any;
  33561. /**
  33562. * Parses an animation object and creates an animation
  33563. * @param parsedAnimation Parsed animation object
  33564. * @returns Animation object
  33565. */
  33566. static Parse(parsedAnimation: any): Animation;
  33567. /**
  33568. * Appends the serialized animations from the source animations
  33569. * @param source Source containing the animations
  33570. * @param destination Target to store the animations
  33571. */
  33572. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33573. /**
  33574. * Creates a new animation or an array of animations from a snippet saved in a remote file
  33575. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  33576. * @param url defines the url to load from
  33577. * @returns a promise that will resolve to the new animation or an array of animations
  33578. */
  33579. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  33580. /**
  33581. * Creates an animation or an array of animations from a snippet saved by the Inspector
  33582. * @param snippetId defines the snippet to load
  33583. * @returns a promise that will resolve to the new animation or a new array of animations
  33584. */
  33585. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  33586. }
  33587. }
  33588. declare module BABYLON {
  33589. /**
  33590. * Interface containing an array of animations
  33591. */
  33592. export interface IAnimatable {
  33593. /**
  33594. * Array of animations
  33595. */
  33596. animations: Nullable<Array<Animation>>;
  33597. }
  33598. }
  33599. declare module BABYLON {
  33600. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  33601. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33602. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33603. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33604. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33605. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33606. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33607. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33608. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33609. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33610. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33611. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33612. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33613. /**
  33614. * Decorator used to define property that can be serialized as reference to a camera
  33615. * @param sourceName defines the name of the property to decorate
  33616. */
  33617. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33618. /**
  33619. * Class used to help serialization objects
  33620. */
  33621. export class SerializationHelper {
  33622. /** @hidden */
  33623. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  33624. /** @hidden */
  33625. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  33626. /** @hidden */
  33627. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  33628. /** @hidden */
  33629. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  33630. /**
  33631. * Appends the serialized animations from the source animations
  33632. * @param source Source containing the animations
  33633. * @param destination Target to store the animations
  33634. */
  33635. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33636. /**
  33637. * Static function used to serialized a specific entity
  33638. * @param entity defines the entity to serialize
  33639. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  33640. * @returns a JSON compatible object representing the serialization of the entity
  33641. */
  33642. static Serialize<T>(entity: T, serializationObject?: any): any;
  33643. /**
  33644. * Creates a new entity from a serialization data object
  33645. * @param creationFunction defines a function used to instanciated the new entity
  33646. * @param source defines the source serialization data
  33647. * @param scene defines the hosting scene
  33648. * @param rootUrl defines the root url for resources
  33649. * @returns a new entity
  33650. */
  33651. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  33652. /**
  33653. * Clones an object
  33654. * @param creationFunction defines the function used to instanciate the new object
  33655. * @param source defines the source object
  33656. * @returns the cloned object
  33657. */
  33658. static Clone<T>(creationFunction: () => T, source: T): T;
  33659. /**
  33660. * Instanciates a new object based on a source one (some data will be shared between both object)
  33661. * @param creationFunction defines the function used to instanciate the new object
  33662. * @param source defines the source object
  33663. * @returns the new object
  33664. */
  33665. static Instanciate<T>(creationFunction: () => T, source: T): T;
  33666. }
  33667. }
  33668. declare module BABYLON {
  33669. /**
  33670. * Base class of all the textures in babylon.
  33671. * It groups all the common properties the materials, post process, lights... might need
  33672. * in order to make a correct use of the texture.
  33673. */
  33674. export class BaseTexture implements IAnimatable {
  33675. /**
  33676. * Default anisotropic filtering level for the application.
  33677. * It is set to 4 as a good tradeoff between perf and quality.
  33678. */
  33679. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  33680. /**
  33681. * Gets or sets the unique id of the texture
  33682. */
  33683. uniqueId: number;
  33684. /**
  33685. * Define the name of the texture.
  33686. */
  33687. name: string;
  33688. /**
  33689. * Gets or sets an object used to store user defined information.
  33690. */
  33691. metadata: any;
  33692. /**
  33693. * For internal use only. Please do not use.
  33694. */
  33695. reservedDataStore: any;
  33696. private _hasAlpha;
  33697. /**
  33698. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  33699. */
  33700. set hasAlpha(value: boolean);
  33701. get hasAlpha(): boolean;
  33702. /**
  33703. * Defines if the alpha value should be determined via the rgb values.
  33704. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  33705. */
  33706. getAlphaFromRGB: boolean;
  33707. /**
  33708. * Intensity or strength of the texture.
  33709. * It is commonly used by materials to fine tune the intensity of the texture
  33710. */
  33711. level: number;
  33712. /**
  33713. * Define the UV chanel to use starting from 0 and defaulting to 0.
  33714. * This is part of the texture as textures usually maps to one uv set.
  33715. */
  33716. coordinatesIndex: number;
  33717. private _coordinatesMode;
  33718. /**
  33719. * How a texture is mapped.
  33720. *
  33721. * | Value | Type | Description |
  33722. * | ----- | ----------------------------------- | ----------- |
  33723. * | 0 | EXPLICIT_MODE | |
  33724. * | 1 | SPHERICAL_MODE | |
  33725. * | 2 | PLANAR_MODE | |
  33726. * | 3 | CUBIC_MODE | |
  33727. * | 4 | PROJECTION_MODE | |
  33728. * | 5 | SKYBOX_MODE | |
  33729. * | 6 | INVCUBIC_MODE | |
  33730. * | 7 | EQUIRECTANGULAR_MODE | |
  33731. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  33732. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  33733. */
  33734. set coordinatesMode(value: number);
  33735. get coordinatesMode(): number;
  33736. /**
  33737. * | Value | Type | Description |
  33738. * | ----- | ------------------ | ----------- |
  33739. * | 0 | CLAMP_ADDRESSMODE | |
  33740. * | 1 | WRAP_ADDRESSMODE | |
  33741. * | 2 | MIRROR_ADDRESSMODE | |
  33742. */
  33743. wrapU: number;
  33744. /**
  33745. * | Value | Type | Description |
  33746. * | ----- | ------------------ | ----------- |
  33747. * | 0 | CLAMP_ADDRESSMODE | |
  33748. * | 1 | WRAP_ADDRESSMODE | |
  33749. * | 2 | MIRROR_ADDRESSMODE | |
  33750. */
  33751. wrapV: number;
  33752. /**
  33753. * | Value | Type | Description |
  33754. * | ----- | ------------------ | ----------- |
  33755. * | 0 | CLAMP_ADDRESSMODE | |
  33756. * | 1 | WRAP_ADDRESSMODE | |
  33757. * | 2 | MIRROR_ADDRESSMODE | |
  33758. */
  33759. wrapR: number;
  33760. /**
  33761. * With compliant hardware and browser (supporting anisotropic filtering)
  33762. * this defines the level of anisotropic filtering in the texture.
  33763. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  33764. */
  33765. anisotropicFilteringLevel: number;
  33766. /**
  33767. * Define if the texture is a cube texture or if false a 2d texture.
  33768. */
  33769. get isCube(): boolean;
  33770. set isCube(value: boolean);
  33771. /**
  33772. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  33773. */
  33774. get is3D(): boolean;
  33775. set is3D(value: boolean);
  33776. /**
  33777. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  33778. */
  33779. get is2DArray(): boolean;
  33780. set is2DArray(value: boolean);
  33781. /**
  33782. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  33783. * HDR texture are usually stored in linear space.
  33784. * This only impacts the PBR and Background materials
  33785. */
  33786. gammaSpace: boolean;
  33787. /**
  33788. * Gets or sets whether or not the texture contains RGBD data.
  33789. */
  33790. get isRGBD(): boolean;
  33791. set isRGBD(value: boolean);
  33792. /**
  33793. * Is Z inverted in the texture (useful in a cube texture).
  33794. */
  33795. invertZ: boolean;
  33796. /**
  33797. * Are mip maps generated for this texture or not.
  33798. */
  33799. get noMipmap(): boolean;
  33800. /**
  33801. * @hidden
  33802. */
  33803. lodLevelInAlpha: boolean;
  33804. /**
  33805. * With prefiltered texture, defined the offset used during the prefiltering steps.
  33806. */
  33807. get lodGenerationOffset(): number;
  33808. set lodGenerationOffset(value: number);
  33809. /**
  33810. * With prefiltered texture, defined the scale used during the prefiltering steps.
  33811. */
  33812. get lodGenerationScale(): number;
  33813. set lodGenerationScale(value: number);
  33814. /**
  33815. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  33816. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  33817. * average roughness values.
  33818. */
  33819. get linearSpecularLOD(): boolean;
  33820. set linearSpecularLOD(value: boolean);
  33821. /**
  33822. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  33823. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  33824. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  33825. */
  33826. get irradianceTexture(): Nullable<BaseTexture>;
  33827. set irradianceTexture(value: Nullable<BaseTexture>);
  33828. /**
  33829. * Define if the texture is a render target.
  33830. */
  33831. isRenderTarget: boolean;
  33832. /**
  33833. * Define the unique id of the texture in the scene.
  33834. */
  33835. get uid(): string;
  33836. /** @hidden */
  33837. _prefiltered: boolean;
  33838. /**
  33839. * Return a string representation of the texture.
  33840. * @returns the texture as a string
  33841. */
  33842. toString(): string;
  33843. /**
  33844. * Get the class name of the texture.
  33845. * @returns "BaseTexture"
  33846. */
  33847. getClassName(): string;
  33848. /**
  33849. * Define the list of animation attached to the texture.
  33850. */
  33851. animations: Animation[];
  33852. /**
  33853. * An event triggered when the texture is disposed.
  33854. */
  33855. onDisposeObservable: Observable<BaseTexture>;
  33856. private _onDisposeObserver;
  33857. /**
  33858. * Callback triggered when the texture has been disposed.
  33859. * Kept for back compatibility, you can use the onDisposeObservable instead.
  33860. */
  33861. set onDispose(callback: () => void);
  33862. /**
  33863. * Define the current state of the loading sequence when in delayed load mode.
  33864. */
  33865. delayLoadState: number;
  33866. protected _scene: Nullable<Scene>;
  33867. protected _engine: Nullable<ThinEngine>;
  33868. /** @hidden */
  33869. _texture: Nullable<InternalTexture>;
  33870. private _uid;
  33871. /**
  33872. * Define if the texture is preventinga material to render or not.
  33873. * If not and the texture is not ready, the engine will use a default black texture instead.
  33874. */
  33875. get isBlocking(): boolean;
  33876. /**
  33877. * Instantiates a new BaseTexture.
  33878. * Base class of all the textures in babylon.
  33879. * It groups all the common properties the materials, post process, lights... might need
  33880. * in order to make a correct use of the texture.
  33881. * @param sceneOrEngine Define the scene or engine the texture blongs to
  33882. */
  33883. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  33884. /**
  33885. * Get the scene the texture belongs to.
  33886. * @returns the scene or null if undefined
  33887. */
  33888. getScene(): Nullable<Scene>;
  33889. /** @hidden */
  33890. protected _getEngine(): Nullable<ThinEngine>;
  33891. /**
  33892. * Get the texture transform matrix used to offset tile the texture for istance.
  33893. * @returns the transformation matrix
  33894. */
  33895. getTextureMatrix(): Matrix;
  33896. /**
  33897. * Get the texture reflection matrix used to rotate/transform the reflection.
  33898. * @returns the reflection matrix
  33899. */
  33900. getReflectionTextureMatrix(): Matrix;
  33901. /**
  33902. * Get the underlying lower level texture from Babylon.
  33903. * @returns the insternal texture
  33904. */
  33905. getInternalTexture(): Nullable<InternalTexture>;
  33906. /**
  33907. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  33908. * @returns true if ready or not blocking
  33909. */
  33910. isReadyOrNotBlocking(): boolean;
  33911. /**
  33912. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  33913. * @returns true if fully ready
  33914. */
  33915. isReady(): boolean;
  33916. private _cachedSize;
  33917. /**
  33918. * Get the size of the texture.
  33919. * @returns the texture size.
  33920. */
  33921. getSize(): ISize;
  33922. /**
  33923. * Get the base size of the texture.
  33924. * It can be different from the size if the texture has been resized for POT for instance
  33925. * @returns the base size
  33926. */
  33927. getBaseSize(): ISize;
  33928. /**
  33929. * Update the sampling mode of the texture.
  33930. * Default is Trilinear mode.
  33931. *
  33932. * | Value | Type | Description |
  33933. * | ----- | ------------------ | ----------- |
  33934. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  33935. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  33936. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  33937. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  33938. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  33939. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  33940. * | 7 | NEAREST_LINEAR | |
  33941. * | 8 | NEAREST_NEAREST | |
  33942. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  33943. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  33944. * | 11 | LINEAR_LINEAR | |
  33945. * | 12 | LINEAR_NEAREST | |
  33946. *
  33947. * > _mag_: magnification filter (close to the viewer)
  33948. * > _min_: minification filter (far from the viewer)
  33949. * > _mip_: filter used between mip map levels
  33950. *@param samplingMode Define the new sampling mode of the texture
  33951. */
  33952. updateSamplingMode(samplingMode: number): void;
  33953. /**
  33954. * Scales the texture if is `canRescale()`
  33955. * @param ratio the resize factor we want to use to rescale
  33956. */
  33957. scale(ratio: number): void;
  33958. /**
  33959. * Get if the texture can rescale.
  33960. */
  33961. get canRescale(): boolean;
  33962. /** @hidden */
  33963. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  33964. /** @hidden */
  33965. _rebuild(): void;
  33966. /**
  33967. * Triggers the load sequence in delayed load mode.
  33968. */
  33969. delayLoad(): void;
  33970. /**
  33971. * Clones the texture.
  33972. * @returns the cloned texture
  33973. */
  33974. clone(): Nullable<BaseTexture>;
  33975. /**
  33976. * Get the texture underlying type (INT, FLOAT...)
  33977. */
  33978. get textureType(): number;
  33979. /**
  33980. * Get the texture underlying format (RGB, RGBA...)
  33981. */
  33982. get textureFormat(): number;
  33983. /**
  33984. * Indicates that textures need to be re-calculated for all materials
  33985. */
  33986. protected _markAllSubMeshesAsTexturesDirty(): void;
  33987. /**
  33988. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  33989. * This will returns an RGBA array buffer containing either in values (0-255) or
  33990. * float values (0-1) depending of the underlying buffer type.
  33991. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  33992. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  33993. * @param buffer defines a user defined buffer to fill with data (can be null)
  33994. * @returns The Array buffer containing the pixels data.
  33995. */
  33996. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  33997. /**
  33998. * Release and destroy the underlying lower level texture aka internalTexture.
  33999. */
  34000. releaseInternalTexture(): void;
  34001. /** @hidden */
  34002. get _lodTextureHigh(): Nullable<BaseTexture>;
  34003. /** @hidden */
  34004. get _lodTextureMid(): Nullable<BaseTexture>;
  34005. /** @hidden */
  34006. get _lodTextureLow(): Nullable<BaseTexture>;
  34007. /**
  34008. * Dispose the texture and release its associated resources.
  34009. */
  34010. dispose(): void;
  34011. /**
  34012. * Serialize the texture into a JSON representation that can be parsed later on.
  34013. * @returns the JSON representation of the texture
  34014. */
  34015. serialize(): any;
  34016. /**
  34017. * Helper function to be called back once a list of texture contains only ready textures.
  34018. * @param textures Define the list of textures to wait for
  34019. * @param callback Define the callback triggered once the entire list will be ready
  34020. */
  34021. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  34022. private static _isScene;
  34023. }
  34024. }
  34025. declare module BABYLON {
  34026. /**
  34027. * Options to be used when creating an effect.
  34028. */
  34029. export interface IEffectCreationOptions {
  34030. /**
  34031. * Atrributes that will be used in the shader.
  34032. */
  34033. attributes: string[];
  34034. /**
  34035. * Uniform varible names that will be set in the shader.
  34036. */
  34037. uniformsNames: string[];
  34038. /**
  34039. * Uniform buffer variable names that will be set in the shader.
  34040. */
  34041. uniformBuffersNames: string[];
  34042. /**
  34043. * Sampler texture variable names that will be set in the shader.
  34044. */
  34045. samplers: string[];
  34046. /**
  34047. * Define statements that will be set in the shader.
  34048. */
  34049. defines: any;
  34050. /**
  34051. * Possible fallbacks for this effect to improve performance when needed.
  34052. */
  34053. fallbacks: Nullable<IEffectFallbacks>;
  34054. /**
  34055. * Callback that will be called when the shader is compiled.
  34056. */
  34057. onCompiled: Nullable<(effect: Effect) => void>;
  34058. /**
  34059. * Callback that will be called if an error occurs during shader compilation.
  34060. */
  34061. onError: Nullable<(effect: Effect, errors: string) => void>;
  34062. /**
  34063. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34064. */
  34065. indexParameters?: any;
  34066. /**
  34067. * Max number of lights that can be used in the shader.
  34068. */
  34069. maxSimultaneousLights?: number;
  34070. /**
  34071. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  34072. */
  34073. transformFeedbackVaryings?: Nullable<string[]>;
  34074. /**
  34075. * 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
  34076. */
  34077. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  34078. /**
  34079. * Is this effect rendering to several color attachments ?
  34080. */
  34081. multiTarget?: boolean;
  34082. }
  34083. /**
  34084. * Effect containing vertex and fragment shader that can be executed on an object.
  34085. */
  34086. export class Effect implements IDisposable {
  34087. /**
  34088. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34089. */
  34090. static ShadersRepository: string;
  34091. /**
  34092. * Enable logging of the shader code when a compilation error occurs
  34093. */
  34094. static LogShaderCodeOnCompilationError: boolean;
  34095. /**
  34096. * Name of the effect.
  34097. */
  34098. name: any;
  34099. /**
  34100. * String container all the define statements that should be set on the shader.
  34101. */
  34102. defines: string;
  34103. /**
  34104. * Callback that will be called when the shader is compiled.
  34105. */
  34106. onCompiled: Nullable<(effect: Effect) => void>;
  34107. /**
  34108. * Callback that will be called if an error occurs during shader compilation.
  34109. */
  34110. onError: Nullable<(effect: Effect, errors: string) => void>;
  34111. /**
  34112. * Callback that will be called when effect is bound.
  34113. */
  34114. onBind: Nullable<(effect: Effect) => void>;
  34115. /**
  34116. * Unique ID of the effect.
  34117. */
  34118. uniqueId: number;
  34119. /**
  34120. * Observable that will be called when the shader is compiled.
  34121. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  34122. */
  34123. onCompileObservable: Observable<Effect>;
  34124. /**
  34125. * Observable that will be called if an error occurs during shader compilation.
  34126. */
  34127. onErrorObservable: Observable<Effect>;
  34128. /** @hidden */
  34129. _onBindObservable: Nullable<Observable<Effect>>;
  34130. /**
  34131. * @hidden
  34132. * Specifies if the effect was previously ready
  34133. */
  34134. _wasPreviouslyReady: boolean;
  34135. /**
  34136. * Observable that will be called when effect is bound.
  34137. */
  34138. get onBindObservable(): Observable<Effect>;
  34139. /** @hidden */
  34140. _bonesComputationForcedToCPU: boolean;
  34141. /** @hidden */
  34142. _multiTarget: boolean;
  34143. private static _uniqueIdSeed;
  34144. private _engine;
  34145. private _uniformBuffersNames;
  34146. private _uniformBuffersNamesList;
  34147. private _uniformsNames;
  34148. private _samplerList;
  34149. private _samplers;
  34150. private _isReady;
  34151. private _compilationError;
  34152. private _allFallbacksProcessed;
  34153. private _attributesNames;
  34154. private _attributes;
  34155. private _attributeLocationByName;
  34156. private _uniforms;
  34157. /**
  34158. * Key for the effect.
  34159. * @hidden
  34160. */
  34161. _key: string;
  34162. private _indexParameters;
  34163. private _fallbacks;
  34164. private _vertexSourceCode;
  34165. private _fragmentSourceCode;
  34166. private _vertexSourceCodeOverride;
  34167. private _fragmentSourceCodeOverride;
  34168. private _transformFeedbackVaryings;
  34169. /**
  34170. * Compiled shader to webGL program.
  34171. * @hidden
  34172. */
  34173. _pipelineContext: Nullable<IPipelineContext>;
  34174. private _valueCache;
  34175. private static _baseCache;
  34176. /**
  34177. * Instantiates an effect.
  34178. * An effect can be used to create/manage/execute vertex and fragment shaders.
  34179. * @param baseName Name of the effect.
  34180. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  34181. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  34182. * @param samplers List of sampler variables that will be passed to the shader.
  34183. * @param engine Engine to be used to render the effect
  34184. * @param defines Define statements to be added to the shader.
  34185. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  34186. * @param onCompiled Callback that will be called when the shader is compiled.
  34187. * @param onError Callback that will be called if an error occurs during shader compilation.
  34188. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34189. */
  34190. 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);
  34191. private _useFinalCode;
  34192. /**
  34193. * Unique key for this effect
  34194. */
  34195. get key(): string;
  34196. /**
  34197. * If the effect has been compiled and prepared.
  34198. * @returns if the effect is compiled and prepared.
  34199. */
  34200. isReady(): boolean;
  34201. private _isReadyInternal;
  34202. /**
  34203. * The engine the effect was initialized with.
  34204. * @returns the engine.
  34205. */
  34206. getEngine(): Engine;
  34207. /**
  34208. * The pipeline context for this effect
  34209. * @returns the associated pipeline context
  34210. */
  34211. getPipelineContext(): Nullable<IPipelineContext>;
  34212. /**
  34213. * The set of names of attribute variables for the shader.
  34214. * @returns An array of attribute names.
  34215. */
  34216. getAttributesNames(): string[];
  34217. /**
  34218. * Returns the attribute at the given index.
  34219. * @param index The index of the attribute.
  34220. * @returns The location of the attribute.
  34221. */
  34222. getAttributeLocation(index: number): number;
  34223. /**
  34224. * Returns the attribute based on the name of the variable.
  34225. * @param name of the attribute to look up.
  34226. * @returns the attribute location.
  34227. */
  34228. getAttributeLocationByName(name: string): number;
  34229. /**
  34230. * The number of attributes.
  34231. * @returns the numnber of attributes.
  34232. */
  34233. getAttributesCount(): number;
  34234. /**
  34235. * Gets the index of a uniform variable.
  34236. * @param uniformName of the uniform to look up.
  34237. * @returns the index.
  34238. */
  34239. getUniformIndex(uniformName: string): number;
  34240. /**
  34241. * Returns the attribute based on the name of the variable.
  34242. * @param uniformName of the uniform to look up.
  34243. * @returns the location of the uniform.
  34244. */
  34245. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  34246. /**
  34247. * Returns an array of sampler variable names
  34248. * @returns The array of sampler variable names.
  34249. */
  34250. getSamplers(): string[];
  34251. /**
  34252. * Returns an array of uniform variable names
  34253. * @returns The array of uniform variable names.
  34254. */
  34255. getUniformNames(): string[];
  34256. /**
  34257. * Returns an array of uniform buffer variable names
  34258. * @returns The array of uniform buffer variable names.
  34259. */
  34260. getUniformBuffersNames(): string[];
  34261. /**
  34262. * Returns the index parameters used to create the effect
  34263. * @returns The index parameters object
  34264. */
  34265. getIndexParameters(): any;
  34266. /**
  34267. * The error from the last compilation.
  34268. * @returns the error string.
  34269. */
  34270. getCompilationError(): string;
  34271. /**
  34272. * Gets a boolean indicating that all fallbacks were used during compilation
  34273. * @returns true if all fallbacks were used
  34274. */
  34275. allFallbacksProcessed(): boolean;
  34276. /**
  34277. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  34278. * @param func The callback to be used.
  34279. */
  34280. executeWhenCompiled(func: (effect: Effect) => void): void;
  34281. private _checkIsReady;
  34282. private _loadShader;
  34283. /**
  34284. * Gets the vertex shader source code of this effect
  34285. */
  34286. get vertexSourceCode(): string;
  34287. /**
  34288. * Gets the fragment shader source code of this effect
  34289. */
  34290. get fragmentSourceCode(): string;
  34291. /**
  34292. * Recompiles the webGL program
  34293. * @param vertexSourceCode The source code for the vertex shader.
  34294. * @param fragmentSourceCode The source code for the fragment shader.
  34295. * @param onCompiled Callback called when completed.
  34296. * @param onError Callback called on error.
  34297. * @hidden
  34298. */
  34299. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  34300. /**
  34301. * Prepares the effect
  34302. * @hidden
  34303. */
  34304. _prepareEffect(): void;
  34305. private _getShaderCodeAndErrorLine;
  34306. private _processCompilationErrors;
  34307. /**
  34308. * Checks if the effect is supported. (Must be called after compilation)
  34309. */
  34310. get isSupported(): boolean;
  34311. /**
  34312. * Binds a texture to the engine to be used as output of the shader.
  34313. * @param channel Name of the output variable.
  34314. * @param texture Texture to bind.
  34315. * @hidden
  34316. */
  34317. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  34318. /**
  34319. * Sets a texture on the engine to be used in the shader.
  34320. * @param channel Name of the sampler variable.
  34321. * @param texture Texture to set.
  34322. */
  34323. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  34324. /**
  34325. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  34326. * @param channel Name of the sampler variable.
  34327. * @param texture Texture to set.
  34328. */
  34329. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  34330. /**
  34331. * Sets an array of textures on the engine to be used in the shader.
  34332. * @param channel Name of the variable.
  34333. * @param textures Textures to set.
  34334. */
  34335. setTextureArray(channel: string, textures: BaseTexture[]): void;
  34336. /**
  34337. * 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)
  34338. * @param channel Name of the sampler variable.
  34339. * @param postProcess Post process to get the input texture from.
  34340. */
  34341. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  34342. /**
  34343. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  34344. * 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)
  34345. * @param channel Name of the sampler variable.
  34346. * @param postProcess Post process to get the output texture from.
  34347. */
  34348. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  34349. /** @hidden */
  34350. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  34351. /** @hidden */
  34352. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  34353. /** @hidden */
  34354. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  34355. /** @hidden */
  34356. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  34357. /**
  34358. * Binds a buffer to a uniform.
  34359. * @param buffer Buffer to bind.
  34360. * @param name Name of the uniform variable to bind to.
  34361. */
  34362. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  34363. /**
  34364. * Binds block to a uniform.
  34365. * @param blockName Name of the block to bind.
  34366. * @param index Index to bind.
  34367. */
  34368. bindUniformBlock(blockName: string, index: number): void;
  34369. /**
  34370. * Sets an interger value on a uniform variable.
  34371. * @param uniformName Name of the variable.
  34372. * @param value Value to be set.
  34373. * @returns this effect.
  34374. */
  34375. setInt(uniformName: string, value: number): Effect;
  34376. /**
  34377. * Sets an int array on a uniform variable.
  34378. * @param uniformName Name of the variable.
  34379. * @param array array to be set.
  34380. * @returns this effect.
  34381. */
  34382. setIntArray(uniformName: string, array: Int32Array): Effect;
  34383. /**
  34384. * 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)
  34385. * @param uniformName Name of the variable.
  34386. * @param array array to be set.
  34387. * @returns this effect.
  34388. */
  34389. setIntArray2(uniformName: string, array: Int32Array): Effect;
  34390. /**
  34391. * 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)
  34392. * @param uniformName Name of the variable.
  34393. * @param array array to be set.
  34394. * @returns this effect.
  34395. */
  34396. setIntArray3(uniformName: string, array: Int32Array): Effect;
  34397. /**
  34398. * 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)
  34399. * @param uniformName Name of the variable.
  34400. * @param array array to be set.
  34401. * @returns this effect.
  34402. */
  34403. setIntArray4(uniformName: string, array: Int32Array): Effect;
  34404. /**
  34405. * Sets an float array on a uniform variable.
  34406. * @param uniformName Name of the variable.
  34407. * @param array array to be set.
  34408. * @returns this effect.
  34409. */
  34410. setFloatArray(uniformName: string, array: Float32Array): Effect;
  34411. /**
  34412. * 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)
  34413. * @param uniformName Name of the variable.
  34414. * @param array array to be set.
  34415. * @returns this effect.
  34416. */
  34417. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  34418. /**
  34419. * 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)
  34420. * @param uniformName Name of the variable.
  34421. * @param array array to be set.
  34422. * @returns this effect.
  34423. */
  34424. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  34425. /**
  34426. * 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)
  34427. * @param uniformName Name of the variable.
  34428. * @param array array to be set.
  34429. * @returns this effect.
  34430. */
  34431. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  34432. /**
  34433. * Sets an array on a uniform variable.
  34434. * @param uniformName Name of the variable.
  34435. * @param array array to be set.
  34436. * @returns this effect.
  34437. */
  34438. setArray(uniformName: string, array: number[]): Effect;
  34439. /**
  34440. * 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)
  34441. * @param uniformName Name of the variable.
  34442. * @param array array to be set.
  34443. * @returns this effect.
  34444. */
  34445. setArray2(uniformName: string, array: number[]): Effect;
  34446. /**
  34447. * 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)
  34448. * @param uniformName Name of the variable.
  34449. * @param array array to be set.
  34450. * @returns this effect.
  34451. */
  34452. setArray3(uniformName: string, array: number[]): Effect;
  34453. /**
  34454. * 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)
  34455. * @param uniformName Name of the variable.
  34456. * @param array array to be set.
  34457. * @returns this effect.
  34458. */
  34459. setArray4(uniformName: string, array: number[]): Effect;
  34460. /**
  34461. * Sets matrices on a uniform variable.
  34462. * @param uniformName Name of the variable.
  34463. * @param matrices matrices to be set.
  34464. * @returns this effect.
  34465. */
  34466. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  34467. /**
  34468. * Sets matrix on a uniform variable.
  34469. * @param uniformName Name of the variable.
  34470. * @param matrix matrix to be set.
  34471. * @returns this effect.
  34472. */
  34473. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  34474. /**
  34475. * 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)
  34476. * @param uniformName Name of the variable.
  34477. * @param matrix matrix to be set.
  34478. * @returns this effect.
  34479. */
  34480. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34481. /**
  34482. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  34483. * @param uniformName Name of the variable.
  34484. * @param matrix matrix to be set.
  34485. * @returns this effect.
  34486. */
  34487. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34488. /**
  34489. * Sets a float on a uniform variable.
  34490. * @param uniformName Name of the variable.
  34491. * @param value value to be set.
  34492. * @returns this effect.
  34493. */
  34494. setFloat(uniformName: string, value: number): Effect;
  34495. /**
  34496. * Sets a boolean on a uniform variable.
  34497. * @param uniformName Name of the variable.
  34498. * @param bool value to be set.
  34499. * @returns this effect.
  34500. */
  34501. setBool(uniformName: string, bool: boolean): Effect;
  34502. /**
  34503. * Sets a Vector2 on a uniform variable.
  34504. * @param uniformName Name of the variable.
  34505. * @param vector2 vector2 to be set.
  34506. * @returns this effect.
  34507. */
  34508. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  34509. /**
  34510. * Sets a float2 on a uniform variable.
  34511. * @param uniformName Name of the variable.
  34512. * @param x First float in float2.
  34513. * @param y Second float in float2.
  34514. * @returns this effect.
  34515. */
  34516. setFloat2(uniformName: string, x: number, y: number): Effect;
  34517. /**
  34518. * Sets a Vector3 on a uniform variable.
  34519. * @param uniformName Name of the variable.
  34520. * @param vector3 Value to be set.
  34521. * @returns this effect.
  34522. */
  34523. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  34524. /**
  34525. * Sets a float3 on a uniform variable.
  34526. * @param uniformName Name of the variable.
  34527. * @param x First float in float3.
  34528. * @param y Second float in float3.
  34529. * @param z Third float in float3.
  34530. * @returns this effect.
  34531. */
  34532. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  34533. /**
  34534. * Sets a Vector4 on a uniform variable.
  34535. * @param uniformName Name of the variable.
  34536. * @param vector4 Value to be set.
  34537. * @returns this effect.
  34538. */
  34539. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  34540. /**
  34541. * Sets a float4 on a uniform variable.
  34542. * @param uniformName Name of the variable.
  34543. * @param x First float in float4.
  34544. * @param y Second float in float4.
  34545. * @param z Third float in float4.
  34546. * @param w Fourth float in float4.
  34547. * @returns this effect.
  34548. */
  34549. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  34550. /**
  34551. * Sets a Color3 on a uniform variable.
  34552. * @param uniformName Name of the variable.
  34553. * @param color3 Value to be set.
  34554. * @returns this effect.
  34555. */
  34556. setColor3(uniformName: string, color3: IColor3Like): Effect;
  34557. /**
  34558. * Sets a Color4 on a uniform variable.
  34559. * @param uniformName Name of the variable.
  34560. * @param color3 Value to be set.
  34561. * @param alpha Alpha value to be set.
  34562. * @returns this effect.
  34563. */
  34564. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  34565. /**
  34566. * Sets a Color4 on a uniform variable
  34567. * @param uniformName defines the name of the variable
  34568. * @param color4 defines the value to be set
  34569. * @returns this effect.
  34570. */
  34571. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  34572. /** Release all associated resources */
  34573. dispose(): void;
  34574. /**
  34575. * This function will add a new shader to the shader store
  34576. * @param name the name of the shader
  34577. * @param pixelShader optional pixel shader content
  34578. * @param vertexShader optional vertex shader content
  34579. */
  34580. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  34581. /**
  34582. * Store of each shader (The can be looked up using effect.key)
  34583. */
  34584. static ShadersStore: {
  34585. [key: string]: string;
  34586. };
  34587. /**
  34588. * Store of each included file for a shader (The can be looked up using effect.key)
  34589. */
  34590. static IncludesShadersStore: {
  34591. [key: string]: string;
  34592. };
  34593. /**
  34594. * Resets the cache of effects.
  34595. */
  34596. static ResetCache(): void;
  34597. }
  34598. }
  34599. declare module BABYLON {
  34600. /**
  34601. * Interface used to describe the capabilities of the engine relatively to the current browser
  34602. */
  34603. export interface EngineCapabilities {
  34604. /** Maximum textures units per fragment shader */
  34605. maxTexturesImageUnits: number;
  34606. /** Maximum texture units per vertex shader */
  34607. maxVertexTextureImageUnits: number;
  34608. /** Maximum textures units in the entire pipeline */
  34609. maxCombinedTexturesImageUnits: number;
  34610. /** Maximum texture size */
  34611. maxTextureSize: number;
  34612. /** Maximum texture samples */
  34613. maxSamples?: number;
  34614. /** Maximum cube texture size */
  34615. maxCubemapTextureSize: number;
  34616. /** Maximum render texture size */
  34617. maxRenderTextureSize: number;
  34618. /** Maximum number of vertex attributes */
  34619. maxVertexAttribs: number;
  34620. /** Maximum number of varyings */
  34621. maxVaryingVectors: number;
  34622. /** Maximum number of uniforms per vertex shader */
  34623. maxVertexUniformVectors: number;
  34624. /** Maximum number of uniforms per fragment shader */
  34625. maxFragmentUniformVectors: number;
  34626. /** Defines if standard derivates (dx/dy) are supported */
  34627. standardDerivatives: boolean;
  34628. /** Defines if s3tc texture compression is supported */
  34629. s3tc?: WEBGL_compressed_texture_s3tc;
  34630. /** Defines if pvrtc texture compression is supported */
  34631. pvrtc: any;
  34632. /** Defines if etc1 texture compression is supported */
  34633. etc1: any;
  34634. /** Defines if etc2 texture compression is supported */
  34635. etc2: any;
  34636. /** Defines if astc texture compression is supported */
  34637. astc: any;
  34638. /** Defines if float textures are supported */
  34639. textureFloat: boolean;
  34640. /** Defines if vertex array objects are supported */
  34641. vertexArrayObject: boolean;
  34642. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  34643. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  34644. /** Gets the maximum level of anisotropy supported */
  34645. maxAnisotropy: number;
  34646. /** Defines if instancing is supported */
  34647. instancedArrays: boolean;
  34648. /** Defines if 32 bits indices are supported */
  34649. uintIndices: boolean;
  34650. /** Defines if high precision shaders are supported */
  34651. highPrecisionShaderSupported: boolean;
  34652. /** Defines if depth reading in the fragment shader is supported */
  34653. fragmentDepthSupported: boolean;
  34654. /** Defines if float texture linear filtering is supported*/
  34655. textureFloatLinearFiltering: boolean;
  34656. /** Defines if rendering to float textures is supported */
  34657. textureFloatRender: boolean;
  34658. /** Defines if half float textures are supported*/
  34659. textureHalfFloat: boolean;
  34660. /** Defines if half float texture linear filtering is supported*/
  34661. textureHalfFloatLinearFiltering: boolean;
  34662. /** Defines if rendering to half float textures is supported */
  34663. textureHalfFloatRender: boolean;
  34664. /** Defines if textureLOD shader command is supported */
  34665. textureLOD: boolean;
  34666. /** Defines if draw buffers extension is supported */
  34667. drawBuffersExtension: boolean;
  34668. /** Defines if depth textures are supported */
  34669. depthTextureExtension: boolean;
  34670. /** Defines if float color buffer are supported */
  34671. colorBufferFloat: boolean;
  34672. /** Gets disjoint timer query extension (null if not supported) */
  34673. timerQuery?: EXT_disjoint_timer_query;
  34674. /** Defines if timestamp can be used with timer query */
  34675. canUseTimestampForTimerQuery: boolean;
  34676. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  34677. multiview?: any;
  34678. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  34679. oculusMultiview?: any;
  34680. /** Function used to let the system compiles shaders in background */
  34681. parallelShaderCompile?: {
  34682. COMPLETION_STATUS_KHR: number;
  34683. };
  34684. /** Max number of texture samples for MSAA */
  34685. maxMSAASamples: number;
  34686. /** Defines if the blend min max extension is supported */
  34687. blendMinMax: boolean;
  34688. }
  34689. }
  34690. declare module BABYLON {
  34691. /**
  34692. * @hidden
  34693. **/
  34694. export class DepthCullingState {
  34695. private _isDepthTestDirty;
  34696. private _isDepthMaskDirty;
  34697. private _isDepthFuncDirty;
  34698. private _isCullFaceDirty;
  34699. private _isCullDirty;
  34700. private _isZOffsetDirty;
  34701. private _isFrontFaceDirty;
  34702. private _depthTest;
  34703. private _depthMask;
  34704. private _depthFunc;
  34705. private _cull;
  34706. private _cullFace;
  34707. private _zOffset;
  34708. private _frontFace;
  34709. /**
  34710. * Initializes the state.
  34711. */
  34712. constructor();
  34713. get isDirty(): boolean;
  34714. get zOffset(): number;
  34715. set zOffset(value: number);
  34716. get cullFace(): Nullable<number>;
  34717. set cullFace(value: Nullable<number>);
  34718. get cull(): Nullable<boolean>;
  34719. set cull(value: Nullable<boolean>);
  34720. get depthFunc(): Nullable<number>;
  34721. set depthFunc(value: Nullable<number>);
  34722. get depthMask(): boolean;
  34723. set depthMask(value: boolean);
  34724. get depthTest(): boolean;
  34725. set depthTest(value: boolean);
  34726. get frontFace(): Nullable<number>;
  34727. set frontFace(value: Nullable<number>);
  34728. reset(): void;
  34729. apply(gl: WebGLRenderingContext): void;
  34730. }
  34731. }
  34732. declare module BABYLON {
  34733. /**
  34734. * @hidden
  34735. **/
  34736. export class StencilState {
  34737. /** 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 */
  34738. static readonly ALWAYS: number;
  34739. /** Passed to stencilOperation to specify that stencil value must be kept */
  34740. static readonly KEEP: number;
  34741. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34742. static readonly REPLACE: number;
  34743. private _isStencilTestDirty;
  34744. private _isStencilMaskDirty;
  34745. private _isStencilFuncDirty;
  34746. private _isStencilOpDirty;
  34747. private _stencilTest;
  34748. private _stencilMask;
  34749. private _stencilFunc;
  34750. private _stencilFuncRef;
  34751. private _stencilFuncMask;
  34752. private _stencilOpStencilFail;
  34753. private _stencilOpDepthFail;
  34754. private _stencilOpStencilDepthPass;
  34755. get isDirty(): boolean;
  34756. get stencilFunc(): number;
  34757. set stencilFunc(value: number);
  34758. get stencilFuncRef(): number;
  34759. set stencilFuncRef(value: number);
  34760. get stencilFuncMask(): number;
  34761. set stencilFuncMask(value: number);
  34762. get stencilOpStencilFail(): number;
  34763. set stencilOpStencilFail(value: number);
  34764. get stencilOpDepthFail(): number;
  34765. set stencilOpDepthFail(value: number);
  34766. get stencilOpStencilDepthPass(): number;
  34767. set stencilOpStencilDepthPass(value: number);
  34768. get stencilMask(): number;
  34769. set stencilMask(value: number);
  34770. get stencilTest(): boolean;
  34771. set stencilTest(value: boolean);
  34772. constructor();
  34773. reset(): void;
  34774. apply(gl: WebGLRenderingContext): void;
  34775. }
  34776. }
  34777. declare module BABYLON {
  34778. /**
  34779. * @hidden
  34780. **/
  34781. export class AlphaState {
  34782. private _isAlphaBlendDirty;
  34783. private _isBlendFunctionParametersDirty;
  34784. private _isBlendEquationParametersDirty;
  34785. private _isBlendConstantsDirty;
  34786. private _alphaBlend;
  34787. private _blendFunctionParameters;
  34788. private _blendEquationParameters;
  34789. private _blendConstants;
  34790. /**
  34791. * Initializes the state.
  34792. */
  34793. constructor();
  34794. get isDirty(): boolean;
  34795. get alphaBlend(): boolean;
  34796. set alphaBlend(value: boolean);
  34797. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  34798. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  34799. setAlphaEquationParameters(rgb: number, alpha: number): void;
  34800. reset(): void;
  34801. apply(gl: WebGLRenderingContext): void;
  34802. }
  34803. }
  34804. declare module BABYLON {
  34805. /** @hidden */
  34806. export class WebGL2ShaderProcessor implements IShaderProcessor {
  34807. attributeProcessor(attribute: string): string;
  34808. varyingProcessor(varying: string, isFragment: boolean): string;
  34809. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  34810. }
  34811. }
  34812. declare module BABYLON {
  34813. /**
  34814. * Interface for attribute information associated with buffer instanciation
  34815. */
  34816. export interface InstancingAttributeInfo {
  34817. /**
  34818. * Name of the GLSL attribute
  34819. * if attribute index is not specified, this is used to retrieve the index from the effect
  34820. */
  34821. attributeName: string;
  34822. /**
  34823. * Index/offset of the attribute in the vertex shader
  34824. * if not specified, this will be computes from the name.
  34825. */
  34826. index?: number;
  34827. /**
  34828. * size of the attribute, 1, 2, 3 or 4
  34829. */
  34830. attributeSize: number;
  34831. /**
  34832. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  34833. */
  34834. offset: number;
  34835. /**
  34836. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  34837. * default to 1
  34838. */
  34839. divisor?: number;
  34840. /**
  34841. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  34842. * default is FLOAT
  34843. */
  34844. attributeType?: number;
  34845. /**
  34846. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  34847. */
  34848. normalized?: boolean;
  34849. }
  34850. }
  34851. declare module BABYLON {
  34852. interface ThinEngine {
  34853. /**
  34854. * Update a video texture
  34855. * @param texture defines the texture to update
  34856. * @param video defines the video element to use
  34857. * @param invertY defines if data must be stored with Y axis inverted
  34858. */
  34859. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  34860. }
  34861. }
  34862. declare module BABYLON {
  34863. interface ThinEngine {
  34864. /**
  34865. * Creates a dynamic texture
  34866. * @param width defines the width of the texture
  34867. * @param height defines the height of the texture
  34868. * @param generateMipMaps defines if the engine should generate the mip levels
  34869. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  34870. * @returns the dynamic texture inside an InternalTexture
  34871. */
  34872. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  34873. /**
  34874. * Update the content of a dynamic texture
  34875. * @param texture defines the texture to update
  34876. * @param canvas defines the canvas containing the source
  34877. * @param invertY defines if data must be stored with Y axis inverted
  34878. * @param premulAlpha defines if alpha is stored as premultiplied
  34879. * @param format defines the format of the data
  34880. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  34881. */
  34882. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  34883. }
  34884. }
  34885. declare module BABYLON {
  34886. /**
  34887. * Settings for finer control over video usage
  34888. */
  34889. export interface VideoTextureSettings {
  34890. /**
  34891. * Applies `autoplay` to video, if specified
  34892. */
  34893. autoPlay?: boolean;
  34894. /**
  34895. * Applies `loop` to video, if specified
  34896. */
  34897. loop?: boolean;
  34898. /**
  34899. * Automatically updates internal texture from video at every frame in the render loop
  34900. */
  34901. autoUpdateTexture: boolean;
  34902. /**
  34903. * Image src displayed during the video loading or until the user interacts with the video.
  34904. */
  34905. poster?: string;
  34906. }
  34907. /**
  34908. * If you want to display a video in your scene, this is the special texture for that.
  34909. * This special texture works similar to other textures, with the exception of a few parameters.
  34910. * @see https://doc.babylonjs.com/how_to/video_texture
  34911. */
  34912. export class VideoTexture extends Texture {
  34913. /**
  34914. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  34915. */
  34916. readonly autoUpdateTexture: boolean;
  34917. /**
  34918. * The video instance used by the texture internally
  34919. */
  34920. readonly video: HTMLVideoElement;
  34921. private _onUserActionRequestedObservable;
  34922. /**
  34923. * Event triggerd when a dom action is required by the user to play the video.
  34924. * This happens due to recent changes in browser policies preventing video to auto start.
  34925. */
  34926. get onUserActionRequestedObservable(): Observable<Texture>;
  34927. private _generateMipMaps;
  34928. private _stillImageCaptured;
  34929. private _displayingPosterTexture;
  34930. private _settings;
  34931. private _createInternalTextureOnEvent;
  34932. private _frameId;
  34933. private _currentSrc;
  34934. /**
  34935. * Creates a video texture.
  34936. * If you want to display a video in your scene, this is the special texture for that.
  34937. * This special texture works similar to other textures, with the exception of a few parameters.
  34938. * @see https://doc.babylonjs.com/how_to/video_texture
  34939. * @param name optional name, will detect from video source, if not defined
  34940. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  34941. * @param scene is obviously the current scene.
  34942. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  34943. * @param invertY is false by default but can be used to invert video on Y axis
  34944. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  34945. * @param settings allows finer control over video usage
  34946. */
  34947. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  34948. private _getName;
  34949. private _getVideo;
  34950. private _createInternalTexture;
  34951. private reset;
  34952. /**
  34953. * @hidden Internal method to initiate `update`.
  34954. */
  34955. _rebuild(): void;
  34956. /**
  34957. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  34958. */
  34959. update(): void;
  34960. /**
  34961. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  34962. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  34963. */
  34964. updateTexture(isVisible: boolean): void;
  34965. protected _updateInternalTexture: () => void;
  34966. /**
  34967. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  34968. * @param url New url.
  34969. */
  34970. updateURL(url: string): void;
  34971. /**
  34972. * Clones the texture.
  34973. * @returns the cloned texture
  34974. */
  34975. clone(): VideoTexture;
  34976. /**
  34977. * Dispose the texture and release its associated resources.
  34978. */
  34979. dispose(): void;
  34980. /**
  34981. * Creates a video texture straight from a stream.
  34982. * @param scene Define the scene the texture should be created in
  34983. * @param stream Define the stream the texture should be created from
  34984. * @returns The created video texture as a promise
  34985. */
  34986. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  34987. /**
  34988. * Creates a video texture straight from your WebCam video feed.
  34989. * @param scene Define the scene the texture should be created in
  34990. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  34991. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  34992. * @returns The created video texture as a promise
  34993. */
  34994. static CreateFromWebCamAsync(scene: Scene, constraints: {
  34995. minWidth: number;
  34996. maxWidth: number;
  34997. minHeight: number;
  34998. maxHeight: number;
  34999. deviceId: string;
  35000. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  35001. /**
  35002. * Creates a video texture straight from your WebCam video feed.
  35003. * @param scene Define the scene the texture should be created in
  35004. * @param onReady Define a callback to triggered once the texture will be ready
  35005. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35006. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35007. */
  35008. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  35009. minWidth: number;
  35010. maxWidth: number;
  35011. minHeight: number;
  35012. maxHeight: number;
  35013. deviceId: string;
  35014. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  35015. }
  35016. }
  35017. declare module BABYLON {
  35018. /**
  35019. * Defines the interface used by objects working like Scene
  35020. * @hidden
  35021. */
  35022. export interface ISceneLike {
  35023. _addPendingData(data: any): void;
  35024. _removePendingData(data: any): void;
  35025. offlineProvider: IOfflineProvider;
  35026. }
  35027. /** Interface defining initialization parameters for Engine class */
  35028. export interface EngineOptions extends WebGLContextAttributes {
  35029. /**
  35030. * Defines if the engine should no exceed a specified device ratio
  35031. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  35032. */
  35033. limitDeviceRatio?: number;
  35034. /**
  35035. * Defines if webvr should be enabled automatically
  35036. * @see https://doc.babylonjs.com/how_to/webvr_camera
  35037. */
  35038. autoEnableWebVR?: boolean;
  35039. /**
  35040. * Defines if webgl2 should be turned off even if supported
  35041. * @see https://doc.babylonjs.com/features/webgl2
  35042. */
  35043. disableWebGL2Support?: boolean;
  35044. /**
  35045. * Defines if webaudio should be initialized as well
  35046. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  35047. */
  35048. audioEngine?: boolean;
  35049. /**
  35050. * Defines if animations should run using a deterministic lock step
  35051. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35052. */
  35053. deterministicLockstep?: boolean;
  35054. /** Defines the maximum steps to use with deterministic lock step mode */
  35055. lockstepMaxSteps?: number;
  35056. /** Defines the seconds between each deterministic lock step */
  35057. timeStep?: number;
  35058. /**
  35059. * Defines that engine should ignore context lost events
  35060. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  35061. */
  35062. doNotHandleContextLost?: boolean;
  35063. /**
  35064. * Defines that engine should ignore modifying touch action attribute and style
  35065. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  35066. */
  35067. doNotHandleTouchAction?: boolean;
  35068. /**
  35069. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  35070. */
  35071. useHighPrecisionFloats?: boolean;
  35072. /**
  35073. * Make the canvas XR Compatible for XR sessions
  35074. */
  35075. xrCompatible?: boolean;
  35076. /**
  35077. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  35078. */
  35079. useHighPrecisionMatrix?: boolean;
  35080. }
  35081. /**
  35082. * The base engine class (root of all engines)
  35083. */
  35084. export class ThinEngine {
  35085. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  35086. static ExceptionList: ({
  35087. key: string;
  35088. capture: string;
  35089. captureConstraint: number;
  35090. targets: string[];
  35091. } | {
  35092. key: string;
  35093. capture: null;
  35094. captureConstraint: null;
  35095. targets: string[];
  35096. })[];
  35097. /** @hidden */
  35098. static _TextureLoaders: IInternalTextureLoader[];
  35099. /**
  35100. * Returns the current npm package of the sdk
  35101. */
  35102. static get NpmPackage(): string;
  35103. /**
  35104. * Returns the current version of the framework
  35105. */
  35106. static get Version(): string;
  35107. /**
  35108. * Returns a string describing the current engine
  35109. */
  35110. get description(): string;
  35111. /**
  35112. * Gets or sets the epsilon value used by collision engine
  35113. */
  35114. static CollisionsEpsilon: number;
  35115. /**
  35116. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35117. */
  35118. static get ShadersRepository(): string;
  35119. static set ShadersRepository(value: string);
  35120. /** @hidden */
  35121. _shaderProcessor: IShaderProcessor;
  35122. /**
  35123. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  35124. */
  35125. forcePOTTextures: boolean;
  35126. /**
  35127. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  35128. */
  35129. isFullscreen: boolean;
  35130. /**
  35131. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  35132. */
  35133. cullBackFaces: boolean;
  35134. /**
  35135. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  35136. */
  35137. renderEvenInBackground: boolean;
  35138. /**
  35139. * Gets or sets a boolean indicating that cache can be kept between frames
  35140. */
  35141. preventCacheWipeBetweenFrames: boolean;
  35142. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  35143. validateShaderPrograms: boolean;
  35144. /**
  35145. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  35146. * This can provide greater z depth for distant objects.
  35147. */
  35148. useReverseDepthBuffer: boolean;
  35149. /**
  35150. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  35151. */
  35152. disableUniformBuffers: boolean;
  35153. /** @hidden */
  35154. _uniformBuffers: UniformBuffer[];
  35155. /**
  35156. * Gets a boolean indicating that the engine supports uniform buffers
  35157. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  35158. */
  35159. get supportsUniformBuffers(): boolean;
  35160. /** @hidden */
  35161. _gl: WebGLRenderingContext;
  35162. /** @hidden */
  35163. _webGLVersion: number;
  35164. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  35165. protected _windowIsBackground: boolean;
  35166. protected _creationOptions: EngineOptions;
  35167. protected _highPrecisionShadersAllowed: boolean;
  35168. /** @hidden */
  35169. get _shouldUseHighPrecisionShader(): boolean;
  35170. /**
  35171. * Gets a boolean indicating that only power of 2 textures are supported
  35172. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  35173. */
  35174. get needPOTTextures(): boolean;
  35175. /** @hidden */
  35176. _badOS: boolean;
  35177. /** @hidden */
  35178. _badDesktopOS: boolean;
  35179. private _hardwareScalingLevel;
  35180. /** @hidden */
  35181. _caps: EngineCapabilities;
  35182. private _isStencilEnable;
  35183. private _glVersion;
  35184. private _glRenderer;
  35185. private _glVendor;
  35186. /** @hidden */
  35187. _videoTextureSupported: boolean;
  35188. protected _renderingQueueLaunched: boolean;
  35189. protected _activeRenderLoops: (() => void)[];
  35190. /**
  35191. * Observable signaled when a context lost event is raised
  35192. */
  35193. onContextLostObservable: Observable<ThinEngine>;
  35194. /**
  35195. * Observable signaled when a context restored event is raised
  35196. */
  35197. onContextRestoredObservable: Observable<ThinEngine>;
  35198. private _onContextLost;
  35199. private _onContextRestored;
  35200. protected _contextWasLost: boolean;
  35201. /** @hidden */
  35202. _doNotHandleContextLost: boolean;
  35203. /**
  35204. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  35205. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  35206. */
  35207. get doNotHandleContextLost(): boolean;
  35208. set doNotHandleContextLost(value: boolean);
  35209. /**
  35210. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  35211. */
  35212. disableVertexArrayObjects: boolean;
  35213. /** @hidden */
  35214. protected _colorWrite: boolean;
  35215. /** @hidden */
  35216. protected _colorWriteChanged: boolean;
  35217. /** @hidden */
  35218. protected _depthCullingState: DepthCullingState;
  35219. /** @hidden */
  35220. protected _stencilState: StencilState;
  35221. /** @hidden */
  35222. _alphaState: AlphaState;
  35223. /** @hidden */
  35224. _alphaMode: number;
  35225. /** @hidden */
  35226. _alphaEquation: number;
  35227. /** @hidden */
  35228. _internalTexturesCache: InternalTexture[];
  35229. /** @hidden */
  35230. protected _activeChannel: number;
  35231. private _currentTextureChannel;
  35232. /** @hidden */
  35233. protected _boundTexturesCache: {
  35234. [key: string]: Nullable<InternalTexture>;
  35235. };
  35236. /** @hidden */
  35237. protected _currentEffect: Nullable<Effect>;
  35238. /** @hidden */
  35239. protected _currentProgram: Nullable<WebGLProgram>;
  35240. private _compiledEffects;
  35241. private _vertexAttribArraysEnabled;
  35242. /** @hidden */
  35243. protected _cachedViewport: Nullable<IViewportLike>;
  35244. private _cachedVertexArrayObject;
  35245. /** @hidden */
  35246. protected _cachedVertexBuffers: any;
  35247. /** @hidden */
  35248. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  35249. /** @hidden */
  35250. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  35251. /** @hidden */
  35252. _currentRenderTarget: Nullable<InternalTexture>;
  35253. private _uintIndicesCurrentlySet;
  35254. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  35255. /** @hidden */
  35256. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  35257. /** @hidden */
  35258. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  35259. private _currentBufferPointers;
  35260. private _currentInstanceLocations;
  35261. private _currentInstanceBuffers;
  35262. private _textureUnits;
  35263. /** @hidden */
  35264. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35265. /** @hidden */
  35266. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35267. /** @hidden */
  35268. _boundRenderFunction: any;
  35269. private _vaoRecordInProgress;
  35270. private _mustWipeVertexAttributes;
  35271. private _emptyTexture;
  35272. private _emptyCubeTexture;
  35273. private _emptyTexture3D;
  35274. private _emptyTexture2DArray;
  35275. /** @hidden */
  35276. _frameHandler: number;
  35277. private _nextFreeTextureSlots;
  35278. private _maxSimultaneousTextures;
  35279. private _activeRequests;
  35280. /** @hidden */
  35281. _transformTextureUrl: Nullable<(url: string) => string>;
  35282. protected get _supportsHardwareTextureRescaling(): boolean;
  35283. private _framebufferDimensionsObject;
  35284. /**
  35285. * sets the object from which width and height will be taken from when getting render width and height
  35286. * Will fallback to the gl object
  35287. * @param dimensions the framebuffer width and height that will be used.
  35288. */
  35289. set framebufferDimensionsObject(dimensions: Nullable<{
  35290. framebufferWidth: number;
  35291. framebufferHeight: number;
  35292. }>);
  35293. /**
  35294. * Gets the current viewport
  35295. */
  35296. get currentViewport(): Nullable<IViewportLike>;
  35297. /**
  35298. * Gets the default empty texture
  35299. */
  35300. get emptyTexture(): InternalTexture;
  35301. /**
  35302. * Gets the default empty 3D texture
  35303. */
  35304. get emptyTexture3D(): InternalTexture;
  35305. /**
  35306. * Gets the default empty 2D array texture
  35307. */
  35308. get emptyTexture2DArray(): InternalTexture;
  35309. /**
  35310. * Gets the default empty cube texture
  35311. */
  35312. get emptyCubeTexture(): InternalTexture;
  35313. /**
  35314. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  35315. */
  35316. readonly premultipliedAlpha: boolean;
  35317. /**
  35318. * Observable event triggered before each texture is initialized
  35319. */
  35320. onBeforeTextureInitObservable: Observable<Texture>;
  35321. /**
  35322. * Creates a new engine
  35323. * @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
  35324. * @param antialias defines enable antialiasing (default: false)
  35325. * @param options defines further options to be sent to the getContext() function
  35326. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  35327. */
  35328. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  35329. private _rebuildInternalTextures;
  35330. private _rebuildEffects;
  35331. /**
  35332. * Gets a boolean indicating if all created effects are ready
  35333. * @returns true if all effects are ready
  35334. */
  35335. areAllEffectsReady(): boolean;
  35336. protected _rebuildBuffers(): void;
  35337. protected _initGLContext(): void;
  35338. /**
  35339. * Gets version of the current webGL context
  35340. */
  35341. get webGLVersion(): number;
  35342. /**
  35343. * Gets a string idenfifying the name of the class
  35344. * @returns "Engine" string
  35345. */
  35346. getClassName(): string;
  35347. /**
  35348. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  35349. */
  35350. get isStencilEnable(): boolean;
  35351. /** @hidden */
  35352. _prepareWorkingCanvas(): void;
  35353. /**
  35354. * Reset the texture cache to empty state
  35355. */
  35356. resetTextureCache(): void;
  35357. /**
  35358. * Gets an object containing information about the current webGL context
  35359. * @returns an object containing the vender, the renderer and the version of the current webGL context
  35360. */
  35361. getGlInfo(): {
  35362. vendor: string;
  35363. renderer: string;
  35364. version: string;
  35365. };
  35366. /**
  35367. * Defines the hardware scaling level.
  35368. * By default the hardware scaling level is computed from the window device ratio.
  35369. * 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.
  35370. * @param level defines the level to use
  35371. */
  35372. setHardwareScalingLevel(level: number): void;
  35373. /**
  35374. * Gets the current hardware scaling level.
  35375. * By default the hardware scaling level is computed from the window device ratio.
  35376. * 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.
  35377. * @returns a number indicating the current hardware scaling level
  35378. */
  35379. getHardwareScalingLevel(): number;
  35380. /**
  35381. * Gets the list of loaded textures
  35382. * @returns an array containing all loaded textures
  35383. */
  35384. getLoadedTexturesCache(): InternalTexture[];
  35385. /**
  35386. * Gets the object containing all engine capabilities
  35387. * @returns the EngineCapabilities object
  35388. */
  35389. getCaps(): EngineCapabilities;
  35390. /**
  35391. * stop executing a render loop function and remove it from the execution array
  35392. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  35393. */
  35394. stopRenderLoop(renderFunction?: () => void): void;
  35395. /** @hidden */
  35396. _renderLoop(): void;
  35397. /**
  35398. * Gets the HTML canvas attached with the current webGL context
  35399. * @returns a HTML canvas
  35400. */
  35401. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  35402. /**
  35403. * Gets host window
  35404. * @returns the host window object
  35405. */
  35406. getHostWindow(): Nullable<Window>;
  35407. /**
  35408. * Gets the current render width
  35409. * @param useScreen defines if screen size must be used (or the current render target if any)
  35410. * @returns a number defining the current render width
  35411. */
  35412. getRenderWidth(useScreen?: boolean): number;
  35413. /**
  35414. * Gets the current render height
  35415. * @param useScreen defines if screen size must be used (or the current render target if any)
  35416. * @returns a number defining the current render height
  35417. */
  35418. getRenderHeight(useScreen?: boolean): number;
  35419. /**
  35420. * Can be used to override the current requestAnimationFrame requester.
  35421. * @hidden
  35422. */
  35423. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  35424. /**
  35425. * Register and execute a render loop. The engine can have more than one render function
  35426. * @param renderFunction defines the function to continuously execute
  35427. */
  35428. runRenderLoop(renderFunction: () => void): void;
  35429. /**
  35430. * Clear the current render buffer or the current render target (if any is set up)
  35431. * @param color defines the color to use
  35432. * @param backBuffer defines if the back buffer must be cleared
  35433. * @param depth defines if the depth buffer must be cleared
  35434. * @param stencil defines if the stencil buffer must be cleared
  35435. */
  35436. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  35437. private _viewportCached;
  35438. /** @hidden */
  35439. _viewport(x: number, y: number, width: number, height: number): void;
  35440. /**
  35441. * Set the WebGL's viewport
  35442. * @param viewport defines the viewport element to be used
  35443. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  35444. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  35445. */
  35446. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  35447. /**
  35448. * Begin a new frame
  35449. */
  35450. beginFrame(): void;
  35451. /**
  35452. * Enf the current frame
  35453. */
  35454. endFrame(): void;
  35455. /**
  35456. * Resize the view according to the canvas' size
  35457. */
  35458. resize(): void;
  35459. /**
  35460. * Force a specific size of the canvas
  35461. * @param width defines the new canvas' width
  35462. * @param height defines the new canvas' height
  35463. * @returns true if the size was changed
  35464. */
  35465. setSize(width: number, height: number): boolean;
  35466. /**
  35467. * Binds the frame buffer to the specified texture.
  35468. * @param texture The texture to render to or null for the default canvas
  35469. * @param faceIndex The face of the texture to render to in case of cube texture
  35470. * @param requiredWidth The width of the target to render to
  35471. * @param requiredHeight The height of the target to render to
  35472. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  35473. * @param lodLevel defines the lod level to bind to the frame buffer
  35474. * @param layer defines the 2d array index to bind to frame buffer to
  35475. */
  35476. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  35477. /** @hidden */
  35478. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  35479. /**
  35480. * Unbind the current render target texture from the webGL context
  35481. * @param texture defines the render target texture to unbind
  35482. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  35483. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  35484. */
  35485. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  35486. /**
  35487. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  35488. */
  35489. flushFramebuffer(): void;
  35490. /**
  35491. * Unbind the current render target and bind the default framebuffer
  35492. */
  35493. restoreDefaultFramebuffer(): void;
  35494. /** @hidden */
  35495. protected _resetVertexBufferBinding(): void;
  35496. /**
  35497. * Creates a vertex buffer
  35498. * @param data the data for the vertex buffer
  35499. * @returns the new WebGL static buffer
  35500. */
  35501. createVertexBuffer(data: DataArray): DataBuffer;
  35502. private _createVertexBuffer;
  35503. /**
  35504. * Creates a dynamic vertex buffer
  35505. * @param data the data for the dynamic vertex buffer
  35506. * @returns the new WebGL dynamic buffer
  35507. */
  35508. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  35509. protected _resetIndexBufferBinding(): void;
  35510. /**
  35511. * Creates a new index buffer
  35512. * @param indices defines the content of the index buffer
  35513. * @param updatable defines if the index buffer must be updatable
  35514. * @returns a new webGL buffer
  35515. */
  35516. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  35517. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  35518. /**
  35519. * Bind a webGL buffer to the webGL context
  35520. * @param buffer defines the buffer to bind
  35521. */
  35522. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  35523. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  35524. private bindBuffer;
  35525. /**
  35526. * update the bound buffer with the given data
  35527. * @param data defines the data to update
  35528. */
  35529. updateArrayBuffer(data: Float32Array): void;
  35530. private _vertexAttribPointer;
  35531. /** @hidden */
  35532. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  35533. private _bindVertexBuffersAttributes;
  35534. /**
  35535. * Records a vertex array object
  35536. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35537. * @param vertexBuffers defines the list of vertex buffers to store
  35538. * @param indexBuffer defines the index buffer to store
  35539. * @param effect defines the effect to store
  35540. * @returns the new vertex array object
  35541. */
  35542. recordVertexArrayObject(vertexBuffers: {
  35543. [key: string]: VertexBuffer;
  35544. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  35545. /**
  35546. * Bind a specific vertex array object
  35547. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35548. * @param vertexArrayObject defines the vertex array object to bind
  35549. * @param indexBuffer defines the index buffer to bind
  35550. */
  35551. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  35552. /**
  35553. * Bind webGl buffers directly to the webGL context
  35554. * @param vertexBuffer defines the vertex buffer to bind
  35555. * @param indexBuffer defines the index buffer to bind
  35556. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  35557. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  35558. * @param effect defines the effect associated with the vertex buffer
  35559. */
  35560. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  35561. private _unbindVertexArrayObject;
  35562. /**
  35563. * Bind a list of vertex buffers to the webGL context
  35564. * @param vertexBuffers defines the list of vertex buffers to bind
  35565. * @param indexBuffer defines the index buffer to bind
  35566. * @param effect defines the effect associated with the vertex buffers
  35567. */
  35568. bindBuffers(vertexBuffers: {
  35569. [key: string]: Nullable<VertexBuffer>;
  35570. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  35571. /**
  35572. * Unbind all instance attributes
  35573. */
  35574. unbindInstanceAttributes(): void;
  35575. /**
  35576. * Release and free the memory of a vertex array object
  35577. * @param vao defines the vertex array object to delete
  35578. */
  35579. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  35580. /** @hidden */
  35581. _releaseBuffer(buffer: DataBuffer): boolean;
  35582. protected _deleteBuffer(buffer: DataBuffer): void;
  35583. /**
  35584. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  35585. * @param instancesBuffer defines the webGL buffer to update and bind
  35586. * @param data defines the data to store in the buffer
  35587. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  35588. */
  35589. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  35590. /**
  35591. * Bind the content of a webGL buffer used with instantiation
  35592. * @param instancesBuffer defines the webGL buffer to bind
  35593. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  35594. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  35595. */
  35596. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  35597. /**
  35598. * Disable the instance attribute corresponding to the name in parameter
  35599. * @param name defines the name of the attribute to disable
  35600. */
  35601. disableInstanceAttributeByName(name: string): void;
  35602. /**
  35603. * Disable the instance attribute corresponding to the location in parameter
  35604. * @param attributeLocation defines the attribute location of the attribute to disable
  35605. */
  35606. disableInstanceAttribute(attributeLocation: number): void;
  35607. /**
  35608. * Disable the attribute corresponding to the location in parameter
  35609. * @param attributeLocation defines the attribute location of the attribute to disable
  35610. */
  35611. disableAttributeByIndex(attributeLocation: number): void;
  35612. /**
  35613. * Send a draw order
  35614. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35615. * @param indexStart defines the starting index
  35616. * @param indexCount defines the number of index to draw
  35617. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35618. */
  35619. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  35620. /**
  35621. * Draw a list of points
  35622. * @param verticesStart defines the index of first vertex to draw
  35623. * @param verticesCount defines the count of vertices to draw
  35624. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35625. */
  35626. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35627. /**
  35628. * Draw a list of unindexed primitives
  35629. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35630. * @param verticesStart defines the index of first vertex to draw
  35631. * @param verticesCount defines the count of vertices to draw
  35632. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35633. */
  35634. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35635. /**
  35636. * Draw a list of indexed primitives
  35637. * @param fillMode defines the primitive to use
  35638. * @param indexStart defines the starting index
  35639. * @param indexCount defines the number of index to draw
  35640. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35641. */
  35642. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  35643. /**
  35644. * Draw a list of unindexed primitives
  35645. * @param fillMode defines the primitive to use
  35646. * @param verticesStart defines the index of first vertex to draw
  35647. * @param verticesCount defines the count of vertices to draw
  35648. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35649. */
  35650. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35651. private _drawMode;
  35652. /** @hidden */
  35653. protected _reportDrawCall(): void;
  35654. /** @hidden */
  35655. _releaseEffect(effect: Effect): void;
  35656. /** @hidden */
  35657. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  35658. /**
  35659. * Create a new effect (used to store vertex/fragment shaders)
  35660. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  35661. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  35662. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  35663. * @param samplers defines an array of string used to represent textures
  35664. * @param defines defines the string containing the defines to use to compile the shaders
  35665. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  35666. * @param onCompiled defines a function to call when the effect creation is successful
  35667. * @param onError defines a function to call when the effect creation has failed
  35668. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  35669. * @returns the new Effect
  35670. */
  35671. 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;
  35672. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  35673. private _compileShader;
  35674. private _compileRawShader;
  35675. /** @hidden */
  35676. _getShaderSource(shader: WebGLShader): Nullable<string>;
  35677. /**
  35678. * Directly creates a webGL program
  35679. * @param pipelineContext defines the pipeline context to attach to
  35680. * @param vertexCode defines the vertex shader code to use
  35681. * @param fragmentCode defines the fragment shader code to use
  35682. * @param context defines the webGL context to use (if not set, the current one will be used)
  35683. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35684. * @returns the new webGL program
  35685. */
  35686. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35687. /**
  35688. * Creates a webGL program
  35689. * @param pipelineContext defines the pipeline context to attach to
  35690. * @param vertexCode defines the vertex shader code to use
  35691. * @param fragmentCode defines the fragment shader code to use
  35692. * @param defines defines the string containing the defines to use to compile the shaders
  35693. * @param context defines the webGL context to use (if not set, the current one will be used)
  35694. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35695. * @returns the new webGL program
  35696. */
  35697. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35698. /**
  35699. * Creates a new pipeline context
  35700. * @returns the new pipeline
  35701. */
  35702. createPipelineContext(): IPipelineContext;
  35703. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35704. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  35705. /** @hidden */
  35706. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  35707. /** @hidden */
  35708. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  35709. /** @hidden */
  35710. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  35711. /**
  35712. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  35713. * @param pipelineContext defines the pipeline context to use
  35714. * @param uniformsNames defines the list of uniform names
  35715. * @returns an array of webGL uniform locations
  35716. */
  35717. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  35718. /**
  35719. * Gets the lsit of active attributes for a given webGL program
  35720. * @param pipelineContext defines the pipeline context to use
  35721. * @param attributesNames defines the list of attribute names to get
  35722. * @returns an array of indices indicating the offset of each attribute
  35723. */
  35724. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  35725. /**
  35726. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  35727. * @param effect defines the effect to activate
  35728. */
  35729. enableEffect(effect: Nullable<Effect>): void;
  35730. /**
  35731. * Set the value of an uniform to a number (int)
  35732. * @param uniform defines the webGL uniform location where to store the value
  35733. * @param value defines the int number to store
  35734. */
  35735. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35736. /**
  35737. * Set the value of an uniform to an array of int32
  35738. * @param uniform defines the webGL uniform location where to store the value
  35739. * @param array defines the array of int32 to store
  35740. */
  35741. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35742. /**
  35743. * Set the value of an uniform to an array of int32 (stored as vec2)
  35744. * @param uniform defines the webGL uniform location where to store the value
  35745. * @param array defines the array of int32 to store
  35746. */
  35747. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35748. /**
  35749. * Set the value of an uniform to an array of int32 (stored as vec3)
  35750. * @param uniform defines the webGL uniform location where to store the value
  35751. * @param array defines the array of int32 to store
  35752. */
  35753. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35754. /**
  35755. * Set the value of an uniform to an array of int32 (stored as vec4)
  35756. * @param uniform defines the webGL uniform location where to store the value
  35757. * @param array defines the array of int32 to store
  35758. */
  35759. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35760. /**
  35761. * Set the value of an uniform to an array of number
  35762. * @param uniform defines the webGL uniform location where to store the value
  35763. * @param array defines the array of number to store
  35764. */
  35765. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35766. /**
  35767. * Set the value of an uniform to an array of number (stored as vec2)
  35768. * @param uniform defines the webGL uniform location where to store the value
  35769. * @param array defines the array of number to store
  35770. */
  35771. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35772. /**
  35773. * Set the value of an uniform to an array of number (stored as vec3)
  35774. * @param uniform defines the webGL uniform location where to store the value
  35775. * @param array defines the array of number to store
  35776. */
  35777. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35778. /**
  35779. * Set the value of an uniform to an array of number (stored as vec4)
  35780. * @param uniform defines the webGL uniform location where to store the value
  35781. * @param array defines the array of number to store
  35782. */
  35783. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35784. /**
  35785. * Set the value of an uniform to an array of float32 (stored as matrices)
  35786. * @param uniform defines the webGL uniform location where to store the value
  35787. * @param matrices defines the array of float32 to store
  35788. */
  35789. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  35790. /**
  35791. * Set the value of an uniform to a matrix (3x3)
  35792. * @param uniform defines the webGL uniform location where to store the value
  35793. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  35794. */
  35795. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35796. /**
  35797. * Set the value of an uniform to a matrix (2x2)
  35798. * @param uniform defines the webGL uniform location where to store the value
  35799. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  35800. */
  35801. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35802. /**
  35803. * Set the value of an uniform to a number (float)
  35804. * @param uniform defines the webGL uniform location where to store the value
  35805. * @param value defines the float number to store
  35806. */
  35807. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35808. /**
  35809. * Set the value of an uniform to a vec2
  35810. * @param uniform defines the webGL uniform location where to store the value
  35811. * @param x defines the 1st component of the value
  35812. * @param y defines the 2nd component of the value
  35813. */
  35814. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  35815. /**
  35816. * Set the value of an uniform to a vec3
  35817. * @param uniform defines the webGL uniform location where to store the value
  35818. * @param x defines the 1st component of the value
  35819. * @param y defines the 2nd component of the value
  35820. * @param z defines the 3rd component of the value
  35821. */
  35822. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  35823. /**
  35824. * Set the value of an uniform to a vec4
  35825. * @param uniform defines the webGL uniform location where to store the value
  35826. * @param x defines the 1st component of the value
  35827. * @param y defines the 2nd component of the value
  35828. * @param z defines the 3rd component of the value
  35829. * @param w defines the 4th component of the value
  35830. */
  35831. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  35832. /**
  35833. * Apply all cached states (depth, culling, stencil and alpha)
  35834. */
  35835. applyStates(): void;
  35836. /**
  35837. * Enable or disable color writing
  35838. * @param enable defines the state to set
  35839. */
  35840. setColorWrite(enable: boolean): void;
  35841. /**
  35842. * Gets a boolean indicating if color writing is enabled
  35843. * @returns the current color writing state
  35844. */
  35845. getColorWrite(): boolean;
  35846. /**
  35847. * Gets the depth culling state manager
  35848. */
  35849. get depthCullingState(): DepthCullingState;
  35850. /**
  35851. * Gets the alpha state manager
  35852. */
  35853. get alphaState(): AlphaState;
  35854. /**
  35855. * Gets the stencil state manager
  35856. */
  35857. get stencilState(): StencilState;
  35858. /**
  35859. * Clears the list of texture accessible through engine.
  35860. * This can help preventing texture load conflict due to name collision.
  35861. */
  35862. clearInternalTexturesCache(): void;
  35863. /**
  35864. * Force the entire cache to be cleared
  35865. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  35866. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  35867. */
  35868. wipeCaches(bruteForce?: boolean): void;
  35869. /** @hidden */
  35870. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  35871. min: number;
  35872. mag: number;
  35873. };
  35874. /** @hidden */
  35875. _createTexture(): WebGLTexture;
  35876. /**
  35877. * Usually called from Texture.ts.
  35878. * Passed information to create a WebGLTexture
  35879. * @param url defines a value which contains one of the following:
  35880. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  35881. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  35882. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  35883. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  35884. * @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)
  35885. * @param scene needed for loading to the correct scene
  35886. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  35887. * @param onLoad optional callback to be called upon successful completion
  35888. * @param onError optional callback to be called upon failure
  35889. * @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
  35890. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  35891. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  35892. * @param forcedExtension defines the extension to use to pick the right loader
  35893. * @param mimeType defines an optional mime type
  35894. * @returns a InternalTexture for assignment back into BABYLON.Texture
  35895. */
  35896. 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;
  35897. /**
  35898. * Loads an image as an HTMLImageElement.
  35899. * @param input url string, ArrayBuffer, or Blob to load
  35900. * @param onLoad callback called when the image successfully loads
  35901. * @param onError callback called when the image fails to load
  35902. * @param offlineProvider offline provider for caching
  35903. * @param mimeType optional mime type
  35904. * @returns the HTMLImageElement of the loaded image
  35905. * @hidden
  35906. */
  35907. 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>;
  35908. /**
  35909. * @hidden
  35910. */
  35911. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  35912. private _unpackFlipYCached;
  35913. /**
  35914. * In case you are sharing the context with other applications, it might
  35915. * be interested to not cache the unpack flip y state to ensure a consistent
  35916. * value would be set.
  35917. */
  35918. enableUnpackFlipYCached: boolean;
  35919. /** @hidden */
  35920. _unpackFlipY(value: boolean): void;
  35921. /** @hidden */
  35922. _getUnpackAlignement(): number;
  35923. private _getTextureTarget;
  35924. /**
  35925. * Update the sampling mode of a given texture
  35926. * @param samplingMode defines the required sampling mode
  35927. * @param texture defines the texture to update
  35928. * @param generateMipMaps defines whether to generate mipmaps for the texture
  35929. */
  35930. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  35931. /**
  35932. * Update the sampling mode of a given texture
  35933. * @param texture defines the texture to update
  35934. * @param wrapU defines the texture wrap mode of the u coordinates
  35935. * @param wrapV defines the texture wrap mode of the v coordinates
  35936. * @param wrapR defines the texture wrap mode of the r coordinates
  35937. */
  35938. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  35939. /** @hidden */
  35940. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  35941. width: number;
  35942. height: number;
  35943. layers?: number;
  35944. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  35945. /** @hidden */
  35946. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  35947. /** @hidden */
  35948. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  35949. /**
  35950. * Update a portion of an internal texture
  35951. * @param texture defines the texture to update
  35952. * @param imageData defines the data to store into the texture
  35953. * @param xOffset defines the x coordinates of the update rectangle
  35954. * @param yOffset defines the y coordinates of the update rectangle
  35955. * @param width defines the width of the update rectangle
  35956. * @param height defines the height of the update rectangle
  35957. * @param faceIndex defines the face index if texture is a cube (0 by default)
  35958. * @param lod defines the lod level to update (0 by default)
  35959. */
  35960. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  35961. /** @hidden */
  35962. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  35963. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  35964. private _prepareWebGLTexture;
  35965. /** @hidden */
  35966. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  35967. private _getDepthStencilBuffer;
  35968. /** @hidden */
  35969. _releaseFramebufferObjects(texture: InternalTexture): void;
  35970. /** @hidden */
  35971. _releaseTexture(texture: InternalTexture): void;
  35972. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  35973. protected _setProgram(program: WebGLProgram): void;
  35974. protected _boundUniforms: {
  35975. [key: number]: WebGLUniformLocation;
  35976. };
  35977. /**
  35978. * Binds an effect to the webGL context
  35979. * @param effect defines the effect to bind
  35980. */
  35981. bindSamplers(effect: Effect): void;
  35982. private _activateCurrentTexture;
  35983. /** @hidden */
  35984. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  35985. /** @hidden */
  35986. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  35987. /**
  35988. * Unbind all textures from the webGL context
  35989. */
  35990. unbindAllTextures(): void;
  35991. /**
  35992. * Sets a texture to the according uniform.
  35993. * @param channel The texture channel
  35994. * @param uniform The uniform to set
  35995. * @param texture The texture to apply
  35996. */
  35997. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  35998. private _bindSamplerUniformToChannel;
  35999. private _getTextureWrapMode;
  36000. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  36001. /**
  36002. * Sets an array of texture to the webGL context
  36003. * @param channel defines the channel where the texture array must be set
  36004. * @param uniform defines the associated uniform location
  36005. * @param textures defines the array of textures to bind
  36006. */
  36007. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  36008. /** @hidden */
  36009. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  36010. private _setTextureParameterFloat;
  36011. private _setTextureParameterInteger;
  36012. /**
  36013. * Unbind all vertex attributes from the webGL context
  36014. */
  36015. unbindAllAttributes(): void;
  36016. /**
  36017. * 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
  36018. */
  36019. releaseEffects(): void;
  36020. /**
  36021. * Dispose and release all associated resources
  36022. */
  36023. dispose(): void;
  36024. /**
  36025. * Attach a new callback raised when context lost event is fired
  36026. * @param callback defines the callback to call
  36027. */
  36028. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36029. /**
  36030. * Attach a new callback raised when context restored event is fired
  36031. * @param callback defines the callback to call
  36032. */
  36033. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36034. /**
  36035. * Get the current error code of the webGL context
  36036. * @returns the error code
  36037. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  36038. */
  36039. getError(): number;
  36040. private _canRenderToFloatFramebuffer;
  36041. private _canRenderToHalfFloatFramebuffer;
  36042. private _canRenderToFramebuffer;
  36043. /** @hidden */
  36044. _getWebGLTextureType(type: number): number;
  36045. /** @hidden */
  36046. _getInternalFormat(format: number): number;
  36047. /** @hidden */
  36048. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  36049. /** @hidden */
  36050. _getRGBAMultiSampleBufferFormat(type: number): number;
  36051. /** @hidden */
  36052. _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;
  36053. /**
  36054. * Loads a file from a url
  36055. * @param url url to load
  36056. * @param onSuccess callback called when the file successfully loads
  36057. * @param onProgress callback called while file is loading (if the server supports this mode)
  36058. * @param offlineProvider defines the offline provider for caching
  36059. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  36060. * @param onError callback called when the file fails to load
  36061. * @returns a file request object
  36062. * @hidden
  36063. */
  36064. 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;
  36065. /**
  36066. * Reads pixels from the current frame buffer. Please note that this function can be slow
  36067. * @param x defines the x coordinate of the rectangle where pixels must be read
  36068. * @param y defines the y coordinate of the rectangle where pixels must be read
  36069. * @param width defines the width of the rectangle where pixels must be read
  36070. * @param height defines the height of the rectangle where pixels must be read
  36071. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  36072. * @returns a Uint8Array containing RGBA colors
  36073. */
  36074. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  36075. private static _isSupported;
  36076. /**
  36077. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  36078. * @returns true if the engine can be created
  36079. * @ignorenaming
  36080. */
  36081. static isSupported(): boolean;
  36082. /**
  36083. * Find the next highest power of two.
  36084. * @param x Number to start search from.
  36085. * @return Next highest power of two.
  36086. */
  36087. static CeilingPOT(x: number): number;
  36088. /**
  36089. * Find the next lowest power of two.
  36090. * @param x Number to start search from.
  36091. * @return Next lowest power of two.
  36092. */
  36093. static FloorPOT(x: number): number;
  36094. /**
  36095. * Find the nearest power of two.
  36096. * @param x Number to start search from.
  36097. * @return Next nearest power of two.
  36098. */
  36099. static NearestPOT(x: number): number;
  36100. /**
  36101. * Get the closest exponent of two
  36102. * @param value defines the value to approximate
  36103. * @param max defines the maximum value to return
  36104. * @param mode defines how to define the closest value
  36105. * @returns closest exponent of two of the given value
  36106. */
  36107. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  36108. /**
  36109. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  36110. * @param func - the function to be called
  36111. * @param requester - the object that will request the next frame. Falls back to window.
  36112. * @returns frame number
  36113. */
  36114. static QueueNewFrame(func: () => void, requester?: any): number;
  36115. /**
  36116. * Gets host document
  36117. * @returns the host document object
  36118. */
  36119. getHostDocument(): Nullable<Document>;
  36120. }
  36121. }
  36122. declare module BABYLON {
  36123. /**
  36124. * Class representing spherical harmonics coefficients to the 3rd degree
  36125. */
  36126. export class SphericalHarmonics {
  36127. /**
  36128. * Defines whether or not the harmonics have been prescaled for rendering.
  36129. */
  36130. preScaled: boolean;
  36131. /**
  36132. * The l0,0 coefficients of the spherical harmonics
  36133. */
  36134. l00: Vector3;
  36135. /**
  36136. * The l1,-1 coefficients of the spherical harmonics
  36137. */
  36138. l1_1: Vector3;
  36139. /**
  36140. * The l1,0 coefficients of the spherical harmonics
  36141. */
  36142. l10: Vector3;
  36143. /**
  36144. * The l1,1 coefficients of the spherical harmonics
  36145. */
  36146. l11: Vector3;
  36147. /**
  36148. * The l2,-2 coefficients of the spherical harmonics
  36149. */
  36150. l2_2: Vector3;
  36151. /**
  36152. * The l2,-1 coefficients of the spherical harmonics
  36153. */
  36154. l2_1: Vector3;
  36155. /**
  36156. * The l2,0 coefficients of the spherical harmonics
  36157. */
  36158. l20: Vector3;
  36159. /**
  36160. * The l2,1 coefficients of the spherical harmonics
  36161. */
  36162. l21: Vector3;
  36163. /**
  36164. * The l2,2 coefficients of the spherical harmonics
  36165. */
  36166. l22: Vector3;
  36167. /**
  36168. * Adds a light to the spherical harmonics
  36169. * @param direction the direction of the light
  36170. * @param color the color of the light
  36171. * @param deltaSolidAngle the delta solid angle of the light
  36172. */
  36173. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  36174. /**
  36175. * Scales the spherical harmonics by the given amount
  36176. * @param scale the amount to scale
  36177. */
  36178. scaleInPlace(scale: number): void;
  36179. /**
  36180. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  36181. *
  36182. * ```
  36183. * E_lm = A_l * L_lm
  36184. * ```
  36185. *
  36186. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  36187. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  36188. * the scaling factors are given in equation 9.
  36189. */
  36190. convertIncidentRadianceToIrradiance(): void;
  36191. /**
  36192. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  36193. *
  36194. * ```
  36195. * L = (1/pi) * E * rho
  36196. * ```
  36197. *
  36198. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  36199. */
  36200. convertIrradianceToLambertianRadiance(): void;
  36201. /**
  36202. * Integrates the reconstruction coefficients directly in to the SH preventing further
  36203. * required operations at run time.
  36204. *
  36205. * This is simply done by scaling back the SH with Ylm constants parameter.
  36206. * The trigonometric part being applied by the shader at run time.
  36207. */
  36208. preScaleForRendering(): void;
  36209. /**
  36210. * Constructs a spherical harmonics from an array.
  36211. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  36212. * @returns the spherical harmonics
  36213. */
  36214. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  36215. /**
  36216. * Gets the spherical harmonics from polynomial
  36217. * @param polynomial the spherical polynomial
  36218. * @returns the spherical harmonics
  36219. */
  36220. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  36221. }
  36222. /**
  36223. * Class representing spherical polynomial coefficients to the 3rd degree
  36224. */
  36225. export class SphericalPolynomial {
  36226. private _harmonics;
  36227. /**
  36228. * The spherical harmonics used to create the polynomials.
  36229. */
  36230. get preScaledHarmonics(): SphericalHarmonics;
  36231. /**
  36232. * The x coefficients of the spherical polynomial
  36233. */
  36234. x: Vector3;
  36235. /**
  36236. * The y coefficients of the spherical polynomial
  36237. */
  36238. y: Vector3;
  36239. /**
  36240. * The z coefficients of the spherical polynomial
  36241. */
  36242. z: Vector3;
  36243. /**
  36244. * The xx coefficients of the spherical polynomial
  36245. */
  36246. xx: Vector3;
  36247. /**
  36248. * The yy coefficients of the spherical polynomial
  36249. */
  36250. yy: Vector3;
  36251. /**
  36252. * The zz coefficients of the spherical polynomial
  36253. */
  36254. zz: Vector3;
  36255. /**
  36256. * The xy coefficients of the spherical polynomial
  36257. */
  36258. xy: Vector3;
  36259. /**
  36260. * The yz coefficients of the spherical polynomial
  36261. */
  36262. yz: Vector3;
  36263. /**
  36264. * The zx coefficients of the spherical polynomial
  36265. */
  36266. zx: Vector3;
  36267. /**
  36268. * Adds an ambient color to the spherical polynomial
  36269. * @param color the color to add
  36270. */
  36271. addAmbient(color: Color3): void;
  36272. /**
  36273. * Scales the spherical polynomial by the given amount
  36274. * @param scale the amount to scale
  36275. */
  36276. scaleInPlace(scale: number): void;
  36277. /**
  36278. * Gets the spherical polynomial from harmonics
  36279. * @param harmonics the spherical harmonics
  36280. * @returns the spherical polynomial
  36281. */
  36282. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  36283. /**
  36284. * Constructs a spherical polynomial from an array.
  36285. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  36286. * @returns the spherical polynomial
  36287. */
  36288. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  36289. }
  36290. }
  36291. declare module BABYLON {
  36292. /**
  36293. * Defines the source of the internal texture
  36294. */
  36295. export enum InternalTextureSource {
  36296. /**
  36297. * The source of the texture data is unknown
  36298. */
  36299. Unknown = 0,
  36300. /**
  36301. * Texture data comes from an URL
  36302. */
  36303. Url = 1,
  36304. /**
  36305. * Texture data is only used for temporary storage
  36306. */
  36307. Temp = 2,
  36308. /**
  36309. * Texture data comes from raw data (ArrayBuffer)
  36310. */
  36311. Raw = 3,
  36312. /**
  36313. * Texture content is dynamic (video or dynamic texture)
  36314. */
  36315. Dynamic = 4,
  36316. /**
  36317. * Texture content is generated by rendering to it
  36318. */
  36319. RenderTarget = 5,
  36320. /**
  36321. * Texture content is part of a multi render target process
  36322. */
  36323. MultiRenderTarget = 6,
  36324. /**
  36325. * Texture data comes from a cube data file
  36326. */
  36327. Cube = 7,
  36328. /**
  36329. * Texture data comes from a raw cube data
  36330. */
  36331. CubeRaw = 8,
  36332. /**
  36333. * Texture data come from a prefiltered cube data file
  36334. */
  36335. CubePrefiltered = 9,
  36336. /**
  36337. * Texture content is raw 3D data
  36338. */
  36339. Raw3D = 10,
  36340. /**
  36341. * Texture content is raw 2D array data
  36342. */
  36343. Raw2DArray = 11,
  36344. /**
  36345. * Texture content is a depth texture
  36346. */
  36347. Depth = 12,
  36348. /**
  36349. * Texture data comes from a raw cube data encoded with RGBD
  36350. */
  36351. CubeRawRGBD = 13
  36352. }
  36353. /**
  36354. * Class used to store data associated with WebGL texture data for the engine
  36355. * This class should not be used directly
  36356. */
  36357. export class InternalTexture {
  36358. /** @hidden */
  36359. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  36360. /**
  36361. * Defines if the texture is ready
  36362. */
  36363. isReady: boolean;
  36364. /**
  36365. * Defines if the texture is a cube texture
  36366. */
  36367. isCube: boolean;
  36368. /**
  36369. * Defines if the texture contains 3D data
  36370. */
  36371. is3D: boolean;
  36372. /**
  36373. * Defines if the texture contains 2D array data
  36374. */
  36375. is2DArray: boolean;
  36376. /**
  36377. * Defines if the texture contains multiview data
  36378. */
  36379. isMultiview: boolean;
  36380. /**
  36381. * Gets the URL used to load this texture
  36382. */
  36383. url: string;
  36384. /**
  36385. * Gets the sampling mode of the texture
  36386. */
  36387. samplingMode: number;
  36388. /**
  36389. * Gets a boolean indicating if the texture needs mipmaps generation
  36390. */
  36391. generateMipMaps: boolean;
  36392. /**
  36393. * Gets the number of samples used by the texture (WebGL2+ only)
  36394. */
  36395. samples: number;
  36396. /**
  36397. * Gets the type of the texture (int, float...)
  36398. */
  36399. type: number;
  36400. /**
  36401. * Gets the format of the texture (RGB, RGBA...)
  36402. */
  36403. format: number;
  36404. /**
  36405. * Observable called when the texture is loaded
  36406. */
  36407. onLoadedObservable: Observable<InternalTexture>;
  36408. /**
  36409. * Gets the width of the texture
  36410. */
  36411. width: number;
  36412. /**
  36413. * Gets the height of the texture
  36414. */
  36415. height: number;
  36416. /**
  36417. * Gets the depth of the texture
  36418. */
  36419. depth: number;
  36420. /**
  36421. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  36422. */
  36423. baseWidth: number;
  36424. /**
  36425. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  36426. */
  36427. baseHeight: number;
  36428. /**
  36429. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  36430. */
  36431. baseDepth: number;
  36432. /**
  36433. * Gets a boolean indicating if the texture is inverted on Y axis
  36434. */
  36435. invertY: boolean;
  36436. /** @hidden */
  36437. _invertVScale: boolean;
  36438. /** @hidden */
  36439. _associatedChannel: number;
  36440. /** @hidden */
  36441. _source: InternalTextureSource;
  36442. /** @hidden */
  36443. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  36444. /** @hidden */
  36445. _bufferView: Nullable<ArrayBufferView>;
  36446. /** @hidden */
  36447. _bufferViewArray: Nullable<ArrayBufferView[]>;
  36448. /** @hidden */
  36449. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  36450. /** @hidden */
  36451. _size: number;
  36452. /** @hidden */
  36453. _extension: string;
  36454. /** @hidden */
  36455. _files: Nullable<string[]>;
  36456. /** @hidden */
  36457. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36458. /** @hidden */
  36459. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36460. /** @hidden */
  36461. _framebuffer: Nullable<WebGLFramebuffer>;
  36462. /** @hidden */
  36463. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  36464. /** @hidden */
  36465. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  36466. /** @hidden */
  36467. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  36468. /** @hidden */
  36469. _attachments: Nullable<number[]>;
  36470. /** @hidden */
  36471. _textureArray: Nullable<InternalTexture[]>;
  36472. /** @hidden */
  36473. _cachedCoordinatesMode: Nullable<number>;
  36474. /** @hidden */
  36475. _cachedWrapU: Nullable<number>;
  36476. /** @hidden */
  36477. _cachedWrapV: Nullable<number>;
  36478. /** @hidden */
  36479. _cachedWrapR: Nullable<number>;
  36480. /** @hidden */
  36481. _cachedAnisotropicFilteringLevel: Nullable<number>;
  36482. /** @hidden */
  36483. _isDisabled: boolean;
  36484. /** @hidden */
  36485. _compression: Nullable<string>;
  36486. /** @hidden */
  36487. _generateStencilBuffer: boolean;
  36488. /** @hidden */
  36489. _generateDepthBuffer: boolean;
  36490. /** @hidden */
  36491. _comparisonFunction: number;
  36492. /** @hidden */
  36493. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  36494. /** @hidden */
  36495. _lodGenerationScale: number;
  36496. /** @hidden */
  36497. _lodGenerationOffset: number;
  36498. /** @hidden */
  36499. _depthStencilTexture: Nullable<InternalTexture>;
  36500. /** @hidden */
  36501. _colorTextureArray: Nullable<WebGLTexture>;
  36502. /** @hidden */
  36503. _depthStencilTextureArray: Nullable<WebGLTexture>;
  36504. /** @hidden */
  36505. _lodTextureHigh: Nullable<BaseTexture>;
  36506. /** @hidden */
  36507. _lodTextureMid: Nullable<BaseTexture>;
  36508. /** @hidden */
  36509. _lodTextureLow: Nullable<BaseTexture>;
  36510. /** @hidden */
  36511. _isRGBD: boolean;
  36512. /** @hidden */
  36513. _linearSpecularLOD: boolean;
  36514. /** @hidden */
  36515. _irradianceTexture: Nullable<BaseTexture>;
  36516. /** @hidden */
  36517. _webGLTexture: Nullable<WebGLTexture>;
  36518. /** @hidden */
  36519. _references: number;
  36520. private _engine;
  36521. /**
  36522. * Gets the Engine the texture belongs to.
  36523. * @returns The babylon engine
  36524. */
  36525. getEngine(): ThinEngine;
  36526. /**
  36527. * Gets the data source type of the texture
  36528. */
  36529. get source(): InternalTextureSource;
  36530. /**
  36531. * Creates a new InternalTexture
  36532. * @param engine defines the engine to use
  36533. * @param source defines the type of data that will be used
  36534. * @param delayAllocation if the texture allocation should be delayed (default: false)
  36535. */
  36536. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  36537. /**
  36538. * Increments the number of references (ie. the number of Texture that point to it)
  36539. */
  36540. incrementReferences(): void;
  36541. /**
  36542. * Change the size of the texture (not the size of the content)
  36543. * @param width defines the new width
  36544. * @param height defines the new height
  36545. * @param depth defines the new depth (1 by default)
  36546. */
  36547. updateSize(width: int, height: int, depth?: int): void;
  36548. /** @hidden */
  36549. _rebuild(): void;
  36550. /** @hidden */
  36551. _swapAndDie(target: InternalTexture): void;
  36552. /**
  36553. * Dispose the current allocated resources
  36554. */
  36555. dispose(): void;
  36556. }
  36557. }
  36558. declare module BABYLON {
  36559. /**
  36560. * Class used to work with sound analyzer using fast fourier transform (FFT)
  36561. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36562. */
  36563. export class Analyser {
  36564. /**
  36565. * Gets or sets the smoothing
  36566. * @ignorenaming
  36567. */
  36568. SMOOTHING: number;
  36569. /**
  36570. * Gets or sets the FFT table size
  36571. * @ignorenaming
  36572. */
  36573. FFT_SIZE: number;
  36574. /**
  36575. * Gets or sets the bar graph amplitude
  36576. * @ignorenaming
  36577. */
  36578. BARGRAPHAMPLITUDE: number;
  36579. /**
  36580. * Gets or sets the position of the debug canvas
  36581. * @ignorenaming
  36582. */
  36583. DEBUGCANVASPOS: {
  36584. x: number;
  36585. y: number;
  36586. };
  36587. /**
  36588. * Gets or sets the debug canvas size
  36589. * @ignorenaming
  36590. */
  36591. DEBUGCANVASSIZE: {
  36592. width: number;
  36593. height: number;
  36594. };
  36595. private _byteFreqs;
  36596. private _byteTime;
  36597. private _floatFreqs;
  36598. private _webAudioAnalyser;
  36599. private _debugCanvas;
  36600. private _debugCanvasContext;
  36601. private _scene;
  36602. private _registerFunc;
  36603. private _audioEngine;
  36604. /**
  36605. * Creates a new analyser
  36606. * @param scene defines hosting scene
  36607. */
  36608. constructor(scene: Scene);
  36609. /**
  36610. * Get the number of data values you will have to play with for the visualization
  36611. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  36612. * @returns a number
  36613. */
  36614. getFrequencyBinCount(): number;
  36615. /**
  36616. * Gets the current frequency data as a byte array
  36617. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36618. * @returns a Uint8Array
  36619. */
  36620. getByteFrequencyData(): Uint8Array;
  36621. /**
  36622. * Gets the current waveform as a byte array
  36623. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  36624. * @returns a Uint8Array
  36625. */
  36626. getByteTimeDomainData(): Uint8Array;
  36627. /**
  36628. * Gets the current frequency data as a float array
  36629. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36630. * @returns a Float32Array
  36631. */
  36632. getFloatFrequencyData(): Float32Array;
  36633. /**
  36634. * Renders the debug canvas
  36635. */
  36636. drawDebugCanvas(): void;
  36637. /**
  36638. * Stops rendering the debug canvas and removes it
  36639. */
  36640. stopDebugCanvas(): void;
  36641. /**
  36642. * Connects two audio nodes
  36643. * @param inputAudioNode defines first node to connect
  36644. * @param outputAudioNode defines second node to connect
  36645. */
  36646. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  36647. /**
  36648. * Releases all associated resources
  36649. */
  36650. dispose(): void;
  36651. }
  36652. }
  36653. declare module BABYLON {
  36654. /**
  36655. * This represents an audio engine and it is responsible
  36656. * to play, synchronize and analyse sounds throughout the application.
  36657. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36658. */
  36659. export interface IAudioEngine extends IDisposable {
  36660. /**
  36661. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36662. */
  36663. readonly canUseWebAudio: boolean;
  36664. /**
  36665. * Gets the current AudioContext if available.
  36666. */
  36667. readonly audioContext: Nullable<AudioContext>;
  36668. /**
  36669. * The master gain node defines the global audio volume of your audio engine.
  36670. */
  36671. readonly masterGain: GainNode;
  36672. /**
  36673. * Gets whether or not mp3 are supported by your browser.
  36674. */
  36675. readonly isMP3supported: boolean;
  36676. /**
  36677. * Gets whether or not ogg are supported by your browser.
  36678. */
  36679. readonly isOGGsupported: boolean;
  36680. /**
  36681. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36682. * @ignoreNaming
  36683. */
  36684. WarnedWebAudioUnsupported: boolean;
  36685. /**
  36686. * Defines if the audio engine relies on a custom unlocked button.
  36687. * In this case, the embedded button will not be displayed.
  36688. */
  36689. useCustomUnlockedButton: boolean;
  36690. /**
  36691. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  36692. */
  36693. readonly unlocked: boolean;
  36694. /**
  36695. * Event raised when audio has been unlocked on the browser.
  36696. */
  36697. onAudioUnlockedObservable: Observable<AudioEngine>;
  36698. /**
  36699. * Event raised when audio has been locked on the browser.
  36700. */
  36701. onAudioLockedObservable: Observable<AudioEngine>;
  36702. /**
  36703. * Flags the audio engine in Locked state.
  36704. * This happens due to new browser policies preventing audio to autoplay.
  36705. */
  36706. lock(): void;
  36707. /**
  36708. * Unlocks the audio engine once a user action has been done on the dom.
  36709. * This is helpful to resume play once browser policies have been satisfied.
  36710. */
  36711. unlock(): void;
  36712. /**
  36713. * Gets the global volume sets on the master gain.
  36714. * @returns the global volume if set or -1 otherwise
  36715. */
  36716. getGlobalVolume(): number;
  36717. /**
  36718. * Sets the global volume of your experience (sets on the master gain).
  36719. * @param newVolume Defines the new global volume of the application
  36720. */
  36721. setGlobalVolume(newVolume: number): void;
  36722. /**
  36723. * Connect the audio engine to an audio analyser allowing some amazing
  36724. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36725. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36726. * @param analyser The analyser to connect to the engine
  36727. */
  36728. connectToAnalyser(analyser: Analyser): void;
  36729. }
  36730. /**
  36731. * This represents the default audio engine used in babylon.
  36732. * It is responsible to play, synchronize and analyse sounds throughout the application.
  36733. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36734. */
  36735. export class AudioEngine implements IAudioEngine {
  36736. private _audioContext;
  36737. private _audioContextInitialized;
  36738. private _muteButton;
  36739. private _hostElement;
  36740. /**
  36741. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36742. */
  36743. canUseWebAudio: boolean;
  36744. /**
  36745. * The master gain node defines the global audio volume of your audio engine.
  36746. */
  36747. masterGain: GainNode;
  36748. /**
  36749. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36750. * @ignoreNaming
  36751. */
  36752. WarnedWebAudioUnsupported: boolean;
  36753. /**
  36754. * Gets whether or not mp3 are supported by your browser.
  36755. */
  36756. isMP3supported: boolean;
  36757. /**
  36758. * Gets whether or not ogg are supported by your browser.
  36759. */
  36760. isOGGsupported: boolean;
  36761. /**
  36762. * Gets whether audio has been unlocked on the device.
  36763. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  36764. * a user interaction has happened.
  36765. */
  36766. unlocked: boolean;
  36767. /**
  36768. * Defines if the audio engine relies on a custom unlocked button.
  36769. * In this case, the embedded button will not be displayed.
  36770. */
  36771. useCustomUnlockedButton: boolean;
  36772. /**
  36773. * Event raised when audio has been unlocked on the browser.
  36774. */
  36775. onAudioUnlockedObservable: Observable<AudioEngine>;
  36776. /**
  36777. * Event raised when audio has been locked on the browser.
  36778. */
  36779. onAudioLockedObservable: Observable<AudioEngine>;
  36780. /**
  36781. * Gets the current AudioContext if available.
  36782. */
  36783. get audioContext(): Nullable<AudioContext>;
  36784. private _connectedAnalyser;
  36785. /**
  36786. * Instantiates a new audio engine.
  36787. *
  36788. * There should be only one per page as some browsers restrict the number
  36789. * of audio contexts you can create.
  36790. * @param hostElement defines the host element where to display the mute icon if necessary
  36791. */
  36792. constructor(hostElement?: Nullable<HTMLElement>);
  36793. /**
  36794. * Flags the audio engine in Locked state.
  36795. * This happens due to new browser policies preventing audio to autoplay.
  36796. */
  36797. lock(): void;
  36798. /**
  36799. * Unlocks the audio engine once a user action has been done on the dom.
  36800. * This is helpful to resume play once browser policies have been satisfied.
  36801. */
  36802. unlock(): void;
  36803. private _resumeAudioContext;
  36804. private _initializeAudioContext;
  36805. private _tryToRun;
  36806. private _triggerRunningState;
  36807. private _triggerSuspendedState;
  36808. private _displayMuteButton;
  36809. private _moveButtonToTopLeft;
  36810. private _onResize;
  36811. private _hideMuteButton;
  36812. /**
  36813. * Destroy and release the resources associated with the audio ccontext.
  36814. */
  36815. dispose(): void;
  36816. /**
  36817. * Gets the global volume sets on the master gain.
  36818. * @returns the global volume if set or -1 otherwise
  36819. */
  36820. getGlobalVolume(): number;
  36821. /**
  36822. * Sets the global volume of your experience (sets on the master gain).
  36823. * @param newVolume Defines the new global volume of the application
  36824. */
  36825. setGlobalVolume(newVolume: number): void;
  36826. /**
  36827. * Connect the audio engine to an audio analyser allowing some amazing
  36828. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36829. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36830. * @param analyser The analyser to connect to the engine
  36831. */
  36832. connectToAnalyser(analyser: Analyser): void;
  36833. }
  36834. }
  36835. declare module BABYLON {
  36836. /**
  36837. * Interface used to present a loading screen while loading a scene
  36838. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36839. */
  36840. export interface ILoadingScreen {
  36841. /**
  36842. * Function called to display the loading screen
  36843. */
  36844. displayLoadingUI: () => void;
  36845. /**
  36846. * Function called to hide the loading screen
  36847. */
  36848. hideLoadingUI: () => void;
  36849. /**
  36850. * Gets or sets the color to use for the background
  36851. */
  36852. loadingUIBackgroundColor: string;
  36853. /**
  36854. * Gets or sets the text to display while loading
  36855. */
  36856. loadingUIText: string;
  36857. }
  36858. /**
  36859. * Class used for the default loading screen
  36860. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36861. */
  36862. export class DefaultLoadingScreen implements ILoadingScreen {
  36863. private _renderingCanvas;
  36864. private _loadingText;
  36865. private _loadingDivBackgroundColor;
  36866. private _loadingDiv;
  36867. private _loadingTextDiv;
  36868. /** Gets or sets the logo url to use for the default loading screen */
  36869. static DefaultLogoUrl: string;
  36870. /** Gets or sets the spinner url to use for the default loading screen */
  36871. static DefaultSpinnerUrl: string;
  36872. /**
  36873. * Creates a new default loading screen
  36874. * @param _renderingCanvas defines the canvas used to render the scene
  36875. * @param _loadingText defines the default text to display
  36876. * @param _loadingDivBackgroundColor defines the default background color
  36877. */
  36878. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  36879. /**
  36880. * Function called to display the loading screen
  36881. */
  36882. displayLoadingUI(): void;
  36883. /**
  36884. * Function called to hide the loading screen
  36885. */
  36886. hideLoadingUI(): void;
  36887. /**
  36888. * Gets or sets the text to display while loading
  36889. */
  36890. set loadingUIText(text: string);
  36891. get loadingUIText(): string;
  36892. /**
  36893. * Gets or sets the color to use for the background
  36894. */
  36895. get loadingUIBackgroundColor(): string;
  36896. set loadingUIBackgroundColor(color: string);
  36897. private _resizeLoadingUI;
  36898. }
  36899. }
  36900. declare module BABYLON {
  36901. /**
  36902. * Interface for any object that can request an animation frame
  36903. */
  36904. export interface ICustomAnimationFrameRequester {
  36905. /**
  36906. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  36907. */
  36908. renderFunction?: Function;
  36909. /**
  36910. * Called to request the next frame to render to
  36911. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  36912. */
  36913. requestAnimationFrame: Function;
  36914. /**
  36915. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  36916. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  36917. */
  36918. requestID?: number;
  36919. }
  36920. }
  36921. declare module BABYLON {
  36922. /**
  36923. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  36924. */
  36925. export class PerformanceMonitor {
  36926. private _enabled;
  36927. private _rollingFrameTime;
  36928. private _lastFrameTimeMs;
  36929. /**
  36930. * constructor
  36931. * @param frameSampleSize The number of samples required to saturate the sliding window
  36932. */
  36933. constructor(frameSampleSize?: number);
  36934. /**
  36935. * Samples current frame
  36936. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  36937. */
  36938. sampleFrame(timeMs?: number): void;
  36939. /**
  36940. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  36941. */
  36942. get averageFrameTime(): number;
  36943. /**
  36944. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  36945. */
  36946. get averageFrameTimeVariance(): number;
  36947. /**
  36948. * Returns the frame time of the most recent frame
  36949. */
  36950. get instantaneousFrameTime(): number;
  36951. /**
  36952. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  36953. */
  36954. get averageFPS(): number;
  36955. /**
  36956. * Returns the average framerate in frames per second using the most recent frame time
  36957. */
  36958. get instantaneousFPS(): number;
  36959. /**
  36960. * Returns true if enough samples have been taken to completely fill the sliding window
  36961. */
  36962. get isSaturated(): boolean;
  36963. /**
  36964. * Enables contributions to the sliding window sample set
  36965. */
  36966. enable(): void;
  36967. /**
  36968. * Disables contributions to the sliding window sample set
  36969. * Samples will not be interpolated over the disabled period
  36970. */
  36971. disable(): void;
  36972. /**
  36973. * Returns true if sampling is enabled
  36974. */
  36975. get isEnabled(): boolean;
  36976. /**
  36977. * Resets performance monitor
  36978. */
  36979. reset(): void;
  36980. }
  36981. /**
  36982. * RollingAverage
  36983. *
  36984. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  36985. */
  36986. export class RollingAverage {
  36987. /**
  36988. * Current average
  36989. */
  36990. average: number;
  36991. /**
  36992. * Current variance
  36993. */
  36994. variance: number;
  36995. protected _samples: Array<number>;
  36996. protected _sampleCount: number;
  36997. protected _pos: number;
  36998. protected _m2: number;
  36999. /**
  37000. * constructor
  37001. * @param length The number of samples required to saturate the sliding window
  37002. */
  37003. constructor(length: number);
  37004. /**
  37005. * Adds a sample to the sample set
  37006. * @param v The sample value
  37007. */
  37008. add(v: number): void;
  37009. /**
  37010. * Returns previously added values or null if outside of history or outside the sliding window domain
  37011. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  37012. * @return Value previously recorded with add() or null if outside of range
  37013. */
  37014. history(i: number): number;
  37015. /**
  37016. * Returns true if enough samples have been taken to completely fill the sliding window
  37017. * @return true if sample-set saturated
  37018. */
  37019. isSaturated(): boolean;
  37020. /**
  37021. * Resets the rolling average (equivalent to 0 samples taken so far)
  37022. */
  37023. reset(): void;
  37024. /**
  37025. * Wraps a value around the sample range boundaries
  37026. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  37027. * @return Wrapped position in sample range
  37028. */
  37029. protected _wrapPosition(i: number): number;
  37030. }
  37031. }
  37032. declare module BABYLON {
  37033. /**
  37034. * This class is used to track a performance counter which is number based.
  37035. * The user has access to many properties which give statistics of different nature.
  37036. *
  37037. * The implementer can track two kinds of Performance Counter: time and count.
  37038. * 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.
  37039. * 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.
  37040. */
  37041. export class PerfCounter {
  37042. /**
  37043. * Gets or sets a global boolean to turn on and off all the counters
  37044. */
  37045. static Enabled: boolean;
  37046. /**
  37047. * Returns the smallest value ever
  37048. */
  37049. get min(): number;
  37050. /**
  37051. * Returns the biggest value ever
  37052. */
  37053. get max(): number;
  37054. /**
  37055. * Returns the average value since the performance counter is running
  37056. */
  37057. get average(): number;
  37058. /**
  37059. * Returns the average value of the last second the counter was monitored
  37060. */
  37061. get lastSecAverage(): number;
  37062. /**
  37063. * Returns the current value
  37064. */
  37065. get current(): number;
  37066. /**
  37067. * Gets the accumulated total
  37068. */
  37069. get total(): number;
  37070. /**
  37071. * Gets the total value count
  37072. */
  37073. get count(): number;
  37074. /**
  37075. * Creates a new counter
  37076. */
  37077. constructor();
  37078. /**
  37079. * Call this method to start monitoring a new frame.
  37080. * 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.
  37081. */
  37082. fetchNewFrame(): void;
  37083. /**
  37084. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  37085. * @param newCount the count value to add to the monitored count
  37086. * @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.
  37087. */
  37088. addCount(newCount: number, fetchResult: boolean): void;
  37089. /**
  37090. * Start monitoring this performance counter
  37091. */
  37092. beginMonitoring(): void;
  37093. /**
  37094. * Compute the time lapsed since the previous beginMonitoring() call.
  37095. * @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
  37096. */
  37097. endMonitoring(newFrame?: boolean): void;
  37098. private _fetchResult;
  37099. private _startMonitoringTime;
  37100. private _min;
  37101. private _max;
  37102. private _average;
  37103. private _current;
  37104. private _totalValueCount;
  37105. private _totalAccumulated;
  37106. private _lastSecAverage;
  37107. private _lastSecAccumulated;
  37108. private _lastSecTime;
  37109. private _lastSecValueCount;
  37110. }
  37111. }
  37112. declare module BABYLON {
  37113. interface ThinEngine {
  37114. /**
  37115. * Sets alpha constants used by some alpha blending modes
  37116. * @param r defines the red component
  37117. * @param g defines the green component
  37118. * @param b defines the blue component
  37119. * @param a defines the alpha component
  37120. */
  37121. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  37122. /**
  37123. * Sets the current alpha mode
  37124. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  37125. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  37126. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37127. */
  37128. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  37129. /**
  37130. * Gets the current alpha mode
  37131. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37132. * @returns the current alpha mode
  37133. */
  37134. getAlphaMode(): number;
  37135. /**
  37136. * Sets the current alpha equation
  37137. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  37138. */
  37139. setAlphaEquation(equation: number): void;
  37140. /**
  37141. * Gets the current alpha equation.
  37142. * @returns the current alpha equation
  37143. */
  37144. getAlphaEquation(): number;
  37145. }
  37146. }
  37147. declare module BABYLON {
  37148. interface ThinEngine {
  37149. /** @hidden */
  37150. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  37151. }
  37152. }
  37153. declare module BABYLON {
  37154. /**
  37155. * Defines the interface used by display changed events
  37156. */
  37157. export interface IDisplayChangedEventArgs {
  37158. /** Gets the vrDisplay object (if any) */
  37159. vrDisplay: Nullable<any>;
  37160. /** Gets a boolean indicating if webVR is supported */
  37161. vrSupported: boolean;
  37162. }
  37163. /**
  37164. * Defines the interface used by objects containing a viewport (like a camera)
  37165. */
  37166. interface IViewportOwnerLike {
  37167. /**
  37168. * Gets or sets the viewport
  37169. */
  37170. viewport: IViewportLike;
  37171. }
  37172. /**
  37173. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  37174. */
  37175. export class Engine extends ThinEngine {
  37176. /** Defines that alpha blending is disabled */
  37177. static readonly ALPHA_DISABLE: number;
  37178. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  37179. static readonly ALPHA_ADD: number;
  37180. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  37181. static readonly ALPHA_COMBINE: number;
  37182. /** Defines that alpha blending to DEST - SRC * DEST */
  37183. static readonly ALPHA_SUBTRACT: number;
  37184. /** Defines that alpha blending to SRC * DEST */
  37185. static readonly ALPHA_MULTIPLY: number;
  37186. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  37187. static readonly ALPHA_MAXIMIZED: number;
  37188. /** Defines that alpha blending to SRC + DEST */
  37189. static readonly ALPHA_ONEONE: number;
  37190. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  37191. static readonly ALPHA_PREMULTIPLIED: number;
  37192. /**
  37193. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  37194. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  37195. */
  37196. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  37197. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  37198. static readonly ALPHA_INTERPOLATE: number;
  37199. /**
  37200. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  37201. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  37202. */
  37203. static readonly ALPHA_SCREENMODE: number;
  37204. /** Defines that the ressource is not delayed*/
  37205. static readonly DELAYLOADSTATE_NONE: number;
  37206. /** Defines that the ressource was successfully delay loaded */
  37207. static readonly DELAYLOADSTATE_LOADED: number;
  37208. /** Defines that the ressource is currently delay loading */
  37209. static readonly DELAYLOADSTATE_LOADING: number;
  37210. /** Defines that the ressource is delayed and has not started loading */
  37211. static readonly DELAYLOADSTATE_NOTLOADED: number;
  37212. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  37213. static readonly NEVER: number;
  37214. /** 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 */
  37215. static readonly ALWAYS: number;
  37216. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  37217. static readonly LESS: number;
  37218. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  37219. static readonly EQUAL: number;
  37220. /** 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 */
  37221. static readonly LEQUAL: number;
  37222. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  37223. static readonly GREATER: number;
  37224. /** 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 */
  37225. static readonly GEQUAL: number;
  37226. /** 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 */
  37227. static readonly NOTEQUAL: number;
  37228. /** Passed to stencilOperation to specify that stencil value must be kept */
  37229. static readonly KEEP: number;
  37230. /** Passed to stencilOperation to specify that stencil value must be replaced */
  37231. static readonly REPLACE: number;
  37232. /** Passed to stencilOperation to specify that stencil value must be incremented */
  37233. static readonly INCR: number;
  37234. /** Passed to stencilOperation to specify that stencil value must be decremented */
  37235. static readonly DECR: number;
  37236. /** Passed to stencilOperation to specify that stencil value must be inverted */
  37237. static readonly INVERT: number;
  37238. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  37239. static readonly INCR_WRAP: number;
  37240. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  37241. static readonly DECR_WRAP: number;
  37242. /** Texture is not repeating outside of 0..1 UVs */
  37243. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  37244. /** Texture is repeating outside of 0..1 UVs */
  37245. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  37246. /** Texture is repeating and mirrored */
  37247. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  37248. /** ALPHA */
  37249. static readonly TEXTUREFORMAT_ALPHA: number;
  37250. /** LUMINANCE */
  37251. static readonly TEXTUREFORMAT_LUMINANCE: number;
  37252. /** LUMINANCE_ALPHA */
  37253. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  37254. /** RGB */
  37255. static readonly TEXTUREFORMAT_RGB: number;
  37256. /** RGBA */
  37257. static readonly TEXTUREFORMAT_RGBA: number;
  37258. /** RED */
  37259. static readonly TEXTUREFORMAT_RED: number;
  37260. /** RED (2nd reference) */
  37261. static readonly TEXTUREFORMAT_R: number;
  37262. /** RG */
  37263. static readonly TEXTUREFORMAT_RG: number;
  37264. /** RED_INTEGER */
  37265. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  37266. /** RED_INTEGER (2nd reference) */
  37267. static readonly TEXTUREFORMAT_R_INTEGER: number;
  37268. /** RG_INTEGER */
  37269. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  37270. /** RGB_INTEGER */
  37271. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  37272. /** RGBA_INTEGER */
  37273. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  37274. /** UNSIGNED_BYTE */
  37275. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  37276. /** UNSIGNED_BYTE (2nd reference) */
  37277. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  37278. /** FLOAT */
  37279. static readonly TEXTURETYPE_FLOAT: number;
  37280. /** HALF_FLOAT */
  37281. static readonly TEXTURETYPE_HALF_FLOAT: number;
  37282. /** BYTE */
  37283. static readonly TEXTURETYPE_BYTE: number;
  37284. /** SHORT */
  37285. static readonly TEXTURETYPE_SHORT: number;
  37286. /** UNSIGNED_SHORT */
  37287. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  37288. /** INT */
  37289. static readonly TEXTURETYPE_INT: number;
  37290. /** UNSIGNED_INT */
  37291. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  37292. /** UNSIGNED_SHORT_4_4_4_4 */
  37293. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  37294. /** UNSIGNED_SHORT_5_5_5_1 */
  37295. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  37296. /** UNSIGNED_SHORT_5_6_5 */
  37297. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  37298. /** UNSIGNED_INT_2_10_10_10_REV */
  37299. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  37300. /** UNSIGNED_INT_24_8 */
  37301. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  37302. /** UNSIGNED_INT_10F_11F_11F_REV */
  37303. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  37304. /** UNSIGNED_INT_5_9_9_9_REV */
  37305. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  37306. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  37307. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  37308. /** nearest is mag = nearest and min = nearest and mip = linear */
  37309. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  37310. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37311. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  37312. /** Trilinear is mag = linear and min = linear and mip = linear */
  37313. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  37314. /** nearest is mag = nearest and min = nearest and mip = linear */
  37315. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  37316. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37317. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  37318. /** Trilinear is mag = linear and min = linear and mip = linear */
  37319. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  37320. /** mag = nearest and min = nearest and mip = nearest */
  37321. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  37322. /** mag = nearest and min = linear and mip = nearest */
  37323. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  37324. /** mag = nearest and min = linear and mip = linear */
  37325. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  37326. /** mag = nearest and min = linear and mip = none */
  37327. static readonly TEXTURE_NEAREST_LINEAR: number;
  37328. /** mag = nearest and min = nearest and mip = none */
  37329. static readonly TEXTURE_NEAREST_NEAREST: number;
  37330. /** mag = linear and min = nearest and mip = nearest */
  37331. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  37332. /** mag = linear and min = nearest and mip = linear */
  37333. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  37334. /** mag = linear and min = linear and mip = none */
  37335. static readonly TEXTURE_LINEAR_LINEAR: number;
  37336. /** mag = linear and min = nearest and mip = none */
  37337. static readonly TEXTURE_LINEAR_NEAREST: number;
  37338. /** Explicit coordinates mode */
  37339. static readonly TEXTURE_EXPLICIT_MODE: number;
  37340. /** Spherical coordinates mode */
  37341. static readonly TEXTURE_SPHERICAL_MODE: number;
  37342. /** Planar coordinates mode */
  37343. static readonly TEXTURE_PLANAR_MODE: number;
  37344. /** Cubic coordinates mode */
  37345. static readonly TEXTURE_CUBIC_MODE: number;
  37346. /** Projection coordinates mode */
  37347. static readonly TEXTURE_PROJECTION_MODE: number;
  37348. /** Skybox coordinates mode */
  37349. static readonly TEXTURE_SKYBOX_MODE: number;
  37350. /** Inverse Cubic coordinates mode */
  37351. static readonly TEXTURE_INVCUBIC_MODE: number;
  37352. /** Equirectangular coordinates mode */
  37353. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  37354. /** Equirectangular Fixed coordinates mode */
  37355. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  37356. /** Equirectangular Fixed Mirrored coordinates mode */
  37357. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  37358. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  37359. static readonly SCALEMODE_FLOOR: number;
  37360. /** Defines that texture rescaling will look for the nearest power of 2 size */
  37361. static readonly SCALEMODE_NEAREST: number;
  37362. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  37363. static readonly SCALEMODE_CEILING: number;
  37364. /**
  37365. * Returns the current npm package of the sdk
  37366. */
  37367. static get NpmPackage(): string;
  37368. /**
  37369. * Returns the current version of the framework
  37370. */
  37371. static get Version(): string;
  37372. /** Gets the list of created engines */
  37373. static get Instances(): Engine[];
  37374. /**
  37375. * Gets the latest created engine
  37376. */
  37377. static get LastCreatedEngine(): Nullable<Engine>;
  37378. /**
  37379. * Gets the latest created scene
  37380. */
  37381. static get LastCreatedScene(): Nullable<Scene>;
  37382. /**
  37383. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  37384. * @param flag defines which part of the materials must be marked as dirty
  37385. * @param predicate defines a predicate used to filter which materials should be affected
  37386. */
  37387. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37388. /**
  37389. * Method called to create the default loading screen.
  37390. * This can be overriden in your own app.
  37391. * @param canvas The rendering canvas element
  37392. * @returns The loading screen
  37393. */
  37394. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  37395. /**
  37396. * Method called to create the default rescale post process on each engine.
  37397. */
  37398. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  37399. /**
  37400. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  37401. **/
  37402. enableOfflineSupport: boolean;
  37403. /**
  37404. * 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)
  37405. **/
  37406. disableManifestCheck: boolean;
  37407. /**
  37408. * Gets the list of created scenes
  37409. */
  37410. scenes: Scene[];
  37411. /**
  37412. * Event raised when a new scene is created
  37413. */
  37414. onNewSceneAddedObservable: Observable<Scene>;
  37415. /**
  37416. * Gets the list of created postprocesses
  37417. */
  37418. postProcesses: PostProcess[];
  37419. /**
  37420. * Gets a boolean indicating if the pointer is currently locked
  37421. */
  37422. isPointerLock: boolean;
  37423. /**
  37424. * Observable event triggered each time the rendering canvas is resized
  37425. */
  37426. onResizeObservable: Observable<Engine>;
  37427. /**
  37428. * Observable event triggered each time the canvas loses focus
  37429. */
  37430. onCanvasBlurObservable: Observable<Engine>;
  37431. /**
  37432. * Observable event triggered each time the canvas gains focus
  37433. */
  37434. onCanvasFocusObservable: Observable<Engine>;
  37435. /**
  37436. * Observable event triggered each time the canvas receives pointerout event
  37437. */
  37438. onCanvasPointerOutObservable: Observable<PointerEvent>;
  37439. /**
  37440. * Observable raised when the engine begins a new frame
  37441. */
  37442. onBeginFrameObservable: Observable<Engine>;
  37443. /**
  37444. * If set, will be used to request the next animation frame for the render loop
  37445. */
  37446. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  37447. /**
  37448. * Observable raised when the engine ends the current frame
  37449. */
  37450. onEndFrameObservable: Observable<Engine>;
  37451. /**
  37452. * Observable raised when the engine is about to compile a shader
  37453. */
  37454. onBeforeShaderCompilationObservable: Observable<Engine>;
  37455. /**
  37456. * Observable raised when the engine has jsut compiled a shader
  37457. */
  37458. onAfterShaderCompilationObservable: Observable<Engine>;
  37459. /**
  37460. * Gets the audio engine
  37461. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37462. * @ignorenaming
  37463. */
  37464. static audioEngine: IAudioEngine;
  37465. /**
  37466. * Default AudioEngine factory responsible of creating the Audio Engine.
  37467. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  37468. */
  37469. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  37470. /**
  37471. * Default offline support factory responsible of creating a tool used to store data locally.
  37472. * By default, this will create a Database object if the workload has been embedded.
  37473. */
  37474. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  37475. private _loadingScreen;
  37476. private _pointerLockRequested;
  37477. private _rescalePostProcess;
  37478. private _deterministicLockstep;
  37479. private _lockstepMaxSteps;
  37480. private _timeStep;
  37481. protected get _supportsHardwareTextureRescaling(): boolean;
  37482. private _fps;
  37483. private _deltaTime;
  37484. /** @hidden */
  37485. _drawCalls: PerfCounter;
  37486. /** 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 */
  37487. canvasTabIndex: number;
  37488. /**
  37489. * Turn this value on if you want to pause FPS computation when in background
  37490. */
  37491. disablePerformanceMonitorInBackground: boolean;
  37492. private _performanceMonitor;
  37493. /**
  37494. * Gets the performance monitor attached to this engine
  37495. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  37496. */
  37497. get performanceMonitor(): PerformanceMonitor;
  37498. private _onFocus;
  37499. private _onBlur;
  37500. private _onCanvasPointerOut;
  37501. private _onCanvasBlur;
  37502. private _onCanvasFocus;
  37503. private _onFullscreenChange;
  37504. private _onPointerLockChange;
  37505. /**
  37506. * Gets the HTML element used to attach event listeners
  37507. * @returns a HTML element
  37508. */
  37509. getInputElement(): Nullable<HTMLElement>;
  37510. /**
  37511. * Creates a new engine
  37512. * @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
  37513. * @param antialias defines enable antialiasing (default: false)
  37514. * @param options defines further options to be sent to the getContext() function
  37515. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  37516. */
  37517. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  37518. /**
  37519. * Gets current aspect ratio
  37520. * @param viewportOwner defines the camera to use to get the aspect ratio
  37521. * @param useScreen defines if screen size must be used (or the current render target if any)
  37522. * @returns a number defining the aspect ratio
  37523. */
  37524. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  37525. /**
  37526. * Gets current screen aspect ratio
  37527. * @returns a number defining the aspect ratio
  37528. */
  37529. getScreenAspectRatio(): number;
  37530. /**
  37531. * Gets the client rect of the HTML canvas attached with the current webGL context
  37532. * @returns a client rectanglee
  37533. */
  37534. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  37535. /**
  37536. * Gets the client rect of the HTML element used for events
  37537. * @returns a client rectanglee
  37538. */
  37539. getInputElementClientRect(): Nullable<ClientRect>;
  37540. /**
  37541. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  37542. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37543. * @returns true if engine is in deterministic lock step mode
  37544. */
  37545. isDeterministicLockStep(): boolean;
  37546. /**
  37547. * Gets the max steps when engine is running in deterministic lock step
  37548. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37549. * @returns the max steps
  37550. */
  37551. getLockstepMaxSteps(): number;
  37552. /**
  37553. * Returns the time in ms between steps when using deterministic lock step.
  37554. * @returns time step in (ms)
  37555. */
  37556. getTimeStep(): number;
  37557. /**
  37558. * Force the mipmap generation for the given render target texture
  37559. * @param texture defines the render target texture to use
  37560. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  37561. */
  37562. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  37563. /** States */
  37564. /**
  37565. * Set various states to the webGL context
  37566. * @param culling defines backface culling state
  37567. * @param zOffset defines the value to apply to zOffset (0 by default)
  37568. * @param force defines if states must be applied even if cache is up to date
  37569. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  37570. */
  37571. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  37572. /**
  37573. * Set the z offset to apply to current rendering
  37574. * @param value defines the offset to apply
  37575. */
  37576. setZOffset(value: number): void;
  37577. /**
  37578. * Gets the current value of the zOffset
  37579. * @returns the current zOffset state
  37580. */
  37581. getZOffset(): number;
  37582. /**
  37583. * Enable or disable depth buffering
  37584. * @param enable defines the state to set
  37585. */
  37586. setDepthBuffer(enable: boolean): void;
  37587. /**
  37588. * Gets a boolean indicating if depth writing is enabled
  37589. * @returns the current depth writing state
  37590. */
  37591. getDepthWrite(): boolean;
  37592. /**
  37593. * Enable or disable depth writing
  37594. * @param enable defines the state to set
  37595. */
  37596. setDepthWrite(enable: boolean): void;
  37597. /**
  37598. * Gets a boolean indicating if stencil buffer is enabled
  37599. * @returns the current stencil buffer state
  37600. */
  37601. getStencilBuffer(): boolean;
  37602. /**
  37603. * Enable or disable the stencil buffer
  37604. * @param enable defines if the stencil buffer must be enabled or disabled
  37605. */
  37606. setStencilBuffer(enable: boolean): void;
  37607. /**
  37608. * Gets the current stencil mask
  37609. * @returns a number defining the new stencil mask to use
  37610. */
  37611. getStencilMask(): number;
  37612. /**
  37613. * Sets the current stencil mask
  37614. * @param mask defines the new stencil mask to use
  37615. */
  37616. setStencilMask(mask: number): void;
  37617. /**
  37618. * Gets the current stencil function
  37619. * @returns a number defining the stencil function to use
  37620. */
  37621. getStencilFunction(): number;
  37622. /**
  37623. * Gets the current stencil reference value
  37624. * @returns a number defining the stencil reference value to use
  37625. */
  37626. getStencilFunctionReference(): number;
  37627. /**
  37628. * Gets the current stencil mask
  37629. * @returns a number defining the stencil mask to use
  37630. */
  37631. getStencilFunctionMask(): number;
  37632. /**
  37633. * Sets the current stencil function
  37634. * @param stencilFunc defines the new stencil function to use
  37635. */
  37636. setStencilFunction(stencilFunc: number): void;
  37637. /**
  37638. * Sets the current stencil reference
  37639. * @param reference defines the new stencil reference to use
  37640. */
  37641. setStencilFunctionReference(reference: number): void;
  37642. /**
  37643. * Sets the current stencil mask
  37644. * @param mask defines the new stencil mask to use
  37645. */
  37646. setStencilFunctionMask(mask: number): void;
  37647. /**
  37648. * Gets the current stencil operation when stencil fails
  37649. * @returns a number defining stencil operation to use when stencil fails
  37650. */
  37651. getStencilOperationFail(): number;
  37652. /**
  37653. * Gets the current stencil operation when depth fails
  37654. * @returns a number defining stencil operation to use when depth fails
  37655. */
  37656. getStencilOperationDepthFail(): number;
  37657. /**
  37658. * Gets the current stencil operation when stencil passes
  37659. * @returns a number defining stencil operation to use when stencil passes
  37660. */
  37661. getStencilOperationPass(): number;
  37662. /**
  37663. * Sets the stencil operation to use when stencil fails
  37664. * @param operation defines the stencil operation to use when stencil fails
  37665. */
  37666. setStencilOperationFail(operation: number): void;
  37667. /**
  37668. * Sets the stencil operation to use when depth fails
  37669. * @param operation defines the stencil operation to use when depth fails
  37670. */
  37671. setStencilOperationDepthFail(operation: number): void;
  37672. /**
  37673. * Sets the stencil operation to use when stencil passes
  37674. * @param operation defines the stencil operation to use when stencil passes
  37675. */
  37676. setStencilOperationPass(operation: number): void;
  37677. /**
  37678. * Sets a boolean indicating if the dithering state is enabled or disabled
  37679. * @param value defines the dithering state
  37680. */
  37681. setDitheringState(value: boolean): void;
  37682. /**
  37683. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  37684. * @param value defines the rasterizer state
  37685. */
  37686. setRasterizerState(value: boolean): void;
  37687. /**
  37688. * Gets the current depth function
  37689. * @returns a number defining the depth function
  37690. */
  37691. getDepthFunction(): Nullable<number>;
  37692. /**
  37693. * Sets the current depth function
  37694. * @param depthFunc defines the function to use
  37695. */
  37696. setDepthFunction(depthFunc: number): void;
  37697. /**
  37698. * Sets the current depth function to GREATER
  37699. */
  37700. setDepthFunctionToGreater(): void;
  37701. /**
  37702. * Sets the current depth function to GEQUAL
  37703. */
  37704. setDepthFunctionToGreaterOrEqual(): void;
  37705. /**
  37706. * Sets the current depth function to LESS
  37707. */
  37708. setDepthFunctionToLess(): void;
  37709. /**
  37710. * Sets the current depth function to LEQUAL
  37711. */
  37712. setDepthFunctionToLessOrEqual(): void;
  37713. private _cachedStencilBuffer;
  37714. private _cachedStencilFunction;
  37715. private _cachedStencilMask;
  37716. private _cachedStencilOperationPass;
  37717. private _cachedStencilOperationFail;
  37718. private _cachedStencilOperationDepthFail;
  37719. private _cachedStencilReference;
  37720. /**
  37721. * Caches the the state of the stencil buffer
  37722. */
  37723. cacheStencilState(): void;
  37724. /**
  37725. * Restores the state of the stencil buffer
  37726. */
  37727. restoreStencilState(): void;
  37728. /**
  37729. * Directly set the WebGL Viewport
  37730. * @param x defines the x coordinate of the viewport (in screen space)
  37731. * @param y defines the y coordinate of the viewport (in screen space)
  37732. * @param width defines the width of the viewport (in screen space)
  37733. * @param height defines the height of the viewport (in screen space)
  37734. * @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
  37735. */
  37736. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  37737. /**
  37738. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  37739. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  37740. * @param y defines the y-coordinate of the corner of the clear rectangle
  37741. * @param width defines the width of the clear rectangle
  37742. * @param height defines the height of the clear rectangle
  37743. * @param clearColor defines the clear color
  37744. */
  37745. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  37746. /**
  37747. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  37748. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  37749. * @param y defines the y-coordinate of the corner of the clear rectangle
  37750. * @param width defines the width of the clear rectangle
  37751. * @param height defines the height of the clear rectangle
  37752. */
  37753. enableScissor(x: number, y: number, width: number, height: number): void;
  37754. /**
  37755. * Disable previously set scissor test rectangle
  37756. */
  37757. disableScissor(): void;
  37758. protected _reportDrawCall(): void;
  37759. /**
  37760. * Initializes a webVR display and starts listening to display change events
  37761. * The onVRDisplayChangedObservable will be notified upon these changes
  37762. * @returns The onVRDisplayChangedObservable
  37763. */
  37764. initWebVR(): Observable<IDisplayChangedEventArgs>;
  37765. /** @hidden */
  37766. _prepareVRComponent(): void;
  37767. /** @hidden */
  37768. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  37769. /** @hidden */
  37770. _submitVRFrame(): void;
  37771. /**
  37772. * Call this function to leave webVR mode
  37773. * Will do nothing if webVR is not supported or if there is no webVR device
  37774. * @see https://doc.babylonjs.com/how_to/webvr_camera
  37775. */
  37776. disableVR(): void;
  37777. /**
  37778. * Gets a boolean indicating that the system is in VR mode and is presenting
  37779. * @returns true if VR mode is engaged
  37780. */
  37781. isVRPresenting(): boolean;
  37782. /** @hidden */
  37783. _requestVRFrame(): void;
  37784. /** @hidden */
  37785. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37786. /**
  37787. * Gets the source code of the vertex shader associated with a specific webGL program
  37788. * @param program defines the program to use
  37789. * @returns a string containing the source code of the vertex shader associated with the program
  37790. */
  37791. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  37792. /**
  37793. * Gets the source code of the fragment shader associated with a specific webGL program
  37794. * @param program defines the program to use
  37795. * @returns a string containing the source code of the fragment shader associated with the program
  37796. */
  37797. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  37798. /**
  37799. * Sets a depth stencil texture from a render target to the according uniform.
  37800. * @param channel The texture channel
  37801. * @param uniform The uniform to set
  37802. * @param texture The render target texture containing the depth stencil texture to apply
  37803. */
  37804. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  37805. /**
  37806. * Sets a texture to the webGL context from a postprocess
  37807. * @param channel defines the channel to use
  37808. * @param postProcess defines the source postprocess
  37809. */
  37810. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  37811. /**
  37812. * Binds the output of the passed in post process to the texture channel specified
  37813. * @param channel The channel the texture should be bound to
  37814. * @param postProcess The post process which's output should be bound
  37815. */
  37816. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  37817. protected _rebuildBuffers(): void;
  37818. /** @hidden */
  37819. _renderFrame(): void;
  37820. _renderLoop(): void;
  37821. /** @hidden */
  37822. _renderViews(): boolean;
  37823. /**
  37824. * Toggle full screen mode
  37825. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37826. */
  37827. switchFullscreen(requestPointerLock: boolean): void;
  37828. /**
  37829. * Enters full screen mode
  37830. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37831. */
  37832. enterFullscreen(requestPointerLock: boolean): void;
  37833. /**
  37834. * Exits full screen mode
  37835. */
  37836. exitFullscreen(): void;
  37837. /**
  37838. * Enters Pointerlock mode
  37839. */
  37840. enterPointerlock(): void;
  37841. /**
  37842. * Exits Pointerlock mode
  37843. */
  37844. exitPointerlock(): void;
  37845. /**
  37846. * Begin a new frame
  37847. */
  37848. beginFrame(): void;
  37849. /**
  37850. * Enf the current frame
  37851. */
  37852. endFrame(): void;
  37853. resize(): void;
  37854. /**
  37855. * Force a specific size of the canvas
  37856. * @param width defines the new canvas' width
  37857. * @param height defines the new canvas' height
  37858. * @returns true if the size was changed
  37859. */
  37860. setSize(width: number, height: number): boolean;
  37861. /**
  37862. * Updates a dynamic vertex buffer.
  37863. * @param vertexBuffer the vertex buffer to update
  37864. * @param data the data used to update the vertex buffer
  37865. * @param byteOffset the byte offset of the data
  37866. * @param byteLength the byte length of the data
  37867. */
  37868. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  37869. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  37870. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37871. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37872. _releaseTexture(texture: InternalTexture): void;
  37873. /**
  37874. * @hidden
  37875. * Rescales a texture
  37876. * @param source input texutre
  37877. * @param destination destination texture
  37878. * @param scene scene to use to render the resize
  37879. * @param internalFormat format to use when resizing
  37880. * @param onComplete callback to be called when resize has completed
  37881. */
  37882. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  37883. /**
  37884. * Gets the current framerate
  37885. * @returns a number representing the framerate
  37886. */
  37887. getFps(): number;
  37888. /**
  37889. * Gets the time spent between current and previous frame
  37890. * @returns a number representing the delta time in ms
  37891. */
  37892. getDeltaTime(): number;
  37893. private _measureFps;
  37894. /** @hidden */
  37895. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  37896. /**
  37897. * Update a dynamic index buffer
  37898. * @param indexBuffer defines the target index buffer
  37899. * @param indices defines the data to update
  37900. * @param offset defines the offset in the target index buffer where update should start
  37901. */
  37902. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  37903. /**
  37904. * Updates the sample count of a render target texture
  37905. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  37906. * @param texture defines the texture to update
  37907. * @param samples defines the sample count to set
  37908. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  37909. */
  37910. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  37911. /**
  37912. * Updates a depth texture Comparison Mode and Function.
  37913. * If the comparison Function is equal to 0, the mode will be set to none.
  37914. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  37915. * @param texture The texture to set the comparison function for
  37916. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  37917. */
  37918. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  37919. /**
  37920. * Creates a webGL buffer to use with instanciation
  37921. * @param capacity defines the size of the buffer
  37922. * @returns the webGL buffer
  37923. */
  37924. createInstancesBuffer(capacity: number): DataBuffer;
  37925. /**
  37926. * Delete a webGL buffer used with instanciation
  37927. * @param buffer defines the webGL buffer to delete
  37928. */
  37929. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  37930. private _clientWaitAsync;
  37931. /** @hidden */
  37932. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  37933. dispose(): void;
  37934. private _disableTouchAction;
  37935. /**
  37936. * Display the loading screen
  37937. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37938. */
  37939. displayLoadingUI(): void;
  37940. /**
  37941. * Hide the loading screen
  37942. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37943. */
  37944. hideLoadingUI(): void;
  37945. /**
  37946. * Gets the current loading screen object
  37947. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37948. */
  37949. get loadingScreen(): ILoadingScreen;
  37950. /**
  37951. * Sets the current loading screen object
  37952. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37953. */
  37954. set loadingScreen(loadingScreen: ILoadingScreen);
  37955. /**
  37956. * Sets the current loading screen text
  37957. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37958. */
  37959. set loadingUIText(text: string);
  37960. /**
  37961. * Sets the current loading screen background color
  37962. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37963. */
  37964. set loadingUIBackgroundColor(color: string);
  37965. /** Pointerlock and fullscreen */
  37966. /**
  37967. * Ask the browser to promote the current element to pointerlock mode
  37968. * @param element defines the DOM element to promote
  37969. */
  37970. static _RequestPointerlock(element: HTMLElement): void;
  37971. /**
  37972. * Asks the browser to exit pointerlock mode
  37973. */
  37974. static _ExitPointerlock(): void;
  37975. /**
  37976. * Ask the browser to promote the current element to fullscreen rendering mode
  37977. * @param element defines the DOM element to promote
  37978. */
  37979. static _RequestFullscreen(element: HTMLElement): void;
  37980. /**
  37981. * Asks the browser to exit fullscreen mode
  37982. */
  37983. static _ExitFullscreen(): void;
  37984. }
  37985. }
  37986. declare module BABYLON {
  37987. /**
  37988. * The engine store class is responsible to hold all the instances of Engine and Scene created
  37989. * during the life time of the application.
  37990. */
  37991. export class EngineStore {
  37992. /** Gets the list of created engines */
  37993. static Instances: Engine[];
  37994. /** @hidden */
  37995. static _LastCreatedScene: Nullable<Scene>;
  37996. /**
  37997. * Gets the latest created engine
  37998. */
  37999. static get LastCreatedEngine(): Nullable<Engine>;
  38000. /**
  38001. * Gets the latest created scene
  38002. */
  38003. static get LastCreatedScene(): Nullable<Scene>;
  38004. /**
  38005. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38006. * @ignorenaming
  38007. */
  38008. static UseFallbackTexture: boolean;
  38009. /**
  38010. * Texture content used if a texture cannot loaded
  38011. * @ignorenaming
  38012. */
  38013. static FallbackTexture: string;
  38014. }
  38015. }
  38016. declare module BABYLON {
  38017. /**
  38018. * Helper class that provides a small promise polyfill
  38019. */
  38020. export class PromisePolyfill {
  38021. /**
  38022. * Static function used to check if the polyfill is required
  38023. * If this is the case then the function will inject the polyfill to window.Promise
  38024. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38025. */
  38026. static Apply(force?: boolean): void;
  38027. }
  38028. }
  38029. declare module BABYLON {
  38030. /**
  38031. * Interface for screenshot methods with describe argument called `size` as object with options
  38032. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  38033. */
  38034. export interface IScreenshotSize {
  38035. /**
  38036. * number in pixels for canvas height
  38037. */
  38038. height?: number;
  38039. /**
  38040. * multiplier allowing render at a higher or lower resolution
  38041. * If value is defined then height and width will be ignored and taken from camera
  38042. */
  38043. precision?: number;
  38044. /**
  38045. * number in pixels for canvas width
  38046. */
  38047. width?: number;
  38048. }
  38049. }
  38050. declare module BABYLON {
  38051. interface IColor4Like {
  38052. r: float;
  38053. g: float;
  38054. b: float;
  38055. a: float;
  38056. }
  38057. /**
  38058. * Class containing a set of static utilities functions
  38059. */
  38060. export class Tools {
  38061. /**
  38062. * Gets or sets the base URL to use to load assets
  38063. */
  38064. static get BaseUrl(): string;
  38065. static set BaseUrl(value: string);
  38066. /**
  38067. * Enable/Disable Custom HTTP Request Headers globally.
  38068. * default = false
  38069. * @see CustomRequestHeaders
  38070. */
  38071. static UseCustomRequestHeaders: boolean;
  38072. /**
  38073. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  38074. * i.e. when loading files, where the server/service expects an Authorization header
  38075. */
  38076. static CustomRequestHeaders: {
  38077. [key: string]: string;
  38078. };
  38079. /**
  38080. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  38081. */
  38082. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  38083. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  38084. /**
  38085. * Default behaviour for cors in the application.
  38086. * It can be a string if the expected behavior is identical in the entire app.
  38087. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  38088. */
  38089. static get CorsBehavior(): string | ((url: string | string[]) => string);
  38090. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  38091. /**
  38092. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38093. * @ignorenaming
  38094. */
  38095. static get UseFallbackTexture(): boolean;
  38096. static set UseFallbackTexture(value: boolean);
  38097. /**
  38098. * Use this object to register external classes like custom textures or material
  38099. * to allow the laoders to instantiate them
  38100. */
  38101. static get RegisteredExternalClasses(): {
  38102. [key: string]: Object;
  38103. };
  38104. static set RegisteredExternalClasses(classes: {
  38105. [key: string]: Object;
  38106. });
  38107. /**
  38108. * Texture content used if a texture cannot loaded
  38109. * @ignorenaming
  38110. */
  38111. static get fallbackTexture(): string;
  38112. static set fallbackTexture(value: string);
  38113. /**
  38114. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  38115. * @param u defines the coordinate on X axis
  38116. * @param v defines the coordinate on Y axis
  38117. * @param width defines the width of the source data
  38118. * @param height defines the height of the source data
  38119. * @param pixels defines the source byte array
  38120. * @param color defines the output color
  38121. */
  38122. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  38123. /**
  38124. * Interpolates between a and b via alpha
  38125. * @param a The lower value (returned when alpha = 0)
  38126. * @param b The upper value (returned when alpha = 1)
  38127. * @param alpha The interpolation-factor
  38128. * @return The mixed value
  38129. */
  38130. static Mix(a: number, b: number, alpha: number): number;
  38131. /**
  38132. * Tries to instantiate a new object from a given class name
  38133. * @param className defines the class name to instantiate
  38134. * @returns the new object or null if the system was not able to do the instantiation
  38135. */
  38136. static Instantiate(className: string): any;
  38137. /**
  38138. * Provides a slice function that will work even on IE
  38139. * @param data defines the array to slice
  38140. * @param start defines the start of the data (optional)
  38141. * @param end defines the end of the data (optional)
  38142. * @returns the new sliced array
  38143. */
  38144. static Slice<T>(data: T, start?: number, end?: number): T;
  38145. /**
  38146. * Polyfill for setImmediate
  38147. * @param action defines the action to execute after the current execution block
  38148. */
  38149. static SetImmediate(action: () => void): void;
  38150. /**
  38151. * Function indicating if a number is an exponent of 2
  38152. * @param value defines the value to test
  38153. * @returns true if the value is an exponent of 2
  38154. */
  38155. static IsExponentOfTwo(value: number): boolean;
  38156. private static _tmpFloatArray;
  38157. /**
  38158. * Returns the nearest 32-bit single precision float representation of a Number
  38159. * @param value A Number. If the parameter is of a different type, it will get converted
  38160. * to a number or to NaN if it cannot be converted
  38161. * @returns number
  38162. */
  38163. static FloatRound(value: number): number;
  38164. /**
  38165. * Extracts the filename from a path
  38166. * @param path defines the path to use
  38167. * @returns the filename
  38168. */
  38169. static GetFilename(path: string): string;
  38170. /**
  38171. * Extracts the "folder" part of a path (everything before the filename).
  38172. * @param uri The URI to extract the info from
  38173. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  38174. * @returns The "folder" part of the path
  38175. */
  38176. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  38177. /**
  38178. * Extracts text content from a DOM element hierarchy
  38179. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  38180. */
  38181. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  38182. /**
  38183. * Convert an angle in radians to degrees
  38184. * @param angle defines the angle to convert
  38185. * @returns the angle in degrees
  38186. */
  38187. static ToDegrees(angle: number): number;
  38188. /**
  38189. * Convert an angle in degrees to radians
  38190. * @param angle defines the angle to convert
  38191. * @returns the angle in radians
  38192. */
  38193. static ToRadians(angle: number): number;
  38194. /**
  38195. * Returns an array if obj is not an array
  38196. * @param obj defines the object to evaluate as an array
  38197. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  38198. * @returns either obj directly if obj is an array or a new array containing obj
  38199. */
  38200. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  38201. /**
  38202. * Gets the pointer prefix to use
  38203. * @param engine defines the engine we are finding the prefix for
  38204. * @returns "pointer" if touch is enabled. Else returns "mouse"
  38205. */
  38206. static GetPointerPrefix(engine: Engine): string;
  38207. /**
  38208. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  38209. * @param url define the url we are trying
  38210. * @param element define the dom element where to configure the cors policy
  38211. */
  38212. static SetCorsBehavior(url: string | string[], element: {
  38213. crossOrigin: string | null;
  38214. }): void;
  38215. /**
  38216. * Removes unwanted characters from an url
  38217. * @param url defines the url to clean
  38218. * @returns the cleaned url
  38219. */
  38220. static CleanUrl(url: string): string;
  38221. /**
  38222. * Gets or sets a function used to pre-process url before using them to load assets
  38223. */
  38224. static get PreprocessUrl(): (url: string) => string;
  38225. static set PreprocessUrl(processor: (url: string) => string);
  38226. /**
  38227. * Loads an image as an HTMLImageElement.
  38228. * @param input url string, ArrayBuffer, or Blob to load
  38229. * @param onLoad callback called when the image successfully loads
  38230. * @param onError callback called when the image fails to load
  38231. * @param offlineProvider offline provider for caching
  38232. * @param mimeType optional mime type
  38233. * @returns the HTMLImageElement of the loaded image
  38234. */
  38235. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  38236. /**
  38237. * Loads a file from a url
  38238. * @param url url string, ArrayBuffer, or Blob to load
  38239. * @param onSuccess callback called when the file successfully loads
  38240. * @param onProgress callback called while file is loading (if the server supports this mode)
  38241. * @param offlineProvider defines the offline provider for caching
  38242. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38243. * @param onError callback called when the file fails to load
  38244. * @returns a file request object
  38245. */
  38246. 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;
  38247. /**
  38248. * Loads a file from a url
  38249. * @param url the file url to load
  38250. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38251. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  38252. */
  38253. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  38254. /**
  38255. * Load a script (identified by an url). When the url returns, the
  38256. * content of this file is added into a new script element, attached to the DOM (body element)
  38257. * @param scriptUrl defines the url of the script to laod
  38258. * @param onSuccess defines the callback called when the script is loaded
  38259. * @param onError defines the callback to call if an error occurs
  38260. * @param scriptId defines the id of the script element
  38261. */
  38262. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  38263. /**
  38264. * Load an asynchronous script (identified by an url). When the url returns, the
  38265. * content of this file is added into a new script element, attached to the DOM (body element)
  38266. * @param scriptUrl defines the url of the script to laod
  38267. * @param scriptId defines the id of the script element
  38268. * @returns a promise request object
  38269. */
  38270. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  38271. /**
  38272. * Loads a file from a blob
  38273. * @param fileToLoad defines the blob to use
  38274. * @param callback defines the callback to call when data is loaded
  38275. * @param progressCallback defines the callback to call during loading process
  38276. * @returns a file request object
  38277. */
  38278. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  38279. /**
  38280. * Reads a file from a File object
  38281. * @param file defines the file to load
  38282. * @param onSuccess defines the callback to call when data is loaded
  38283. * @param onProgress defines the callback to call during loading process
  38284. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  38285. * @param onError defines the callback to call when an error occurs
  38286. * @returns a file request object
  38287. */
  38288. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38289. /**
  38290. * Creates a data url from a given string content
  38291. * @param content defines the content to convert
  38292. * @returns the new data url link
  38293. */
  38294. static FileAsURL(content: string): string;
  38295. /**
  38296. * Format the given number to a specific decimal format
  38297. * @param value defines the number to format
  38298. * @param decimals defines the number of decimals to use
  38299. * @returns the formatted string
  38300. */
  38301. static Format(value: number, decimals?: number): string;
  38302. /**
  38303. * Tries to copy an object by duplicating every property
  38304. * @param source defines the source object
  38305. * @param destination defines the target object
  38306. * @param doNotCopyList defines a list of properties to avoid
  38307. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  38308. */
  38309. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  38310. /**
  38311. * Gets a boolean indicating if the given object has no own property
  38312. * @param obj defines the object to test
  38313. * @returns true if object has no own property
  38314. */
  38315. static IsEmpty(obj: any): boolean;
  38316. /**
  38317. * Function used to register events at window level
  38318. * @param windowElement defines the Window object to use
  38319. * @param events defines the events to register
  38320. */
  38321. static RegisterTopRootEvents(windowElement: Window, events: {
  38322. name: string;
  38323. handler: Nullable<(e: FocusEvent) => any>;
  38324. }[]): void;
  38325. /**
  38326. * Function used to unregister events from window level
  38327. * @param windowElement defines the Window object to use
  38328. * @param events defines the events to unregister
  38329. */
  38330. static UnregisterTopRootEvents(windowElement: Window, events: {
  38331. name: string;
  38332. handler: Nullable<(e: FocusEvent) => any>;
  38333. }[]): void;
  38334. /**
  38335. * @ignore
  38336. */
  38337. static _ScreenshotCanvas: HTMLCanvasElement;
  38338. /**
  38339. * Dumps the current bound framebuffer
  38340. * @param width defines the rendering width
  38341. * @param height defines the rendering height
  38342. * @param engine defines the hosting engine
  38343. * @param successCallback defines the callback triggered once the data are available
  38344. * @param mimeType defines the mime type of the result
  38345. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  38346. */
  38347. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38348. /**
  38349. * Converts the canvas data to blob.
  38350. * This acts as a polyfill for browsers not supporting the to blob function.
  38351. * @param canvas Defines the canvas to extract the data from
  38352. * @param successCallback Defines the callback triggered once the data are available
  38353. * @param mimeType Defines the mime type of the result
  38354. */
  38355. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  38356. /**
  38357. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  38358. * @param successCallback defines the callback triggered once the data are available
  38359. * @param mimeType defines the mime type of the result
  38360. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  38361. */
  38362. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38363. /**
  38364. * Downloads a blob in the browser
  38365. * @param blob defines the blob to download
  38366. * @param fileName defines the name of the downloaded file
  38367. */
  38368. static Download(blob: Blob, fileName: string): void;
  38369. /**
  38370. * Captures a screenshot of the current rendering
  38371. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38372. * @param engine defines the rendering engine
  38373. * @param camera defines the source camera
  38374. * @param size This parameter can be set to a single number or to an object with the
  38375. * following (optional) properties: precision, width, height. If a single number is passed,
  38376. * it will be used for both width and height. If an object is passed, the screenshot size
  38377. * will be derived from the parameters. The precision property is a multiplier allowing
  38378. * rendering at a higher or lower resolution
  38379. * @param successCallback defines the callback receives a single parameter which contains the
  38380. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38381. * src parameter of an <img> to display it
  38382. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38383. * Check your browser for supported MIME types
  38384. */
  38385. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  38386. /**
  38387. * Captures a screenshot of the current rendering
  38388. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38389. * @param engine defines the rendering engine
  38390. * @param camera defines the source camera
  38391. * @param size This parameter can be set to a single number or to an object with the
  38392. * following (optional) properties: precision, width, height. If a single number is passed,
  38393. * it will be used for both width and height. If an object is passed, the screenshot size
  38394. * will be derived from the parameters. The precision property is a multiplier allowing
  38395. * rendering at a higher or lower resolution
  38396. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38397. * Check your browser for supported MIME types
  38398. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38399. * to the src parameter of an <img> to display it
  38400. */
  38401. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  38402. /**
  38403. * Generates an image screenshot from the specified camera.
  38404. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38405. * @param engine The engine to use for rendering
  38406. * @param camera The camera to use for rendering
  38407. * @param size This parameter can be set to a single number or to an object with the
  38408. * following (optional) properties: precision, width, height. If a single number is passed,
  38409. * it will be used for both width and height. If an object is passed, the screenshot size
  38410. * will be derived from the parameters. The precision property is a multiplier allowing
  38411. * rendering at a higher or lower resolution
  38412. * @param successCallback The callback receives a single parameter which contains the
  38413. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38414. * src parameter of an <img> to display it
  38415. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38416. * Check your browser for supported MIME types
  38417. * @param samples Texture samples (default: 1)
  38418. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38419. * @param fileName A name for for the downloaded file.
  38420. */
  38421. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  38422. /**
  38423. * Generates an image screenshot from the specified camera.
  38424. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38425. * @param engine The engine to use for rendering
  38426. * @param camera The camera to use for rendering
  38427. * @param size This parameter can be set to a single number or to an object with the
  38428. * following (optional) properties: precision, width, height. If a single number is passed,
  38429. * it will be used for both width and height. If an object is passed, the screenshot size
  38430. * will be derived from the parameters. The precision property is a multiplier allowing
  38431. * rendering at a higher or lower resolution
  38432. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38433. * Check your browser for supported MIME types
  38434. * @param samples Texture samples (default: 1)
  38435. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38436. * @param fileName A name for for the downloaded file.
  38437. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38438. * to the src parameter of an <img> to display it
  38439. */
  38440. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  38441. /**
  38442. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  38443. * Be aware Math.random() could cause collisions, but:
  38444. * "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"
  38445. * @returns a pseudo random id
  38446. */
  38447. static RandomId(): string;
  38448. /**
  38449. * Test if the given uri is a base64 string
  38450. * @param uri The uri to test
  38451. * @return True if the uri is a base64 string or false otherwise
  38452. */
  38453. static IsBase64(uri: string): boolean;
  38454. /**
  38455. * Decode the given base64 uri.
  38456. * @param uri The uri to decode
  38457. * @return The decoded base64 data.
  38458. */
  38459. static DecodeBase64(uri: string): ArrayBuffer;
  38460. /**
  38461. * Gets the absolute url.
  38462. * @param url the input url
  38463. * @return the absolute url
  38464. */
  38465. static GetAbsoluteUrl(url: string): string;
  38466. /**
  38467. * No log
  38468. */
  38469. static readonly NoneLogLevel: number;
  38470. /**
  38471. * Only message logs
  38472. */
  38473. static readonly MessageLogLevel: number;
  38474. /**
  38475. * Only warning logs
  38476. */
  38477. static readonly WarningLogLevel: number;
  38478. /**
  38479. * Only error logs
  38480. */
  38481. static readonly ErrorLogLevel: number;
  38482. /**
  38483. * All logs
  38484. */
  38485. static readonly AllLogLevel: number;
  38486. /**
  38487. * Gets a value indicating the number of loading errors
  38488. * @ignorenaming
  38489. */
  38490. static get errorsCount(): number;
  38491. /**
  38492. * Callback called when a new log is added
  38493. */
  38494. static OnNewCacheEntry: (entry: string) => void;
  38495. /**
  38496. * Log a message to the console
  38497. * @param message defines the message to log
  38498. */
  38499. static Log(message: string): void;
  38500. /**
  38501. * Write a warning message to the console
  38502. * @param message defines the message to log
  38503. */
  38504. static Warn(message: string): void;
  38505. /**
  38506. * Write an error message to the console
  38507. * @param message defines the message to log
  38508. */
  38509. static Error(message: string): void;
  38510. /**
  38511. * Gets current log cache (list of logs)
  38512. */
  38513. static get LogCache(): string;
  38514. /**
  38515. * Clears the log cache
  38516. */
  38517. static ClearLogCache(): void;
  38518. /**
  38519. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  38520. */
  38521. static set LogLevels(level: number);
  38522. /**
  38523. * Checks if the window object exists
  38524. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  38525. */
  38526. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  38527. /**
  38528. * No performance log
  38529. */
  38530. static readonly PerformanceNoneLogLevel: number;
  38531. /**
  38532. * Use user marks to log performance
  38533. */
  38534. static readonly PerformanceUserMarkLogLevel: number;
  38535. /**
  38536. * Log performance to the console
  38537. */
  38538. static readonly PerformanceConsoleLogLevel: number;
  38539. private static _performance;
  38540. /**
  38541. * Sets the current performance log level
  38542. */
  38543. static set PerformanceLogLevel(level: number);
  38544. private static _StartPerformanceCounterDisabled;
  38545. private static _EndPerformanceCounterDisabled;
  38546. private static _StartUserMark;
  38547. private static _EndUserMark;
  38548. private static _StartPerformanceConsole;
  38549. private static _EndPerformanceConsole;
  38550. /**
  38551. * Starts a performance counter
  38552. */
  38553. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38554. /**
  38555. * Ends a specific performance coutner
  38556. */
  38557. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38558. /**
  38559. * Gets either window.performance.now() if supported or Date.now() else
  38560. */
  38561. static get Now(): number;
  38562. /**
  38563. * This method will return the name of the class used to create the instance of the given object.
  38564. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  38565. * @param object the object to get the class name from
  38566. * @param isType defines if the object is actually a type
  38567. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  38568. */
  38569. static GetClassName(object: any, isType?: boolean): string;
  38570. /**
  38571. * Gets the first element of an array satisfying a given predicate
  38572. * @param array defines the array to browse
  38573. * @param predicate defines the predicate to use
  38574. * @returns null if not found or the element
  38575. */
  38576. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  38577. /**
  38578. * This method will return the name of the full name of the class, including its owning module (if any).
  38579. * 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).
  38580. * @param object the object to get the class name from
  38581. * @param isType defines if the object is actually a type
  38582. * @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.
  38583. * @ignorenaming
  38584. */
  38585. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  38586. /**
  38587. * Returns a promise that resolves after the given amount of time.
  38588. * @param delay Number of milliseconds to delay
  38589. * @returns Promise that resolves after the given amount of time
  38590. */
  38591. static DelayAsync(delay: number): Promise<void>;
  38592. /**
  38593. * Utility function to detect if the current user agent is Safari
  38594. * @returns whether or not the current user agent is safari
  38595. */
  38596. static IsSafari(): boolean;
  38597. }
  38598. /**
  38599. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  38600. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  38601. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  38602. * @param name The name of the class, case should be preserved
  38603. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  38604. */
  38605. export function className(name: string, module?: string): (target: Object) => void;
  38606. /**
  38607. * An implementation of a loop for asynchronous functions.
  38608. */
  38609. export class AsyncLoop {
  38610. /**
  38611. * Defines the number of iterations for the loop
  38612. */
  38613. iterations: number;
  38614. /**
  38615. * Defines the current index of the loop.
  38616. */
  38617. index: number;
  38618. private _done;
  38619. private _fn;
  38620. private _successCallback;
  38621. /**
  38622. * Constructor.
  38623. * @param iterations the number of iterations.
  38624. * @param func the function to run each iteration
  38625. * @param successCallback the callback that will be called upon succesful execution
  38626. * @param offset starting offset.
  38627. */
  38628. constructor(
  38629. /**
  38630. * Defines the number of iterations for the loop
  38631. */
  38632. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  38633. /**
  38634. * Execute the next iteration. Must be called after the last iteration was finished.
  38635. */
  38636. executeNext(): void;
  38637. /**
  38638. * Break the loop and run the success callback.
  38639. */
  38640. breakLoop(): void;
  38641. /**
  38642. * Create and run an async loop.
  38643. * @param iterations the number of iterations.
  38644. * @param fn the function to run each iteration
  38645. * @param successCallback the callback that will be called upon succesful execution
  38646. * @param offset starting offset.
  38647. * @returns the created async loop object
  38648. */
  38649. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  38650. /**
  38651. * A for-loop that will run a given number of iterations synchronous and the rest async.
  38652. * @param iterations total number of iterations
  38653. * @param syncedIterations number of synchronous iterations in each async iteration.
  38654. * @param fn the function to call each iteration.
  38655. * @param callback a success call back that will be called when iterating stops.
  38656. * @param breakFunction a break condition (optional)
  38657. * @param timeout timeout settings for the setTimeout function. default - 0.
  38658. * @returns the created async loop object
  38659. */
  38660. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  38661. }
  38662. }
  38663. declare module BABYLON {
  38664. /**
  38665. * This class implement a typical dictionary using a string as key and the generic type T as value.
  38666. * The underlying implementation relies on an associative array to ensure the best performances.
  38667. * The value can be anything including 'null' but except 'undefined'
  38668. */
  38669. export class StringDictionary<T> {
  38670. /**
  38671. * This will clear this dictionary and copy the content from the 'source' one.
  38672. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  38673. * @param source the dictionary to take the content from and copy to this dictionary
  38674. */
  38675. copyFrom(source: StringDictionary<T>): void;
  38676. /**
  38677. * Get a value based from its key
  38678. * @param key the given key to get the matching value from
  38679. * @return the value if found, otherwise undefined is returned
  38680. */
  38681. get(key: string): T | undefined;
  38682. /**
  38683. * Get a value from its key or add it if it doesn't exist.
  38684. * This method will ensure you that a given key/data will be present in the dictionary.
  38685. * @param key the given key to get the matching value from
  38686. * @param factory the factory that will create the value if the key is not present in the dictionary.
  38687. * The factory will only be invoked if there's no data for the given key.
  38688. * @return the value corresponding to the key.
  38689. */
  38690. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  38691. /**
  38692. * Get a value from its key if present in the dictionary otherwise add it
  38693. * @param key the key to get the value from
  38694. * @param val if there's no such key/value pair in the dictionary add it with this value
  38695. * @return the value corresponding to the key
  38696. */
  38697. getOrAdd(key: string, val: T): T;
  38698. /**
  38699. * Check if there's a given key in the dictionary
  38700. * @param key the key to check for
  38701. * @return true if the key is present, false otherwise
  38702. */
  38703. contains(key: string): boolean;
  38704. /**
  38705. * Add a new key and its corresponding value
  38706. * @param key the key to add
  38707. * @param value the value corresponding to the key
  38708. * @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
  38709. */
  38710. add(key: string, value: T): boolean;
  38711. /**
  38712. * Update a specific value associated to a key
  38713. * @param key defines the key to use
  38714. * @param value defines the value to store
  38715. * @returns true if the value was updated (or false if the key was not found)
  38716. */
  38717. set(key: string, value: T): boolean;
  38718. /**
  38719. * Get the element of the given key and remove it from the dictionary
  38720. * @param key defines the key to search
  38721. * @returns the value associated with the key or null if not found
  38722. */
  38723. getAndRemove(key: string): Nullable<T>;
  38724. /**
  38725. * Remove a key/value from the dictionary.
  38726. * @param key the key to remove
  38727. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  38728. */
  38729. remove(key: string): boolean;
  38730. /**
  38731. * Clear the whole content of the dictionary
  38732. */
  38733. clear(): void;
  38734. /**
  38735. * Gets the current count
  38736. */
  38737. get count(): number;
  38738. /**
  38739. * Execute a callback on each key/val of the dictionary.
  38740. * Note that you can remove any element in this dictionary in the callback implementation
  38741. * @param callback the callback to execute on a given key/value pair
  38742. */
  38743. forEach(callback: (key: string, val: T) => void): void;
  38744. /**
  38745. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  38746. * If the callback returns null or undefined the method will iterate to the next key/value pair
  38747. * Note that you can remove any element in this dictionary in the callback implementation
  38748. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  38749. * @returns the first item
  38750. */
  38751. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  38752. private _count;
  38753. private _data;
  38754. }
  38755. }
  38756. declare module BABYLON {
  38757. /** @hidden */
  38758. export interface ICollisionCoordinator {
  38759. createCollider(): Collider;
  38760. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  38761. init(scene: Scene): void;
  38762. }
  38763. /** @hidden */
  38764. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  38765. private _scene;
  38766. private _scaledPosition;
  38767. private _scaledVelocity;
  38768. private _finalPosition;
  38769. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  38770. createCollider(): Collider;
  38771. init(scene: Scene): void;
  38772. private _collideWithWorld;
  38773. }
  38774. }
  38775. declare module BABYLON {
  38776. /**
  38777. * Class used to manage all inputs for the scene.
  38778. */
  38779. export class InputManager {
  38780. /** The distance in pixel that you have to move to prevent some events */
  38781. static DragMovementThreshold: number;
  38782. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  38783. static LongPressDelay: number;
  38784. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  38785. static DoubleClickDelay: number;
  38786. /** If you need to check double click without raising a single click at first click, enable this flag */
  38787. static ExclusiveDoubleClickMode: boolean;
  38788. /** This is a defensive check to not allow control attachment prior to an already active one. If already attached, previous control is unattached before attaching the new one. */
  38789. private _alreadyAttached;
  38790. private _wheelEventName;
  38791. private _onPointerMove;
  38792. private _onPointerDown;
  38793. private _onPointerUp;
  38794. private _initClickEvent;
  38795. private _initActionManager;
  38796. private _delayedSimpleClick;
  38797. private _delayedSimpleClickTimeout;
  38798. private _previousDelayedSimpleClickTimeout;
  38799. private _meshPickProceed;
  38800. private _previousButtonPressed;
  38801. private _currentPickResult;
  38802. private _previousPickResult;
  38803. private _totalPointersPressed;
  38804. private _doubleClickOccured;
  38805. private _pointerOverMesh;
  38806. private _pickedDownMesh;
  38807. private _pickedUpMesh;
  38808. private _pointerX;
  38809. private _pointerY;
  38810. private _unTranslatedPointerX;
  38811. private _unTranslatedPointerY;
  38812. private _startingPointerPosition;
  38813. private _previousStartingPointerPosition;
  38814. private _startingPointerTime;
  38815. private _previousStartingPointerTime;
  38816. private _pointerCaptures;
  38817. private _onKeyDown;
  38818. private _onKeyUp;
  38819. private _onCanvasFocusObserver;
  38820. private _onCanvasBlurObserver;
  38821. private _scene;
  38822. /**
  38823. * Creates a new InputManager
  38824. * @param scene defines the hosting scene
  38825. */
  38826. constructor(scene: Scene);
  38827. /**
  38828. * Gets the mesh that is currently under the pointer
  38829. */
  38830. get meshUnderPointer(): Nullable<AbstractMesh>;
  38831. /**
  38832. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  38833. */
  38834. get unTranslatedPointer(): Vector2;
  38835. /**
  38836. * Gets or sets the current on-screen X position of the pointer
  38837. */
  38838. get pointerX(): number;
  38839. set pointerX(value: number);
  38840. /**
  38841. * Gets or sets the current on-screen Y position of the pointer
  38842. */
  38843. get pointerY(): number;
  38844. set pointerY(value: number);
  38845. private _updatePointerPosition;
  38846. private _processPointerMove;
  38847. private _setRayOnPointerInfo;
  38848. private _checkPrePointerObservable;
  38849. /**
  38850. * Use this method to simulate a pointer move on a mesh
  38851. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38852. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38853. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38854. */
  38855. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38856. /**
  38857. * Use this method to simulate a pointer down on a mesh
  38858. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38859. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38860. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38861. */
  38862. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38863. private _processPointerDown;
  38864. /** @hidden */
  38865. _isPointerSwiping(): boolean;
  38866. /**
  38867. * Use this method to simulate a pointer up on a mesh
  38868. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38869. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38870. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38871. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  38872. */
  38873. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  38874. private _processPointerUp;
  38875. /**
  38876. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  38877. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  38878. * @returns true if the pointer was captured
  38879. */
  38880. isPointerCaptured(pointerId?: number): boolean;
  38881. /**
  38882. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  38883. * @param attachUp defines if you want to attach events to pointerup
  38884. * @param attachDown defines if you want to attach events to pointerdown
  38885. * @param attachMove defines if you want to attach events to pointermove
  38886. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  38887. */
  38888. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  38889. /**
  38890. * Detaches all event handlers
  38891. */
  38892. detachControl(): void;
  38893. /**
  38894. * Force the value of meshUnderPointer
  38895. * @param mesh defines the mesh to use
  38896. */
  38897. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  38898. /**
  38899. * Gets the mesh under the pointer
  38900. * @returns a Mesh or null if no mesh is under the pointer
  38901. */
  38902. getPointerOverMesh(): Nullable<AbstractMesh>;
  38903. }
  38904. }
  38905. declare module BABYLON {
  38906. /**
  38907. * This class defines the direct association between an animation and a target
  38908. */
  38909. export class TargetedAnimation {
  38910. /**
  38911. * Animation to perform
  38912. */
  38913. animation: Animation;
  38914. /**
  38915. * Target to animate
  38916. */
  38917. target: any;
  38918. /**
  38919. * Returns the string "TargetedAnimation"
  38920. * @returns "TargetedAnimation"
  38921. */
  38922. getClassName(): string;
  38923. /**
  38924. * Serialize the object
  38925. * @returns the JSON object representing the current entity
  38926. */
  38927. serialize(): any;
  38928. }
  38929. /**
  38930. * Use this class to create coordinated animations on multiple targets
  38931. */
  38932. export class AnimationGroup implements IDisposable {
  38933. /** The name of the animation group */
  38934. name: string;
  38935. private _scene;
  38936. private _targetedAnimations;
  38937. private _animatables;
  38938. private _from;
  38939. private _to;
  38940. private _isStarted;
  38941. private _isPaused;
  38942. private _speedRatio;
  38943. private _loopAnimation;
  38944. private _isAdditive;
  38945. /**
  38946. * Gets or sets the unique id of the node
  38947. */
  38948. uniqueId: number;
  38949. /**
  38950. * This observable will notify when one animation have ended
  38951. */
  38952. onAnimationEndObservable: Observable<TargetedAnimation>;
  38953. /**
  38954. * Observer raised when one animation loops
  38955. */
  38956. onAnimationLoopObservable: Observable<TargetedAnimation>;
  38957. /**
  38958. * Observer raised when all animations have looped
  38959. */
  38960. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  38961. /**
  38962. * This observable will notify when all animations have ended.
  38963. */
  38964. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  38965. /**
  38966. * This observable will notify when all animations have paused.
  38967. */
  38968. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  38969. /**
  38970. * This observable will notify when all animations are playing.
  38971. */
  38972. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  38973. /**
  38974. * Gets the first frame
  38975. */
  38976. get from(): number;
  38977. /**
  38978. * Gets the last frame
  38979. */
  38980. get to(): number;
  38981. /**
  38982. * Define if the animations are started
  38983. */
  38984. get isStarted(): boolean;
  38985. /**
  38986. * Gets a value indicating that the current group is playing
  38987. */
  38988. get isPlaying(): boolean;
  38989. /**
  38990. * Gets or sets the speed ratio to use for all animations
  38991. */
  38992. get speedRatio(): number;
  38993. /**
  38994. * Gets or sets the speed ratio to use for all animations
  38995. */
  38996. set speedRatio(value: number);
  38997. /**
  38998. * Gets or sets if all animations should loop or not
  38999. */
  39000. get loopAnimation(): boolean;
  39001. set loopAnimation(value: boolean);
  39002. /**
  39003. * Gets or sets if all animations should be evaluated additively
  39004. */
  39005. get isAdditive(): boolean;
  39006. set isAdditive(value: boolean);
  39007. /**
  39008. * Gets the targeted animations for this animation group
  39009. */
  39010. get targetedAnimations(): Array<TargetedAnimation>;
  39011. /**
  39012. * returning the list of animatables controlled by this animation group.
  39013. */
  39014. get animatables(): Array<Animatable>;
  39015. /**
  39016. * Gets the list of target animations
  39017. */
  39018. get children(): TargetedAnimation[];
  39019. /**
  39020. * Instantiates a new Animation Group.
  39021. * This helps managing several animations at once.
  39022. * @see https://doc.babylonjs.com/how_to/group
  39023. * @param name Defines the name of the group
  39024. * @param scene Defines the scene the group belongs to
  39025. */
  39026. constructor(
  39027. /** The name of the animation group */
  39028. name: string, scene?: Nullable<Scene>);
  39029. /**
  39030. * Add an animation (with its target) in the group
  39031. * @param animation defines the animation we want to add
  39032. * @param target defines the target of the animation
  39033. * @returns the TargetedAnimation object
  39034. */
  39035. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  39036. /**
  39037. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  39038. * It can add constant keys at begin or end
  39039. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  39040. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  39041. * @returns the animation group
  39042. */
  39043. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  39044. private _animationLoopCount;
  39045. private _animationLoopFlags;
  39046. private _processLoop;
  39047. /**
  39048. * Start all animations on given targets
  39049. * @param loop defines if animations must loop
  39050. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  39051. * @param from defines the from key (optional)
  39052. * @param to defines the to key (optional)
  39053. * @param isAdditive defines the additive state for the resulting animatables (optional)
  39054. * @returns the current animation group
  39055. */
  39056. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  39057. /**
  39058. * Pause all animations
  39059. * @returns the animation group
  39060. */
  39061. pause(): AnimationGroup;
  39062. /**
  39063. * Play all animations to initial state
  39064. * This function will start() the animations if they were not started or will restart() them if they were paused
  39065. * @param loop defines if animations must loop
  39066. * @returns the animation group
  39067. */
  39068. play(loop?: boolean): AnimationGroup;
  39069. /**
  39070. * Reset all animations to initial state
  39071. * @returns the animation group
  39072. */
  39073. reset(): AnimationGroup;
  39074. /**
  39075. * Restart animations from key 0
  39076. * @returns the animation group
  39077. */
  39078. restart(): AnimationGroup;
  39079. /**
  39080. * Stop all animations
  39081. * @returns the animation group
  39082. */
  39083. stop(): AnimationGroup;
  39084. /**
  39085. * Set animation weight for all animatables
  39086. * @param weight defines the weight to use
  39087. * @return the animationGroup
  39088. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39089. */
  39090. setWeightForAllAnimatables(weight: number): AnimationGroup;
  39091. /**
  39092. * Synchronize and normalize all animatables with a source animatable
  39093. * @param root defines the root animatable to synchronize with
  39094. * @return the animationGroup
  39095. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39096. */
  39097. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  39098. /**
  39099. * Goes to a specific frame in this animation group
  39100. * @param frame the frame number to go to
  39101. * @return the animationGroup
  39102. */
  39103. goToFrame(frame: number): AnimationGroup;
  39104. /**
  39105. * Dispose all associated resources
  39106. */
  39107. dispose(): void;
  39108. private _checkAnimationGroupEnded;
  39109. /**
  39110. * Clone the current animation group and returns a copy
  39111. * @param newName defines the name of the new group
  39112. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  39113. * @returns the new aniamtion group
  39114. */
  39115. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  39116. /**
  39117. * Serializes the animationGroup to an object
  39118. * @returns Serialized object
  39119. */
  39120. serialize(): any;
  39121. /**
  39122. * Returns a new AnimationGroup object parsed from the source provided.
  39123. * @param parsedAnimationGroup defines the source
  39124. * @param scene defines the scene that will receive the animationGroup
  39125. * @returns a new AnimationGroup
  39126. */
  39127. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  39128. /**
  39129. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  39130. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  39131. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  39132. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  39133. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  39134. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  39135. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  39136. */
  39137. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  39138. /**
  39139. * Returns the string "AnimationGroup"
  39140. * @returns "AnimationGroup"
  39141. */
  39142. getClassName(): string;
  39143. /**
  39144. * Creates a detailled string about the object
  39145. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  39146. * @returns a string representing the object
  39147. */
  39148. toString(fullDetails?: boolean): string;
  39149. }
  39150. }
  39151. declare module BABYLON {
  39152. /**
  39153. * Define an interface for all classes that will hold resources
  39154. */
  39155. export interface IDisposable {
  39156. /**
  39157. * Releases all held resources
  39158. */
  39159. dispose(): void;
  39160. }
  39161. /** Interface defining initialization parameters for Scene class */
  39162. export interface SceneOptions {
  39163. /**
  39164. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  39165. * It will improve performance when the number of geometries becomes important.
  39166. */
  39167. useGeometryUniqueIdsMap?: boolean;
  39168. /**
  39169. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  39170. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39171. */
  39172. useMaterialMeshMap?: boolean;
  39173. /**
  39174. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  39175. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39176. */
  39177. useClonedMeshMap?: boolean;
  39178. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  39179. virtual?: boolean;
  39180. }
  39181. /**
  39182. * Represents a scene to be rendered by the engine.
  39183. * @see https://doc.babylonjs.com/features/scene
  39184. */
  39185. export class Scene extends AbstractScene implements IAnimatable {
  39186. /** The fog is deactivated */
  39187. static readonly FOGMODE_NONE: number;
  39188. /** The fog density is following an exponential function */
  39189. static readonly FOGMODE_EXP: number;
  39190. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  39191. static readonly FOGMODE_EXP2: number;
  39192. /** The fog density is following a linear function. */
  39193. static readonly FOGMODE_LINEAR: number;
  39194. /**
  39195. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  39196. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39197. */
  39198. static MinDeltaTime: number;
  39199. /**
  39200. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  39201. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39202. */
  39203. static MaxDeltaTime: number;
  39204. /**
  39205. * Factory used to create the default material.
  39206. * @param name The name of the material to create
  39207. * @param scene The scene to create the material for
  39208. * @returns The default material
  39209. */
  39210. static DefaultMaterialFactory(scene: Scene): Material;
  39211. /**
  39212. * Factory used to create the a collision coordinator.
  39213. * @returns The collision coordinator
  39214. */
  39215. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  39216. /** @hidden */
  39217. _inputManager: InputManager;
  39218. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  39219. cameraToUseForPointers: Nullable<Camera>;
  39220. /** @hidden */
  39221. readonly _isScene: boolean;
  39222. /** @hidden */
  39223. _blockEntityCollection: boolean;
  39224. /**
  39225. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  39226. */
  39227. autoClear: boolean;
  39228. /**
  39229. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  39230. */
  39231. autoClearDepthAndStencil: boolean;
  39232. /**
  39233. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  39234. */
  39235. clearColor: Color4;
  39236. /**
  39237. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  39238. */
  39239. ambientColor: Color3;
  39240. /**
  39241. * This is use to store the default BRDF lookup for PBR materials in your scene.
  39242. * It should only be one of the following (if not the default embedded one):
  39243. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  39244. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  39245. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  39246. * The material properties need to be setup according to the type of texture in use.
  39247. */
  39248. environmentBRDFTexture: BaseTexture;
  39249. /** @hidden */
  39250. protected _environmentTexture: Nullable<BaseTexture>;
  39251. /**
  39252. * Texture used in all pbr material as the reflection texture.
  39253. * As in the majority of the scene they are the same (exception for multi room and so on),
  39254. * this is easier to reference from here than from all the materials.
  39255. */
  39256. get environmentTexture(): Nullable<BaseTexture>;
  39257. /**
  39258. * Texture used in all pbr material as the reflection texture.
  39259. * As in the majority of the scene they are the same (exception for multi room and so on),
  39260. * this is easier to set here than in all the materials.
  39261. */
  39262. set environmentTexture(value: Nullable<BaseTexture>);
  39263. /** @hidden */
  39264. protected _environmentIntensity: number;
  39265. /**
  39266. * Intensity of the environment in all pbr material.
  39267. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39268. * As in the majority of the scene they are the same (exception for multi room and so on),
  39269. * this is easier to reference from here than from all the materials.
  39270. */
  39271. get environmentIntensity(): number;
  39272. /**
  39273. * Intensity of the environment in all pbr material.
  39274. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39275. * As in the majority of the scene they are the same (exception for multi room and so on),
  39276. * this is easier to set here than in all the materials.
  39277. */
  39278. set environmentIntensity(value: number);
  39279. /** @hidden */
  39280. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39281. /**
  39282. * Default image processing configuration used either in the rendering
  39283. * Forward main pass or through the imageProcessingPostProcess if present.
  39284. * As in the majority of the scene they are the same (exception for multi camera),
  39285. * this is easier to reference from here than from all the materials and post process.
  39286. *
  39287. * No setter as we it is a shared configuration, you can set the values instead.
  39288. */
  39289. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  39290. private _forceWireframe;
  39291. /**
  39292. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  39293. */
  39294. set forceWireframe(value: boolean);
  39295. get forceWireframe(): boolean;
  39296. private _skipFrustumClipping;
  39297. /**
  39298. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  39299. */
  39300. set skipFrustumClipping(value: boolean);
  39301. get skipFrustumClipping(): boolean;
  39302. private _forcePointsCloud;
  39303. /**
  39304. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  39305. */
  39306. set forcePointsCloud(value: boolean);
  39307. get forcePointsCloud(): boolean;
  39308. /**
  39309. * Gets or sets the active clipplane 1
  39310. */
  39311. clipPlane: Nullable<Plane>;
  39312. /**
  39313. * Gets or sets the active clipplane 2
  39314. */
  39315. clipPlane2: Nullable<Plane>;
  39316. /**
  39317. * Gets or sets the active clipplane 3
  39318. */
  39319. clipPlane3: Nullable<Plane>;
  39320. /**
  39321. * Gets or sets the active clipplane 4
  39322. */
  39323. clipPlane4: Nullable<Plane>;
  39324. /**
  39325. * Gets or sets the active clipplane 5
  39326. */
  39327. clipPlane5: Nullable<Plane>;
  39328. /**
  39329. * Gets or sets the active clipplane 6
  39330. */
  39331. clipPlane6: Nullable<Plane>;
  39332. /**
  39333. * Gets or sets a boolean indicating if animations are enabled
  39334. */
  39335. animationsEnabled: boolean;
  39336. private _animationPropertiesOverride;
  39337. /**
  39338. * Gets or sets the animation properties override
  39339. */
  39340. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  39341. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  39342. /**
  39343. * Gets or sets a boolean indicating if a constant deltatime has to be used
  39344. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  39345. */
  39346. useConstantAnimationDeltaTime: boolean;
  39347. /**
  39348. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  39349. * Please note that it requires to run a ray cast through the scene on every frame
  39350. */
  39351. constantlyUpdateMeshUnderPointer: boolean;
  39352. /**
  39353. * Defines the HTML cursor to use when hovering over interactive elements
  39354. */
  39355. hoverCursor: string;
  39356. /**
  39357. * Defines the HTML default cursor to use (empty by default)
  39358. */
  39359. defaultCursor: string;
  39360. /**
  39361. * Defines whether cursors are handled by the scene.
  39362. */
  39363. doNotHandleCursors: boolean;
  39364. /**
  39365. * This is used to call preventDefault() on pointer down
  39366. * in order to block unwanted artifacts like system double clicks
  39367. */
  39368. preventDefaultOnPointerDown: boolean;
  39369. /**
  39370. * This is used to call preventDefault() on pointer up
  39371. * in order to block unwanted artifacts like system double clicks
  39372. */
  39373. preventDefaultOnPointerUp: boolean;
  39374. /**
  39375. * Gets or sets user defined metadata
  39376. */
  39377. metadata: any;
  39378. /**
  39379. * For internal use only. Please do not use.
  39380. */
  39381. reservedDataStore: any;
  39382. /**
  39383. * Gets the name of the plugin used to load this scene (null by default)
  39384. */
  39385. loadingPluginName: string;
  39386. /**
  39387. * Use this array to add regular expressions used to disable offline support for specific urls
  39388. */
  39389. disableOfflineSupportExceptionRules: RegExp[];
  39390. /**
  39391. * An event triggered when the scene is disposed.
  39392. */
  39393. onDisposeObservable: Observable<Scene>;
  39394. private _onDisposeObserver;
  39395. /** Sets a function to be executed when this scene is disposed. */
  39396. set onDispose(callback: () => void);
  39397. /**
  39398. * An event triggered before rendering the scene (right after animations and physics)
  39399. */
  39400. onBeforeRenderObservable: Observable<Scene>;
  39401. private _onBeforeRenderObserver;
  39402. /** Sets a function to be executed before rendering this scene */
  39403. set beforeRender(callback: Nullable<() => void>);
  39404. /**
  39405. * An event triggered after rendering the scene
  39406. */
  39407. onAfterRenderObservable: Observable<Scene>;
  39408. /**
  39409. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  39410. */
  39411. onAfterRenderCameraObservable: Observable<Camera>;
  39412. private _onAfterRenderObserver;
  39413. /** Sets a function to be executed after rendering this scene */
  39414. set afterRender(callback: Nullable<() => void>);
  39415. /**
  39416. * An event triggered before animating the scene
  39417. */
  39418. onBeforeAnimationsObservable: Observable<Scene>;
  39419. /**
  39420. * An event triggered after animations processing
  39421. */
  39422. onAfterAnimationsObservable: Observable<Scene>;
  39423. /**
  39424. * An event triggered before draw calls are ready to be sent
  39425. */
  39426. onBeforeDrawPhaseObservable: Observable<Scene>;
  39427. /**
  39428. * An event triggered after draw calls have been sent
  39429. */
  39430. onAfterDrawPhaseObservable: Observable<Scene>;
  39431. /**
  39432. * An event triggered when the scene is ready
  39433. */
  39434. onReadyObservable: Observable<Scene>;
  39435. /**
  39436. * An event triggered before rendering a camera
  39437. */
  39438. onBeforeCameraRenderObservable: Observable<Camera>;
  39439. private _onBeforeCameraRenderObserver;
  39440. /** Sets a function to be executed before rendering a camera*/
  39441. set beforeCameraRender(callback: () => void);
  39442. /**
  39443. * An event triggered after rendering a camera
  39444. */
  39445. onAfterCameraRenderObservable: Observable<Camera>;
  39446. private _onAfterCameraRenderObserver;
  39447. /** Sets a function to be executed after rendering a camera*/
  39448. set afterCameraRender(callback: () => void);
  39449. /**
  39450. * An event triggered when active meshes evaluation is about to start
  39451. */
  39452. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  39453. /**
  39454. * An event triggered when active meshes evaluation is done
  39455. */
  39456. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  39457. /**
  39458. * An event triggered when particles rendering is about to start
  39459. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39460. */
  39461. onBeforeParticlesRenderingObservable: Observable<Scene>;
  39462. /**
  39463. * An event triggered when particles rendering is done
  39464. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39465. */
  39466. onAfterParticlesRenderingObservable: Observable<Scene>;
  39467. /**
  39468. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  39469. */
  39470. onDataLoadedObservable: Observable<Scene>;
  39471. /**
  39472. * An event triggered when a camera is created
  39473. */
  39474. onNewCameraAddedObservable: Observable<Camera>;
  39475. /**
  39476. * An event triggered when a camera is removed
  39477. */
  39478. onCameraRemovedObservable: Observable<Camera>;
  39479. /**
  39480. * An event triggered when a light is created
  39481. */
  39482. onNewLightAddedObservable: Observable<Light>;
  39483. /**
  39484. * An event triggered when a light is removed
  39485. */
  39486. onLightRemovedObservable: Observable<Light>;
  39487. /**
  39488. * An event triggered when a geometry is created
  39489. */
  39490. onNewGeometryAddedObservable: Observable<Geometry>;
  39491. /**
  39492. * An event triggered when a geometry is removed
  39493. */
  39494. onGeometryRemovedObservable: Observable<Geometry>;
  39495. /**
  39496. * An event triggered when a transform node is created
  39497. */
  39498. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  39499. /**
  39500. * An event triggered when a transform node is removed
  39501. */
  39502. onTransformNodeRemovedObservable: Observable<TransformNode>;
  39503. /**
  39504. * An event triggered when a mesh is created
  39505. */
  39506. onNewMeshAddedObservable: Observable<AbstractMesh>;
  39507. /**
  39508. * An event triggered when a mesh is removed
  39509. */
  39510. onMeshRemovedObservable: Observable<AbstractMesh>;
  39511. /**
  39512. * An event triggered when a skeleton is created
  39513. */
  39514. onNewSkeletonAddedObservable: Observable<Skeleton>;
  39515. /**
  39516. * An event triggered when a skeleton is removed
  39517. */
  39518. onSkeletonRemovedObservable: Observable<Skeleton>;
  39519. /**
  39520. * An event triggered when a material is created
  39521. */
  39522. onNewMaterialAddedObservable: Observable<Material>;
  39523. /**
  39524. * An event triggered when a material is removed
  39525. */
  39526. onMaterialRemovedObservable: Observable<Material>;
  39527. /**
  39528. * An event triggered when a texture is created
  39529. */
  39530. onNewTextureAddedObservable: Observable<BaseTexture>;
  39531. /**
  39532. * An event triggered when a texture is removed
  39533. */
  39534. onTextureRemovedObservable: Observable<BaseTexture>;
  39535. /**
  39536. * An event triggered when render targets are about to be rendered
  39537. * Can happen multiple times per frame.
  39538. */
  39539. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  39540. /**
  39541. * An event triggered when render targets were rendered.
  39542. * Can happen multiple times per frame.
  39543. */
  39544. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  39545. /**
  39546. * An event triggered before calculating deterministic simulation step
  39547. */
  39548. onBeforeStepObservable: Observable<Scene>;
  39549. /**
  39550. * An event triggered after calculating deterministic simulation step
  39551. */
  39552. onAfterStepObservable: Observable<Scene>;
  39553. /**
  39554. * An event triggered when the activeCamera property is updated
  39555. */
  39556. onActiveCameraChanged: Observable<Scene>;
  39557. /**
  39558. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  39559. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39560. * 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)
  39561. */
  39562. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39563. /**
  39564. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  39565. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39566. * 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)
  39567. */
  39568. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39569. /**
  39570. * This Observable will when a mesh has been imported into the scene.
  39571. */
  39572. onMeshImportedObservable: Observable<AbstractMesh>;
  39573. /**
  39574. * This Observable will when an animation file has been imported into the scene.
  39575. */
  39576. onAnimationFileImportedObservable: Observable<Scene>;
  39577. /**
  39578. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  39579. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  39580. */
  39581. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  39582. /** @hidden */
  39583. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  39584. /**
  39585. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  39586. */
  39587. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  39588. /**
  39589. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  39590. */
  39591. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  39592. /**
  39593. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  39594. */
  39595. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  39596. /** Callback called when a pointer move is detected */
  39597. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39598. /** Callback called when a pointer down is detected */
  39599. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39600. /** Callback called when a pointer up is detected */
  39601. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  39602. /** Callback called when a pointer pick is detected */
  39603. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  39604. /**
  39605. * 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).
  39606. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  39607. */
  39608. onPrePointerObservable: Observable<PointerInfoPre>;
  39609. /**
  39610. * Observable event triggered each time an input event is received from the rendering canvas
  39611. */
  39612. onPointerObservable: Observable<PointerInfo>;
  39613. /**
  39614. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  39615. */
  39616. get unTranslatedPointer(): Vector2;
  39617. /**
  39618. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  39619. */
  39620. static get DragMovementThreshold(): number;
  39621. static set DragMovementThreshold(value: number);
  39622. /**
  39623. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  39624. */
  39625. static get LongPressDelay(): number;
  39626. static set LongPressDelay(value: number);
  39627. /**
  39628. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  39629. */
  39630. static get DoubleClickDelay(): number;
  39631. static set DoubleClickDelay(value: number);
  39632. /** If you need to check double click without raising a single click at first click, enable this flag */
  39633. static get ExclusiveDoubleClickMode(): boolean;
  39634. static set ExclusiveDoubleClickMode(value: boolean);
  39635. /** @hidden */
  39636. _mirroredCameraPosition: Nullable<Vector3>;
  39637. /**
  39638. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  39639. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  39640. */
  39641. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  39642. /**
  39643. * Observable event triggered each time an keyboard event is received from the hosting window
  39644. */
  39645. onKeyboardObservable: Observable<KeyboardInfo>;
  39646. private _useRightHandedSystem;
  39647. /**
  39648. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  39649. */
  39650. set useRightHandedSystem(value: boolean);
  39651. get useRightHandedSystem(): boolean;
  39652. private _timeAccumulator;
  39653. private _currentStepId;
  39654. private _currentInternalStep;
  39655. /**
  39656. * Sets the step Id used by deterministic lock step
  39657. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39658. * @param newStepId defines the step Id
  39659. */
  39660. setStepId(newStepId: number): void;
  39661. /**
  39662. * Gets the step Id used by deterministic lock step
  39663. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39664. * @returns the step Id
  39665. */
  39666. getStepId(): number;
  39667. /**
  39668. * Gets the internal step used by deterministic lock step
  39669. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39670. * @returns the internal step
  39671. */
  39672. getInternalStep(): number;
  39673. private _fogEnabled;
  39674. /**
  39675. * Gets or sets a boolean indicating if fog is enabled on this scene
  39676. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39677. * (Default is true)
  39678. */
  39679. set fogEnabled(value: boolean);
  39680. get fogEnabled(): boolean;
  39681. private _fogMode;
  39682. /**
  39683. * Gets or sets the fog mode to use
  39684. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39685. * | mode | value |
  39686. * | --- | --- |
  39687. * | FOGMODE_NONE | 0 |
  39688. * | FOGMODE_EXP | 1 |
  39689. * | FOGMODE_EXP2 | 2 |
  39690. * | FOGMODE_LINEAR | 3 |
  39691. */
  39692. set fogMode(value: number);
  39693. get fogMode(): number;
  39694. /**
  39695. * Gets or sets the fog color to use
  39696. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39697. * (Default is Color3(0.2, 0.2, 0.3))
  39698. */
  39699. fogColor: Color3;
  39700. /**
  39701. * Gets or sets the fog density to use
  39702. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39703. * (Default is 0.1)
  39704. */
  39705. fogDensity: number;
  39706. /**
  39707. * Gets or sets the fog start distance to use
  39708. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39709. * (Default is 0)
  39710. */
  39711. fogStart: number;
  39712. /**
  39713. * Gets or sets the fog end distance to use
  39714. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39715. * (Default is 1000)
  39716. */
  39717. fogEnd: number;
  39718. /**
  39719. * Flag indicating that the frame buffer binding is handled by another component
  39720. */
  39721. prePass: boolean;
  39722. private _shadowsEnabled;
  39723. /**
  39724. * Gets or sets a boolean indicating if shadows are enabled on this scene
  39725. */
  39726. set shadowsEnabled(value: boolean);
  39727. get shadowsEnabled(): boolean;
  39728. private _lightsEnabled;
  39729. /**
  39730. * Gets or sets a boolean indicating if lights are enabled on this scene
  39731. */
  39732. set lightsEnabled(value: boolean);
  39733. get lightsEnabled(): boolean;
  39734. /** All of the active cameras added to this scene. */
  39735. activeCameras: Camera[];
  39736. /** @hidden */
  39737. _activeCamera: Nullable<Camera>;
  39738. /** Gets or sets the current active camera */
  39739. get activeCamera(): Nullable<Camera>;
  39740. set activeCamera(value: Nullable<Camera>);
  39741. private _defaultMaterial;
  39742. /** The default material used on meshes when no material is affected */
  39743. get defaultMaterial(): Material;
  39744. /** The default material used on meshes when no material is affected */
  39745. set defaultMaterial(value: Material);
  39746. private _texturesEnabled;
  39747. /**
  39748. * Gets or sets a boolean indicating if textures are enabled on this scene
  39749. */
  39750. set texturesEnabled(value: boolean);
  39751. get texturesEnabled(): boolean;
  39752. /**
  39753. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  39754. */
  39755. physicsEnabled: boolean;
  39756. /**
  39757. * Gets or sets a boolean indicating if particles are enabled on this scene
  39758. */
  39759. particlesEnabled: boolean;
  39760. /**
  39761. * Gets or sets a boolean indicating if sprites are enabled on this scene
  39762. */
  39763. spritesEnabled: boolean;
  39764. private _skeletonsEnabled;
  39765. /**
  39766. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  39767. */
  39768. set skeletonsEnabled(value: boolean);
  39769. get skeletonsEnabled(): boolean;
  39770. /**
  39771. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  39772. */
  39773. lensFlaresEnabled: boolean;
  39774. /**
  39775. * Gets or sets a boolean indicating if collisions are enabled on this scene
  39776. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  39777. */
  39778. collisionsEnabled: boolean;
  39779. private _collisionCoordinator;
  39780. /** @hidden */
  39781. get collisionCoordinator(): ICollisionCoordinator;
  39782. /**
  39783. * Defines the gravity applied to this scene (used only for collisions)
  39784. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  39785. */
  39786. gravity: Vector3;
  39787. /**
  39788. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  39789. */
  39790. postProcessesEnabled: boolean;
  39791. /**
  39792. * The list of postprocesses added to the scene
  39793. */
  39794. postProcesses: PostProcess[];
  39795. /**
  39796. * Gets the current postprocess manager
  39797. */
  39798. postProcessManager: PostProcessManager;
  39799. /**
  39800. * Gets or sets a boolean indicating if render targets are enabled on this scene
  39801. */
  39802. renderTargetsEnabled: boolean;
  39803. /**
  39804. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  39805. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  39806. */
  39807. dumpNextRenderTargets: boolean;
  39808. /**
  39809. * The list of user defined render targets added to the scene
  39810. */
  39811. customRenderTargets: RenderTargetTexture[];
  39812. /**
  39813. * Defines if texture loading must be delayed
  39814. * If true, textures will only be loaded when they need to be rendered
  39815. */
  39816. useDelayedTextureLoading: boolean;
  39817. /**
  39818. * Gets the list of meshes imported to the scene through SceneLoader
  39819. */
  39820. importedMeshesFiles: String[];
  39821. /**
  39822. * Gets or sets a boolean indicating if probes are enabled on this scene
  39823. */
  39824. probesEnabled: boolean;
  39825. /**
  39826. * Gets or sets the current offline provider to use to store scene data
  39827. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  39828. */
  39829. offlineProvider: IOfflineProvider;
  39830. /**
  39831. * Gets or sets the action manager associated with the scene
  39832. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  39833. */
  39834. actionManager: AbstractActionManager;
  39835. private _meshesForIntersections;
  39836. /**
  39837. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  39838. */
  39839. proceduralTexturesEnabled: boolean;
  39840. private _engine;
  39841. private _totalVertices;
  39842. /** @hidden */
  39843. _activeIndices: PerfCounter;
  39844. /** @hidden */
  39845. _activeParticles: PerfCounter;
  39846. /** @hidden */
  39847. _activeBones: PerfCounter;
  39848. private _animationRatio;
  39849. /** @hidden */
  39850. _animationTimeLast: number;
  39851. /** @hidden */
  39852. _animationTime: number;
  39853. /**
  39854. * Gets or sets a general scale for animation speed
  39855. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  39856. */
  39857. animationTimeScale: number;
  39858. /** @hidden */
  39859. _cachedMaterial: Nullable<Material>;
  39860. /** @hidden */
  39861. _cachedEffect: Nullable<Effect>;
  39862. /** @hidden */
  39863. _cachedVisibility: Nullable<number>;
  39864. private _renderId;
  39865. private _frameId;
  39866. private _executeWhenReadyTimeoutId;
  39867. private _intermediateRendering;
  39868. private _viewUpdateFlag;
  39869. private _projectionUpdateFlag;
  39870. /** @hidden */
  39871. _toBeDisposed: Nullable<IDisposable>[];
  39872. private _activeRequests;
  39873. /** @hidden */
  39874. _pendingData: any[];
  39875. private _isDisposed;
  39876. /**
  39877. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  39878. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  39879. */
  39880. dispatchAllSubMeshesOfActiveMeshes: boolean;
  39881. private _activeMeshes;
  39882. private _processedMaterials;
  39883. private _renderTargets;
  39884. /** @hidden */
  39885. _activeParticleSystems: SmartArray<IParticleSystem>;
  39886. private _activeSkeletons;
  39887. private _softwareSkinnedMeshes;
  39888. private _renderingManager;
  39889. /** @hidden */
  39890. _activeAnimatables: Animatable[];
  39891. private _transformMatrix;
  39892. private _sceneUbo;
  39893. /** @hidden */
  39894. _viewMatrix: Matrix;
  39895. private _projectionMatrix;
  39896. /** @hidden */
  39897. _forcedViewPosition: Nullable<Vector3>;
  39898. /** @hidden */
  39899. _frustumPlanes: Plane[];
  39900. /**
  39901. * Gets the list of frustum planes (built from the active camera)
  39902. */
  39903. get frustumPlanes(): Plane[];
  39904. /**
  39905. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  39906. * This is useful if there are more lights that the maximum simulteanous authorized
  39907. */
  39908. requireLightSorting: boolean;
  39909. /** @hidden */
  39910. readonly useMaterialMeshMap: boolean;
  39911. /** @hidden */
  39912. readonly useClonedMeshMap: boolean;
  39913. private _externalData;
  39914. private _uid;
  39915. /**
  39916. * @hidden
  39917. * Backing store of defined scene components.
  39918. */
  39919. _components: ISceneComponent[];
  39920. /**
  39921. * @hidden
  39922. * Backing store of defined scene components.
  39923. */
  39924. _serializableComponents: ISceneSerializableComponent[];
  39925. /**
  39926. * List of components to register on the next registration step.
  39927. */
  39928. private _transientComponents;
  39929. /**
  39930. * Registers the transient components if needed.
  39931. */
  39932. private _registerTransientComponents;
  39933. /**
  39934. * @hidden
  39935. * Add a component to the scene.
  39936. * Note that the ccomponent could be registered on th next frame if this is called after
  39937. * the register component stage.
  39938. * @param component Defines the component to add to the scene
  39939. */
  39940. _addComponent(component: ISceneComponent): void;
  39941. /**
  39942. * @hidden
  39943. * Gets a component from the scene.
  39944. * @param name defines the name of the component to retrieve
  39945. * @returns the component or null if not present
  39946. */
  39947. _getComponent(name: string): Nullable<ISceneComponent>;
  39948. /**
  39949. * @hidden
  39950. * Defines the actions happening before camera updates.
  39951. */
  39952. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  39953. /**
  39954. * @hidden
  39955. * Defines the actions happening before clear the canvas.
  39956. */
  39957. _beforeClearStage: Stage<SimpleStageAction>;
  39958. /**
  39959. * @hidden
  39960. * Defines the actions when collecting render targets for the frame.
  39961. */
  39962. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  39963. /**
  39964. * @hidden
  39965. * Defines the actions happening for one camera in the frame.
  39966. */
  39967. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  39968. /**
  39969. * @hidden
  39970. * Defines the actions happening during the per mesh ready checks.
  39971. */
  39972. _isReadyForMeshStage: Stage<MeshStageAction>;
  39973. /**
  39974. * @hidden
  39975. * Defines the actions happening before evaluate active mesh checks.
  39976. */
  39977. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  39978. /**
  39979. * @hidden
  39980. * Defines the actions happening during the evaluate sub mesh checks.
  39981. */
  39982. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  39983. /**
  39984. * @hidden
  39985. * Defines the actions happening during the active mesh stage.
  39986. */
  39987. _activeMeshStage: Stage<ActiveMeshStageAction>;
  39988. /**
  39989. * @hidden
  39990. * Defines the actions happening during the per camera render target step.
  39991. */
  39992. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  39993. /**
  39994. * @hidden
  39995. * Defines the actions happening just before the active camera is drawing.
  39996. */
  39997. _beforeCameraDrawStage: Stage<CameraStageAction>;
  39998. /**
  39999. * @hidden
  40000. * Defines the actions happening just before a render target is drawing.
  40001. */
  40002. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40003. /**
  40004. * @hidden
  40005. * Defines the actions happening just before a rendering group is drawing.
  40006. */
  40007. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40008. /**
  40009. * @hidden
  40010. * Defines the actions happening just before a mesh is drawing.
  40011. */
  40012. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40013. /**
  40014. * @hidden
  40015. * Defines the actions happening just after a mesh has been drawn.
  40016. */
  40017. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40018. /**
  40019. * @hidden
  40020. * Defines the actions happening just after a rendering group has been drawn.
  40021. */
  40022. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40023. /**
  40024. * @hidden
  40025. * Defines the actions happening just after the active camera has been drawn.
  40026. */
  40027. _afterCameraDrawStage: Stage<CameraStageAction>;
  40028. /**
  40029. * @hidden
  40030. * Defines the actions happening just after a render target has been drawn.
  40031. */
  40032. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40033. /**
  40034. * @hidden
  40035. * Defines the actions happening just after rendering all cameras and computing intersections.
  40036. */
  40037. _afterRenderStage: Stage<SimpleStageAction>;
  40038. /**
  40039. * @hidden
  40040. * Defines the actions happening when a pointer move event happens.
  40041. */
  40042. _pointerMoveStage: Stage<PointerMoveStageAction>;
  40043. /**
  40044. * @hidden
  40045. * Defines the actions happening when a pointer down event happens.
  40046. */
  40047. _pointerDownStage: Stage<PointerUpDownStageAction>;
  40048. /**
  40049. * @hidden
  40050. * Defines the actions happening when a pointer up event happens.
  40051. */
  40052. _pointerUpStage: Stage<PointerUpDownStageAction>;
  40053. /**
  40054. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  40055. */
  40056. private geometriesByUniqueId;
  40057. /**
  40058. * Creates a new Scene
  40059. * @param engine defines the engine to use to render this scene
  40060. * @param options defines the scene options
  40061. */
  40062. constructor(engine: Engine, options?: SceneOptions);
  40063. /**
  40064. * Gets a string idenfifying the name of the class
  40065. * @returns "Scene" string
  40066. */
  40067. getClassName(): string;
  40068. private _defaultMeshCandidates;
  40069. /**
  40070. * @hidden
  40071. */
  40072. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40073. private _defaultSubMeshCandidates;
  40074. /**
  40075. * @hidden
  40076. */
  40077. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40078. /**
  40079. * Sets the default candidate providers for the scene.
  40080. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  40081. * and getCollidingSubMeshCandidates to their default function
  40082. */
  40083. setDefaultCandidateProviders(): void;
  40084. /**
  40085. * Gets the mesh that is currently under the pointer
  40086. */
  40087. get meshUnderPointer(): Nullable<AbstractMesh>;
  40088. /**
  40089. * Gets or sets the current on-screen X position of the pointer
  40090. */
  40091. get pointerX(): number;
  40092. set pointerX(value: number);
  40093. /**
  40094. * Gets or sets the current on-screen Y position of the pointer
  40095. */
  40096. get pointerY(): number;
  40097. set pointerY(value: number);
  40098. /**
  40099. * Gets the cached material (ie. the latest rendered one)
  40100. * @returns the cached material
  40101. */
  40102. getCachedMaterial(): Nullable<Material>;
  40103. /**
  40104. * Gets the cached effect (ie. the latest rendered one)
  40105. * @returns the cached effect
  40106. */
  40107. getCachedEffect(): Nullable<Effect>;
  40108. /**
  40109. * Gets the cached visibility state (ie. the latest rendered one)
  40110. * @returns the cached visibility state
  40111. */
  40112. getCachedVisibility(): Nullable<number>;
  40113. /**
  40114. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  40115. * @param material defines the current material
  40116. * @param effect defines the current effect
  40117. * @param visibility defines the current visibility state
  40118. * @returns true if one parameter is not cached
  40119. */
  40120. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  40121. /**
  40122. * Gets the engine associated with the scene
  40123. * @returns an Engine
  40124. */
  40125. getEngine(): Engine;
  40126. /**
  40127. * Gets the total number of vertices rendered per frame
  40128. * @returns the total number of vertices rendered per frame
  40129. */
  40130. getTotalVertices(): number;
  40131. /**
  40132. * Gets the performance counter for total vertices
  40133. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40134. */
  40135. get totalVerticesPerfCounter(): PerfCounter;
  40136. /**
  40137. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  40138. * @returns the total number of active indices rendered per frame
  40139. */
  40140. getActiveIndices(): number;
  40141. /**
  40142. * Gets the performance counter for active indices
  40143. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40144. */
  40145. get totalActiveIndicesPerfCounter(): PerfCounter;
  40146. /**
  40147. * Gets the total number of active particles rendered per frame
  40148. * @returns the total number of active particles rendered per frame
  40149. */
  40150. getActiveParticles(): number;
  40151. /**
  40152. * Gets the performance counter for active particles
  40153. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40154. */
  40155. get activeParticlesPerfCounter(): PerfCounter;
  40156. /**
  40157. * Gets the total number of active bones rendered per frame
  40158. * @returns the total number of active bones rendered per frame
  40159. */
  40160. getActiveBones(): number;
  40161. /**
  40162. * Gets the performance counter for active bones
  40163. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40164. */
  40165. get activeBonesPerfCounter(): PerfCounter;
  40166. /**
  40167. * Gets the array of active meshes
  40168. * @returns an array of AbstractMesh
  40169. */
  40170. getActiveMeshes(): SmartArray<AbstractMesh>;
  40171. /**
  40172. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  40173. * @returns a number
  40174. */
  40175. getAnimationRatio(): number;
  40176. /**
  40177. * Gets an unique Id for the current render phase
  40178. * @returns a number
  40179. */
  40180. getRenderId(): number;
  40181. /**
  40182. * Gets an unique Id for the current frame
  40183. * @returns a number
  40184. */
  40185. getFrameId(): number;
  40186. /** Call this function if you want to manually increment the render Id*/
  40187. incrementRenderId(): void;
  40188. private _createUbo;
  40189. /**
  40190. * Use this method to simulate a pointer move on a mesh
  40191. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40192. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40193. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40194. * @returns the current scene
  40195. */
  40196. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40197. /**
  40198. * Use this method to simulate a pointer down on a mesh
  40199. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40200. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40201. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40202. * @returns the current scene
  40203. */
  40204. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40205. /**
  40206. * Use this method to simulate a pointer up on a mesh
  40207. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40208. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40209. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40210. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40211. * @returns the current scene
  40212. */
  40213. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  40214. /**
  40215. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40216. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40217. * @returns true if the pointer was captured
  40218. */
  40219. isPointerCaptured(pointerId?: number): boolean;
  40220. /**
  40221. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40222. * @param attachUp defines if you want to attach events to pointerup
  40223. * @param attachDown defines if you want to attach events to pointerdown
  40224. * @param attachMove defines if you want to attach events to pointermove
  40225. */
  40226. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  40227. /** Detaches all event handlers*/
  40228. detachControl(): void;
  40229. /**
  40230. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  40231. * Delay loaded resources are not taking in account
  40232. * @return true if all required resources are ready
  40233. */
  40234. isReady(): boolean;
  40235. /** Resets all cached information relative to material (including effect and visibility) */
  40236. resetCachedMaterial(): void;
  40237. /**
  40238. * Registers a function to be called before every frame render
  40239. * @param func defines the function to register
  40240. */
  40241. registerBeforeRender(func: () => void): void;
  40242. /**
  40243. * Unregisters a function called before every frame render
  40244. * @param func defines the function to unregister
  40245. */
  40246. unregisterBeforeRender(func: () => void): void;
  40247. /**
  40248. * Registers a function to be called after every frame render
  40249. * @param func defines the function to register
  40250. */
  40251. registerAfterRender(func: () => void): void;
  40252. /**
  40253. * Unregisters a function called after every frame render
  40254. * @param func defines the function to unregister
  40255. */
  40256. unregisterAfterRender(func: () => void): void;
  40257. private _executeOnceBeforeRender;
  40258. /**
  40259. * The provided function will run before render once and will be disposed afterwards.
  40260. * A timeout delay can be provided so that the function will be executed in N ms.
  40261. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  40262. * @param func The function to be executed.
  40263. * @param timeout optional delay in ms
  40264. */
  40265. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  40266. /** @hidden */
  40267. _addPendingData(data: any): void;
  40268. /** @hidden */
  40269. _removePendingData(data: any): void;
  40270. /**
  40271. * Returns the number of items waiting to be loaded
  40272. * @returns the number of items waiting to be loaded
  40273. */
  40274. getWaitingItemsCount(): number;
  40275. /**
  40276. * Returns a boolean indicating if the scene is still loading data
  40277. */
  40278. get isLoading(): boolean;
  40279. /**
  40280. * Registers a function to be executed when the scene is ready
  40281. * @param {Function} func - the function to be executed
  40282. */
  40283. executeWhenReady(func: () => void): void;
  40284. /**
  40285. * Returns a promise that resolves when the scene is ready
  40286. * @returns A promise that resolves when the scene is ready
  40287. */
  40288. whenReadyAsync(): Promise<void>;
  40289. /** @hidden */
  40290. _checkIsReady(): void;
  40291. /**
  40292. * Gets all animatable attached to the scene
  40293. */
  40294. get animatables(): Animatable[];
  40295. /**
  40296. * Resets the last animation time frame.
  40297. * Useful to override when animations start running when loading a scene for the first time.
  40298. */
  40299. resetLastAnimationTimeFrame(): void;
  40300. /**
  40301. * Gets the current view matrix
  40302. * @returns a Matrix
  40303. */
  40304. getViewMatrix(): Matrix;
  40305. /**
  40306. * Gets the current projection matrix
  40307. * @returns a Matrix
  40308. */
  40309. getProjectionMatrix(): Matrix;
  40310. /**
  40311. * Gets the current transform matrix
  40312. * @returns a Matrix made of View * Projection
  40313. */
  40314. getTransformMatrix(): Matrix;
  40315. /**
  40316. * Sets the current transform matrix
  40317. * @param viewL defines the View matrix to use
  40318. * @param projectionL defines the Projection matrix to use
  40319. * @param viewR defines the right View matrix to use (if provided)
  40320. * @param projectionR defines the right Projection matrix to use (if provided)
  40321. */
  40322. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  40323. /**
  40324. * Gets the uniform buffer used to store scene data
  40325. * @returns a UniformBuffer
  40326. */
  40327. getSceneUniformBuffer(): UniformBuffer;
  40328. /**
  40329. * Gets an unique (relatively to the current scene) Id
  40330. * @returns an unique number for the scene
  40331. */
  40332. getUniqueId(): number;
  40333. /**
  40334. * Add a mesh to the list of scene's meshes
  40335. * @param newMesh defines the mesh to add
  40336. * @param recursive if all child meshes should also be added to the scene
  40337. */
  40338. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  40339. /**
  40340. * Remove a mesh for the list of scene's meshes
  40341. * @param toRemove defines the mesh to remove
  40342. * @param recursive if all child meshes should also be removed from the scene
  40343. * @returns the index where the mesh was in the mesh list
  40344. */
  40345. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  40346. /**
  40347. * Add a transform node to the list of scene's transform nodes
  40348. * @param newTransformNode defines the transform node to add
  40349. */
  40350. addTransformNode(newTransformNode: TransformNode): void;
  40351. /**
  40352. * Remove a transform node for the list of scene's transform nodes
  40353. * @param toRemove defines the transform node to remove
  40354. * @returns the index where the transform node was in the transform node list
  40355. */
  40356. removeTransformNode(toRemove: TransformNode): number;
  40357. /**
  40358. * Remove a skeleton for the list of scene's skeletons
  40359. * @param toRemove defines the skeleton to remove
  40360. * @returns the index where the skeleton was in the skeleton list
  40361. */
  40362. removeSkeleton(toRemove: Skeleton): number;
  40363. /**
  40364. * Remove a morph target for the list of scene's morph targets
  40365. * @param toRemove defines the morph target to remove
  40366. * @returns the index where the morph target was in the morph target list
  40367. */
  40368. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  40369. /**
  40370. * Remove a light for the list of scene's lights
  40371. * @param toRemove defines the light to remove
  40372. * @returns the index where the light was in the light list
  40373. */
  40374. removeLight(toRemove: Light): number;
  40375. /**
  40376. * Remove a camera for the list of scene's cameras
  40377. * @param toRemove defines the camera to remove
  40378. * @returns the index where the camera was in the camera list
  40379. */
  40380. removeCamera(toRemove: Camera): number;
  40381. /**
  40382. * Remove a particle system for the list of scene's particle systems
  40383. * @param toRemove defines the particle system to remove
  40384. * @returns the index where the particle system was in the particle system list
  40385. */
  40386. removeParticleSystem(toRemove: IParticleSystem): number;
  40387. /**
  40388. * Remove a animation for the list of scene's animations
  40389. * @param toRemove defines the animation to remove
  40390. * @returns the index where the animation was in the animation list
  40391. */
  40392. removeAnimation(toRemove: Animation): number;
  40393. /**
  40394. * Will stop the animation of the given target
  40395. * @param target - the target
  40396. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  40397. * @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)
  40398. */
  40399. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  40400. /**
  40401. * Removes the given animation group from this scene.
  40402. * @param toRemove The animation group to remove
  40403. * @returns The index of the removed animation group
  40404. */
  40405. removeAnimationGroup(toRemove: AnimationGroup): number;
  40406. /**
  40407. * Removes the given multi-material from this scene.
  40408. * @param toRemove The multi-material to remove
  40409. * @returns The index of the removed multi-material
  40410. */
  40411. removeMultiMaterial(toRemove: MultiMaterial): number;
  40412. /**
  40413. * Removes the given material from this scene.
  40414. * @param toRemove The material to remove
  40415. * @returns The index of the removed material
  40416. */
  40417. removeMaterial(toRemove: Material): number;
  40418. /**
  40419. * Removes the given action manager from this scene.
  40420. * @param toRemove The action manager to remove
  40421. * @returns The index of the removed action manager
  40422. */
  40423. removeActionManager(toRemove: AbstractActionManager): number;
  40424. /**
  40425. * Removes the given texture from this scene.
  40426. * @param toRemove The texture to remove
  40427. * @returns The index of the removed texture
  40428. */
  40429. removeTexture(toRemove: BaseTexture): number;
  40430. /**
  40431. * Adds the given light to this scene
  40432. * @param newLight The light to add
  40433. */
  40434. addLight(newLight: Light): void;
  40435. /**
  40436. * Sorts the list list based on light priorities
  40437. */
  40438. sortLightsByPriority(): void;
  40439. /**
  40440. * Adds the given camera to this scene
  40441. * @param newCamera The camera to add
  40442. */
  40443. addCamera(newCamera: Camera): void;
  40444. /**
  40445. * Adds the given skeleton to this scene
  40446. * @param newSkeleton The skeleton to add
  40447. */
  40448. addSkeleton(newSkeleton: Skeleton): void;
  40449. /**
  40450. * Adds the given particle system to this scene
  40451. * @param newParticleSystem The particle system to add
  40452. */
  40453. addParticleSystem(newParticleSystem: IParticleSystem): void;
  40454. /**
  40455. * Adds the given animation to this scene
  40456. * @param newAnimation The animation to add
  40457. */
  40458. addAnimation(newAnimation: Animation): void;
  40459. /**
  40460. * Adds the given animation group to this scene.
  40461. * @param newAnimationGroup The animation group to add
  40462. */
  40463. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  40464. /**
  40465. * Adds the given multi-material to this scene
  40466. * @param newMultiMaterial The multi-material to add
  40467. */
  40468. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  40469. /**
  40470. * Adds the given material to this scene
  40471. * @param newMaterial The material to add
  40472. */
  40473. addMaterial(newMaterial: Material): void;
  40474. /**
  40475. * Adds the given morph target to this scene
  40476. * @param newMorphTargetManager The morph target to add
  40477. */
  40478. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  40479. /**
  40480. * Adds the given geometry to this scene
  40481. * @param newGeometry The geometry to add
  40482. */
  40483. addGeometry(newGeometry: Geometry): void;
  40484. /**
  40485. * Adds the given action manager to this scene
  40486. * @param newActionManager The action manager to add
  40487. */
  40488. addActionManager(newActionManager: AbstractActionManager): void;
  40489. /**
  40490. * Adds the given texture to this scene.
  40491. * @param newTexture The texture to add
  40492. */
  40493. addTexture(newTexture: BaseTexture): void;
  40494. /**
  40495. * Switch active camera
  40496. * @param newCamera defines the new active camera
  40497. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  40498. */
  40499. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  40500. /**
  40501. * sets the active camera of the scene using its ID
  40502. * @param id defines the camera's ID
  40503. * @return the new active camera or null if none found.
  40504. */
  40505. setActiveCameraByID(id: string): Nullable<Camera>;
  40506. /**
  40507. * sets the active camera of the scene using its name
  40508. * @param name defines the camera's name
  40509. * @returns the new active camera or null if none found.
  40510. */
  40511. setActiveCameraByName(name: string): Nullable<Camera>;
  40512. /**
  40513. * get an animation group using its name
  40514. * @param name defines the material's name
  40515. * @return the animation group or null if none found.
  40516. */
  40517. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  40518. /**
  40519. * Get a material using its unique id
  40520. * @param uniqueId defines the material's unique id
  40521. * @return the material or null if none found.
  40522. */
  40523. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  40524. /**
  40525. * get a material using its id
  40526. * @param id defines the material's ID
  40527. * @return the material or null if none found.
  40528. */
  40529. getMaterialByID(id: string): Nullable<Material>;
  40530. /**
  40531. * Gets a the last added material using a given id
  40532. * @param id defines the material's ID
  40533. * @return the last material with the given id or null if none found.
  40534. */
  40535. getLastMaterialByID(id: string): Nullable<Material>;
  40536. /**
  40537. * Gets a material using its name
  40538. * @param name defines the material's name
  40539. * @return the material or null if none found.
  40540. */
  40541. getMaterialByName(name: string): Nullable<Material>;
  40542. /**
  40543. * Get a texture using its unique id
  40544. * @param uniqueId defines the texture's unique id
  40545. * @return the texture or null if none found.
  40546. */
  40547. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  40548. /**
  40549. * Gets a camera using its id
  40550. * @param id defines the id to look for
  40551. * @returns the camera or null if not found
  40552. */
  40553. getCameraByID(id: string): Nullable<Camera>;
  40554. /**
  40555. * Gets a camera using its unique id
  40556. * @param uniqueId defines the unique id to look for
  40557. * @returns the camera or null if not found
  40558. */
  40559. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  40560. /**
  40561. * Gets a camera using its name
  40562. * @param name defines the camera's name
  40563. * @return the camera or null if none found.
  40564. */
  40565. getCameraByName(name: string): Nullable<Camera>;
  40566. /**
  40567. * Gets a bone using its id
  40568. * @param id defines the bone's id
  40569. * @return the bone or null if not found
  40570. */
  40571. getBoneByID(id: string): Nullable<Bone>;
  40572. /**
  40573. * Gets a bone using its id
  40574. * @param name defines the bone's name
  40575. * @return the bone or null if not found
  40576. */
  40577. getBoneByName(name: string): Nullable<Bone>;
  40578. /**
  40579. * Gets a light node using its name
  40580. * @param name defines the the light's name
  40581. * @return the light or null if none found.
  40582. */
  40583. getLightByName(name: string): Nullable<Light>;
  40584. /**
  40585. * Gets a light node using its id
  40586. * @param id defines the light's id
  40587. * @return the light or null if none found.
  40588. */
  40589. getLightByID(id: string): Nullable<Light>;
  40590. /**
  40591. * Gets a light node using its scene-generated unique ID
  40592. * @param uniqueId defines the light's unique id
  40593. * @return the light or null if none found.
  40594. */
  40595. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  40596. /**
  40597. * Gets a particle system by id
  40598. * @param id defines the particle system id
  40599. * @return the corresponding system or null if none found
  40600. */
  40601. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  40602. /**
  40603. * Gets a geometry using its ID
  40604. * @param id defines the geometry's id
  40605. * @return the geometry or null if none found.
  40606. */
  40607. getGeometryByID(id: string): Nullable<Geometry>;
  40608. private _getGeometryByUniqueID;
  40609. /**
  40610. * Add a new geometry to this scene
  40611. * @param geometry defines the geometry to be added to the scene.
  40612. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  40613. * @return a boolean defining if the geometry was added or not
  40614. */
  40615. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  40616. /**
  40617. * Removes an existing geometry
  40618. * @param geometry defines the geometry to be removed from the scene
  40619. * @return a boolean defining if the geometry was removed or not
  40620. */
  40621. removeGeometry(geometry: Geometry): boolean;
  40622. /**
  40623. * Gets the list of geometries attached to the scene
  40624. * @returns an array of Geometry
  40625. */
  40626. getGeometries(): Geometry[];
  40627. /**
  40628. * Gets the first added mesh found of a given ID
  40629. * @param id defines the id to search for
  40630. * @return the mesh found or null if not found at all
  40631. */
  40632. getMeshByID(id: string): Nullable<AbstractMesh>;
  40633. /**
  40634. * Gets a list of meshes using their id
  40635. * @param id defines the id to search for
  40636. * @returns a list of meshes
  40637. */
  40638. getMeshesByID(id: string): Array<AbstractMesh>;
  40639. /**
  40640. * Gets the first added transform node found of a given ID
  40641. * @param id defines the id to search for
  40642. * @return the found transform node or null if not found at all.
  40643. */
  40644. getTransformNodeByID(id: string): Nullable<TransformNode>;
  40645. /**
  40646. * Gets a transform node with its auto-generated unique id
  40647. * @param uniqueId efines the unique id to search for
  40648. * @return the found transform node or null if not found at all.
  40649. */
  40650. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  40651. /**
  40652. * Gets a list of transform nodes using their id
  40653. * @param id defines the id to search for
  40654. * @returns a list of transform nodes
  40655. */
  40656. getTransformNodesByID(id: string): Array<TransformNode>;
  40657. /**
  40658. * Gets a mesh with its auto-generated unique id
  40659. * @param uniqueId defines the unique id to search for
  40660. * @return the found mesh or null if not found at all.
  40661. */
  40662. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  40663. /**
  40664. * Gets a the last added mesh using a given id
  40665. * @param id defines the id to search for
  40666. * @return the found mesh or null if not found at all.
  40667. */
  40668. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  40669. /**
  40670. * Gets a the last added node (Mesh, Camera, Light) using a given id
  40671. * @param id defines the id to search for
  40672. * @return the found node or null if not found at all
  40673. */
  40674. getLastEntryByID(id: string): Nullable<Node>;
  40675. /**
  40676. * Gets a node (Mesh, Camera, Light) using a given id
  40677. * @param id defines the id to search for
  40678. * @return the found node or null if not found at all
  40679. */
  40680. getNodeByID(id: string): Nullable<Node>;
  40681. /**
  40682. * Gets a node (Mesh, Camera, Light) using a given name
  40683. * @param name defines the name to search for
  40684. * @return the found node or null if not found at all.
  40685. */
  40686. getNodeByName(name: string): Nullable<Node>;
  40687. /**
  40688. * Gets a mesh using a given name
  40689. * @param name defines the name to search for
  40690. * @return the found mesh or null if not found at all.
  40691. */
  40692. getMeshByName(name: string): Nullable<AbstractMesh>;
  40693. /**
  40694. * Gets a transform node using a given name
  40695. * @param name defines the name to search for
  40696. * @return the found transform node or null if not found at all.
  40697. */
  40698. getTransformNodeByName(name: string): Nullable<TransformNode>;
  40699. /**
  40700. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  40701. * @param id defines the id to search for
  40702. * @return the found skeleton or null if not found at all.
  40703. */
  40704. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  40705. /**
  40706. * Gets a skeleton using a given auto generated unique id
  40707. * @param uniqueId defines the unique id to search for
  40708. * @return the found skeleton or null if not found at all.
  40709. */
  40710. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  40711. /**
  40712. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  40713. * @param id defines the id to search for
  40714. * @return the found skeleton or null if not found at all.
  40715. */
  40716. getSkeletonById(id: string): Nullable<Skeleton>;
  40717. /**
  40718. * Gets a skeleton using a given name
  40719. * @param name defines the name to search for
  40720. * @return the found skeleton or null if not found at all.
  40721. */
  40722. getSkeletonByName(name: string): Nullable<Skeleton>;
  40723. /**
  40724. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  40725. * @param id defines the id to search for
  40726. * @return the found morph target manager or null if not found at all.
  40727. */
  40728. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  40729. /**
  40730. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  40731. * @param id defines the id to search for
  40732. * @return the found morph target or null if not found at all.
  40733. */
  40734. getMorphTargetById(id: string): Nullable<MorphTarget>;
  40735. /**
  40736. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  40737. * @param name defines the name to search for
  40738. * @return the found morph target or null if not found at all.
  40739. */
  40740. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  40741. /**
  40742. * Gets a boolean indicating if the given mesh is active
  40743. * @param mesh defines the mesh to look for
  40744. * @returns true if the mesh is in the active list
  40745. */
  40746. isActiveMesh(mesh: AbstractMesh): boolean;
  40747. /**
  40748. * Return a unique id as a string which can serve as an identifier for the scene
  40749. */
  40750. get uid(): string;
  40751. /**
  40752. * Add an externaly attached data from its key.
  40753. * This method call will fail and return false, if such key already exists.
  40754. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  40755. * @param key the unique key that identifies the data
  40756. * @param data the data object to associate to the key for this Engine instance
  40757. * @return true if no such key were already present and the data was added successfully, false otherwise
  40758. */
  40759. addExternalData<T>(key: string, data: T): boolean;
  40760. /**
  40761. * Get an externaly attached data from its key
  40762. * @param key the unique key that identifies the data
  40763. * @return the associated data, if present (can be null), or undefined if not present
  40764. */
  40765. getExternalData<T>(key: string): Nullable<T>;
  40766. /**
  40767. * Get an externaly attached data from its key, create it using a factory if it's not already present
  40768. * @param key the unique key that identifies the data
  40769. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  40770. * @return the associated data, can be null if the factory returned null.
  40771. */
  40772. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  40773. /**
  40774. * Remove an externaly attached data from the Engine instance
  40775. * @param key the unique key that identifies the data
  40776. * @return true if the data was successfully removed, false if it doesn't exist
  40777. */
  40778. removeExternalData(key: string): boolean;
  40779. private _evaluateSubMesh;
  40780. /**
  40781. * Clear the processed materials smart array preventing retention point in material dispose.
  40782. */
  40783. freeProcessedMaterials(): void;
  40784. private _preventFreeActiveMeshesAndRenderingGroups;
  40785. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  40786. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  40787. * when disposing several meshes in a row or a hierarchy of meshes.
  40788. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  40789. */
  40790. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  40791. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  40792. /**
  40793. * Clear the active meshes smart array preventing retention point in mesh dispose.
  40794. */
  40795. freeActiveMeshes(): void;
  40796. /**
  40797. * Clear the info related to rendering groups preventing retention points during dispose.
  40798. */
  40799. freeRenderingGroups(): void;
  40800. /** @hidden */
  40801. _isInIntermediateRendering(): boolean;
  40802. /**
  40803. * Lambda returning the list of potentially active meshes.
  40804. */
  40805. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  40806. /**
  40807. * Lambda returning the list of potentially active sub meshes.
  40808. */
  40809. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  40810. /**
  40811. * Lambda returning the list of potentially intersecting sub meshes.
  40812. */
  40813. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  40814. /**
  40815. * Lambda returning the list of potentially colliding sub meshes.
  40816. */
  40817. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  40818. private _activeMeshesFrozen;
  40819. private _skipEvaluateActiveMeshesCompletely;
  40820. /**
  40821. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  40822. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  40823. * @returns the current scene
  40824. */
  40825. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  40826. /**
  40827. * Use this function to restart evaluating active meshes on every frame
  40828. * @returns the current scene
  40829. */
  40830. unfreezeActiveMeshes(): Scene;
  40831. private _evaluateActiveMeshes;
  40832. private _activeMesh;
  40833. /**
  40834. * Update the transform matrix to update from the current active camera
  40835. * @param force defines a boolean used to force the update even if cache is up to date
  40836. */
  40837. updateTransformMatrix(force?: boolean): void;
  40838. private _bindFrameBuffer;
  40839. /** @hidden */
  40840. _allowPostProcessClearColor: boolean;
  40841. /** @hidden */
  40842. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  40843. private _processSubCameras;
  40844. private _checkIntersections;
  40845. /** @hidden */
  40846. _advancePhysicsEngineStep(step: number): void;
  40847. /**
  40848. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  40849. */
  40850. getDeterministicFrameTime: () => number;
  40851. /** @hidden */
  40852. _animate(): void;
  40853. /** Execute all animations (for a frame) */
  40854. animate(): void;
  40855. /**
  40856. * Render the scene
  40857. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  40858. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  40859. */
  40860. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  40861. /**
  40862. * Freeze all materials
  40863. * A frozen material will not be updatable but should be faster to render
  40864. */
  40865. freezeMaterials(): void;
  40866. /**
  40867. * Unfreeze all materials
  40868. * A frozen material will not be updatable but should be faster to render
  40869. */
  40870. unfreezeMaterials(): void;
  40871. /**
  40872. * Releases all held ressources
  40873. */
  40874. dispose(): void;
  40875. /**
  40876. * Gets if the scene is already disposed
  40877. */
  40878. get isDisposed(): boolean;
  40879. /**
  40880. * Call this function to reduce memory footprint of the scene.
  40881. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  40882. */
  40883. clearCachedVertexData(): void;
  40884. /**
  40885. * This function will remove the local cached buffer data from texture.
  40886. * It will save memory but will prevent the texture from being rebuilt
  40887. */
  40888. cleanCachedTextureBuffer(): void;
  40889. /**
  40890. * Get the world extend vectors with an optional filter
  40891. *
  40892. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  40893. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  40894. */
  40895. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  40896. min: Vector3;
  40897. max: Vector3;
  40898. };
  40899. /**
  40900. * Creates a ray that can be used to pick in the scene
  40901. * @param x defines the x coordinate of the origin (on-screen)
  40902. * @param y defines the y coordinate of the origin (on-screen)
  40903. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  40904. * @param camera defines the camera to use for the picking
  40905. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  40906. * @returns a Ray
  40907. */
  40908. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  40909. /**
  40910. * Creates a ray that can be used to pick in the scene
  40911. * @param x defines the x coordinate of the origin (on-screen)
  40912. * @param y defines the y coordinate of the origin (on-screen)
  40913. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  40914. * @param result defines the ray where to store the picking ray
  40915. * @param camera defines the camera to use for the picking
  40916. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  40917. * @returns the current scene
  40918. */
  40919. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  40920. /**
  40921. * Creates a ray that can be used to pick in the scene
  40922. * @param x defines the x coordinate of the origin (on-screen)
  40923. * @param y defines the y coordinate of the origin (on-screen)
  40924. * @param camera defines the camera to use for the picking
  40925. * @returns a Ray
  40926. */
  40927. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  40928. /**
  40929. * Creates a ray that can be used to pick in the scene
  40930. * @param x defines the x coordinate of the origin (on-screen)
  40931. * @param y defines the y coordinate of the origin (on-screen)
  40932. * @param result defines the ray where to store the picking ray
  40933. * @param camera defines the camera to use for the picking
  40934. * @returns the current scene
  40935. */
  40936. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  40937. /** Launch a ray to try to pick a mesh in the scene
  40938. * @param x position on screen
  40939. * @param y position on screen
  40940. * @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
  40941. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40942. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40943. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40944. * @returns a PickingInfo
  40945. */
  40946. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  40947. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  40948. * @param x position on screen
  40949. * @param y position on screen
  40950. * @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
  40951. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40952. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40953. * @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)
  40954. */
  40955. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  40956. /** Use the given ray to pick a mesh in the scene
  40957. * @param ray The ray to use to pick meshes
  40958. * @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
  40959. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40960. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40961. * @returns a PickingInfo
  40962. */
  40963. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  40964. /**
  40965. * Launch a ray to try to pick a mesh in the scene
  40966. * @param x X position on screen
  40967. * @param y Y position on screen
  40968. * @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
  40969. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40970. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40971. * @returns an array of PickingInfo
  40972. */
  40973. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  40974. /**
  40975. * Launch a ray to try to pick a mesh in the scene
  40976. * @param ray Ray to use
  40977. * @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
  40978. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40979. * @returns an array of PickingInfo
  40980. */
  40981. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  40982. /**
  40983. * Force the value of meshUnderPointer
  40984. * @param mesh defines the mesh to use
  40985. */
  40986. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  40987. /**
  40988. * Gets the mesh under the pointer
  40989. * @returns a Mesh or null if no mesh is under the pointer
  40990. */
  40991. getPointerOverMesh(): Nullable<AbstractMesh>;
  40992. /** @hidden */
  40993. _rebuildGeometries(): void;
  40994. /** @hidden */
  40995. _rebuildTextures(): void;
  40996. private _getByTags;
  40997. /**
  40998. * Get a list of meshes by tags
  40999. * @param tagsQuery defines the tags query to use
  41000. * @param forEach defines a predicate used to filter results
  41001. * @returns an array of Mesh
  41002. */
  41003. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  41004. /**
  41005. * Get a list of cameras by tags
  41006. * @param tagsQuery defines the tags query to use
  41007. * @param forEach defines a predicate used to filter results
  41008. * @returns an array of Camera
  41009. */
  41010. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  41011. /**
  41012. * Get a list of lights by tags
  41013. * @param tagsQuery defines the tags query to use
  41014. * @param forEach defines a predicate used to filter results
  41015. * @returns an array of Light
  41016. */
  41017. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  41018. /**
  41019. * Get a list of materials by tags
  41020. * @param tagsQuery defines the tags query to use
  41021. * @param forEach defines a predicate used to filter results
  41022. * @returns an array of Material
  41023. */
  41024. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  41025. /**
  41026. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  41027. * This allowed control for front to back rendering or reversly depending of the special needs.
  41028. *
  41029. * @param renderingGroupId The rendering group id corresponding to its index
  41030. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  41031. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  41032. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  41033. */
  41034. 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;
  41035. /**
  41036. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  41037. *
  41038. * @param renderingGroupId The rendering group id corresponding to its index
  41039. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  41040. * @param depth Automatically clears depth between groups if true and autoClear is true.
  41041. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  41042. */
  41043. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  41044. /**
  41045. * Gets the current auto clear configuration for one rendering group of the rendering
  41046. * manager.
  41047. * @param index the rendering group index to get the information for
  41048. * @returns The auto clear setup for the requested rendering group
  41049. */
  41050. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  41051. private _blockMaterialDirtyMechanism;
  41052. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  41053. get blockMaterialDirtyMechanism(): boolean;
  41054. set blockMaterialDirtyMechanism(value: boolean);
  41055. /**
  41056. * Will flag all materials as dirty to trigger new shader compilation
  41057. * @param flag defines the flag used to specify which material part must be marked as dirty
  41058. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  41059. */
  41060. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41061. /** @hidden */
  41062. _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;
  41063. /** @hidden */
  41064. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41065. /** @hidden */
  41066. _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;
  41067. /** @hidden */
  41068. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  41069. /** @hidden */
  41070. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41071. /** @hidden */
  41072. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41073. }
  41074. }
  41075. declare module BABYLON {
  41076. /**
  41077. * Set of assets to keep when moving a scene into an asset container.
  41078. */
  41079. export class KeepAssets extends AbstractScene {
  41080. }
  41081. /**
  41082. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  41083. */
  41084. export class InstantiatedEntries {
  41085. /**
  41086. * List of new root nodes (eg. nodes with no parent)
  41087. */
  41088. rootNodes: TransformNode[];
  41089. /**
  41090. * List of new skeletons
  41091. */
  41092. skeletons: Skeleton[];
  41093. /**
  41094. * List of new animation groups
  41095. */
  41096. animationGroups: AnimationGroup[];
  41097. }
  41098. /**
  41099. * Container with a set of assets that can be added or removed from a scene.
  41100. */
  41101. export class AssetContainer extends AbstractScene {
  41102. private _wasAddedToScene;
  41103. /**
  41104. * The scene the AssetContainer belongs to.
  41105. */
  41106. scene: Scene;
  41107. /**
  41108. * Instantiates an AssetContainer.
  41109. * @param scene The scene the AssetContainer belongs to.
  41110. */
  41111. constructor(scene: Scene);
  41112. /**
  41113. * Instantiate or clone all meshes and add the new ones to the scene.
  41114. * Skeletons and animation groups will all be cloned
  41115. * @param nameFunction defines an optional function used to get new names for clones
  41116. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  41117. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  41118. */
  41119. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  41120. /**
  41121. * Adds all the assets from the container to the scene.
  41122. */
  41123. addAllToScene(): void;
  41124. /**
  41125. * Removes all the assets in the container from the scene
  41126. */
  41127. removeAllFromScene(): void;
  41128. /**
  41129. * Disposes all the assets in the container
  41130. */
  41131. dispose(): void;
  41132. private _moveAssets;
  41133. /**
  41134. * Removes all the assets contained in the scene and adds them to the container.
  41135. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  41136. */
  41137. moveAllFromScene(keepAssets?: KeepAssets): void;
  41138. /**
  41139. * 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.
  41140. * @returns the root mesh
  41141. */
  41142. createRootMesh(): Mesh;
  41143. /**
  41144. * Merge animations (direct and animation groups) from this asset container into a scene
  41145. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41146. * @param animatables set of animatables to retarget to a node from the scene
  41147. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  41148. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  41149. */
  41150. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  41151. }
  41152. }
  41153. declare module BABYLON {
  41154. /**
  41155. * Defines how the parser contract is defined.
  41156. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  41157. */
  41158. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  41159. /**
  41160. * Defines how the individual parser contract is defined.
  41161. * These parser can parse an individual asset
  41162. */
  41163. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  41164. /**
  41165. * Base class of the scene acting as a container for the different elements composing a scene.
  41166. * This class is dynamically extended by the different components of the scene increasing
  41167. * flexibility and reducing coupling
  41168. */
  41169. export abstract class AbstractScene {
  41170. /**
  41171. * Stores the list of available parsers in the application.
  41172. */
  41173. private static _BabylonFileParsers;
  41174. /**
  41175. * Stores the list of available individual parsers in the application.
  41176. */
  41177. private static _IndividualBabylonFileParsers;
  41178. /**
  41179. * Adds a parser in the list of available ones
  41180. * @param name Defines the name of the parser
  41181. * @param parser Defines the parser to add
  41182. */
  41183. static AddParser(name: string, parser: BabylonFileParser): void;
  41184. /**
  41185. * Gets a general parser from the list of avaialble ones
  41186. * @param name Defines the name of the parser
  41187. * @returns the requested parser or null
  41188. */
  41189. static GetParser(name: string): Nullable<BabylonFileParser>;
  41190. /**
  41191. * Adds n individual parser in the list of available ones
  41192. * @param name Defines the name of the parser
  41193. * @param parser Defines the parser to add
  41194. */
  41195. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  41196. /**
  41197. * Gets an individual parser from the list of avaialble ones
  41198. * @param name Defines the name of the parser
  41199. * @returns the requested parser or null
  41200. */
  41201. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  41202. /**
  41203. * Parser json data and populate both a scene and its associated container object
  41204. * @param jsonData Defines the data to parse
  41205. * @param scene Defines the scene to parse the data for
  41206. * @param container Defines the container attached to the parsing sequence
  41207. * @param rootUrl Defines the root url of the data
  41208. */
  41209. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  41210. /**
  41211. * Gets the list of root nodes (ie. nodes with no parent)
  41212. */
  41213. rootNodes: Node[];
  41214. /** All of the cameras added to this scene
  41215. * @see https://doc.babylonjs.com/babylon101/cameras
  41216. */
  41217. cameras: Camera[];
  41218. /**
  41219. * All of the lights added to this scene
  41220. * @see https://doc.babylonjs.com/babylon101/lights
  41221. */
  41222. lights: Light[];
  41223. /**
  41224. * All of the (abstract) meshes added to this scene
  41225. */
  41226. meshes: AbstractMesh[];
  41227. /**
  41228. * The list of skeletons added to the scene
  41229. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  41230. */
  41231. skeletons: Skeleton[];
  41232. /**
  41233. * All of the particle systems added to this scene
  41234. * @see https://doc.babylonjs.com/babylon101/particles
  41235. */
  41236. particleSystems: IParticleSystem[];
  41237. /**
  41238. * Gets a list of Animations associated with the scene
  41239. */
  41240. animations: Animation[];
  41241. /**
  41242. * All of the animation groups added to this scene
  41243. * @see https://doc.babylonjs.com/how_to/group
  41244. */
  41245. animationGroups: AnimationGroup[];
  41246. /**
  41247. * All of the multi-materials added to this scene
  41248. * @see https://doc.babylonjs.com/how_to/multi_materials
  41249. */
  41250. multiMaterials: MultiMaterial[];
  41251. /**
  41252. * All of the materials added to this scene
  41253. * In the context of a Scene, it is not supposed to be modified manually.
  41254. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  41255. * Note also that the order of the Material within the array is not significant and might change.
  41256. * @see https://doc.babylonjs.com/babylon101/materials
  41257. */
  41258. materials: Material[];
  41259. /**
  41260. * The list of morph target managers added to the scene
  41261. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  41262. */
  41263. morphTargetManagers: MorphTargetManager[];
  41264. /**
  41265. * The list of geometries used in the scene.
  41266. */
  41267. geometries: Geometry[];
  41268. /**
  41269. * All of the tranform nodes added to this scene
  41270. * In the context of a Scene, it is not supposed to be modified manually.
  41271. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  41272. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  41273. * @see https://doc.babylonjs.com/how_to/transformnode
  41274. */
  41275. transformNodes: TransformNode[];
  41276. /**
  41277. * ActionManagers available on the scene.
  41278. */
  41279. actionManagers: AbstractActionManager[];
  41280. /**
  41281. * Textures to keep.
  41282. */
  41283. textures: BaseTexture[];
  41284. /**
  41285. * Environment texture for the scene
  41286. */
  41287. environmentTexture: Nullable<BaseTexture>;
  41288. /**
  41289. * @returns all meshes, lights, cameras, transformNodes and bones
  41290. */
  41291. getNodes(): Array<Node>;
  41292. }
  41293. }
  41294. declare module BABYLON {
  41295. /**
  41296. * Interface used to define options for Sound class
  41297. */
  41298. export interface ISoundOptions {
  41299. /**
  41300. * Does the sound autoplay once loaded.
  41301. */
  41302. autoplay?: boolean;
  41303. /**
  41304. * Does the sound loop after it finishes playing once.
  41305. */
  41306. loop?: boolean;
  41307. /**
  41308. * Sound's volume
  41309. */
  41310. volume?: number;
  41311. /**
  41312. * Is it a spatial sound?
  41313. */
  41314. spatialSound?: boolean;
  41315. /**
  41316. * Maximum distance to hear that sound
  41317. */
  41318. maxDistance?: number;
  41319. /**
  41320. * Uses user defined attenuation function
  41321. */
  41322. useCustomAttenuation?: boolean;
  41323. /**
  41324. * Define the roll off factor of spatial sounds.
  41325. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41326. */
  41327. rolloffFactor?: number;
  41328. /**
  41329. * Define the reference distance the sound should be heard perfectly.
  41330. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41331. */
  41332. refDistance?: number;
  41333. /**
  41334. * Define the distance attenuation model the sound will follow.
  41335. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41336. */
  41337. distanceModel?: string;
  41338. /**
  41339. * Defines the playback speed (1 by default)
  41340. */
  41341. playbackRate?: number;
  41342. /**
  41343. * Defines if the sound is from a streaming source
  41344. */
  41345. streaming?: boolean;
  41346. /**
  41347. * Defines an optional length (in seconds) inside the sound file
  41348. */
  41349. length?: number;
  41350. /**
  41351. * Defines an optional offset (in seconds) inside the sound file
  41352. */
  41353. offset?: number;
  41354. /**
  41355. * If true, URLs will not be required to state the audio file codec to use.
  41356. */
  41357. skipCodecCheck?: boolean;
  41358. }
  41359. /**
  41360. * Defines a sound that can be played in the application.
  41361. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  41362. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41363. */
  41364. export class Sound {
  41365. /**
  41366. * The name of the sound in the scene.
  41367. */
  41368. name: string;
  41369. /**
  41370. * Does the sound autoplay once loaded.
  41371. */
  41372. autoplay: boolean;
  41373. /**
  41374. * Does the sound loop after it finishes playing once.
  41375. */
  41376. loop: boolean;
  41377. /**
  41378. * Does the sound use a custom attenuation curve to simulate the falloff
  41379. * happening when the source gets further away from the camera.
  41380. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41381. */
  41382. useCustomAttenuation: boolean;
  41383. /**
  41384. * The sound track id this sound belongs to.
  41385. */
  41386. soundTrackId: number;
  41387. /**
  41388. * Is this sound currently played.
  41389. */
  41390. isPlaying: boolean;
  41391. /**
  41392. * Is this sound currently paused.
  41393. */
  41394. isPaused: boolean;
  41395. /**
  41396. * Does this sound enables spatial sound.
  41397. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41398. */
  41399. spatialSound: boolean;
  41400. /**
  41401. * Define the reference distance the sound should be heard perfectly.
  41402. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41403. */
  41404. refDistance: number;
  41405. /**
  41406. * Define the roll off factor of spatial sounds.
  41407. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41408. */
  41409. rolloffFactor: number;
  41410. /**
  41411. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  41412. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41413. */
  41414. maxDistance: number;
  41415. /**
  41416. * Define the distance attenuation model the sound will follow.
  41417. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41418. */
  41419. distanceModel: string;
  41420. /**
  41421. * @hidden
  41422. * Back Compat
  41423. **/
  41424. onended: () => any;
  41425. /**
  41426. * Gets or sets an object used to store user defined information for the sound.
  41427. */
  41428. metadata: any;
  41429. /**
  41430. * Observable event when the current playing sound finishes.
  41431. */
  41432. onEndedObservable: Observable<Sound>;
  41433. private _panningModel;
  41434. private _playbackRate;
  41435. private _streaming;
  41436. private _startTime;
  41437. private _startOffset;
  41438. private _position;
  41439. /** @hidden */
  41440. _positionInEmitterSpace: boolean;
  41441. private _localDirection;
  41442. private _volume;
  41443. private _isReadyToPlay;
  41444. private _isDirectional;
  41445. private _readyToPlayCallback;
  41446. private _audioBuffer;
  41447. private _soundSource;
  41448. private _streamingSource;
  41449. private _soundPanner;
  41450. private _soundGain;
  41451. private _inputAudioNode;
  41452. private _outputAudioNode;
  41453. private _coneInnerAngle;
  41454. private _coneOuterAngle;
  41455. private _coneOuterGain;
  41456. private _scene;
  41457. private _connectedTransformNode;
  41458. private _customAttenuationFunction;
  41459. private _registerFunc;
  41460. private _isOutputConnected;
  41461. private _htmlAudioElement;
  41462. private _urlType;
  41463. private _length?;
  41464. private _offset?;
  41465. /** @hidden */
  41466. static _SceneComponentInitialization: (scene: Scene) => void;
  41467. /**
  41468. * Create a sound and attach it to a scene
  41469. * @param name Name of your sound
  41470. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  41471. * @param scene defines the scene the sound belongs to
  41472. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  41473. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  41474. */
  41475. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  41476. /**
  41477. * Release the sound and its associated resources
  41478. */
  41479. dispose(): void;
  41480. /**
  41481. * Gets if the sounds is ready to be played or not.
  41482. * @returns true if ready, otherwise false
  41483. */
  41484. isReady(): boolean;
  41485. private _soundLoaded;
  41486. /**
  41487. * Sets the data of the sound from an audiobuffer
  41488. * @param audioBuffer The audioBuffer containing the data
  41489. */
  41490. setAudioBuffer(audioBuffer: AudioBuffer): void;
  41491. /**
  41492. * Updates the current sounds options such as maxdistance, loop...
  41493. * @param options A JSON object containing values named as the object properties
  41494. */
  41495. updateOptions(options: ISoundOptions): void;
  41496. private _createSpatialParameters;
  41497. private _updateSpatialParameters;
  41498. /**
  41499. * Switch the panning model to HRTF:
  41500. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41501. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41502. */
  41503. switchPanningModelToHRTF(): void;
  41504. /**
  41505. * Switch the panning model to Equal Power:
  41506. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41507. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41508. */
  41509. switchPanningModelToEqualPower(): void;
  41510. private _switchPanningModel;
  41511. /**
  41512. * Connect this sound to a sound track audio node like gain...
  41513. * @param soundTrackAudioNode the sound track audio node to connect to
  41514. */
  41515. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  41516. /**
  41517. * Transform this sound into a directional source
  41518. * @param coneInnerAngle Size of the inner cone in degree
  41519. * @param coneOuterAngle Size of the outer cone in degree
  41520. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  41521. */
  41522. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  41523. /**
  41524. * Gets or sets the inner angle for the directional cone.
  41525. */
  41526. get directionalConeInnerAngle(): number;
  41527. /**
  41528. * Gets or sets the inner angle for the directional cone.
  41529. */
  41530. set directionalConeInnerAngle(value: number);
  41531. /**
  41532. * Gets or sets the outer angle for the directional cone.
  41533. */
  41534. get directionalConeOuterAngle(): number;
  41535. /**
  41536. * Gets or sets the outer angle for the directional cone.
  41537. */
  41538. set directionalConeOuterAngle(value: number);
  41539. /**
  41540. * Sets the position of the emitter if spatial sound is enabled
  41541. * @param newPosition Defines the new posisiton
  41542. */
  41543. setPosition(newPosition: Vector3): void;
  41544. /**
  41545. * Sets the local direction of the emitter if spatial sound is enabled
  41546. * @param newLocalDirection Defines the new local direction
  41547. */
  41548. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  41549. private _updateDirection;
  41550. /** @hidden */
  41551. updateDistanceFromListener(): void;
  41552. /**
  41553. * Sets a new custom attenuation function for the sound.
  41554. * @param callback Defines the function used for the attenuation
  41555. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41556. */
  41557. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  41558. /**
  41559. * Play the sound
  41560. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  41561. * @param offset (optional) Start the sound at a specific time in seconds
  41562. * @param length (optional) Sound duration (in seconds)
  41563. */
  41564. play(time?: number, offset?: number, length?: number): void;
  41565. private _onended;
  41566. /**
  41567. * Stop the sound
  41568. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  41569. */
  41570. stop(time?: number): void;
  41571. /**
  41572. * Put the sound in pause
  41573. */
  41574. pause(): void;
  41575. /**
  41576. * Sets a dedicated volume for this sounds
  41577. * @param newVolume Define the new volume of the sound
  41578. * @param time Define time for gradual change to new volume
  41579. */
  41580. setVolume(newVolume: number, time?: number): void;
  41581. /**
  41582. * Set the sound play back rate
  41583. * @param newPlaybackRate Define the playback rate the sound should be played at
  41584. */
  41585. setPlaybackRate(newPlaybackRate: number): void;
  41586. /**
  41587. * Gets the volume of the sound.
  41588. * @returns the volume of the sound
  41589. */
  41590. getVolume(): number;
  41591. /**
  41592. * Attach the sound to a dedicated mesh
  41593. * @param transformNode The transform node to connect the sound with
  41594. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41595. */
  41596. attachToMesh(transformNode: TransformNode): void;
  41597. /**
  41598. * Detach the sound from the previously attached mesh
  41599. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41600. */
  41601. detachFromMesh(): void;
  41602. private _onRegisterAfterWorldMatrixUpdate;
  41603. /**
  41604. * Clone the current sound in the scene.
  41605. * @returns the new sound clone
  41606. */
  41607. clone(): Nullable<Sound>;
  41608. /**
  41609. * Gets the current underlying audio buffer containing the data
  41610. * @returns the audio buffer
  41611. */
  41612. getAudioBuffer(): Nullable<AudioBuffer>;
  41613. /**
  41614. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  41615. * @returns the source node
  41616. */
  41617. getSoundSource(): Nullable<AudioBufferSourceNode>;
  41618. /**
  41619. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  41620. * @returns the gain node
  41621. */
  41622. getSoundGain(): Nullable<GainNode>;
  41623. /**
  41624. * Serializes the Sound in a JSON representation
  41625. * @returns the JSON representation of the sound
  41626. */
  41627. serialize(): any;
  41628. /**
  41629. * Parse a JSON representation of a sound to innstantiate in a given scene
  41630. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  41631. * @param scene Define the scene the new parsed sound should be created in
  41632. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  41633. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  41634. * @returns the newly parsed sound
  41635. */
  41636. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  41637. }
  41638. }
  41639. declare module BABYLON {
  41640. /**
  41641. * This defines an action helpful to play a defined sound on a triggered action.
  41642. */
  41643. export class PlaySoundAction extends Action {
  41644. private _sound;
  41645. /**
  41646. * Instantiate the action
  41647. * @param triggerOptions defines the trigger options
  41648. * @param sound defines the sound to play
  41649. * @param condition defines the trigger related conditions
  41650. */
  41651. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41652. /** @hidden */
  41653. _prepare(): void;
  41654. /**
  41655. * Execute the action and play the sound.
  41656. */
  41657. execute(): void;
  41658. /**
  41659. * Serializes the actions and its related information.
  41660. * @param parent defines the object to serialize in
  41661. * @returns the serialized object
  41662. */
  41663. serialize(parent: any): any;
  41664. }
  41665. /**
  41666. * This defines an action helpful to stop a defined sound on a triggered action.
  41667. */
  41668. export class StopSoundAction extends Action {
  41669. private _sound;
  41670. /**
  41671. * Instantiate the action
  41672. * @param triggerOptions defines the trigger options
  41673. * @param sound defines the sound to stop
  41674. * @param condition defines the trigger related conditions
  41675. */
  41676. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41677. /** @hidden */
  41678. _prepare(): void;
  41679. /**
  41680. * Execute the action and stop the sound.
  41681. */
  41682. execute(): void;
  41683. /**
  41684. * Serializes the actions and its related information.
  41685. * @param parent defines the object to serialize in
  41686. * @returns the serialized object
  41687. */
  41688. serialize(parent: any): any;
  41689. }
  41690. }
  41691. declare module BABYLON {
  41692. /**
  41693. * This defines an action responsible to change the value of a property
  41694. * by interpolating between its current value and the newly set one once triggered.
  41695. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  41696. */
  41697. export class InterpolateValueAction extends Action {
  41698. /**
  41699. * Defines the path of the property where the value should be interpolated
  41700. */
  41701. propertyPath: string;
  41702. /**
  41703. * Defines the target value at the end of the interpolation.
  41704. */
  41705. value: any;
  41706. /**
  41707. * Defines the time it will take for the property to interpolate to the value.
  41708. */
  41709. duration: number;
  41710. /**
  41711. * Defines if the other scene animations should be stopped when the action has been triggered
  41712. */
  41713. stopOtherAnimations?: boolean;
  41714. /**
  41715. * Defines a callback raised once the interpolation animation has been done.
  41716. */
  41717. onInterpolationDone?: () => void;
  41718. /**
  41719. * Observable triggered once the interpolation animation has been done.
  41720. */
  41721. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  41722. private _target;
  41723. private _effectiveTarget;
  41724. private _property;
  41725. /**
  41726. * Instantiate the action
  41727. * @param triggerOptions defines the trigger options
  41728. * @param target defines the object containing the value to interpolate
  41729. * @param propertyPath defines the path to the property in the target object
  41730. * @param value defines the target value at the end of the interpolation
  41731. * @param duration deines the time it will take for the property to interpolate to the value.
  41732. * @param condition defines the trigger related conditions
  41733. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  41734. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  41735. */
  41736. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  41737. /** @hidden */
  41738. _prepare(): void;
  41739. /**
  41740. * Execute the action starts the value interpolation.
  41741. */
  41742. execute(): void;
  41743. /**
  41744. * Serializes the actions and its related information.
  41745. * @param parent defines the object to serialize in
  41746. * @returns the serialized object
  41747. */
  41748. serialize(parent: any): any;
  41749. }
  41750. }
  41751. declare module BABYLON {
  41752. /**
  41753. * Options allowed during the creation of a sound track.
  41754. */
  41755. export interface ISoundTrackOptions {
  41756. /**
  41757. * The volume the sound track should take during creation
  41758. */
  41759. volume?: number;
  41760. /**
  41761. * Define if the sound track is the main sound track of the scene
  41762. */
  41763. mainTrack?: boolean;
  41764. }
  41765. /**
  41766. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  41767. * It will be also used in a future release to apply effects on a specific track.
  41768. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  41769. */
  41770. export class SoundTrack {
  41771. /**
  41772. * The unique identifier of the sound track in the scene.
  41773. */
  41774. id: number;
  41775. /**
  41776. * The list of sounds included in the sound track.
  41777. */
  41778. soundCollection: Array<Sound>;
  41779. private _outputAudioNode;
  41780. private _scene;
  41781. private _connectedAnalyser;
  41782. private _options;
  41783. private _isInitialized;
  41784. /**
  41785. * Creates a new sound track.
  41786. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  41787. * @param scene Define the scene the sound track belongs to
  41788. * @param options
  41789. */
  41790. constructor(scene: Scene, options?: ISoundTrackOptions);
  41791. private _initializeSoundTrackAudioGraph;
  41792. /**
  41793. * Release the sound track and its associated resources
  41794. */
  41795. dispose(): void;
  41796. /**
  41797. * Adds a sound to this sound track
  41798. * @param sound define the cound to add
  41799. * @ignoreNaming
  41800. */
  41801. AddSound(sound: Sound): void;
  41802. /**
  41803. * Removes a sound to this sound track
  41804. * @param sound define the cound to remove
  41805. * @ignoreNaming
  41806. */
  41807. RemoveSound(sound: Sound): void;
  41808. /**
  41809. * Set a global volume for the full sound track.
  41810. * @param newVolume Define the new volume of the sound track
  41811. */
  41812. setVolume(newVolume: number): void;
  41813. /**
  41814. * Switch the panning model to HRTF:
  41815. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41816. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41817. */
  41818. switchPanningModelToHRTF(): void;
  41819. /**
  41820. * Switch the panning model to Equal Power:
  41821. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41822. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41823. */
  41824. switchPanningModelToEqualPower(): void;
  41825. /**
  41826. * Connect the sound track to an audio analyser allowing some amazing
  41827. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41828. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41829. * @param analyser The analyser to connect to the engine
  41830. */
  41831. connectToAnalyser(analyser: Analyser): void;
  41832. }
  41833. }
  41834. declare module BABYLON {
  41835. interface AbstractScene {
  41836. /**
  41837. * The list of sounds used in the scene.
  41838. */
  41839. sounds: Nullable<Array<Sound>>;
  41840. }
  41841. interface Scene {
  41842. /**
  41843. * @hidden
  41844. * Backing field
  41845. */
  41846. _mainSoundTrack: SoundTrack;
  41847. /**
  41848. * The main sound track played by the scene.
  41849. * It cotains your primary collection of sounds.
  41850. */
  41851. mainSoundTrack: SoundTrack;
  41852. /**
  41853. * The list of sound tracks added to the scene
  41854. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41855. */
  41856. soundTracks: Nullable<Array<SoundTrack>>;
  41857. /**
  41858. * Gets a sound using a given name
  41859. * @param name defines the name to search for
  41860. * @return the found sound or null if not found at all.
  41861. */
  41862. getSoundByName(name: string): Nullable<Sound>;
  41863. /**
  41864. * Gets or sets if audio support is enabled
  41865. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41866. */
  41867. audioEnabled: boolean;
  41868. /**
  41869. * Gets or sets if audio will be output to headphones
  41870. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41871. */
  41872. headphone: boolean;
  41873. /**
  41874. * Gets or sets custom audio listener position provider
  41875. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41876. */
  41877. audioListenerPositionProvider: Nullable<() => Vector3>;
  41878. /**
  41879. * Gets or sets a refresh rate when using 3D audio positioning
  41880. */
  41881. audioPositioningRefreshRate: number;
  41882. }
  41883. /**
  41884. * Defines the sound scene component responsible to manage any sounds
  41885. * in a given scene.
  41886. */
  41887. export class AudioSceneComponent implements ISceneSerializableComponent {
  41888. /**
  41889. * The component name helpfull to identify the component in the list of scene components.
  41890. */
  41891. readonly name: string;
  41892. /**
  41893. * The scene the component belongs to.
  41894. */
  41895. scene: Scene;
  41896. private _audioEnabled;
  41897. /**
  41898. * Gets whether audio is enabled or not.
  41899. * Please use related enable/disable method to switch state.
  41900. */
  41901. get audioEnabled(): boolean;
  41902. private _headphone;
  41903. /**
  41904. * Gets whether audio is outputing to headphone or not.
  41905. * Please use the according Switch methods to change output.
  41906. */
  41907. get headphone(): boolean;
  41908. /**
  41909. * Gets or sets a refresh rate when using 3D audio positioning
  41910. */
  41911. audioPositioningRefreshRate: number;
  41912. private _audioListenerPositionProvider;
  41913. /**
  41914. * Gets the current audio listener position provider
  41915. */
  41916. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  41917. /**
  41918. * Sets a custom listener position for all sounds in the scene
  41919. * By default, this is the position of the first active camera
  41920. */
  41921. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  41922. /**
  41923. * Creates a new instance of the component for the given scene
  41924. * @param scene Defines the scene to register the component in
  41925. */
  41926. constructor(scene: Scene);
  41927. /**
  41928. * Registers the component in a given scene
  41929. */
  41930. register(): void;
  41931. /**
  41932. * Rebuilds the elements related to this component in case of
  41933. * context lost for instance.
  41934. */
  41935. rebuild(): void;
  41936. /**
  41937. * Serializes the component data to the specified json object
  41938. * @param serializationObject The object to serialize to
  41939. */
  41940. serialize(serializationObject: any): void;
  41941. /**
  41942. * Adds all the elements from the container to the scene
  41943. * @param container the container holding the elements
  41944. */
  41945. addFromContainer(container: AbstractScene): void;
  41946. /**
  41947. * Removes all the elements in the container from the scene
  41948. * @param container contains the elements to remove
  41949. * @param dispose if the removed element should be disposed (default: false)
  41950. */
  41951. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  41952. /**
  41953. * Disposes the component and the associated ressources.
  41954. */
  41955. dispose(): void;
  41956. /**
  41957. * Disables audio in the associated scene.
  41958. */
  41959. disableAudio(): void;
  41960. /**
  41961. * Enables audio in the associated scene.
  41962. */
  41963. enableAudio(): void;
  41964. /**
  41965. * Switch audio to headphone output.
  41966. */
  41967. switchAudioModeForHeadphones(): void;
  41968. /**
  41969. * Switch audio to normal speakers.
  41970. */
  41971. switchAudioModeForNormalSpeakers(): void;
  41972. private _cachedCameraDirection;
  41973. private _cachedCameraPosition;
  41974. private _lastCheck;
  41975. private _afterRender;
  41976. }
  41977. }
  41978. declare module BABYLON {
  41979. /**
  41980. * Wraps one or more Sound objects and selects one with random weight for playback.
  41981. */
  41982. export class WeightedSound {
  41983. /** When true a Sound will be selected and played when the current playing Sound completes. */
  41984. loop: boolean;
  41985. private _coneInnerAngle;
  41986. private _coneOuterAngle;
  41987. private _volume;
  41988. /** A Sound is currently playing. */
  41989. isPlaying: boolean;
  41990. /** A Sound is currently paused. */
  41991. isPaused: boolean;
  41992. private _sounds;
  41993. private _weights;
  41994. private _currentIndex?;
  41995. /**
  41996. * Creates a new WeightedSound from the list of sounds given.
  41997. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  41998. * @param sounds Array of Sounds that will be selected from.
  41999. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  42000. */
  42001. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  42002. /**
  42003. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  42004. */
  42005. get directionalConeInnerAngle(): number;
  42006. /**
  42007. * The size of cone in degress for a directional sound in which there will be no attenuation.
  42008. */
  42009. set directionalConeInnerAngle(value: number);
  42010. /**
  42011. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42012. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42013. */
  42014. get directionalConeOuterAngle(): number;
  42015. /**
  42016. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42017. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42018. */
  42019. set directionalConeOuterAngle(value: number);
  42020. /**
  42021. * Playback volume.
  42022. */
  42023. get volume(): number;
  42024. /**
  42025. * Playback volume.
  42026. */
  42027. set volume(value: number);
  42028. private _onended;
  42029. /**
  42030. * Suspend playback
  42031. */
  42032. pause(): void;
  42033. /**
  42034. * Stop playback
  42035. */
  42036. stop(): void;
  42037. /**
  42038. * Start playback.
  42039. * @param startOffset Position the clip head at a specific time in seconds.
  42040. */
  42041. play(startOffset?: number): void;
  42042. }
  42043. }
  42044. declare module BABYLON {
  42045. /**
  42046. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  42047. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42048. */
  42049. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  42050. /**
  42051. * Gets the name of the behavior.
  42052. */
  42053. get name(): string;
  42054. /**
  42055. * The easing function used by animations
  42056. */
  42057. static EasingFunction: BackEase;
  42058. /**
  42059. * The easing mode used by animations
  42060. */
  42061. static EasingMode: number;
  42062. /**
  42063. * The duration of the animation, in milliseconds
  42064. */
  42065. transitionDuration: number;
  42066. /**
  42067. * Length of the distance animated by the transition when lower radius is reached
  42068. */
  42069. lowerRadiusTransitionRange: number;
  42070. /**
  42071. * Length of the distance animated by the transition when upper radius is reached
  42072. */
  42073. upperRadiusTransitionRange: number;
  42074. private _autoTransitionRange;
  42075. /**
  42076. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42077. */
  42078. get autoTransitionRange(): boolean;
  42079. /**
  42080. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42081. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  42082. */
  42083. set autoTransitionRange(value: boolean);
  42084. private _attachedCamera;
  42085. private _onAfterCheckInputsObserver;
  42086. private _onMeshTargetChangedObserver;
  42087. /**
  42088. * Initializes the behavior.
  42089. */
  42090. init(): void;
  42091. /**
  42092. * Attaches the behavior to its arc rotate camera.
  42093. * @param camera Defines the camera to attach the behavior to
  42094. */
  42095. attach(camera: ArcRotateCamera): void;
  42096. /**
  42097. * Detaches the behavior from its current arc rotate camera.
  42098. */
  42099. detach(): void;
  42100. private _radiusIsAnimating;
  42101. private _radiusBounceTransition;
  42102. private _animatables;
  42103. private _cachedWheelPrecision;
  42104. /**
  42105. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  42106. * @param radiusLimit The limit to check against.
  42107. * @return Bool to indicate if at limit.
  42108. */
  42109. private _isRadiusAtLimit;
  42110. /**
  42111. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  42112. * @param radiusDelta The delta by which to animate to. Can be negative.
  42113. */
  42114. private _applyBoundRadiusAnimation;
  42115. /**
  42116. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  42117. */
  42118. protected _clearAnimationLocks(): void;
  42119. /**
  42120. * Stops and removes all animations that have been applied to the camera
  42121. */
  42122. stopAllAnimations(): void;
  42123. }
  42124. }
  42125. declare module BABYLON {
  42126. /**
  42127. * 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.
  42128. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42129. */
  42130. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  42131. /**
  42132. * Gets the name of the behavior.
  42133. */
  42134. get name(): string;
  42135. private _mode;
  42136. private _radiusScale;
  42137. private _positionScale;
  42138. private _defaultElevation;
  42139. private _elevationReturnTime;
  42140. private _elevationReturnWaitTime;
  42141. private _zoomStopsAnimation;
  42142. private _framingTime;
  42143. /**
  42144. * The easing function used by animations
  42145. */
  42146. static EasingFunction: ExponentialEase;
  42147. /**
  42148. * The easing mode used by animations
  42149. */
  42150. static EasingMode: number;
  42151. /**
  42152. * Sets the current mode used by the behavior
  42153. */
  42154. set mode(mode: number);
  42155. /**
  42156. * Gets current mode used by the behavior.
  42157. */
  42158. get mode(): number;
  42159. /**
  42160. * Sets the scale applied to the radius (1 by default)
  42161. */
  42162. set radiusScale(radius: number);
  42163. /**
  42164. * Gets the scale applied to the radius
  42165. */
  42166. get radiusScale(): number;
  42167. /**
  42168. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42169. */
  42170. set positionScale(scale: number);
  42171. /**
  42172. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42173. */
  42174. get positionScale(): number;
  42175. /**
  42176. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42177. * behaviour is triggered, in radians.
  42178. */
  42179. set defaultElevation(elevation: number);
  42180. /**
  42181. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42182. * behaviour is triggered, in radians.
  42183. */
  42184. get defaultElevation(): number;
  42185. /**
  42186. * Sets the time (in milliseconds) taken to return to the default beta position.
  42187. * Negative value indicates camera should not return to default.
  42188. */
  42189. set elevationReturnTime(speed: number);
  42190. /**
  42191. * Gets the time (in milliseconds) taken to return to the default beta position.
  42192. * Negative value indicates camera should not return to default.
  42193. */
  42194. get elevationReturnTime(): number;
  42195. /**
  42196. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42197. */
  42198. set elevationReturnWaitTime(time: number);
  42199. /**
  42200. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42201. */
  42202. get elevationReturnWaitTime(): number;
  42203. /**
  42204. * Sets the flag that indicates if user zooming should stop animation.
  42205. */
  42206. set zoomStopsAnimation(flag: boolean);
  42207. /**
  42208. * Gets the flag that indicates if user zooming should stop animation.
  42209. */
  42210. get zoomStopsAnimation(): boolean;
  42211. /**
  42212. * Sets the transition time when framing the mesh, in milliseconds
  42213. */
  42214. set framingTime(time: number);
  42215. /**
  42216. * Gets the transition time when framing the mesh, in milliseconds
  42217. */
  42218. get framingTime(): number;
  42219. /**
  42220. * Define if the behavior should automatically change the configured
  42221. * camera limits and sensibilities.
  42222. */
  42223. autoCorrectCameraLimitsAndSensibility: boolean;
  42224. private _onPrePointerObservableObserver;
  42225. private _onAfterCheckInputsObserver;
  42226. private _onMeshTargetChangedObserver;
  42227. private _attachedCamera;
  42228. private _isPointerDown;
  42229. private _lastInteractionTime;
  42230. /**
  42231. * Initializes the behavior.
  42232. */
  42233. init(): void;
  42234. /**
  42235. * Attaches the behavior to its arc rotate camera.
  42236. * @param camera Defines the camera to attach the behavior to
  42237. */
  42238. attach(camera: ArcRotateCamera): void;
  42239. /**
  42240. * Detaches the behavior from its current arc rotate camera.
  42241. */
  42242. detach(): void;
  42243. private _animatables;
  42244. private _betaIsAnimating;
  42245. private _betaTransition;
  42246. private _radiusTransition;
  42247. private _vectorTransition;
  42248. /**
  42249. * Targets the given mesh and updates zoom level accordingly.
  42250. * @param mesh The mesh to target.
  42251. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42252. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42253. */
  42254. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42255. /**
  42256. * Targets the given mesh with its children and updates zoom level accordingly.
  42257. * @param mesh The mesh to target.
  42258. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42259. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42260. */
  42261. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42262. /**
  42263. * Targets the given meshes with their children and updates zoom level accordingly.
  42264. * @param meshes The mesh to target.
  42265. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42266. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42267. */
  42268. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42269. /**
  42270. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  42271. * @param minimumWorld Determines the smaller position of the bounding box extend
  42272. * @param maximumWorld Determines the bigger position of the bounding box extend
  42273. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42274. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42275. */
  42276. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42277. /**
  42278. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  42279. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  42280. * frustum width.
  42281. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  42282. * to fully enclose the mesh in the viewing frustum.
  42283. */
  42284. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  42285. /**
  42286. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  42287. * is automatically returned to its default position (expected to be above ground plane).
  42288. */
  42289. private _maintainCameraAboveGround;
  42290. /**
  42291. * Returns the frustum slope based on the canvas ratio and camera FOV
  42292. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  42293. */
  42294. private _getFrustumSlope;
  42295. /**
  42296. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  42297. */
  42298. private _clearAnimationLocks;
  42299. /**
  42300. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42301. */
  42302. private _applyUserInteraction;
  42303. /**
  42304. * Stops and removes all animations that have been applied to the camera
  42305. */
  42306. stopAllAnimations(): void;
  42307. /**
  42308. * Gets a value indicating if the user is moving the camera
  42309. */
  42310. get isUserIsMoving(): boolean;
  42311. /**
  42312. * The camera can move all the way towards the mesh.
  42313. */
  42314. static IgnoreBoundsSizeMode: number;
  42315. /**
  42316. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  42317. */
  42318. static FitFrustumSidesMode: number;
  42319. }
  42320. }
  42321. declare module BABYLON {
  42322. /**
  42323. * Base class for Camera Pointer Inputs.
  42324. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  42325. * for example usage.
  42326. */
  42327. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  42328. /**
  42329. * Defines the camera the input is attached to.
  42330. */
  42331. abstract camera: Camera;
  42332. /**
  42333. * Whether keyboard modifier keys are pressed at time of last mouse event.
  42334. */
  42335. protected _altKey: boolean;
  42336. protected _ctrlKey: boolean;
  42337. protected _metaKey: boolean;
  42338. protected _shiftKey: boolean;
  42339. /**
  42340. * Which mouse buttons were pressed at time of last mouse event.
  42341. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  42342. */
  42343. protected _buttonsPressed: number;
  42344. /**
  42345. * Defines the buttons associated with the input to handle camera move.
  42346. */
  42347. buttons: number[];
  42348. /**
  42349. * Attach the input controls to a specific dom element to get the input from.
  42350. * @param element Defines the element the controls should be listened from
  42351. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42352. */
  42353. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42354. /**
  42355. * Detach the current controls from the specified dom element.
  42356. * @param element Defines the element to stop listening the inputs from
  42357. */
  42358. detachControl(element: Nullable<HTMLElement>): void;
  42359. /**
  42360. * Gets the class name of the current input.
  42361. * @returns the class name
  42362. */
  42363. getClassName(): string;
  42364. /**
  42365. * Get the friendly name associated with the input class.
  42366. * @returns the input friendly name
  42367. */
  42368. getSimpleName(): string;
  42369. /**
  42370. * Called on pointer POINTERDOUBLETAP event.
  42371. * Override this method to provide functionality on POINTERDOUBLETAP event.
  42372. */
  42373. protected onDoubleTap(type: string): void;
  42374. /**
  42375. * Called on pointer POINTERMOVE event if only a single touch is active.
  42376. * Override this method to provide functionality.
  42377. */
  42378. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42379. /**
  42380. * Called on pointer POINTERMOVE event if multiple touches are active.
  42381. * Override this method to provide functionality.
  42382. */
  42383. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42384. /**
  42385. * Called on JS contextmenu event.
  42386. * Override this method to provide functionality.
  42387. */
  42388. protected onContextMenu(evt: PointerEvent): void;
  42389. /**
  42390. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42391. * press.
  42392. * Override this method to provide functionality.
  42393. */
  42394. protected onButtonDown(evt: PointerEvent): void;
  42395. /**
  42396. * Called each time a new POINTERUP event occurs. Ie, for each button
  42397. * release.
  42398. * Override this method to provide functionality.
  42399. */
  42400. protected onButtonUp(evt: PointerEvent): void;
  42401. /**
  42402. * Called when window becomes inactive.
  42403. * Override this method to provide functionality.
  42404. */
  42405. protected onLostFocus(): void;
  42406. private _pointerInput;
  42407. private _observer;
  42408. private _onLostFocus;
  42409. private pointA;
  42410. private pointB;
  42411. }
  42412. }
  42413. declare module BABYLON {
  42414. /**
  42415. * Manage the pointers inputs to control an arc rotate camera.
  42416. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42417. */
  42418. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  42419. /**
  42420. * Defines the camera the input is attached to.
  42421. */
  42422. camera: ArcRotateCamera;
  42423. /**
  42424. * Gets the class name of the current input.
  42425. * @returns the class name
  42426. */
  42427. getClassName(): string;
  42428. /**
  42429. * Defines the buttons associated with the input to handle camera move.
  42430. */
  42431. buttons: number[];
  42432. /**
  42433. * Defines the pointer angular sensibility along the X axis or how fast is
  42434. * the camera rotating.
  42435. */
  42436. angularSensibilityX: number;
  42437. /**
  42438. * Defines the pointer angular sensibility along the Y axis or how fast is
  42439. * the camera rotating.
  42440. */
  42441. angularSensibilityY: number;
  42442. /**
  42443. * Defines the pointer pinch precision or how fast is the camera zooming.
  42444. */
  42445. pinchPrecision: number;
  42446. /**
  42447. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  42448. * from 0.
  42449. * It defines the percentage of current camera.radius to use as delta when
  42450. * pinch zoom is used.
  42451. */
  42452. pinchDeltaPercentage: number;
  42453. /**
  42454. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42455. * that any object in the plane at the camera's target point will scale
  42456. * perfectly with finger motion.
  42457. * Overrides pinchDeltaPercentage and pinchPrecision.
  42458. */
  42459. useNaturalPinchZoom: boolean;
  42460. /**
  42461. * Defines the pointer panning sensibility or how fast is the camera moving.
  42462. */
  42463. panningSensibility: number;
  42464. /**
  42465. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  42466. */
  42467. multiTouchPanning: boolean;
  42468. /**
  42469. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  42470. * zoom (pinch) through multitouch.
  42471. */
  42472. multiTouchPanAndZoom: boolean;
  42473. /**
  42474. * Revers pinch action direction.
  42475. */
  42476. pinchInwards: boolean;
  42477. private _isPanClick;
  42478. private _twoFingerActivityCount;
  42479. private _isPinching;
  42480. /**
  42481. * Called on pointer POINTERMOVE event if only a single touch is active.
  42482. */
  42483. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42484. /**
  42485. * Called on pointer POINTERDOUBLETAP event.
  42486. */
  42487. protected onDoubleTap(type: string): void;
  42488. /**
  42489. * Called on pointer POINTERMOVE event if multiple touches are active.
  42490. */
  42491. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42492. /**
  42493. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42494. * press.
  42495. */
  42496. protected onButtonDown(evt: PointerEvent): void;
  42497. /**
  42498. * Called each time a new POINTERUP event occurs. Ie, for each button
  42499. * release.
  42500. */
  42501. protected onButtonUp(evt: PointerEvent): void;
  42502. /**
  42503. * Called when window becomes inactive.
  42504. */
  42505. protected onLostFocus(): void;
  42506. }
  42507. }
  42508. declare module BABYLON {
  42509. /**
  42510. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  42511. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42512. */
  42513. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  42514. /**
  42515. * Defines the camera the input is attached to.
  42516. */
  42517. camera: ArcRotateCamera;
  42518. /**
  42519. * Defines the list of key codes associated with the up action (increase alpha)
  42520. */
  42521. keysUp: number[];
  42522. /**
  42523. * Defines the list of key codes associated with the down action (decrease alpha)
  42524. */
  42525. keysDown: number[];
  42526. /**
  42527. * Defines the list of key codes associated with the left action (increase beta)
  42528. */
  42529. keysLeft: number[];
  42530. /**
  42531. * Defines the list of key codes associated with the right action (decrease beta)
  42532. */
  42533. keysRight: number[];
  42534. /**
  42535. * Defines the list of key codes associated with the reset action.
  42536. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  42537. */
  42538. keysReset: number[];
  42539. /**
  42540. * Defines the panning sensibility of the inputs.
  42541. * (How fast is the camera panning)
  42542. */
  42543. panningSensibility: number;
  42544. /**
  42545. * Defines the zooming sensibility of the inputs.
  42546. * (How fast is the camera zooming)
  42547. */
  42548. zoomingSensibility: number;
  42549. /**
  42550. * Defines whether maintaining the alt key down switch the movement mode from
  42551. * orientation to zoom.
  42552. */
  42553. useAltToZoom: boolean;
  42554. /**
  42555. * Rotation speed of the camera
  42556. */
  42557. angularSpeed: number;
  42558. private _keys;
  42559. private _ctrlPressed;
  42560. private _altPressed;
  42561. private _onCanvasBlurObserver;
  42562. private _onKeyboardObserver;
  42563. private _engine;
  42564. private _scene;
  42565. /**
  42566. * Attach the input controls to a specific dom element to get the input from.
  42567. * @param element Defines the element the controls should be listened from
  42568. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42569. */
  42570. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42571. /**
  42572. * Detach the current controls from the specified dom element.
  42573. * @param element Defines the element to stop listening the inputs from
  42574. */
  42575. detachControl(element: Nullable<HTMLElement>): void;
  42576. /**
  42577. * Update the current camera state depending on the inputs that have been used this frame.
  42578. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42579. */
  42580. checkInputs(): void;
  42581. /**
  42582. * Gets the class name of the current intput.
  42583. * @returns the class name
  42584. */
  42585. getClassName(): string;
  42586. /**
  42587. * Get the friendly name associated with the input class.
  42588. * @returns the input friendly name
  42589. */
  42590. getSimpleName(): string;
  42591. }
  42592. }
  42593. declare module BABYLON {
  42594. /**
  42595. * Manage the mouse wheel inputs to control an arc rotate camera.
  42596. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42597. */
  42598. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  42599. /**
  42600. * Defines the camera the input is attached to.
  42601. */
  42602. camera: ArcRotateCamera;
  42603. /**
  42604. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42605. */
  42606. wheelPrecision: number;
  42607. /**
  42608. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  42609. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  42610. */
  42611. wheelDeltaPercentage: number;
  42612. private _wheel;
  42613. private _observer;
  42614. private computeDeltaFromMouseWheelLegacyEvent;
  42615. /**
  42616. * Attach the input controls to a specific dom element to get the input from.
  42617. * @param element Defines the element the controls should be listened from
  42618. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42619. */
  42620. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42621. /**
  42622. * Detach the current controls from the specified dom element.
  42623. * @param element Defines the element to stop listening the inputs from
  42624. */
  42625. detachControl(element: Nullable<HTMLElement>): void;
  42626. /**
  42627. * Gets the class name of the current intput.
  42628. * @returns the class name
  42629. */
  42630. getClassName(): string;
  42631. /**
  42632. * Get the friendly name associated with the input class.
  42633. * @returns the input friendly name
  42634. */
  42635. getSimpleName(): string;
  42636. }
  42637. }
  42638. declare module BABYLON {
  42639. /**
  42640. * Default Inputs manager for the ArcRotateCamera.
  42641. * It groups all the default supported inputs for ease of use.
  42642. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42643. */
  42644. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  42645. /**
  42646. * Instantiates a new ArcRotateCameraInputsManager.
  42647. * @param camera Defines the camera the inputs belong to
  42648. */
  42649. constructor(camera: ArcRotateCamera);
  42650. /**
  42651. * Add mouse wheel input support to the input manager.
  42652. * @returns the current input manager
  42653. */
  42654. addMouseWheel(): ArcRotateCameraInputsManager;
  42655. /**
  42656. * Add pointers input support to the input manager.
  42657. * @returns the current input manager
  42658. */
  42659. addPointers(): ArcRotateCameraInputsManager;
  42660. /**
  42661. * Add keyboard input support to the input manager.
  42662. * @returns the current input manager
  42663. */
  42664. addKeyboard(): ArcRotateCameraInputsManager;
  42665. }
  42666. }
  42667. declare module BABYLON {
  42668. /**
  42669. * This represents an orbital type of camera.
  42670. *
  42671. * 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.
  42672. * 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.
  42673. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  42674. */
  42675. export class ArcRotateCamera extends TargetCamera {
  42676. /**
  42677. * Defines the rotation angle of the camera along the longitudinal axis.
  42678. */
  42679. alpha: number;
  42680. /**
  42681. * Defines the rotation angle of the camera along the latitudinal axis.
  42682. */
  42683. beta: number;
  42684. /**
  42685. * Defines the radius of the camera from it s target point.
  42686. */
  42687. radius: number;
  42688. protected _target: Vector3;
  42689. protected _targetHost: Nullable<AbstractMesh>;
  42690. /**
  42691. * Defines the target point of the camera.
  42692. * The camera looks towards it form the radius distance.
  42693. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  42694. */
  42695. get target(): Vector3;
  42696. set target(value: Vector3);
  42697. /**
  42698. * Define the current local position of the camera in the scene
  42699. */
  42700. get position(): Vector3;
  42701. set position(newPosition: Vector3);
  42702. protected _upVector: Vector3;
  42703. protected _upToYMatrix: Matrix;
  42704. protected _YToUpMatrix: Matrix;
  42705. /**
  42706. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  42707. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  42708. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  42709. */
  42710. set upVector(vec: Vector3);
  42711. get upVector(): Vector3;
  42712. /**
  42713. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  42714. */
  42715. setMatUp(): void;
  42716. /**
  42717. * Current inertia value on the longitudinal axis.
  42718. * The bigger this number the longer it will take for the camera to stop.
  42719. */
  42720. inertialAlphaOffset: number;
  42721. /**
  42722. * Current inertia value on the latitudinal axis.
  42723. * The bigger this number the longer it will take for the camera to stop.
  42724. */
  42725. inertialBetaOffset: number;
  42726. /**
  42727. * Current inertia value on the radius axis.
  42728. * The bigger this number the longer it will take for the camera to stop.
  42729. */
  42730. inertialRadiusOffset: number;
  42731. /**
  42732. * Minimum allowed angle on the longitudinal axis.
  42733. * This can help limiting how the Camera is able to move in the scene.
  42734. */
  42735. lowerAlphaLimit: Nullable<number>;
  42736. /**
  42737. * Maximum allowed angle on the longitudinal axis.
  42738. * This can help limiting how the Camera is able to move in the scene.
  42739. */
  42740. upperAlphaLimit: Nullable<number>;
  42741. /**
  42742. * Minimum allowed angle on the latitudinal axis.
  42743. * This can help limiting how the Camera is able to move in the scene.
  42744. */
  42745. lowerBetaLimit: number;
  42746. /**
  42747. * Maximum allowed angle on the latitudinal axis.
  42748. * This can help limiting how the Camera is able to move in the scene.
  42749. */
  42750. upperBetaLimit: number;
  42751. /**
  42752. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  42753. * This can help limiting how the Camera is able to move in the scene.
  42754. */
  42755. lowerRadiusLimit: Nullable<number>;
  42756. /**
  42757. * Maximum allowed distance of the camera to the target (The camera can not get further).
  42758. * This can help limiting how the Camera is able to move in the scene.
  42759. */
  42760. upperRadiusLimit: Nullable<number>;
  42761. /**
  42762. * Defines the current inertia value used during panning of the camera along the X axis.
  42763. */
  42764. inertialPanningX: number;
  42765. /**
  42766. * Defines the current inertia value used during panning of the camera along the Y axis.
  42767. */
  42768. inertialPanningY: number;
  42769. /**
  42770. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  42771. * Basically if your fingers moves away from more than this distance you will be considered
  42772. * in pinch mode.
  42773. */
  42774. pinchToPanMaxDistance: number;
  42775. /**
  42776. * Defines the maximum distance the camera can pan.
  42777. * This could help keeping the cammera always in your scene.
  42778. */
  42779. panningDistanceLimit: Nullable<number>;
  42780. /**
  42781. * Defines the target of the camera before paning.
  42782. */
  42783. panningOriginTarget: Vector3;
  42784. /**
  42785. * Defines the value of the inertia used during panning.
  42786. * 0 would mean stop inertia and one would mean no decelleration at all.
  42787. */
  42788. panningInertia: number;
  42789. /**
  42790. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  42791. */
  42792. get angularSensibilityX(): number;
  42793. set angularSensibilityX(value: number);
  42794. /**
  42795. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  42796. */
  42797. get angularSensibilityY(): number;
  42798. set angularSensibilityY(value: number);
  42799. /**
  42800. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  42801. */
  42802. get pinchPrecision(): number;
  42803. set pinchPrecision(value: number);
  42804. /**
  42805. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  42806. * It will be used instead of pinchDeltaPrecision if different from 0.
  42807. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  42808. */
  42809. get pinchDeltaPercentage(): number;
  42810. set pinchDeltaPercentage(value: number);
  42811. /**
  42812. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  42813. * and pinch delta percentage.
  42814. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42815. * that any object in the plane at the camera's target point will scale
  42816. * perfectly with finger motion.
  42817. */
  42818. get useNaturalPinchZoom(): boolean;
  42819. set useNaturalPinchZoom(value: boolean);
  42820. /**
  42821. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  42822. */
  42823. get panningSensibility(): number;
  42824. set panningSensibility(value: number);
  42825. /**
  42826. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  42827. */
  42828. get keysUp(): number[];
  42829. set keysUp(value: number[]);
  42830. /**
  42831. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  42832. */
  42833. get keysDown(): number[];
  42834. set keysDown(value: number[]);
  42835. /**
  42836. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  42837. */
  42838. get keysLeft(): number[];
  42839. set keysLeft(value: number[]);
  42840. /**
  42841. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  42842. */
  42843. get keysRight(): number[];
  42844. set keysRight(value: number[]);
  42845. /**
  42846. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42847. */
  42848. get wheelPrecision(): number;
  42849. set wheelPrecision(value: number);
  42850. /**
  42851. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  42852. * It will be used instead of pinchDeltaPrecision if different from 0.
  42853. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  42854. */
  42855. get wheelDeltaPercentage(): number;
  42856. set wheelDeltaPercentage(value: number);
  42857. /**
  42858. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  42859. */
  42860. zoomOnFactor: number;
  42861. /**
  42862. * Defines a screen offset for the camera position.
  42863. */
  42864. targetScreenOffset: Vector2;
  42865. /**
  42866. * Allows the camera to be completely reversed.
  42867. * If false the camera can not arrive upside down.
  42868. */
  42869. allowUpsideDown: boolean;
  42870. /**
  42871. * Define if double tap/click is used to restore the previously saved state of the camera.
  42872. */
  42873. useInputToRestoreState: boolean;
  42874. /** @hidden */
  42875. _viewMatrix: Matrix;
  42876. /** @hidden */
  42877. _useCtrlForPanning: boolean;
  42878. /** @hidden */
  42879. _panningMouseButton: number;
  42880. /**
  42881. * Defines the input associated to the camera.
  42882. */
  42883. inputs: ArcRotateCameraInputsManager;
  42884. /** @hidden */
  42885. _reset: () => void;
  42886. /**
  42887. * Defines the allowed panning axis.
  42888. */
  42889. panningAxis: Vector3;
  42890. protected _localDirection: Vector3;
  42891. protected _transformedDirection: Vector3;
  42892. private _bouncingBehavior;
  42893. /**
  42894. * Gets the bouncing behavior of the camera if it has been enabled.
  42895. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42896. */
  42897. get bouncingBehavior(): Nullable<BouncingBehavior>;
  42898. /**
  42899. * Defines if the bouncing behavior of the camera is enabled on the camera.
  42900. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42901. */
  42902. get useBouncingBehavior(): boolean;
  42903. set useBouncingBehavior(value: boolean);
  42904. private _framingBehavior;
  42905. /**
  42906. * Gets the framing behavior of the camera if it has been enabled.
  42907. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42908. */
  42909. get framingBehavior(): Nullable<FramingBehavior>;
  42910. /**
  42911. * Defines if the framing behavior of the camera is enabled on the camera.
  42912. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42913. */
  42914. get useFramingBehavior(): boolean;
  42915. set useFramingBehavior(value: boolean);
  42916. private _autoRotationBehavior;
  42917. /**
  42918. * Gets the auto rotation behavior of the camera if it has been enabled.
  42919. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42920. */
  42921. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  42922. /**
  42923. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  42924. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42925. */
  42926. get useAutoRotationBehavior(): boolean;
  42927. set useAutoRotationBehavior(value: boolean);
  42928. /**
  42929. * Observable triggered when the mesh target has been changed on the camera.
  42930. */
  42931. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  42932. /**
  42933. * Event raised when the camera is colliding with a mesh.
  42934. */
  42935. onCollide: (collidedMesh: AbstractMesh) => void;
  42936. /**
  42937. * Defines whether the camera should check collision with the objects oh the scene.
  42938. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  42939. */
  42940. checkCollisions: boolean;
  42941. /**
  42942. * Defines the collision radius of the camera.
  42943. * This simulates a sphere around the camera.
  42944. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  42945. */
  42946. collisionRadius: Vector3;
  42947. protected _collider: Collider;
  42948. protected _previousPosition: Vector3;
  42949. protected _collisionVelocity: Vector3;
  42950. protected _newPosition: Vector3;
  42951. protected _previousAlpha: number;
  42952. protected _previousBeta: number;
  42953. protected _previousRadius: number;
  42954. protected _collisionTriggered: boolean;
  42955. protected _targetBoundingCenter: Nullable<Vector3>;
  42956. private _computationVector;
  42957. /**
  42958. * Instantiates a new ArcRotateCamera in a given scene
  42959. * @param name Defines the name of the camera
  42960. * @param alpha Defines the camera rotation along the logitudinal axis
  42961. * @param beta Defines the camera rotation along the latitudinal axis
  42962. * @param radius Defines the camera distance from its target
  42963. * @param target Defines the camera target
  42964. * @param scene Defines the scene the camera belongs to
  42965. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  42966. */
  42967. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  42968. /** @hidden */
  42969. _initCache(): void;
  42970. /** @hidden */
  42971. _updateCache(ignoreParentClass?: boolean): void;
  42972. protected _getTargetPosition(): Vector3;
  42973. private _storedAlpha;
  42974. private _storedBeta;
  42975. private _storedRadius;
  42976. private _storedTarget;
  42977. private _storedTargetScreenOffset;
  42978. /**
  42979. * Stores the current state of the camera (alpha, beta, radius and target)
  42980. * @returns the camera itself
  42981. */
  42982. storeState(): Camera;
  42983. /**
  42984. * @hidden
  42985. * Restored camera state. You must call storeState() first
  42986. */
  42987. _restoreStateValues(): boolean;
  42988. /** @hidden */
  42989. _isSynchronizedViewMatrix(): boolean;
  42990. /**
  42991. * Attached controls to the current camera.
  42992. * @param element Defines the element the controls should be listened from
  42993. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42994. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  42995. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  42996. */
  42997. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  42998. /**
  42999. * Detach the current controls from the camera.
  43000. * The camera will stop reacting to inputs.
  43001. * @param element Defines the element to stop listening the inputs from
  43002. */
  43003. detachControl(element: HTMLElement): void;
  43004. /** @hidden */
  43005. _checkInputs(): void;
  43006. protected _checkLimits(): void;
  43007. /**
  43008. * Rebuilds angles (alpha, beta) and radius from the give position and target
  43009. */
  43010. rebuildAnglesAndRadius(): void;
  43011. /**
  43012. * Use a position to define the current camera related information like alpha, beta and radius
  43013. * @param position Defines the position to set the camera at
  43014. */
  43015. setPosition(position: Vector3): void;
  43016. /**
  43017. * Defines the target the camera should look at.
  43018. * This will automatically adapt alpha beta and radius to fit within the new target.
  43019. * @param target Defines the new target as a Vector or a mesh
  43020. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  43021. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  43022. */
  43023. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  43024. /** @hidden */
  43025. _getViewMatrix(): Matrix;
  43026. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  43027. /**
  43028. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  43029. * @param meshes Defines the mesh to zoom on
  43030. * @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)
  43031. */
  43032. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  43033. /**
  43034. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  43035. * The target will be changed but the radius
  43036. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  43037. * @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)
  43038. */
  43039. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  43040. min: Vector3;
  43041. max: Vector3;
  43042. distance: number;
  43043. }, doNotUpdateMaxZ?: boolean): void;
  43044. /**
  43045. * @override
  43046. * Override Camera.createRigCamera
  43047. */
  43048. createRigCamera(name: string, cameraIndex: number): Camera;
  43049. /**
  43050. * @hidden
  43051. * @override
  43052. * Override Camera._updateRigCameras
  43053. */
  43054. _updateRigCameras(): void;
  43055. /**
  43056. * Destroy the camera and release the current resources hold by it.
  43057. */
  43058. dispose(): void;
  43059. /**
  43060. * Gets the current object class name.
  43061. * @return the class name
  43062. */
  43063. getClassName(): string;
  43064. }
  43065. }
  43066. declare module BABYLON {
  43067. /**
  43068. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  43069. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43070. */
  43071. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  43072. /**
  43073. * Gets the name of the behavior.
  43074. */
  43075. get name(): string;
  43076. private _zoomStopsAnimation;
  43077. private _idleRotationSpeed;
  43078. private _idleRotationWaitTime;
  43079. private _idleRotationSpinupTime;
  43080. /**
  43081. * Sets the flag that indicates if user zooming should stop animation.
  43082. */
  43083. set zoomStopsAnimation(flag: boolean);
  43084. /**
  43085. * Gets the flag that indicates if user zooming should stop animation.
  43086. */
  43087. get zoomStopsAnimation(): boolean;
  43088. /**
  43089. * Sets the default speed at which the camera rotates around the model.
  43090. */
  43091. set idleRotationSpeed(speed: number);
  43092. /**
  43093. * Gets the default speed at which the camera rotates around the model.
  43094. */
  43095. get idleRotationSpeed(): number;
  43096. /**
  43097. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  43098. */
  43099. set idleRotationWaitTime(time: number);
  43100. /**
  43101. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  43102. */
  43103. get idleRotationWaitTime(): number;
  43104. /**
  43105. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43106. */
  43107. set idleRotationSpinupTime(time: number);
  43108. /**
  43109. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43110. */
  43111. get idleRotationSpinupTime(): number;
  43112. /**
  43113. * Gets a value indicating if the camera is currently rotating because of this behavior
  43114. */
  43115. get rotationInProgress(): boolean;
  43116. private _onPrePointerObservableObserver;
  43117. private _onAfterCheckInputsObserver;
  43118. private _attachedCamera;
  43119. private _isPointerDown;
  43120. private _lastFrameTime;
  43121. private _lastInteractionTime;
  43122. private _cameraRotationSpeed;
  43123. /**
  43124. * Initializes the behavior.
  43125. */
  43126. init(): void;
  43127. /**
  43128. * Attaches the behavior to its arc rotate camera.
  43129. * @param camera Defines the camera to attach the behavior to
  43130. */
  43131. attach(camera: ArcRotateCamera): void;
  43132. /**
  43133. * Detaches the behavior from its current arc rotate camera.
  43134. */
  43135. detach(): void;
  43136. /**
  43137. * Returns true if user is scrolling.
  43138. * @return true if user is scrolling.
  43139. */
  43140. private _userIsZooming;
  43141. private _lastFrameRadius;
  43142. private _shouldAnimationStopForInteraction;
  43143. /**
  43144. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43145. */
  43146. private _applyUserInteraction;
  43147. private _userIsMoving;
  43148. }
  43149. }
  43150. declare module BABYLON {
  43151. /**
  43152. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  43153. */
  43154. export class AttachToBoxBehavior implements Behavior<Mesh> {
  43155. private ui;
  43156. /**
  43157. * The name of the behavior
  43158. */
  43159. name: string;
  43160. /**
  43161. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  43162. */
  43163. distanceAwayFromFace: number;
  43164. /**
  43165. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  43166. */
  43167. distanceAwayFromBottomOfFace: number;
  43168. private _faceVectors;
  43169. private _target;
  43170. private _scene;
  43171. private _onRenderObserver;
  43172. private _tmpMatrix;
  43173. private _tmpVector;
  43174. /**
  43175. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  43176. * @param ui The transform node that should be attched to the mesh
  43177. */
  43178. constructor(ui: TransformNode);
  43179. /**
  43180. * Initializes the behavior
  43181. */
  43182. init(): void;
  43183. private _closestFace;
  43184. private _zeroVector;
  43185. private _lookAtTmpMatrix;
  43186. private _lookAtToRef;
  43187. /**
  43188. * Attaches the AttachToBoxBehavior to the passed in mesh
  43189. * @param target The mesh that the specified node will be attached to
  43190. */
  43191. attach(target: Mesh): void;
  43192. /**
  43193. * Detaches the behavior from the mesh
  43194. */
  43195. detach(): void;
  43196. }
  43197. }
  43198. declare module BABYLON {
  43199. /**
  43200. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  43201. */
  43202. export class FadeInOutBehavior implements Behavior<Mesh> {
  43203. /**
  43204. * Time in milliseconds to delay before fading in (Default: 0)
  43205. */
  43206. delay: number;
  43207. /**
  43208. * Time in milliseconds for the mesh to fade in (Default: 300)
  43209. */
  43210. fadeInTime: number;
  43211. private _millisecondsPerFrame;
  43212. private _hovered;
  43213. private _hoverValue;
  43214. private _ownerNode;
  43215. /**
  43216. * Instatiates the FadeInOutBehavior
  43217. */
  43218. constructor();
  43219. /**
  43220. * The name of the behavior
  43221. */
  43222. get name(): string;
  43223. /**
  43224. * Initializes the behavior
  43225. */
  43226. init(): void;
  43227. /**
  43228. * Attaches the fade behavior on the passed in mesh
  43229. * @param ownerNode The mesh that will be faded in/out once attached
  43230. */
  43231. attach(ownerNode: Mesh): void;
  43232. /**
  43233. * Detaches the behavior from the mesh
  43234. */
  43235. detach(): void;
  43236. /**
  43237. * Triggers the mesh to begin fading in or out
  43238. * @param value if the object should fade in or out (true to fade in)
  43239. */
  43240. fadeIn(value: boolean): void;
  43241. private _update;
  43242. private _setAllVisibility;
  43243. }
  43244. }
  43245. declare module BABYLON {
  43246. /**
  43247. * Class containing a set of static utilities functions for managing Pivots
  43248. * @hidden
  43249. */
  43250. export class PivotTools {
  43251. private static _PivotCached;
  43252. private static _OldPivotPoint;
  43253. private static _PivotTranslation;
  43254. private static _PivotTmpVector;
  43255. /** @hidden */
  43256. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  43257. /** @hidden */
  43258. static _RestorePivotPoint(mesh: AbstractMesh): void;
  43259. }
  43260. }
  43261. declare module BABYLON {
  43262. /**
  43263. * Class containing static functions to help procedurally build meshes
  43264. */
  43265. export class PlaneBuilder {
  43266. /**
  43267. * Creates a plane mesh
  43268. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  43269. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  43270. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  43271. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43272. * * 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
  43273. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43274. * @param name defines the name of the mesh
  43275. * @param options defines the options used to create the mesh
  43276. * @param scene defines the hosting scene
  43277. * @returns the plane mesh
  43278. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  43279. */
  43280. static CreatePlane(name: string, options: {
  43281. size?: number;
  43282. width?: number;
  43283. height?: number;
  43284. sideOrientation?: number;
  43285. frontUVs?: Vector4;
  43286. backUVs?: Vector4;
  43287. updatable?: boolean;
  43288. sourcePlane?: Plane;
  43289. }, scene?: Nullable<Scene>): Mesh;
  43290. }
  43291. }
  43292. declare module BABYLON {
  43293. /**
  43294. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  43295. */
  43296. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  43297. private static _AnyMouseID;
  43298. /**
  43299. * Abstract mesh the behavior is set on
  43300. */
  43301. attachedNode: AbstractMesh;
  43302. private _dragPlane;
  43303. private _scene;
  43304. private _pointerObserver;
  43305. private _beforeRenderObserver;
  43306. private static _planeScene;
  43307. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  43308. /**
  43309. * 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)
  43310. */
  43311. maxDragAngle: number;
  43312. /**
  43313. * @hidden
  43314. */
  43315. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  43316. /**
  43317. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43318. */
  43319. currentDraggingPointerID: number;
  43320. /**
  43321. * The last position where the pointer hit the drag plane in world space
  43322. */
  43323. lastDragPosition: Vector3;
  43324. /**
  43325. * If the behavior is currently in a dragging state
  43326. */
  43327. dragging: boolean;
  43328. /**
  43329. * 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)
  43330. */
  43331. dragDeltaRatio: number;
  43332. /**
  43333. * If the drag plane orientation should be updated during the dragging (Default: true)
  43334. */
  43335. updateDragPlane: boolean;
  43336. private _debugMode;
  43337. private _moving;
  43338. /**
  43339. * Fires each time the attached mesh is dragged with the pointer
  43340. * * delta between last drag position and current drag position in world space
  43341. * * dragDistance along the drag axis
  43342. * * dragPlaneNormal normal of the current drag plane used during the drag
  43343. * * dragPlanePoint in world space where the drag intersects the drag plane
  43344. */
  43345. onDragObservable: Observable<{
  43346. delta: Vector3;
  43347. dragPlanePoint: Vector3;
  43348. dragPlaneNormal: Vector3;
  43349. dragDistance: number;
  43350. pointerId: number;
  43351. }>;
  43352. /**
  43353. * Fires each time a drag begins (eg. mouse down on mesh)
  43354. */
  43355. onDragStartObservable: Observable<{
  43356. dragPlanePoint: Vector3;
  43357. pointerId: number;
  43358. }>;
  43359. /**
  43360. * Fires each time a drag ends (eg. mouse release after drag)
  43361. */
  43362. onDragEndObservable: Observable<{
  43363. dragPlanePoint: Vector3;
  43364. pointerId: number;
  43365. }>;
  43366. /**
  43367. * If the attached mesh should be moved when dragged
  43368. */
  43369. moveAttached: boolean;
  43370. /**
  43371. * If the drag behavior will react to drag events (Default: true)
  43372. */
  43373. enabled: boolean;
  43374. /**
  43375. * If pointer events should start and release the drag (Default: true)
  43376. */
  43377. startAndReleaseDragOnPointerEvents: boolean;
  43378. /**
  43379. * If camera controls should be detached during the drag
  43380. */
  43381. detachCameraControls: boolean;
  43382. /**
  43383. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  43384. */
  43385. useObjectOrientationForDragging: boolean;
  43386. private _options;
  43387. /**
  43388. * Gets the options used by the behavior
  43389. */
  43390. get options(): {
  43391. dragAxis?: Vector3;
  43392. dragPlaneNormal?: Vector3;
  43393. };
  43394. /**
  43395. * Sets the options used by the behavior
  43396. */
  43397. set options(options: {
  43398. dragAxis?: Vector3;
  43399. dragPlaneNormal?: Vector3;
  43400. });
  43401. /**
  43402. * Creates a pointer drag behavior that can be attached to a mesh
  43403. * @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)
  43404. */
  43405. constructor(options?: {
  43406. dragAxis?: Vector3;
  43407. dragPlaneNormal?: Vector3;
  43408. });
  43409. /**
  43410. * Predicate to determine if it is valid to move the object to a new position when it is moved
  43411. */
  43412. validateDrag: (targetPosition: Vector3) => boolean;
  43413. /**
  43414. * The name of the behavior
  43415. */
  43416. get name(): string;
  43417. /**
  43418. * Initializes the behavior
  43419. */
  43420. init(): void;
  43421. private _tmpVector;
  43422. private _alternatePickedPoint;
  43423. private _worldDragAxis;
  43424. private _targetPosition;
  43425. private _attachedElement;
  43426. /**
  43427. * Attaches the drag behavior the passed in mesh
  43428. * @param ownerNode The mesh that will be dragged around once attached
  43429. * @param predicate Predicate to use for pick filtering
  43430. */
  43431. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  43432. /**
  43433. * Force relase the drag action by code.
  43434. */
  43435. releaseDrag(): void;
  43436. private _startDragRay;
  43437. private _lastPointerRay;
  43438. /**
  43439. * Simulates the start of a pointer drag event on the behavior
  43440. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  43441. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  43442. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  43443. */
  43444. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  43445. private _startDrag;
  43446. private _dragDelta;
  43447. private _moveDrag;
  43448. private _pickWithRayOnDragPlane;
  43449. private _pointA;
  43450. private _pointC;
  43451. private _localAxis;
  43452. private _lookAt;
  43453. private _updateDragPlanePosition;
  43454. /**
  43455. * Detaches the behavior from the mesh
  43456. */
  43457. detach(): void;
  43458. }
  43459. }
  43460. declare module BABYLON {
  43461. /**
  43462. * A behavior that when attached to a mesh will allow the mesh to be scaled
  43463. */
  43464. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  43465. private _dragBehaviorA;
  43466. private _dragBehaviorB;
  43467. private _startDistance;
  43468. private _initialScale;
  43469. private _targetScale;
  43470. private _ownerNode;
  43471. private _sceneRenderObserver;
  43472. /**
  43473. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  43474. */
  43475. constructor();
  43476. /**
  43477. * The name of the behavior
  43478. */
  43479. get name(): string;
  43480. /**
  43481. * Initializes the behavior
  43482. */
  43483. init(): void;
  43484. private _getCurrentDistance;
  43485. /**
  43486. * Attaches the scale behavior the passed in mesh
  43487. * @param ownerNode The mesh that will be scaled around once attached
  43488. */
  43489. attach(ownerNode: Mesh): void;
  43490. /**
  43491. * Detaches the behavior from the mesh
  43492. */
  43493. detach(): void;
  43494. }
  43495. }
  43496. declare module BABYLON {
  43497. /**
  43498. * A behavior that when attached to a mesh will allow the mesh to be dragged around based on directions and origin of the pointer's ray
  43499. */
  43500. export class SixDofDragBehavior implements Behavior<Mesh> {
  43501. private static _virtualScene;
  43502. private _ownerNode;
  43503. private _sceneRenderObserver;
  43504. private _scene;
  43505. private _targetPosition;
  43506. private _virtualOriginMesh;
  43507. private _virtualDragMesh;
  43508. private _pointerObserver;
  43509. private _moving;
  43510. private _startingOrientation;
  43511. private _attachedElement;
  43512. /**
  43513. * 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)
  43514. */
  43515. private zDragFactor;
  43516. /**
  43517. * If the object should rotate to face the drag origin
  43518. */
  43519. rotateDraggedObject: boolean;
  43520. /**
  43521. * If the behavior is currently in a dragging state
  43522. */
  43523. dragging: boolean;
  43524. /**
  43525. * 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)
  43526. */
  43527. dragDeltaRatio: number;
  43528. /**
  43529. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43530. */
  43531. currentDraggingPointerID: number;
  43532. /**
  43533. * If camera controls should be detached during the drag
  43534. */
  43535. detachCameraControls: boolean;
  43536. /**
  43537. * Fires each time a drag starts
  43538. */
  43539. onDragStartObservable: Observable<{}>;
  43540. /**
  43541. * Fires each time a drag ends (eg. mouse release after drag)
  43542. */
  43543. onDragEndObservable: Observable<{}>;
  43544. /**
  43545. * 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
  43546. */
  43547. constructor();
  43548. /**
  43549. * The name of the behavior
  43550. */
  43551. get name(): string;
  43552. /**
  43553. * Initializes the behavior
  43554. */
  43555. init(): void;
  43556. /**
  43557. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  43558. */
  43559. private get _pointerCamera();
  43560. /**
  43561. * Attaches the scale behavior the passed in mesh
  43562. * @param ownerNode The mesh that will be scaled around once attached
  43563. */
  43564. attach(ownerNode: Mesh): void;
  43565. /**
  43566. * Detaches the behavior from the mesh
  43567. */
  43568. detach(): void;
  43569. }
  43570. }
  43571. declare module BABYLON {
  43572. /**
  43573. * Class used to apply inverse kinematics to bones
  43574. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  43575. */
  43576. export class BoneIKController {
  43577. private static _tmpVecs;
  43578. private static _tmpQuat;
  43579. private static _tmpMats;
  43580. /**
  43581. * Gets or sets the target mesh
  43582. */
  43583. targetMesh: AbstractMesh;
  43584. /** Gets or sets the mesh used as pole */
  43585. poleTargetMesh: AbstractMesh;
  43586. /**
  43587. * Gets or sets the bone used as pole
  43588. */
  43589. poleTargetBone: Nullable<Bone>;
  43590. /**
  43591. * Gets or sets the target position
  43592. */
  43593. targetPosition: Vector3;
  43594. /**
  43595. * Gets or sets the pole target position
  43596. */
  43597. poleTargetPosition: Vector3;
  43598. /**
  43599. * Gets or sets the pole target local offset
  43600. */
  43601. poleTargetLocalOffset: Vector3;
  43602. /**
  43603. * Gets or sets the pole angle
  43604. */
  43605. poleAngle: number;
  43606. /**
  43607. * Gets or sets the mesh associated with the controller
  43608. */
  43609. mesh: AbstractMesh;
  43610. /**
  43611. * 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)
  43612. */
  43613. slerpAmount: number;
  43614. private _bone1Quat;
  43615. private _bone1Mat;
  43616. private _bone2Ang;
  43617. private _bone1;
  43618. private _bone2;
  43619. private _bone1Length;
  43620. private _bone2Length;
  43621. private _maxAngle;
  43622. private _maxReach;
  43623. private _rightHandedSystem;
  43624. private _bendAxis;
  43625. private _slerping;
  43626. private _adjustRoll;
  43627. /**
  43628. * Gets or sets maximum allowed angle
  43629. */
  43630. get maxAngle(): number;
  43631. set maxAngle(value: number);
  43632. /**
  43633. * Creates a new BoneIKController
  43634. * @param mesh defines the mesh to control
  43635. * @param bone defines the bone to control
  43636. * @param options defines options to set up the controller
  43637. */
  43638. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  43639. targetMesh?: AbstractMesh;
  43640. poleTargetMesh?: AbstractMesh;
  43641. poleTargetBone?: Bone;
  43642. poleTargetLocalOffset?: Vector3;
  43643. poleAngle?: number;
  43644. bendAxis?: Vector3;
  43645. maxAngle?: number;
  43646. slerpAmount?: number;
  43647. });
  43648. private _setMaxAngle;
  43649. /**
  43650. * Force the controller to update the bones
  43651. */
  43652. update(): void;
  43653. }
  43654. }
  43655. declare module BABYLON {
  43656. /**
  43657. * Class used to make a bone look toward a point in space
  43658. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  43659. */
  43660. export class BoneLookController {
  43661. private static _tmpVecs;
  43662. private static _tmpQuat;
  43663. private static _tmpMats;
  43664. /**
  43665. * The target Vector3 that the bone will look at
  43666. */
  43667. target: Vector3;
  43668. /**
  43669. * The mesh that the bone is attached to
  43670. */
  43671. mesh: AbstractMesh;
  43672. /**
  43673. * The bone that will be looking to the target
  43674. */
  43675. bone: Bone;
  43676. /**
  43677. * The up axis of the coordinate system that is used when the bone is rotated
  43678. */
  43679. upAxis: Vector3;
  43680. /**
  43681. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  43682. */
  43683. upAxisSpace: Space;
  43684. /**
  43685. * Used to make an adjustment to the yaw of the bone
  43686. */
  43687. adjustYaw: number;
  43688. /**
  43689. * Used to make an adjustment to the pitch of the bone
  43690. */
  43691. adjustPitch: number;
  43692. /**
  43693. * Used to make an adjustment to the roll of the bone
  43694. */
  43695. adjustRoll: number;
  43696. /**
  43697. * 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)
  43698. */
  43699. slerpAmount: number;
  43700. private _minYaw;
  43701. private _maxYaw;
  43702. private _minPitch;
  43703. private _maxPitch;
  43704. private _minYawSin;
  43705. private _minYawCos;
  43706. private _maxYawSin;
  43707. private _maxYawCos;
  43708. private _midYawConstraint;
  43709. private _minPitchTan;
  43710. private _maxPitchTan;
  43711. private _boneQuat;
  43712. private _slerping;
  43713. private _transformYawPitch;
  43714. private _transformYawPitchInv;
  43715. private _firstFrameSkipped;
  43716. private _yawRange;
  43717. private _fowardAxis;
  43718. /**
  43719. * Gets or sets the minimum yaw angle that the bone can look to
  43720. */
  43721. get minYaw(): number;
  43722. set minYaw(value: number);
  43723. /**
  43724. * Gets or sets the maximum yaw angle that the bone can look to
  43725. */
  43726. get maxYaw(): number;
  43727. set maxYaw(value: number);
  43728. /**
  43729. * Gets or sets the minimum pitch angle that the bone can look to
  43730. */
  43731. get minPitch(): number;
  43732. set minPitch(value: number);
  43733. /**
  43734. * Gets or sets the maximum pitch angle that the bone can look to
  43735. */
  43736. get maxPitch(): number;
  43737. set maxPitch(value: number);
  43738. /**
  43739. * Create a BoneLookController
  43740. * @param mesh the mesh that the bone belongs to
  43741. * @param bone the bone that will be looking to the target
  43742. * @param target the target Vector3 to look at
  43743. * @param options optional settings:
  43744. * * maxYaw: the maximum angle the bone will yaw to
  43745. * * minYaw: the minimum angle the bone will yaw to
  43746. * * maxPitch: the maximum angle the bone will pitch to
  43747. * * minPitch: the minimum angle the bone will yaw to
  43748. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  43749. * * upAxis: the up axis of the coordinate system
  43750. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  43751. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  43752. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  43753. * * adjustYaw: used to make an adjustment to the yaw of the bone
  43754. * * adjustPitch: used to make an adjustment to the pitch of the bone
  43755. * * adjustRoll: used to make an adjustment to the roll of the bone
  43756. **/
  43757. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  43758. maxYaw?: number;
  43759. minYaw?: number;
  43760. maxPitch?: number;
  43761. minPitch?: number;
  43762. slerpAmount?: number;
  43763. upAxis?: Vector3;
  43764. upAxisSpace?: Space;
  43765. yawAxis?: Vector3;
  43766. pitchAxis?: Vector3;
  43767. adjustYaw?: number;
  43768. adjustPitch?: number;
  43769. adjustRoll?: number;
  43770. });
  43771. /**
  43772. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  43773. */
  43774. update(): void;
  43775. private _getAngleDiff;
  43776. private _getAngleBetween;
  43777. private _isAngleBetween;
  43778. }
  43779. }
  43780. declare module BABYLON {
  43781. /**
  43782. * Manage the gamepad inputs to control an arc rotate camera.
  43783. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43784. */
  43785. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  43786. /**
  43787. * Defines the camera the input is attached to.
  43788. */
  43789. camera: ArcRotateCamera;
  43790. /**
  43791. * Defines the gamepad the input is gathering event from.
  43792. */
  43793. gamepad: Nullable<Gamepad>;
  43794. /**
  43795. * Defines the gamepad rotation sensiblity.
  43796. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43797. */
  43798. gamepadRotationSensibility: number;
  43799. /**
  43800. * Defines the gamepad move sensiblity.
  43801. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43802. */
  43803. gamepadMoveSensibility: number;
  43804. private _yAxisScale;
  43805. /**
  43806. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  43807. */
  43808. get invertYAxis(): boolean;
  43809. set invertYAxis(value: boolean);
  43810. private _onGamepadConnectedObserver;
  43811. private _onGamepadDisconnectedObserver;
  43812. /**
  43813. * Attach the input controls to a specific dom element to get the input from.
  43814. * @param element Defines the element the controls should be listened from
  43815. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43816. */
  43817. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43818. /**
  43819. * Detach the current controls from the specified dom element.
  43820. * @param element Defines the element to stop listening the inputs from
  43821. */
  43822. detachControl(element: Nullable<HTMLElement>): void;
  43823. /**
  43824. * Update the current camera state depending on the inputs that have been used this frame.
  43825. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43826. */
  43827. checkInputs(): void;
  43828. /**
  43829. * Gets the class name of the current intput.
  43830. * @returns the class name
  43831. */
  43832. getClassName(): string;
  43833. /**
  43834. * Get the friendly name associated with the input class.
  43835. * @returns the input friendly name
  43836. */
  43837. getSimpleName(): string;
  43838. }
  43839. }
  43840. declare module BABYLON {
  43841. interface ArcRotateCameraInputsManager {
  43842. /**
  43843. * Add orientation input support to the input manager.
  43844. * @returns the current input manager
  43845. */
  43846. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  43847. }
  43848. /**
  43849. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  43850. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43851. */
  43852. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  43853. /**
  43854. * Defines the camera the input is attached to.
  43855. */
  43856. camera: ArcRotateCamera;
  43857. /**
  43858. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  43859. */
  43860. alphaCorrection: number;
  43861. /**
  43862. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  43863. */
  43864. gammaCorrection: number;
  43865. private _alpha;
  43866. private _gamma;
  43867. private _dirty;
  43868. private _deviceOrientationHandler;
  43869. /**
  43870. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  43871. */
  43872. constructor();
  43873. /**
  43874. * Attach the input controls to a specific dom element to get the input from.
  43875. * @param element Defines the element the controls should be listened from
  43876. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43877. */
  43878. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43879. /** @hidden */
  43880. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  43881. /**
  43882. * Update the current camera state depending on the inputs that have been used this frame.
  43883. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43884. */
  43885. checkInputs(): void;
  43886. /**
  43887. * Detach the current controls from the specified dom element.
  43888. * @param element Defines the element to stop listening the inputs from
  43889. */
  43890. detachControl(element: Nullable<HTMLElement>): void;
  43891. /**
  43892. * Gets the class name of the current intput.
  43893. * @returns the class name
  43894. */
  43895. getClassName(): string;
  43896. /**
  43897. * Get the friendly name associated with the input class.
  43898. * @returns the input friendly name
  43899. */
  43900. getSimpleName(): string;
  43901. }
  43902. }
  43903. declare module BABYLON {
  43904. /**
  43905. * Listen to mouse events to control the camera.
  43906. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43907. */
  43908. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  43909. /**
  43910. * Defines the camera the input is attached to.
  43911. */
  43912. camera: FlyCamera;
  43913. /**
  43914. * Defines if touch is enabled. (Default is true.)
  43915. */
  43916. touchEnabled: boolean;
  43917. /**
  43918. * Defines the buttons associated with the input to handle camera rotation.
  43919. */
  43920. buttons: number[];
  43921. /**
  43922. * Assign buttons for Yaw control.
  43923. */
  43924. buttonsYaw: number[];
  43925. /**
  43926. * Assign buttons for Pitch control.
  43927. */
  43928. buttonsPitch: number[];
  43929. /**
  43930. * Assign buttons for Roll control.
  43931. */
  43932. buttonsRoll: number[];
  43933. /**
  43934. * Detect if any button is being pressed while mouse is moved.
  43935. * -1 = Mouse locked.
  43936. * 0 = Left button.
  43937. * 1 = Middle Button.
  43938. * 2 = Right Button.
  43939. */
  43940. activeButton: number;
  43941. /**
  43942. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  43943. * Higher values reduce its sensitivity.
  43944. */
  43945. angularSensibility: number;
  43946. private _mousemoveCallback;
  43947. private _observer;
  43948. private _rollObserver;
  43949. private previousPosition;
  43950. private noPreventDefault;
  43951. private element;
  43952. /**
  43953. * Listen to mouse events to control the camera.
  43954. * @param touchEnabled Define if touch is enabled. (Default is true.)
  43955. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43956. */
  43957. constructor(touchEnabled?: boolean);
  43958. /**
  43959. * Attach the mouse control to the HTML DOM element.
  43960. * @param element Defines the element that listens to the input events.
  43961. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  43962. */
  43963. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43964. /**
  43965. * Detach the current controls from the specified dom element.
  43966. * @param element Defines the element to stop listening the inputs from
  43967. */
  43968. detachControl(element: Nullable<HTMLElement>): void;
  43969. /**
  43970. * Gets the class name of the current input.
  43971. * @returns the class name.
  43972. */
  43973. getClassName(): string;
  43974. /**
  43975. * Get the friendly name associated with the input class.
  43976. * @returns the input's friendly name.
  43977. */
  43978. getSimpleName(): string;
  43979. private _pointerInput;
  43980. private _onMouseMove;
  43981. /**
  43982. * Rotate camera by mouse offset.
  43983. */
  43984. private rotateCamera;
  43985. }
  43986. }
  43987. declare module BABYLON {
  43988. /**
  43989. * Default Inputs manager for the FlyCamera.
  43990. * It groups all the default supported inputs for ease of use.
  43991. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43992. */
  43993. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  43994. /**
  43995. * Instantiates a new FlyCameraInputsManager.
  43996. * @param camera Defines the camera the inputs belong to.
  43997. */
  43998. constructor(camera: FlyCamera);
  43999. /**
  44000. * Add keyboard input support to the input manager.
  44001. * @returns the new FlyCameraKeyboardMoveInput().
  44002. */
  44003. addKeyboard(): FlyCameraInputsManager;
  44004. /**
  44005. * Add mouse input support to the input manager.
  44006. * @param touchEnabled Enable touch screen support.
  44007. * @returns the new FlyCameraMouseInput().
  44008. */
  44009. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  44010. }
  44011. }
  44012. declare module BABYLON {
  44013. /**
  44014. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44015. * such as in a 3D Space Shooter or a Flight Simulator.
  44016. */
  44017. export class FlyCamera extends TargetCamera {
  44018. /**
  44019. * Define the collision ellipsoid of the camera.
  44020. * This is helpful for simulating a camera body, like a player's body.
  44021. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44022. */
  44023. ellipsoid: Vector3;
  44024. /**
  44025. * Define an offset for the position of the ellipsoid around the camera.
  44026. * This can be helpful if the camera is attached away from the player's body center,
  44027. * such as at its head.
  44028. */
  44029. ellipsoidOffset: Vector3;
  44030. /**
  44031. * Enable or disable collisions of the camera with the rest of the scene objects.
  44032. */
  44033. checkCollisions: boolean;
  44034. /**
  44035. * Enable or disable gravity on the camera.
  44036. */
  44037. applyGravity: boolean;
  44038. /**
  44039. * Define the current direction the camera is moving to.
  44040. */
  44041. cameraDirection: Vector3;
  44042. /**
  44043. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  44044. * This overrides and empties cameraRotation.
  44045. */
  44046. rotationQuaternion: Quaternion;
  44047. /**
  44048. * Track Roll to maintain the wanted Rolling when looking around.
  44049. */
  44050. _trackRoll: number;
  44051. /**
  44052. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  44053. */
  44054. rollCorrect: number;
  44055. /**
  44056. * Mimic a banked turn, Rolling the camera when Yawing.
  44057. * It's recommended to use rollCorrect = 10 for faster banking correction.
  44058. */
  44059. bankedTurn: boolean;
  44060. /**
  44061. * Limit in radians for how much Roll banking will add. (Default: 90°)
  44062. */
  44063. bankedTurnLimit: number;
  44064. /**
  44065. * Value of 0 disables the banked Roll.
  44066. * Value of 1 is equal to the Yaw angle in radians.
  44067. */
  44068. bankedTurnMultiplier: number;
  44069. /**
  44070. * The inputs manager loads all the input sources, such as keyboard and mouse.
  44071. */
  44072. inputs: FlyCameraInputsManager;
  44073. /**
  44074. * Gets the input sensibility for mouse input.
  44075. * Higher values reduce sensitivity.
  44076. */
  44077. get angularSensibility(): number;
  44078. /**
  44079. * Sets the input sensibility for a mouse input.
  44080. * Higher values reduce sensitivity.
  44081. */
  44082. set angularSensibility(value: number);
  44083. /**
  44084. * Get the keys for camera movement forward.
  44085. */
  44086. get keysForward(): number[];
  44087. /**
  44088. * Set the keys for camera movement forward.
  44089. */
  44090. set keysForward(value: number[]);
  44091. /**
  44092. * Get the keys for camera movement backward.
  44093. */
  44094. get keysBackward(): number[];
  44095. set keysBackward(value: number[]);
  44096. /**
  44097. * Get the keys for camera movement up.
  44098. */
  44099. get keysUp(): number[];
  44100. /**
  44101. * Set the keys for camera movement up.
  44102. */
  44103. set keysUp(value: number[]);
  44104. /**
  44105. * Get the keys for camera movement down.
  44106. */
  44107. get keysDown(): number[];
  44108. /**
  44109. * Set the keys for camera movement down.
  44110. */
  44111. set keysDown(value: number[]);
  44112. /**
  44113. * Get the keys for camera movement left.
  44114. */
  44115. get keysLeft(): number[];
  44116. /**
  44117. * Set the keys for camera movement left.
  44118. */
  44119. set keysLeft(value: number[]);
  44120. /**
  44121. * Set the keys for camera movement right.
  44122. */
  44123. get keysRight(): number[];
  44124. /**
  44125. * Set the keys for camera movement right.
  44126. */
  44127. set keysRight(value: number[]);
  44128. /**
  44129. * Event raised when the camera collides with a mesh in the scene.
  44130. */
  44131. onCollide: (collidedMesh: AbstractMesh) => void;
  44132. private _collider;
  44133. private _needMoveForGravity;
  44134. private _oldPosition;
  44135. private _diffPosition;
  44136. private _newPosition;
  44137. /** @hidden */
  44138. _localDirection: Vector3;
  44139. /** @hidden */
  44140. _transformedDirection: Vector3;
  44141. /**
  44142. * Instantiates a FlyCamera.
  44143. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44144. * such as in a 3D Space Shooter or a Flight Simulator.
  44145. * @param name Define the name of the camera in the scene.
  44146. * @param position Define the starting position of the camera in the scene.
  44147. * @param scene Define the scene the camera belongs to.
  44148. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  44149. */
  44150. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44151. /**
  44152. * Attach a control to the HTML DOM element.
  44153. * @param element Defines the element that listens to the input events.
  44154. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  44155. */
  44156. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44157. /**
  44158. * Detach a control from the HTML DOM element.
  44159. * The camera will stop reacting to that input.
  44160. * @param element Defines the element that listens to the input events.
  44161. */
  44162. detachControl(element: HTMLElement): void;
  44163. private _collisionMask;
  44164. /**
  44165. * Get the mask that the camera ignores in collision events.
  44166. */
  44167. get collisionMask(): number;
  44168. /**
  44169. * Set the mask that the camera ignores in collision events.
  44170. */
  44171. set collisionMask(mask: number);
  44172. /** @hidden */
  44173. _collideWithWorld(displacement: Vector3): void;
  44174. /** @hidden */
  44175. private _onCollisionPositionChange;
  44176. /** @hidden */
  44177. _checkInputs(): void;
  44178. /** @hidden */
  44179. _decideIfNeedsToMove(): boolean;
  44180. /** @hidden */
  44181. _updatePosition(): void;
  44182. /**
  44183. * Restore the Roll to its target value at the rate specified.
  44184. * @param rate - Higher means slower restoring.
  44185. * @hidden
  44186. */
  44187. restoreRoll(rate: number): void;
  44188. /**
  44189. * Destroy the camera and release the current resources held by it.
  44190. */
  44191. dispose(): void;
  44192. /**
  44193. * Get the current object class name.
  44194. * @returns the class name.
  44195. */
  44196. getClassName(): string;
  44197. }
  44198. }
  44199. declare module BABYLON {
  44200. /**
  44201. * Listen to keyboard events to control the camera.
  44202. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44203. */
  44204. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  44205. /**
  44206. * Defines the camera the input is attached to.
  44207. */
  44208. camera: FlyCamera;
  44209. /**
  44210. * The list of keyboard keys used to control the forward move of the camera.
  44211. */
  44212. keysForward: number[];
  44213. /**
  44214. * The list of keyboard keys used to control the backward move of the camera.
  44215. */
  44216. keysBackward: number[];
  44217. /**
  44218. * The list of keyboard keys used to control the forward move of the camera.
  44219. */
  44220. keysUp: number[];
  44221. /**
  44222. * The list of keyboard keys used to control the backward move of the camera.
  44223. */
  44224. keysDown: number[];
  44225. /**
  44226. * The list of keyboard keys used to control the right strafe move of the camera.
  44227. */
  44228. keysRight: number[];
  44229. /**
  44230. * The list of keyboard keys used to control the left strafe move of the camera.
  44231. */
  44232. keysLeft: number[];
  44233. private _keys;
  44234. private _onCanvasBlurObserver;
  44235. private _onKeyboardObserver;
  44236. private _engine;
  44237. private _scene;
  44238. /**
  44239. * Attach the input controls to a specific dom element to get the input from.
  44240. * @param element Defines the element the controls should be listened from
  44241. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44242. */
  44243. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44244. /**
  44245. * Detach the current controls from the specified dom element.
  44246. * @param element Defines the element to stop listening the inputs from
  44247. */
  44248. detachControl(element: Nullable<HTMLElement>): void;
  44249. /**
  44250. * Gets the class name of the current intput.
  44251. * @returns the class name
  44252. */
  44253. getClassName(): string;
  44254. /** @hidden */
  44255. _onLostFocus(e: FocusEvent): void;
  44256. /**
  44257. * Get the friendly name associated with the input class.
  44258. * @returns the input friendly name
  44259. */
  44260. getSimpleName(): string;
  44261. /**
  44262. * Update the current camera state depending on the inputs that have been used this frame.
  44263. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44264. */
  44265. checkInputs(): void;
  44266. }
  44267. }
  44268. declare module BABYLON {
  44269. /**
  44270. * Manage the mouse wheel inputs to control a follow camera.
  44271. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44272. */
  44273. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  44274. /**
  44275. * Defines the camera the input is attached to.
  44276. */
  44277. camera: FollowCamera;
  44278. /**
  44279. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  44280. */
  44281. axisControlRadius: boolean;
  44282. /**
  44283. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  44284. */
  44285. axisControlHeight: boolean;
  44286. /**
  44287. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  44288. */
  44289. axisControlRotation: boolean;
  44290. /**
  44291. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  44292. * relation to mouseWheel events.
  44293. */
  44294. wheelPrecision: number;
  44295. /**
  44296. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44297. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44298. */
  44299. wheelDeltaPercentage: number;
  44300. private _wheel;
  44301. private _observer;
  44302. /**
  44303. * Attach the input controls to a specific dom element to get the input from.
  44304. * @param element Defines the element the controls should be listened from
  44305. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44306. */
  44307. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44308. /**
  44309. * Detach the current controls from the specified dom element.
  44310. * @param element Defines the element to stop listening the inputs from
  44311. */
  44312. detachControl(element: Nullable<HTMLElement>): void;
  44313. /**
  44314. * Gets the class name of the current intput.
  44315. * @returns the class name
  44316. */
  44317. getClassName(): string;
  44318. /**
  44319. * Get the friendly name associated with the input class.
  44320. * @returns the input friendly name
  44321. */
  44322. getSimpleName(): string;
  44323. }
  44324. }
  44325. declare module BABYLON {
  44326. /**
  44327. * Manage the pointers inputs to control an follow camera.
  44328. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44329. */
  44330. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  44331. /**
  44332. * Defines the camera the input is attached to.
  44333. */
  44334. camera: FollowCamera;
  44335. /**
  44336. * Gets the class name of the current input.
  44337. * @returns the class name
  44338. */
  44339. getClassName(): string;
  44340. /**
  44341. * Defines the pointer angular sensibility along the X axis or how fast is
  44342. * the camera rotating.
  44343. * A negative number will reverse the axis direction.
  44344. */
  44345. angularSensibilityX: number;
  44346. /**
  44347. * Defines the pointer angular sensibility along the Y axis or how fast is
  44348. * the camera rotating.
  44349. * A negative number will reverse the axis direction.
  44350. */
  44351. angularSensibilityY: number;
  44352. /**
  44353. * Defines the pointer pinch precision or how fast is the camera zooming.
  44354. * A negative number will reverse the axis direction.
  44355. */
  44356. pinchPrecision: number;
  44357. /**
  44358. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44359. * from 0.
  44360. * It defines the percentage of current camera.radius to use as delta when
  44361. * pinch zoom is used.
  44362. */
  44363. pinchDeltaPercentage: number;
  44364. /**
  44365. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  44366. */
  44367. axisXControlRadius: boolean;
  44368. /**
  44369. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  44370. */
  44371. axisXControlHeight: boolean;
  44372. /**
  44373. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  44374. */
  44375. axisXControlRotation: boolean;
  44376. /**
  44377. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  44378. */
  44379. axisYControlRadius: boolean;
  44380. /**
  44381. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  44382. */
  44383. axisYControlHeight: boolean;
  44384. /**
  44385. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  44386. */
  44387. axisYControlRotation: boolean;
  44388. /**
  44389. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  44390. */
  44391. axisPinchControlRadius: boolean;
  44392. /**
  44393. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  44394. */
  44395. axisPinchControlHeight: boolean;
  44396. /**
  44397. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  44398. */
  44399. axisPinchControlRotation: boolean;
  44400. /**
  44401. * Log error messages if basic misconfiguration has occurred.
  44402. */
  44403. warningEnable: boolean;
  44404. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44405. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44406. private _warningCounter;
  44407. private _warning;
  44408. }
  44409. }
  44410. declare module BABYLON {
  44411. /**
  44412. * Default Inputs manager for the FollowCamera.
  44413. * It groups all the default supported inputs for ease of use.
  44414. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44415. */
  44416. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  44417. /**
  44418. * Instantiates a new FollowCameraInputsManager.
  44419. * @param camera Defines the camera the inputs belong to
  44420. */
  44421. constructor(camera: FollowCamera);
  44422. /**
  44423. * Add keyboard input support to the input manager.
  44424. * @returns the current input manager
  44425. */
  44426. addKeyboard(): FollowCameraInputsManager;
  44427. /**
  44428. * Add mouse wheel input support to the input manager.
  44429. * @returns the current input manager
  44430. */
  44431. addMouseWheel(): FollowCameraInputsManager;
  44432. /**
  44433. * Add pointers input support to the input manager.
  44434. * @returns the current input manager
  44435. */
  44436. addPointers(): FollowCameraInputsManager;
  44437. /**
  44438. * Add orientation input support to the input manager.
  44439. * @returns the current input manager
  44440. */
  44441. addVRDeviceOrientation(): FollowCameraInputsManager;
  44442. }
  44443. }
  44444. declare module BABYLON {
  44445. /**
  44446. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  44447. * an arc rotate version arcFollowCamera are available.
  44448. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44449. */
  44450. export class FollowCamera extends TargetCamera {
  44451. /**
  44452. * Distance the follow camera should follow an object at
  44453. */
  44454. radius: number;
  44455. /**
  44456. * Minimum allowed distance of the camera to the axis of rotation
  44457. * (The camera can not get closer).
  44458. * This can help limiting how the Camera is able to move in the scene.
  44459. */
  44460. lowerRadiusLimit: Nullable<number>;
  44461. /**
  44462. * Maximum allowed distance of the camera to the axis of rotation
  44463. * (The camera can not get further).
  44464. * This can help limiting how the Camera is able to move in the scene.
  44465. */
  44466. upperRadiusLimit: Nullable<number>;
  44467. /**
  44468. * Define a rotation offset between the camera and the object it follows
  44469. */
  44470. rotationOffset: number;
  44471. /**
  44472. * Minimum allowed angle to camera position relative to target object.
  44473. * This can help limiting how the Camera is able to move in the scene.
  44474. */
  44475. lowerRotationOffsetLimit: Nullable<number>;
  44476. /**
  44477. * Maximum allowed angle to camera position relative to target object.
  44478. * This can help limiting how the Camera is able to move in the scene.
  44479. */
  44480. upperRotationOffsetLimit: Nullable<number>;
  44481. /**
  44482. * Define a height offset between the camera and the object it follows.
  44483. * It can help following an object from the top (like a car chaing a plane)
  44484. */
  44485. heightOffset: number;
  44486. /**
  44487. * Minimum allowed height of camera position relative to target object.
  44488. * This can help limiting how the Camera is able to move in the scene.
  44489. */
  44490. lowerHeightOffsetLimit: Nullable<number>;
  44491. /**
  44492. * Maximum allowed height of camera position relative to target object.
  44493. * This can help limiting how the Camera is able to move in the scene.
  44494. */
  44495. upperHeightOffsetLimit: Nullable<number>;
  44496. /**
  44497. * Define how fast the camera can accelerate to follow it s target.
  44498. */
  44499. cameraAcceleration: number;
  44500. /**
  44501. * Define the speed limit of the camera following an object.
  44502. */
  44503. maxCameraSpeed: number;
  44504. /**
  44505. * Define the target of the camera.
  44506. */
  44507. lockedTarget: Nullable<AbstractMesh>;
  44508. /**
  44509. * Defines the input associated with the camera.
  44510. */
  44511. inputs: FollowCameraInputsManager;
  44512. /**
  44513. * Instantiates the follow camera.
  44514. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44515. * @param name Define the name of the camera in the scene
  44516. * @param position Define the position of the camera
  44517. * @param scene Define the scene the camera belong to
  44518. * @param lockedTarget Define the target of the camera
  44519. */
  44520. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  44521. private _follow;
  44522. /**
  44523. * Attached controls to the current camera.
  44524. * @param element Defines the element the controls should be listened from
  44525. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44526. */
  44527. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44528. /**
  44529. * Detach the current controls from the camera.
  44530. * The camera will stop reacting to inputs.
  44531. * @param element Defines the element to stop listening the inputs from
  44532. */
  44533. detachControl(element: HTMLElement): void;
  44534. /** @hidden */
  44535. _checkInputs(): void;
  44536. private _checkLimits;
  44537. /**
  44538. * Gets the camera class name.
  44539. * @returns the class name
  44540. */
  44541. getClassName(): string;
  44542. }
  44543. /**
  44544. * Arc Rotate version of the follow camera.
  44545. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  44546. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44547. */
  44548. export class ArcFollowCamera extends TargetCamera {
  44549. /** The longitudinal angle of the camera */
  44550. alpha: number;
  44551. /** The latitudinal angle of the camera */
  44552. beta: number;
  44553. /** The radius of the camera from its target */
  44554. radius: number;
  44555. private _cartesianCoordinates;
  44556. /** Define the camera target (the mesh it should follow) */
  44557. private _meshTarget;
  44558. /**
  44559. * Instantiates a new ArcFollowCamera
  44560. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44561. * @param name Define the name of the camera
  44562. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  44563. * @param beta Define the rotation angle of the camera around the elevation axis
  44564. * @param radius Define the radius of the camera from its target point
  44565. * @param target Define the target of the camera
  44566. * @param scene Define the scene the camera belongs to
  44567. */
  44568. constructor(name: string,
  44569. /** The longitudinal angle of the camera */
  44570. alpha: number,
  44571. /** The latitudinal angle of the camera */
  44572. beta: number,
  44573. /** The radius of the camera from its target */
  44574. radius: number,
  44575. /** Define the camera target (the mesh it should follow) */
  44576. target: Nullable<AbstractMesh>, scene: Scene);
  44577. private _follow;
  44578. /** @hidden */
  44579. _checkInputs(): void;
  44580. /**
  44581. * Returns the class name of the object.
  44582. * It is mostly used internally for serialization purposes.
  44583. */
  44584. getClassName(): string;
  44585. }
  44586. }
  44587. declare module BABYLON {
  44588. /**
  44589. * Manage the keyboard inputs to control the movement of a follow camera.
  44590. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44591. */
  44592. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  44593. /**
  44594. * Defines the camera the input is attached to.
  44595. */
  44596. camera: FollowCamera;
  44597. /**
  44598. * Defines the list of key codes associated with the up action (increase heightOffset)
  44599. */
  44600. keysHeightOffsetIncr: number[];
  44601. /**
  44602. * Defines the list of key codes associated with the down action (decrease heightOffset)
  44603. */
  44604. keysHeightOffsetDecr: number[];
  44605. /**
  44606. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  44607. */
  44608. keysHeightOffsetModifierAlt: boolean;
  44609. /**
  44610. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  44611. */
  44612. keysHeightOffsetModifierCtrl: boolean;
  44613. /**
  44614. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  44615. */
  44616. keysHeightOffsetModifierShift: boolean;
  44617. /**
  44618. * Defines the list of key codes associated with the left action (increase rotationOffset)
  44619. */
  44620. keysRotationOffsetIncr: number[];
  44621. /**
  44622. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  44623. */
  44624. keysRotationOffsetDecr: number[];
  44625. /**
  44626. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  44627. */
  44628. keysRotationOffsetModifierAlt: boolean;
  44629. /**
  44630. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  44631. */
  44632. keysRotationOffsetModifierCtrl: boolean;
  44633. /**
  44634. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  44635. */
  44636. keysRotationOffsetModifierShift: boolean;
  44637. /**
  44638. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  44639. */
  44640. keysRadiusIncr: number[];
  44641. /**
  44642. * Defines the list of key codes associated with the zoom-out action (increase radius)
  44643. */
  44644. keysRadiusDecr: number[];
  44645. /**
  44646. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  44647. */
  44648. keysRadiusModifierAlt: boolean;
  44649. /**
  44650. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  44651. */
  44652. keysRadiusModifierCtrl: boolean;
  44653. /**
  44654. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  44655. */
  44656. keysRadiusModifierShift: boolean;
  44657. /**
  44658. * Defines the rate of change of heightOffset.
  44659. */
  44660. heightSensibility: number;
  44661. /**
  44662. * Defines the rate of change of rotationOffset.
  44663. */
  44664. rotationSensibility: number;
  44665. /**
  44666. * Defines the rate of change of radius.
  44667. */
  44668. radiusSensibility: number;
  44669. private _keys;
  44670. private _ctrlPressed;
  44671. private _altPressed;
  44672. private _shiftPressed;
  44673. private _onCanvasBlurObserver;
  44674. private _onKeyboardObserver;
  44675. private _engine;
  44676. private _scene;
  44677. /**
  44678. * Attach the input controls to a specific dom element to get the input from.
  44679. * @param element Defines the element the controls should be listened from
  44680. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44681. */
  44682. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44683. /**
  44684. * Detach the current controls from the specified dom element.
  44685. * @param element Defines the element to stop listening the inputs from
  44686. */
  44687. detachControl(element: Nullable<HTMLElement>): void;
  44688. /**
  44689. * Update the current camera state depending on the inputs that have been used this frame.
  44690. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44691. */
  44692. checkInputs(): void;
  44693. /**
  44694. * Gets the class name of the current input.
  44695. * @returns the class name
  44696. */
  44697. getClassName(): string;
  44698. /**
  44699. * Get the friendly name associated with the input class.
  44700. * @returns the input friendly name
  44701. */
  44702. getSimpleName(): string;
  44703. /**
  44704. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44705. * allow modification of the heightOffset value.
  44706. */
  44707. private _modifierHeightOffset;
  44708. /**
  44709. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44710. * allow modification of the rotationOffset value.
  44711. */
  44712. private _modifierRotationOffset;
  44713. /**
  44714. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44715. * allow modification of the radius value.
  44716. */
  44717. private _modifierRadius;
  44718. }
  44719. }
  44720. declare module BABYLON {
  44721. interface FreeCameraInputsManager {
  44722. /**
  44723. * @hidden
  44724. */
  44725. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  44726. /**
  44727. * Add orientation input support to the input manager.
  44728. * @returns the current input manager
  44729. */
  44730. addDeviceOrientation(): FreeCameraInputsManager;
  44731. }
  44732. /**
  44733. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  44734. * Screen rotation is taken into account.
  44735. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44736. */
  44737. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  44738. private _camera;
  44739. private _screenOrientationAngle;
  44740. private _constantTranform;
  44741. private _screenQuaternion;
  44742. private _alpha;
  44743. private _beta;
  44744. private _gamma;
  44745. /**
  44746. * Can be used to detect if a device orientation sensor is available on a device
  44747. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  44748. * @returns a promise that will resolve on orientation change
  44749. */
  44750. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  44751. /**
  44752. * @hidden
  44753. */
  44754. _onDeviceOrientationChangedObservable: Observable<void>;
  44755. /**
  44756. * Instantiates a new input
  44757. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44758. */
  44759. constructor();
  44760. /**
  44761. * Define the camera controlled by the input.
  44762. */
  44763. get camera(): FreeCamera;
  44764. set camera(camera: FreeCamera);
  44765. /**
  44766. * Attach the input controls to a specific dom element to get the input from.
  44767. * @param element Defines the element the controls should be listened from
  44768. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44769. */
  44770. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44771. private _orientationChanged;
  44772. private _deviceOrientation;
  44773. /**
  44774. * Detach the current controls from the specified dom element.
  44775. * @param element Defines the element to stop listening the inputs from
  44776. */
  44777. detachControl(element: Nullable<HTMLElement>): void;
  44778. /**
  44779. * Update the current camera state depending on the inputs that have been used this frame.
  44780. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44781. */
  44782. checkInputs(): void;
  44783. /**
  44784. * Gets the class name of the current intput.
  44785. * @returns the class name
  44786. */
  44787. getClassName(): string;
  44788. /**
  44789. * Get the friendly name associated with the input class.
  44790. * @returns the input friendly name
  44791. */
  44792. getSimpleName(): string;
  44793. }
  44794. }
  44795. declare module BABYLON {
  44796. /**
  44797. * Manage the gamepad inputs to control a free camera.
  44798. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44799. */
  44800. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  44801. /**
  44802. * Define the camera the input is attached to.
  44803. */
  44804. camera: FreeCamera;
  44805. /**
  44806. * Define the Gamepad controlling the input
  44807. */
  44808. gamepad: Nullable<Gamepad>;
  44809. /**
  44810. * Defines the gamepad rotation sensiblity.
  44811. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44812. */
  44813. gamepadAngularSensibility: number;
  44814. /**
  44815. * Defines the gamepad move sensiblity.
  44816. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44817. */
  44818. gamepadMoveSensibility: number;
  44819. private _yAxisScale;
  44820. /**
  44821. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44822. */
  44823. get invertYAxis(): boolean;
  44824. set invertYAxis(value: boolean);
  44825. private _onGamepadConnectedObserver;
  44826. private _onGamepadDisconnectedObserver;
  44827. private _cameraTransform;
  44828. private _deltaTransform;
  44829. private _vector3;
  44830. private _vector2;
  44831. /**
  44832. * Attach the input controls to a specific dom element to get the input from.
  44833. * @param element Defines the element the controls should be listened from
  44834. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44835. */
  44836. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44837. /**
  44838. * Detach the current controls from the specified dom element.
  44839. * @param element Defines the element to stop listening the inputs from
  44840. */
  44841. detachControl(element: Nullable<HTMLElement>): void;
  44842. /**
  44843. * Update the current camera state depending on the inputs that have been used this frame.
  44844. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44845. */
  44846. checkInputs(): void;
  44847. /**
  44848. * Gets the class name of the current intput.
  44849. * @returns the class name
  44850. */
  44851. getClassName(): string;
  44852. /**
  44853. * Get the friendly name associated with the input class.
  44854. * @returns the input friendly name
  44855. */
  44856. getSimpleName(): string;
  44857. }
  44858. }
  44859. declare module BABYLON {
  44860. /**
  44861. * Defines the potential axis of a Joystick
  44862. */
  44863. export enum JoystickAxis {
  44864. /** X axis */
  44865. X = 0,
  44866. /** Y axis */
  44867. Y = 1,
  44868. /** Z axis */
  44869. Z = 2
  44870. }
  44871. /**
  44872. * Represents the different customization options available
  44873. * for VirtualJoystick
  44874. */
  44875. interface VirtualJoystickCustomizations {
  44876. /**
  44877. * Size of the joystick's puck
  44878. */
  44879. puckSize: number;
  44880. /**
  44881. * Size of the joystick's container
  44882. */
  44883. containerSize: number;
  44884. /**
  44885. * Color of the joystick && puck
  44886. */
  44887. color: string;
  44888. /**
  44889. * Image URL for the joystick's puck
  44890. */
  44891. puckImage?: string;
  44892. /**
  44893. * Image URL for the joystick's container
  44894. */
  44895. containerImage?: string;
  44896. /**
  44897. * Defines the unmoving position of the joystick container
  44898. */
  44899. position?: {
  44900. x: number;
  44901. y: number;
  44902. };
  44903. /**
  44904. * Defines whether or not the joystick container is always visible
  44905. */
  44906. alwaysVisible: boolean;
  44907. /**
  44908. * Defines whether or not to limit the movement of the puck to the joystick's container
  44909. */
  44910. limitToContainer: boolean;
  44911. }
  44912. /**
  44913. * Class used to define virtual joystick (used in touch mode)
  44914. */
  44915. export class VirtualJoystick {
  44916. /**
  44917. * Gets or sets a boolean indicating that left and right values must be inverted
  44918. */
  44919. reverseLeftRight: boolean;
  44920. /**
  44921. * Gets or sets a boolean indicating that up and down values must be inverted
  44922. */
  44923. reverseUpDown: boolean;
  44924. /**
  44925. * Gets the offset value for the position (ie. the change of the position value)
  44926. */
  44927. deltaPosition: Vector3;
  44928. /**
  44929. * Gets a boolean indicating if the virtual joystick was pressed
  44930. */
  44931. pressed: boolean;
  44932. /**
  44933. * Canvas the virtual joystick will render onto, default z-index of this is 5
  44934. */
  44935. static Canvas: Nullable<HTMLCanvasElement>;
  44936. /**
  44937. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  44938. */
  44939. limitToContainer: boolean;
  44940. private static _globalJoystickIndex;
  44941. private static _alwaysVisibleSticks;
  44942. private static vjCanvasContext;
  44943. private static vjCanvasWidth;
  44944. private static vjCanvasHeight;
  44945. private static halfWidth;
  44946. private static _GetDefaultOptions;
  44947. private _action;
  44948. private _axisTargetedByLeftAndRight;
  44949. private _axisTargetedByUpAndDown;
  44950. private _joystickSensibility;
  44951. private _inversedSensibility;
  44952. private _joystickPointerID;
  44953. private _joystickColor;
  44954. private _joystickPointerPos;
  44955. private _joystickPreviousPointerPos;
  44956. private _joystickPointerStartPos;
  44957. private _deltaJoystickVector;
  44958. private _leftJoystick;
  44959. private _touches;
  44960. private _joystickPosition;
  44961. private _alwaysVisible;
  44962. private _puckImage;
  44963. private _containerImage;
  44964. private _joystickPuckSize;
  44965. private _joystickContainerSize;
  44966. private _clearPuckSize;
  44967. private _clearContainerSize;
  44968. private _clearPuckSizeOffset;
  44969. private _clearContainerSizeOffset;
  44970. private _onPointerDownHandlerRef;
  44971. private _onPointerMoveHandlerRef;
  44972. private _onPointerUpHandlerRef;
  44973. private _onResize;
  44974. /**
  44975. * Creates a new virtual joystick
  44976. * @param leftJoystick defines that the joystick is for left hand (false by default)
  44977. * @param customizations Defines the options we want to customize the VirtualJoystick
  44978. */
  44979. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  44980. /**
  44981. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  44982. * @param newJoystickSensibility defines the new sensibility
  44983. */
  44984. setJoystickSensibility(newJoystickSensibility: number): void;
  44985. private _onPointerDown;
  44986. private _onPointerMove;
  44987. private _onPointerUp;
  44988. /**
  44989. * Change the color of the virtual joystick
  44990. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  44991. */
  44992. setJoystickColor(newColor: string): void;
  44993. /**
  44994. * Size of the joystick's container
  44995. */
  44996. set containerSize(newSize: number);
  44997. get containerSize(): number;
  44998. /**
  44999. * Size of the joystick's puck
  45000. */
  45001. set puckSize(newSize: number);
  45002. get puckSize(): number;
  45003. /**
  45004. * Clears the set position of the joystick
  45005. */
  45006. clearPosition(): void;
  45007. /**
  45008. * Defines whether or not the joystick container is always visible
  45009. */
  45010. set alwaysVisible(value: boolean);
  45011. get alwaysVisible(): boolean;
  45012. /**
  45013. * Sets the constant position of the Joystick container
  45014. * @param x X axis coordinate
  45015. * @param y Y axis coordinate
  45016. */
  45017. setPosition(x: number, y: number): void;
  45018. /**
  45019. * Defines a callback to call when the joystick is touched
  45020. * @param action defines the callback
  45021. */
  45022. setActionOnTouch(action: () => any): void;
  45023. /**
  45024. * Defines which axis you'd like to control for left & right
  45025. * @param axis defines the axis to use
  45026. */
  45027. setAxisForLeftRight(axis: JoystickAxis): void;
  45028. /**
  45029. * Defines which axis you'd like to control for up & down
  45030. * @param axis defines the axis to use
  45031. */
  45032. setAxisForUpDown(axis: JoystickAxis): void;
  45033. /**
  45034. * Clears the canvas from the previous puck / container draw
  45035. */
  45036. private _clearPreviousDraw;
  45037. /**
  45038. * Loads `urlPath` to be used for the container's image
  45039. * @param urlPath defines the urlPath of an image to use
  45040. */
  45041. setContainerImage(urlPath: string): void;
  45042. /**
  45043. * Loads `urlPath` to be used for the puck's image
  45044. * @param urlPath defines the urlPath of an image to use
  45045. */
  45046. setPuckImage(urlPath: string): void;
  45047. /**
  45048. * Draws the Virtual Joystick's container
  45049. */
  45050. private _drawContainer;
  45051. /**
  45052. * Draws the Virtual Joystick's puck
  45053. */
  45054. private _drawPuck;
  45055. private _drawVirtualJoystick;
  45056. /**
  45057. * Release internal HTML canvas
  45058. */
  45059. releaseCanvas(): void;
  45060. }
  45061. }
  45062. declare module BABYLON {
  45063. interface FreeCameraInputsManager {
  45064. /**
  45065. * Add virtual joystick input support to the input manager.
  45066. * @returns the current input manager
  45067. */
  45068. addVirtualJoystick(): FreeCameraInputsManager;
  45069. }
  45070. /**
  45071. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  45072. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45073. */
  45074. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  45075. /**
  45076. * Defines the camera the input is attached to.
  45077. */
  45078. camera: FreeCamera;
  45079. private _leftjoystick;
  45080. private _rightjoystick;
  45081. /**
  45082. * Gets the left stick of the virtual joystick.
  45083. * @returns The virtual Joystick
  45084. */
  45085. getLeftJoystick(): VirtualJoystick;
  45086. /**
  45087. * Gets the right stick of the virtual joystick.
  45088. * @returns The virtual Joystick
  45089. */
  45090. getRightJoystick(): VirtualJoystick;
  45091. /**
  45092. * Update the current camera state depending on the inputs that have been used this frame.
  45093. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45094. */
  45095. checkInputs(): void;
  45096. /**
  45097. * Attach the input controls to a specific dom element to get the input from.
  45098. * @param element Defines the element the controls should be listened from
  45099. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45100. */
  45101. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45102. /**
  45103. * Detach the current controls from the specified dom element.
  45104. * @param element Defines the element to stop listening the inputs from
  45105. */
  45106. detachControl(element: Nullable<HTMLElement>): void;
  45107. /**
  45108. * Gets the class name of the current intput.
  45109. * @returns the class name
  45110. */
  45111. getClassName(): string;
  45112. /**
  45113. * Get the friendly name associated with the input class.
  45114. * @returns the input friendly name
  45115. */
  45116. getSimpleName(): string;
  45117. }
  45118. }
  45119. declare module BABYLON {
  45120. /**
  45121. * This represents a FPS type of camera controlled by touch.
  45122. * This is like a universal camera minus the Gamepad controls.
  45123. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45124. */
  45125. export class TouchCamera extends FreeCamera {
  45126. /**
  45127. * Defines the touch sensibility for rotation.
  45128. * The higher the faster.
  45129. */
  45130. get touchAngularSensibility(): number;
  45131. set touchAngularSensibility(value: number);
  45132. /**
  45133. * Defines the touch sensibility for move.
  45134. * The higher the faster.
  45135. */
  45136. get touchMoveSensibility(): number;
  45137. set touchMoveSensibility(value: number);
  45138. /**
  45139. * Instantiates a new touch camera.
  45140. * This represents a FPS type of camera controlled by touch.
  45141. * This is like a universal camera minus the Gamepad controls.
  45142. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45143. * @param name Define the name of the camera in the scene
  45144. * @param position Define the start position of the camera in the scene
  45145. * @param scene Define the scene the camera belongs to
  45146. */
  45147. constructor(name: string, position: Vector3, scene: Scene);
  45148. /**
  45149. * Gets the current object class name.
  45150. * @return the class name
  45151. */
  45152. getClassName(): string;
  45153. /** @hidden */
  45154. _setupInputs(): void;
  45155. }
  45156. }
  45157. declare module BABYLON {
  45158. /**
  45159. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  45160. * being tilted forward or back and left or right.
  45161. */
  45162. export class DeviceOrientationCamera extends FreeCamera {
  45163. private _initialQuaternion;
  45164. private _quaternionCache;
  45165. private _tmpDragQuaternion;
  45166. private _disablePointerInputWhenUsingDeviceOrientation;
  45167. /**
  45168. * Creates a new device orientation camera
  45169. * @param name The name of the camera
  45170. * @param position The start position camera
  45171. * @param scene The scene the camera belongs to
  45172. */
  45173. constructor(name: string, position: Vector3, scene: Scene);
  45174. /**
  45175. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  45176. */
  45177. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  45178. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  45179. private _dragFactor;
  45180. /**
  45181. * Enabled turning on the y axis when the orientation sensor is active
  45182. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  45183. */
  45184. enableHorizontalDragging(dragFactor?: number): void;
  45185. /**
  45186. * Gets the current instance class name ("DeviceOrientationCamera").
  45187. * This helps avoiding instanceof at run time.
  45188. * @returns the class name
  45189. */
  45190. getClassName(): string;
  45191. /**
  45192. * @hidden
  45193. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  45194. */
  45195. _checkInputs(): void;
  45196. /**
  45197. * Reset the camera to its default orientation on the specified axis only.
  45198. * @param axis The axis to reset
  45199. */
  45200. resetToCurrentRotation(axis?: Axis): void;
  45201. }
  45202. }
  45203. declare module BABYLON {
  45204. /**
  45205. * Defines supported buttons for XBox360 compatible gamepads
  45206. */
  45207. export enum Xbox360Button {
  45208. /** A */
  45209. A = 0,
  45210. /** B */
  45211. B = 1,
  45212. /** X */
  45213. X = 2,
  45214. /** Y */
  45215. Y = 3,
  45216. /** Left button */
  45217. LB = 4,
  45218. /** Right button */
  45219. RB = 5,
  45220. /** Back */
  45221. Back = 8,
  45222. /** Start */
  45223. Start = 9,
  45224. /** Left stick */
  45225. LeftStick = 10,
  45226. /** Right stick */
  45227. RightStick = 11
  45228. }
  45229. /** Defines values for XBox360 DPad */
  45230. export enum Xbox360Dpad {
  45231. /** Up */
  45232. Up = 12,
  45233. /** Down */
  45234. Down = 13,
  45235. /** Left */
  45236. Left = 14,
  45237. /** Right */
  45238. Right = 15
  45239. }
  45240. /**
  45241. * Defines a XBox360 gamepad
  45242. */
  45243. export class Xbox360Pad extends Gamepad {
  45244. private _leftTrigger;
  45245. private _rightTrigger;
  45246. private _onlefttriggerchanged;
  45247. private _onrighttriggerchanged;
  45248. private _onbuttondown;
  45249. private _onbuttonup;
  45250. private _ondpaddown;
  45251. private _ondpadup;
  45252. /** Observable raised when a button is pressed */
  45253. onButtonDownObservable: Observable<Xbox360Button>;
  45254. /** Observable raised when a button is released */
  45255. onButtonUpObservable: Observable<Xbox360Button>;
  45256. /** Observable raised when a pad is pressed */
  45257. onPadDownObservable: Observable<Xbox360Dpad>;
  45258. /** Observable raised when a pad is released */
  45259. onPadUpObservable: Observable<Xbox360Dpad>;
  45260. private _buttonA;
  45261. private _buttonB;
  45262. private _buttonX;
  45263. private _buttonY;
  45264. private _buttonBack;
  45265. private _buttonStart;
  45266. private _buttonLB;
  45267. private _buttonRB;
  45268. private _buttonLeftStick;
  45269. private _buttonRightStick;
  45270. private _dPadUp;
  45271. private _dPadDown;
  45272. private _dPadLeft;
  45273. private _dPadRight;
  45274. private _isXboxOnePad;
  45275. /**
  45276. * Creates a new XBox360 gamepad object
  45277. * @param id defines the id of this gamepad
  45278. * @param index defines its index
  45279. * @param gamepad defines the internal HTML gamepad object
  45280. * @param xboxOne defines if it is a XBox One gamepad
  45281. */
  45282. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  45283. /**
  45284. * Defines the callback to call when left trigger is pressed
  45285. * @param callback defines the callback to use
  45286. */
  45287. onlefttriggerchanged(callback: (value: number) => void): void;
  45288. /**
  45289. * Defines the callback to call when right trigger is pressed
  45290. * @param callback defines the callback to use
  45291. */
  45292. onrighttriggerchanged(callback: (value: number) => void): void;
  45293. /**
  45294. * Gets the left trigger value
  45295. */
  45296. get leftTrigger(): number;
  45297. /**
  45298. * Sets the left trigger value
  45299. */
  45300. set leftTrigger(newValue: number);
  45301. /**
  45302. * Gets the right trigger value
  45303. */
  45304. get rightTrigger(): number;
  45305. /**
  45306. * Sets the right trigger value
  45307. */
  45308. set rightTrigger(newValue: number);
  45309. /**
  45310. * Defines the callback to call when a button is pressed
  45311. * @param callback defines the callback to use
  45312. */
  45313. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  45314. /**
  45315. * Defines the callback to call when a button is released
  45316. * @param callback defines the callback to use
  45317. */
  45318. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  45319. /**
  45320. * Defines the callback to call when a pad is pressed
  45321. * @param callback defines the callback to use
  45322. */
  45323. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  45324. /**
  45325. * Defines the callback to call when a pad is released
  45326. * @param callback defines the callback to use
  45327. */
  45328. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  45329. private _setButtonValue;
  45330. private _setDPadValue;
  45331. /**
  45332. * Gets the value of the `A` button
  45333. */
  45334. get buttonA(): number;
  45335. /**
  45336. * Sets the value of the `A` button
  45337. */
  45338. set buttonA(value: number);
  45339. /**
  45340. * Gets the value of the `B` button
  45341. */
  45342. get buttonB(): number;
  45343. /**
  45344. * Sets the value of the `B` button
  45345. */
  45346. set buttonB(value: number);
  45347. /**
  45348. * Gets the value of the `X` button
  45349. */
  45350. get buttonX(): number;
  45351. /**
  45352. * Sets the value of the `X` button
  45353. */
  45354. set buttonX(value: number);
  45355. /**
  45356. * Gets the value of the `Y` button
  45357. */
  45358. get buttonY(): number;
  45359. /**
  45360. * Sets the value of the `Y` button
  45361. */
  45362. set buttonY(value: number);
  45363. /**
  45364. * Gets the value of the `Start` button
  45365. */
  45366. get buttonStart(): number;
  45367. /**
  45368. * Sets the value of the `Start` button
  45369. */
  45370. set buttonStart(value: number);
  45371. /**
  45372. * Gets the value of the `Back` button
  45373. */
  45374. get buttonBack(): number;
  45375. /**
  45376. * Sets the value of the `Back` button
  45377. */
  45378. set buttonBack(value: number);
  45379. /**
  45380. * Gets the value of the `Left` button
  45381. */
  45382. get buttonLB(): number;
  45383. /**
  45384. * Sets the value of the `Left` button
  45385. */
  45386. set buttonLB(value: number);
  45387. /**
  45388. * Gets the value of the `Right` button
  45389. */
  45390. get buttonRB(): number;
  45391. /**
  45392. * Sets the value of the `Right` button
  45393. */
  45394. set buttonRB(value: number);
  45395. /**
  45396. * Gets the value of the Left joystick
  45397. */
  45398. get buttonLeftStick(): number;
  45399. /**
  45400. * Sets the value of the Left joystick
  45401. */
  45402. set buttonLeftStick(value: number);
  45403. /**
  45404. * Gets the value of the Right joystick
  45405. */
  45406. get buttonRightStick(): number;
  45407. /**
  45408. * Sets the value of the Right joystick
  45409. */
  45410. set buttonRightStick(value: number);
  45411. /**
  45412. * Gets the value of D-pad up
  45413. */
  45414. get dPadUp(): number;
  45415. /**
  45416. * Sets the value of D-pad up
  45417. */
  45418. set dPadUp(value: number);
  45419. /**
  45420. * Gets the value of D-pad down
  45421. */
  45422. get dPadDown(): number;
  45423. /**
  45424. * Sets the value of D-pad down
  45425. */
  45426. set dPadDown(value: number);
  45427. /**
  45428. * Gets the value of D-pad left
  45429. */
  45430. get dPadLeft(): number;
  45431. /**
  45432. * Sets the value of D-pad left
  45433. */
  45434. set dPadLeft(value: number);
  45435. /**
  45436. * Gets the value of D-pad right
  45437. */
  45438. get dPadRight(): number;
  45439. /**
  45440. * Sets the value of D-pad right
  45441. */
  45442. set dPadRight(value: number);
  45443. /**
  45444. * Force the gamepad to synchronize with device values
  45445. */
  45446. update(): void;
  45447. /**
  45448. * Disposes the gamepad
  45449. */
  45450. dispose(): void;
  45451. }
  45452. }
  45453. declare module BABYLON {
  45454. /**
  45455. * Defines supported buttons for DualShock compatible gamepads
  45456. */
  45457. export enum DualShockButton {
  45458. /** Cross */
  45459. Cross = 0,
  45460. /** Circle */
  45461. Circle = 1,
  45462. /** Square */
  45463. Square = 2,
  45464. /** Triangle */
  45465. Triangle = 3,
  45466. /** L1 */
  45467. L1 = 4,
  45468. /** R1 */
  45469. R1 = 5,
  45470. /** Share */
  45471. Share = 8,
  45472. /** Options */
  45473. Options = 9,
  45474. /** Left stick */
  45475. LeftStick = 10,
  45476. /** Right stick */
  45477. RightStick = 11
  45478. }
  45479. /** Defines values for DualShock DPad */
  45480. export enum DualShockDpad {
  45481. /** Up */
  45482. Up = 12,
  45483. /** Down */
  45484. Down = 13,
  45485. /** Left */
  45486. Left = 14,
  45487. /** Right */
  45488. Right = 15
  45489. }
  45490. /**
  45491. * Defines a DualShock gamepad
  45492. */
  45493. export class DualShockPad extends Gamepad {
  45494. private _leftTrigger;
  45495. private _rightTrigger;
  45496. private _onlefttriggerchanged;
  45497. private _onrighttriggerchanged;
  45498. private _onbuttondown;
  45499. private _onbuttonup;
  45500. private _ondpaddown;
  45501. private _ondpadup;
  45502. /** Observable raised when a button is pressed */
  45503. onButtonDownObservable: Observable<DualShockButton>;
  45504. /** Observable raised when a button is released */
  45505. onButtonUpObservable: Observable<DualShockButton>;
  45506. /** Observable raised when a pad is pressed */
  45507. onPadDownObservable: Observable<DualShockDpad>;
  45508. /** Observable raised when a pad is released */
  45509. onPadUpObservable: Observable<DualShockDpad>;
  45510. private _buttonCross;
  45511. private _buttonCircle;
  45512. private _buttonSquare;
  45513. private _buttonTriangle;
  45514. private _buttonShare;
  45515. private _buttonOptions;
  45516. private _buttonL1;
  45517. private _buttonR1;
  45518. private _buttonLeftStick;
  45519. private _buttonRightStick;
  45520. private _dPadUp;
  45521. private _dPadDown;
  45522. private _dPadLeft;
  45523. private _dPadRight;
  45524. /**
  45525. * Creates a new DualShock gamepad object
  45526. * @param id defines the id of this gamepad
  45527. * @param index defines its index
  45528. * @param gamepad defines the internal HTML gamepad object
  45529. */
  45530. constructor(id: string, index: number, gamepad: any);
  45531. /**
  45532. * Defines the callback to call when left trigger is pressed
  45533. * @param callback defines the callback to use
  45534. */
  45535. onlefttriggerchanged(callback: (value: number) => void): void;
  45536. /**
  45537. * Defines the callback to call when right trigger is pressed
  45538. * @param callback defines the callback to use
  45539. */
  45540. onrighttriggerchanged(callback: (value: number) => void): void;
  45541. /**
  45542. * Gets the left trigger value
  45543. */
  45544. get leftTrigger(): number;
  45545. /**
  45546. * Sets the left trigger value
  45547. */
  45548. set leftTrigger(newValue: number);
  45549. /**
  45550. * Gets the right trigger value
  45551. */
  45552. get rightTrigger(): number;
  45553. /**
  45554. * Sets the right trigger value
  45555. */
  45556. set rightTrigger(newValue: number);
  45557. /**
  45558. * Defines the callback to call when a button is pressed
  45559. * @param callback defines the callback to use
  45560. */
  45561. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  45562. /**
  45563. * Defines the callback to call when a button is released
  45564. * @param callback defines the callback to use
  45565. */
  45566. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  45567. /**
  45568. * Defines the callback to call when a pad is pressed
  45569. * @param callback defines the callback to use
  45570. */
  45571. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  45572. /**
  45573. * Defines the callback to call when a pad is released
  45574. * @param callback defines the callback to use
  45575. */
  45576. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  45577. private _setButtonValue;
  45578. private _setDPadValue;
  45579. /**
  45580. * Gets the value of the `Cross` button
  45581. */
  45582. get buttonCross(): number;
  45583. /**
  45584. * Sets the value of the `Cross` button
  45585. */
  45586. set buttonCross(value: number);
  45587. /**
  45588. * Gets the value of the `Circle` button
  45589. */
  45590. get buttonCircle(): number;
  45591. /**
  45592. * Sets the value of the `Circle` button
  45593. */
  45594. set buttonCircle(value: number);
  45595. /**
  45596. * Gets the value of the `Square` button
  45597. */
  45598. get buttonSquare(): number;
  45599. /**
  45600. * Sets the value of the `Square` button
  45601. */
  45602. set buttonSquare(value: number);
  45603. /**
  45604. * Gets the value of the `Triangle` button
  45605. */
  45606. get buttonTriangle(): number;
  45607. /**
  45608. * Sets the value of the `Triangle` button
  45609. */
  45610. set buttonTriangle(value: number);
  45611. /**
  45612. * Gets the value of the `Options` button
  45613. */
  45614. get buttonOptions(): number;
  45615. /**
  45616. * Sets the value of the `Options` button
  45617. */
  45618. set buttonOptions(value: number);
  45619. /**
  45620. * Gets the value of the `Share` button
  45621. */
  45622. get buttonShare(): number;
  45623. /**
  45624. * Sets the value of the `Share` button
  45625. */
  45626. set buttonShare(value: number);
  45627. /**
  45628. * Gets the value of the `L1` button
  45629. */
  45630. get buttonL1(): number;
  45631. /**
  45632. * Sets the value of the `L1` button
  45633. */
  45634. set buttonL1(value: number);
  45635. /**
  45636. * Gets the value of the `R1` button
  45637. */
  45638. get buttonR1(): number;
  45639. /**
  45640. * Sets the value of the `R1` button
  45641. */
  45642. set buttonR1(value: number);
  45643. /**
  45644. * Gets the value of the Left joystick
  45645. */
  45646. get buttonLeftStick(): number;
  45647. /**
  45648. * Sets the value of the Left joystick
  45649. */
  45650. set buttonLeftStick(value: number);
  45651. /**
  45652. * Gets the value of the Right joystick
  45653. */
  45654. get buttonRightStick(): number;
  45655. /**
  45656. * Sets the value of the Right joystick
  45657. */
  45658. set buttonRightStick(value: number);
  45659. /**
  45660. * Gets the value of D-pad up
  45661. */
  45662. get dPadUp(): number;
  45663. /**
  45664. * Sets the value of D-pad up
  45665. */
  45666. set dPadUp(value: number);
  45667. /**
  45668. * Gets the value of D-pad down
  45669. */
  45670. get dPadDown(): number;
  45671. /**
  45672. * Sets the value of D-pad down
  45673. */
  45674. set dPadDown(value: number);
  45675. /**
  45676. * Gets the value of D-pad left
  45677. */
  45678. get dPadLeft(): number;
  45679. /**
  45680. * Sets the value of D-pad left
  45681. */
  45682. set dPadLeft(value: number);
  45683. /**
  45684. * Gets the value of D-pad right
  45685. */
  45686. get dPadRight(): number;
  45687. /**
  45688. * Sets the value of D-pad right
  45689. */
  45690. set dPadRight(value: number);
  45691. /**
  45692. * Force the gamepad to synchronize with device values
  45693. */
  45694. update(): void;
  45695. /**
  45696. * Disposes the gamepad
  45697. */
  45698. dispose(): void;
  45699. }
  45700. }
  45701. declare module BABYLON {
  45702. /**
  45703. * Manager for handling gamepads
  45704. */
  45705. export class GamepadManager {
  45706. private _scene?;
  45707. private _babylonGamepads;
  45708. private _oneGamepadConnected;
  45709. /** @hidden */
  45710. _isMonitoring: boolean;
  45711. private _gamepadEventSupported;
  45712. private _gamepadSupport?;
  45713. /**
  45714. * observable to be triggered when the gamepad controller has been connected
  45715. */
  45716. onGamepadConnectedObservable: Observable<Gamepad>;
  45717. /**
  45718. * observable to be triggered when the gamepad controller has been disconnected
  45719. */
  45720. onGamepadDisconnectedObservable: Observable<Gamepad>;
  45721. private _onGamepadConnectedEvent;
  45722. private _onGamepadDisconnectedEvent;
  45723. /**
  45724. * Initializes the gamepad manager
  45725. * @param _scene BabylonJS scene
  45726. */
  45727. constructor(_scene?: Scene | undefined);
  45728. /**
  45729. * The gamepads in the game pad manager
  45730. */
  45731. get gamepads(): Gamepad[];
  45732. /**
  45733. * Get the gamepad controllers based on type
  45734. * @param type The type of gamepad controller
  45735. * @returns Nullable gamepad
  45736. */
  45737. getGamepadByType(type?: number): Nullable<Gamepad>;
  45738. /**
  45739. * Disposes the gamepad manager
  45740. */
  45741. dispose(): void;
  45742. private _addNewGamepad;
  45743. private _startMonitoringGamepads;
  45744. private _stopMonitoringGamepads;
  45745. /** @hidden */
  45746. _checkGamepadsStatus(): void;
  45747. private _updateGamepadObjects;
  45748. }
  45749. }
  45750. declare module BABYLON {
  45751. interface Scene {
  45752. /** @hidden */
  45753. _gamepadManager: Nullable<GamepadManager>;
  45754. /**
  45755. * Gets the gamepad manager associated with the scene
  45756. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  45757. */
  45758. gamepadManager: GamepadManager;
  45759. }
  45760. /**
  45761. * Interface representing a free camera inputs manager
  45762. */
  45763. interface FreeCameraInputsManager {
  45764. /**
  45765. * Adds gamepad input support to the FreeCameraInputsManager.
  45766. * @returns the FreeCameraInputsManager
  45767. */
  45768. addGamepad(): FreeCameraInputsManager;
  45769. }
  45770. /**
  45771. * Interface representing an arc rotate camera inputs manager
  45772. */
  45773. interface ArcRotateCameraInputsManager {
  45774. /**
  45775. * Adds gamepad input support to the ArcRotateCamera InputManager.
  45776. * @returns the camera inputs manager
  45777. */
  45778. addGamepad(): ArcRotateCameraInputsManager;
  45779. }
  45780. /**
  45781. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  45782. */
  45783. export class GamepadSystemSceneComponent implements ISceneComponent {
  45784. /**
  45785. * The component name helpfull to identify the component in the list of scene components.
  45786. */
  45787. readonly name: string;
  45788. /**
  45789. * The scene the component belongs to.
  45790. */
  45791. scene: Scene;
  45792. /**
  45793. * Creates a new instance of the component for the given scene
  45794. * @param scene Defines the scene to register the component in
  45795. */
  45796. constructor(scene: Scene);
  45797. /**
  45798. * Registers the component in a given scene
  45799. */
  45800. register(): void;
  45801. /**
  45802. * Rebuilds the elements related to this component in case of
  45803. * context lost for instance.
  45804. */
  45805. rebuild(): void;
  45806. /**
  45807. * Disposes the component and the associated ressources
  45808. */
  45809. dispose(): void;
  45810. private _beforeCameraUpdate;
  45811. }
  45812. }
  45813. declare module BABYLON {
  45814. /**
  45815. * 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,
  45816. * which still works and will still be found in many Playgrounds.
  45817. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45818. */
  45819. export class UniversalCamera extends TouchCamera {
  45820. /**
  45821. * Defines the gamepad rotation sensiblity.
  45822. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45823. */
  45824. get gamepadAngularSensibility(): number;
  45825. set gamepadAngularSensibility(value: number);
  45826. /**
  45827. * Defines the gamepad move sensiblity.
  45828. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45829. */
  45830. get gamepadMoveSensibility(): number;
  45831. set gamepadMoveSensibility(value: number);
  45832. /**
  45833. * 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,
  45834. * which still works and will still be found in many Playgrounds.
  45835. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45836. * @param name Define the name of the camera in the scene
  45837. * @param position Define the start position of the camera in the scene
  45838. * @param scene Define the scene the camera belongs to
  45839. */
  45840. constructor(name: string, position: Vector3, scene: Scene);
  45841. /**
  45842. * Gets the current object class name.
  45843. * @return the class name
  45844. */
  45845. getClassName(): string;
  45846. }
  45847. }
  45848. declare module BABYLON {
  45849. /**
  45850. * This represents a FPS type of camera. This is only here for back compat purpose.
  45851. * Please use the UniversalCamera instead as both are identical.
  45852. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45853. */
  45854. export class GamepadCamera extends UniversalCamera {
  45855. /**
  45856. * Instantiates a new Gamepad Camera
  45857. * This represents a FPS type of camera. This is only here for back compat purpose.
  45858. * Please use the UniversalCamera instead as both are identical.
  45859. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45860. * @param name Define the name of the camera in the scene
  45861. * @param position Define the start position of the camera in the scene
  45862. * @param scene Define the scene the camera belongs to
  45863. */
  45864. constructor(name: string, position: Vector3, scene: Scene);
  45865. /**
  45866. * Gets the current object class name.
  45867. * @return the class name
  45868. */
  45869. getClassName(): string;
  45870. }
  45871. }
  45872. declare module BABYLON {
  45873. /** @hidden */
  45874. export var passPixelShader: {
  45875. name: string;
  45876. shader: string;
  45877. };
  45878. }
  45879. declare module BABYLON {
  45880. /** @hidden */
  45881. export var passCubePixelShader: {
  45882. name: string;
  45883. shader: string;
  45884. };
  45885. }
  45886. declare module BABYLON {
  45887. /**
  45888. * PassPostProcess which produces an output the same as it's input
  45889. */
  45890. export class PassPostProcess extends PostProcess {
  45891. /**
  45892. * Creates the PassPostProcess
  45893. * @param name The name of the effect.
  45894. * @param options The required width/height ratio to downsize to before computing the render pass.
  45895. * @param camera The camera to apply the render pass to.
  45896. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  45897. * @param engine The engine which the post process will be applied. (default: current engine)
  45898. * @param reusable If the post process can be reused on the same frame. (default: false)
  45899. * @param textureType The type of texture to be used when performing the post processing.
  45900. * @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)
  45901. */
  45902. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  45903. }
  45904. /**
  45905. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  45906. */
  45907. export class PassCubePostProcess extends PostProcess {
  45908. private _face;
  45909. /**
  45910. * Gets or sets the cube face to display.
  45911. * * 0 is +X
  45912. * * 1 is -X
  45913. * * 2 is +Y
  45914. * * 3 is -Y
  45915. * * 4 is +Z
  45916. * * 5 is -Z
  45917. */
  45918. get face(): number;
  45919. set face(value: number);
  45920. /**
  45921. * Creates the PassCubePostProcess
  45922. * @param name The name of the effect.
  45923. * @param options The required width/height ratio to downsize to before computing the render pass.
  45924. * @param camera The camera to apply the render pass to.
  45925. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  45926. * @param engine The engine which the post process will be applied. (default: current engine)
  45927. * @param reusable If the post process can be reused on the same frame. (default: false)
  45928. * @param textureType The type of texture to be used when performing the post processing.
  45929. * @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)
  45930. */
  45931. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  45932. }
  45933. }
  45934. declare module BABYLON {
  45935. /** @hidden */
  45936. export var anaglyphPixelShader: {
  45937. name: string;
  45938. shader: string;
  45939. };
  45940. }
  45941. declare module BABYLON {
  45942. /**
  45943. * Postprocess used to generate anaglyphic rendering
  45944. */
  45945. export class AnaglyphPostProcess extends PostProcess {
  45946. private _passedProcess;
  45947. /**
  45948. * Creates a new AnaglyphPostProcess
  45949. * @param name defines postprocess name
  45950. * @param options defines creation options or target ratio scale
  45951. * @param rigCameras defines cameras using this postprocess
  45952. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  45953. * @param engine defines hosting engine
  45954. * @param reusable defines if the postprocess will be reused multiple times per frame
  45955. */
  45956. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  45957. }
  45958. }
  45959. declare module BABYLON {
  45960. /**
  45961. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  45962. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45963. */
  45964. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  45965. /**
  45966. * Creates a new AnaglyphArcRotateCamera
  45967. * @param name defines camera name
  45968. * @param alpha defines alpha angle (in radians)
  45969. * @param beta defines beta angle (in radians)
  45970. * @param radius defines radius
  45971. * @param target defines camera target
  45972. * @param interaxialDistance defines distance between each color axis
  45973. * @param scene defines the hosting scene
  45974. */
  45975. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  45976. /**
  45977. * Gets camera class name
  45978. * @returns AnaglyphArcRotateCamera
  45979. */
  45980. getClassName(): string;
  45981. }
  45982. }
  45983. declare module BABYLON {
  45984. /**
  45985. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  45986. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45987. */
  45988. export class AnaglyphFreeCamera extends FreeCamera {
  45989. /**
  45990. * Creates a new AnaglyphFreeCamera
  45991. * @param name defines camera name
  45992. * @param position defines initial position
  45993. * @param interaxialDistance defines distance between each color axis
  45994. * @param scene defines the hosting scene
  45995. */
  45996. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45997. /**
  45998. * Gets camera class name
  45999. * @returns AnaglyphFreeCamera
  46000. */
  46001. getClassName(): string;
  46002. }
  46003. }
  46004. declare module BABYLON {
  46005. /**
  46006. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  46007. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46008. */
  46009. export class AnaglyphGamepadCamera extends GamepadCamera {
  46010. /**
  46011. * Creates a new AnaglyphGamepadCamera
  46012. * @param name defines camera name
  46013. * @param position defines initial position
  46014. * @param interaxialDistance defines distance between each color axis
  46015. * @param scene defines the hosting scene
  46016. */
  46017. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46018. /**
  46019. * Gets camera class name
  46020. * @returns AnaglyphGamepadCamera
  46021. */
  46022. getClassName(): string;
  46023. }
  46024. }
  46025. declare module BABYLON {
  46026. /**
  46027. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  46028. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46029. */
  46030. export class AnaglyphUniversalCamera extends UniversalCamera {
  46031. /**
  46032. * Creates a new AnaglyphUniversalCamera
  46033. * @param name defines camera name
  46034. * @param position defines initial position
  46035. * @param interaxialDistance defines distance between each color axis
  46036. * @param scene defines the hosting scene
  46037. */
  46038. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46039. /**
  46040. * Gets camera class name
  46041. * @returns AnaglyphUniversalCamera
  46042. */
  46043. getClassName(): string;
  46044. }
  46045. }
  46046. declare module BABYLON {
  46047. /**
  46048. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  46049. * @see https://doc.babylonjs.com/features/cameras
  46050. */
  46051. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  46052. /**
  46053. * Creates a new StereoscopicArcRotateCamera
  46054. * @param name defines camera name
  46055. * @param alpha defines alpha angle (in radians)
  46056. * @param beta defines beta angle (in radians)
  46057. * @param radius defines radius
  46058. * @param target defines camera target
  46059. * @param interaxialDistance defines distance between each color axis
  46060. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46061. * @param scene defines the hosting scene
  46062. */
  46063. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46064. /**
  46065. * Gets camera class name
  46066. * @returns StereoscopicArcRotateCamera
  46067. */
  46068. getClassName(): string;
  46069. }
  46070. }
  46071. declare module BABYLON {
  46072. /**
  46073. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  46074. * @see https://doc.babylonjs.com/features/cameras
  46075. */
  46076. export class StereoscopicFreeCamera extends FreeCamera {
  46077. /**
  46078. * Creates a new StereoscopicFreeCamera
  46079. * @param name defines camera name
  46080. * @param position defines initial position
  46081. * @param interaxialDistance defines distance between each color axis
  46082. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46083. * @param scene defines the hosting scene
  46084. */
  46085. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46086. /**
  46087. * Gets camera class name
  46088. * @returns StereoscopicFreeCamera
  46089. */
  46090. getClassName(): string;
  46091. }
  46092. }
  46093. declare module BABYLON {
  46094. /**
  46095. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  46096. * @see https://doc.babylonjs.com/features/cameras
  46097. */
  46098. export class StereoscopicGamepadCamera extends GamepadCamera {
  46099. /**
  46100. * Creates a new StereoscopicGamepadCamera
  46101. * @param name defines camera name
  46102. * @param position defines initial position
  46103. * @param interaxialDistance defines distance between each color axis
  46104. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46105. * @param scene defines the hosting scene
  46106. */
  46107. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46108. /**
  46109. * Gets camera class name
  46110. * @returns StereoscopicGamepadCamera
  46111. */
  46112. getClassName(): string;
  46113. }
  46114. }
  46115. declare module BABYLON {
  46116. /**
  46117. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  46118. * @see https://doc.babylonjs.com/features/cameras
  46119. */
  46120. export class StereoscopicUniversalCamera extends UniversalCamera {
  46121. /**
  46122. * Creates a new StereoscopicUniversalCamera
  46123. * @param name defines camera name
  46124. * @param position defines initial position
  46125. * @param interaxialDistance defines distance between each color axis
  46126. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46127. * @param scene defines the hosting scene
  46128. */
  46129. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46130. /**
  46131. * Gets camera class name
  46132. * @returns StereoscopicUniversalCamera
  46133. */
  46134. getClassName(): string;
  46135. }
  46136. }
  46137. declare module BABYLON {
  46138. /**
  46139. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  46140. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46141. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46142. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46143. */
  46144. export class VirtualJoysticksCamera extends FreeCamera {
  46145. /**
  46146. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  46147. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46148. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46149. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46150. * @param name Define the name of the camera in the scene
  46151. * @param position Define the start position of the camera in the scene
  46152. * @param scene Define the scene the camera belongs to
  46153. */
  46154. constructor(name: string, position: Vector3, scene: Scene);
  46155. /**
  46156. * Gets the current object class name.
  46157. * @return the class name
  46158. */
  46159. getClassName(): string;
  46160. }
  46161. }
  46162. declare module BABYLON {
  46163. /**
  46164. * This represents all the required metrics to create a VR camera.
  46165. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  46166. */
  46167. export class VRCameraMetrics {
  46168. /**
  46169. * Define the horizontal resolution off the screen.
  46170. */
  46171. hResolution: number;
  46172. /**
  46173. * Define the vertical resolution off the screen.
  46174. */
  46175. vResolution: number;
  46176. /**
  46177. * Define the horizontal screen size.
  46178. */
  46179. hScreenSize: number;
  46180. /**
  46181. * Define the vertical screen size.
  46182. */
  46183. vScreenSize: number;
  46184. /**
  46185. * Define the vertical screen center position.
  46186. */
  46187. vScreenCenter: number;
  46188. /**
  46189. * Define the distance of the eyes to the screen.
  46190. */
  46191. eyeToScreenDistance: number;
  46192. /**
  46193. * Define the distance between both lenses
  46194. */
  46195. lensSeparationDistance: number;
  46196. /**
  46197. * Define the distance between both viewer's eyes.
  46198. */
  46199. interpupillaryDistance: number;
  46200. /**
  46201. * Define the distortion factor of the VR postprocess.
  46202. * Please, touch with care.
  46203. */
  46204. distortionK: number[];
  46205. /**
  46206. * Define the chromatic aberration correction factors for the VR post process.
  46207. */
  46208. chromaAbCorrection: number[];
  46209. /**
  46210. * Define the scale factor of the post process.
  46211. * The smaller the better but the slower.
  46212. */
  46213. postProcessScaleFactor: number;
  46214. /**
  46215. * Define an offset for the lens center.
  46216. */
  46217. lensCenterOffset: number;
  46218. /**
  46219. * Define if the current vr camera should compensate the distortion of the lense or not.
  46220. */
  46221. compensateDistortion: boolean;
  46222. /**
  46223. * Defines if multiview should be enabled when rendering (Default: false)
  46224. */
  46225. multiviewEnabled: boolean;
  46226. /**
  46227. * Gets the rendering aspect ratio based on the provided resolutions.
  46228. */
  46229. get aspectRatio(): number;
  46230. /**
  46231. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  46232. */
  46233. get aspectRatioFov(): number;
  46234. /**
  46235. * @hidden
  46236. */
  46237. get leftHMatrix(): Matrix;
  46238. /**
  46239. * @hidden
  46240. */
  46241. get rightHMatrix(): Matrix;
  46242. /**
  46243. * @hidden
  46244. */
  46245. get leftPreViewMatrix(): Matrix;
  46246. /**
  46247. * @hidden
  46248. */
  46249. get rightPreViewMatrix(): Matrix;
  46250. /**
  46251. * Get the default VRMetrics based on the most generic setup.
  46252. * @returns the default vr metrics
  46253. */
  46254. static GetDefault(): VRCameraMetrics;
  46255. }
  46256. }
  46257. declare module BABYLON {
  46258. /** @hidden */
  46259. export var vrDistortionCorrectionPixelShader: {
  46260. name: string;
  46261. shader: string;
  46262. };
  46263. }
  46264. declare module BABYLON {
  46265. /**
  46266. * VRDistortionCorrectionPostProcess used for mobile VR
  46267. */
  46268. export class VRDistortionCorrectionPostProcess extends PostProcess {
  46269. private _isRightEye;
  46270. private _distortionFactors;
  46271. private _postProcessScaleFactor;
  46272. private _lensCenterOffset;
  46273. private _scaleIn;
  46274. private _scaleFactor;
  46275. private _lensCenter;
  46276. /**
  46277. * Initializes the VRDistortionCorrectionPostProcess
  46278. * @param name The name of the effect.
  46279. * @param camera The camera to apply the render pass to.
  46280. * @param isRightEye If this is for the right eye distortion
  46281. * @param vrMetrics All the required metrics for the VR camera
  46282. */
  46283. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  46284. }
  46285. }
  46286. declare module BABYLON {
  46287. /**
  46288. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  46289. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46290. */
  46291. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  46292. /**
  46293. * Creates a new VRDeviceOrientationArcRotateCamera
  46294. * @param name defines camera name
  46295. * @param alpha defines the camera rotation along the logitudinal axis
  46296. * @param beta defines the camera rotation along the latitudinal axis
  46297. * @param radius defines the camera distance from its target
  46298. * @param target defines the camera target
  46299. * @param scene defines the scene the camera belongs to
  46300. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46301. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46302. */
  46303. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46304. /**
  46305. * Gets camera class name
  46306. * @returns VRDeviceOrientationArcRotateCamera
  46307. */
  46308. getClassName(): string;
  46309. }
  46310. }
  46311. declare module BABYLON {
  46312. /**
  46313. * Camera used to simulate VR rendering (based on FreeCamera)
  46314. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46315. */
  46316. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  46317. /**
  46318. * Creates a new VRDeviceOrientationFreeCamera
  46319. * @param name defines camera name
  46320. * @param position defines the start position of the camera
  46321. * @param scene defines the scene the camera belongs to
  46322. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46323. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46324. */
  46325. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46326. /**
  46327. * Gets camera class name
  46328. * @returns VRDeviceOrientationFreeCamera
  46329. */
  46330. getClassName(): string;
  46331. }
  46332. }
  46333. declare module BABYLON {
  46334. /**
  46335. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  46336. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46337. */
  46338. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  46339. /**
  46340. * Creates a new VRDeviceOrientationGamepadCamera
  46341. * @param name defines camera name
  46342. * @param position defines the start position of the camera
  46343. * @param scene defines the scene the camera belongs to
  46344. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46345. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46346. */
  46347. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46348. /**
  46349. * Gets camera class name
  46350. * @returns VRDeviceOrientationGamepadCamera
  46351. */
  46352. getClassName(): string;
  46353. }
  46354. }
  46355. declare module BABYLON {
  46356. /**
  46357. * A class extending Texture allowing drawing on a texture
  46358. * @see https://doc.babylonjs.com/how_to/dynamictexture
  46359. */
  46360. export class DynamicTexture extends Texture {
  46361. private _generateMipMaps;
  46362. private _canvas;
  46363. private _context;
  46364. /**
  46365. * Creates a DynamicTexture
  46366. * @param name defines the name of the texture
  46367. * @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
  46368. * @param scene defines the scene where you want the texture
  46369. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  46370. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  46371. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  46372. */
  46373. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  46374. /**
  46375. * Get the current class name of the texture useful for serialization or dynamic coding.
  46376. * @returns "DynamicTexture"
  46377. */
  46378. getClassName(): string;
  46379. /**
  46380. * Gets the current state of canRescale
  46381. */
  46382. get canRescale(): boolean;
  46383. private _recreate;
  46384. /**
  46385. * Scales the texture
  46386. * @param ratio the scale factor to apply to both width and height
  46387. */
  46388. scale(ratio: number): void;
  46389. /**
  46390. * Resizes the texture
  46391. * @param width the new width
  46392. * @param height the new height
  46393. */
  46394. scaleTo(width: number, height: number): void;
  46395. /**
  46396. * Gets the context of the canvas used by the texture
  46397. * @returns the canvas context of the dynamic texture
  46398. */
  46399. getContext(): CanvasRenderingContext2D;
  46400. /**
  46401. * Clears the texture
  46402. */
  46403. clear(): void;
  46404. /**
  46405. * Updates the texture
  46406. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46407. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  46408. */
  46409. update(invertY?: boolean, premulAlpha?: boolean): void;
  46410. /**
  46411. * Draws text onto the texture
  46412. * @param text defines the text to be drawn
  46413. * @param x defines the placement of the text from the left
  46414. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  46415. * @param font defines the font to be used with font-style, font-size, font-name
  46416. * @param color defines the color used for the text
  46417. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  46418. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46419. * @param update defines whether texture is immediately update (default is true)
  46420. */
  46421. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  46422. /**
  46423. * Clones the texture
  46424. * @returns the clone of the texture.
  46425. */
  46426. clone(): DynamicTexture;
  46427. /**
  46428. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  46429. * @returns a serialized dynamic texture object
  46430. */
  46431. serialize(): any;
  46432. private _IsCanvasElement;
  46433. /** @hidden */
  46434. _rebuild(): void;
  46435. }
  46436. }
  46437. declare module BABYLON {
  46438. /**
  46439. * Class containing static functions to help procedurally build meshes
  46440. */
  46441. export class GroundBuilder {
  46442. /**
  46443. * Creates a ground mesh
  46444. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  46445. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  46446. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46447. * @param name defines the name of the mesh
  46448. * @param options defines the options used to create the mesh
  46449. * @param scene defines the hosting scene
  46450. * @returns the ground mesh
  46451. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  46452. */
  46453. static CreateGround(name: string, options: {
  46454. width?: number;
  46455. height?: number;
  46456. subdivisions?: number;
  46457. subdivisionsX?: number;
  46458. subdivisionsY?: number;
  46459. updatable?: boolean;
  46460. }, scene: any): Mesh;
  46461. /**
  46462. * Creates a tiled ground mesh
  46463. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  46464. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  46465. * * 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
  46466. * * 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
  46467. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46468. * @param name defines the name of the mesh
  46469. * @param options defines the options used to create the mesh
  46470. * @param scene defines the hosting scene
  46471. * @returns the tiled ground mesh
  46472. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  46473. */
  46474. static CreateTiledGround(name: string, options: {
  46475. xmin: number;
  46476. zmin: number;
  46477. xmax: number;
  46478. zmax: number;
  46479. subdivisions?: {
  46480. w: number;
  46481. h: number;
  46482. };
  46483. precision?: {
  46484. w: number;
  46485. h: number;
  46486. };
  46487. updatable?: boolean;
  46488. }, scene?: Nullable<Scene>): Mesh;
  46489. /**
  46490. * Creates a ground mesh from a height map
  46491. * * The parameter `url` sets the URL of the height map image resource.
  46492. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  46493. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  46494. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  46495. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  46496. * * 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.
  46497. * * 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).
  46498. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  46499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46500. * @param name defines the name of the mesh
  46501. * @param url defines the url to the height map
  46502. * @param options defines the options used to create the mesh
  46503. * @param scene defines the hosting scene
  46504. * @returns the ground mesh
  46505. * @see https://doc.babylonjs.com/babylon101/height_map
  46506. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  46507. */
  46508. static CreateGroundFromHeightMap(name: string, url: string, options: {
  46509. width?: number;
  46510. height?: number;
  46511. subdivisions?: number;
  46512. minHeight?: number;
  46513. maxHeight?: number;
  46514. colorFilter?: Color3;
  46515. alphaFilter?: number;
  46516. updatable?: boolean;
  46517. onReady?: (mesh: GroundMesh) => void;
  46518. }, scene?: Nullable<Scene>): GroundMesh;
  46519. }
  46520. }
  46521. declare module BABYLON {
  46522. /**
  46523. * Class containing static functions to help procedurally build meshes
  46524. */
  46525. export class TorusBuilder {
  46526. /**
  46527. * Creates a torus mesh
  46528. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  46529. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  46530. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  46531. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46532. * * 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
  46533. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46534. * @param name defines the name of the mesh
  46535. * @param options defines the options used to create the mesh
  46536. * @param scene defines the hosting scene
  46537. * @returns the torus mesh
  46538. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  46539. */
  46540. static CreateTorus(name: string, options: {
  46541. diameter?: number;
  46542. thickness?: number;
  46543. tessellation?: number;
  46544. updatable?: boolean;
  46545. sideOrientation?: number;
  46546. frontUVs?: Vector4;
  46547. backUVs?: Vector4;
  46548. }, scene: any): Mesh;
  46549. }
  46550. }
  46551. declare module BABYLON {
  46552. /**
  46553. * Class containing static functions to help procedurally build meshes
  46554. */
  46555. export class CylinderBuilder {
  46556. /**
  46557. * Creates a cylinder or a cone mesh
  46558. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  46559. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  46560. * * 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.
  46561. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  46562. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  46563. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  46564. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  46565. * * 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).
  46566. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  46567. * * 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).
  46568. * * 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
  46569. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  46570. * * 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
  46571. * * 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.
  46572. * * If `enclose` is false, a ring surface is one element.
  46573. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  46574. * * 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
  46575. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46576. * * 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
  46577. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46578. * @param name defines the name of the mesh
  46579. * @param options defines the options used to create the mesh
  46580. * @param scene defines the hosting scene
  46581. * @returns the cylinder mesh
  46582. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  46583. */
  46584. static CreateCylinder(name: string, options: {
  46585. height?: number;
  46586. diameterTop?: number;
  46587. diameterBottom?: number;
  46588. diameter?: number;
  46589. tessellation?: number;
  46590. subdivisions?: number;
  46591. arc?: number;
  46592. faceColors?: Color4[];
  46593. faceUV?: Vector4[];
  46594. updatable?: boolean;
  46595. hasRings?: boolean;
  46596. enclose?: boolean;
  46597. cap?: number;
  46598. sideOrientation?: number;
  46599. frontUVs?: Vector4;
  46600. backUVs?: Vector4;
  46601. }, scene: any): Mesh;
  46602. }
  46603. }
  46604. declare module BABYLON {
  46605. /**
  46606. * States of the webXR experience
  46607. */
  46608. export enum WebXRState {
  46609. /**
  46610. * Transitioning to being in XR mode
  46611. */
  46612. ENTERING_XR = 0,
  46613. /**
  46614. * Transitioning to non XR mode
  46615. */
  46616. EXITING_XR = 1,
  46617. /**
  46618. * In XR mode and presenting
  46619. */
  46620. IN_XR = 2,
  46621. /**
  46622. * Not entered XR mode
  46623. */
  46624. NOT_IN_XR = 3
  46625. }
  46626. /**
  46627. * Abstraction of the XR render target
  46628. */
  46629. export interface WebXRRenderTarget extends IDisposable {
  46630. /**
  46631. * xrpresent context of the canvas which can be used to display/mirror xr content
  46632. */
  46633. canvasContext: WebGLRenderingContext;
  46634. /**
  46635. * xr layer for the canvas
  46636. */
  46637. xrLayer: Nullable<XRWebGLLayer>;
  46638. /**
  46639. * Initializes the xr layer for the session
  46640. * @param xrSession xr session
  46641. * @returns a promise that will resolve once the XR Layer has been created
  46642. */
  46643. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46644. }
  46645. }
  46646. declare module BABYLON {
  46647. /**
  46648. * COnfiguration object for WebXR output canvas
  46649. */
  46650. export class WebXRManagedOutputCanvasOptions {
  46651. /**
  46652. * An optional canvas in case you wish to create it yourself and provide it here.
  46653. * If not provided, a new canvas will be created
  46654. */
  46655. canvasElement?: HTMLCanvasElement;
  46656. /**
  46657. * Options for this XR Layer output
  46658. */
  46659. canvasOptions?: XRWebGLLayerOptions;
  46660. /**
  46661. * CSS styling for a newly created canvas (if not provided)
  46662. */
  46663. newCanvasCssStyle?: string;
  46664. /**
  46665. * Get the default values of the configuration object
  46666. * @returns default values of this configuration object
  46667. */
  46668. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  46669. }
  46670. /**
  46671. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  46672. */
  46673. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  46674. private _options;
  46675. private _canvas;
  46676. private _engine;
  46677. private _originalCanvasSize;
  46678. /**
  46679. * Rendering context of the canvas which can be used to display/mirror xr content
  46680. */
  46681. canvasContext: WebGLRenderingContext;
  46682. /**
  46683. * xr layer for the canvas
  46684. */
  46685. xrLayer: Nullable<XRWebGLLayer>;
  46686. /**
  46687. * Obseervers registered here will be triggered when the xr layer was initialized
  46688. */
  46689. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  46690. /**
  46691. * Initializes the canvas to be added/removed upon entering/exiting xr
  46692. * @param _xrSessionManager The XR Session manager
  46693. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  46694. */
  46695. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  46696. /**
  46697. * Disposes of the object
  46698. */
  46699. dispose(): void;
  46700. /**
  46701. * Initializes the xr layer for the session
  46702. * @param xrSession xr session
  46703. * @returns a promise that will resolve once the XR Layer has been created
  46704. */
  46705. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46706. private _addCanvas;
  46707. private _removeCanvas;
  46708. private _setCanvasSize;
  46709. private _setManagedOutputCanvas;
  46710. }
  46711. }
  46712. declare module BABYLON {
  46713. /**
  46714. * Manages an XRSession to work with Babylon's engine
  46715. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  46716. */
  46717. export class WebXRSessionManager implements IDisposable {
  46718. /** The scene which the session should be created for */
  46719. scene: Scene;
  46720. private _referenceSpace;
  46721. private _rttProvider;
  46722. private _sessionEnded;
  46723. private _xrNavigator;
  46724. private baseLayer;
  46725. /**
  46726. * The base reference space from which the session started. good if you want to reset your
  46727. * reference space
  46728. */
  46729. baseReferenceSpace: XRReferenceSpace;
  46730. /**
  46731. * Current XR frame
  46732. */
  46733. currentFrame: Nullable<XRFrame>;
  46734. /** WebXR timestamp updated every frame */
  46735. currentTimestamp: number;
  46736. /**
  46737. * Used just in case of a failure to initialize an immersive session.
  46738. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  46739. */
  46740. defaultHeightCompensation: number;
  46741. /**
  46742. * Fires every time a new xrFrame arrives which can be used to update the camera
  46743. */
  46744. onXRFrameObservable: Observable<XRFrame>;
  46745. /**
  46746. * Fires when the reference space changed
  46747. */
  46748. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  46749. /**
  46750. * Fires when the xr session is ended either by the device or manually done
  46751. */
  46752. onXRSessionEnded: Observable<any>;
  46753. /**
  46754. * Fires when the xr session is ended either by the device or manually done
  46755. */
  46756. onXRSessionInit: Observable<XRSession>;
  46757. /**
  46758. * Underlying xr session
  46759. */
  46760. session: XRSession;
  46761. /**
  46762. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  46763. * or get the offset the player is currently at.
  46764. */
  46765. viewerReferenceSpace: XRReferenceSpace;
  46766. /**
  46767. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  46768. * @param scene The scene which the session should be created for
  46769. */
  46770. constructor(
  46771. /** The scene which the session should be created for */
  46772. scene: Scene);
  46773. /**
  46774. * The current reference space used in this session. This reference space can constantly change!
  46775. * It is mainly used to offset the camera's position.
  46776. */
  46777. get referenceSpace(): XRReferenceSpace;
  46778. /**
  46779. * Set a new reference space and triggers the observable
  46780. */
  46781. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  46782. /**
  46783. * Disposes of the session manager
  46784. */
  46785. dispose(): void;
  46786. /**
  46787. * Stops the xrSession and restores the render loop
  46788. * @returns Promise which resolves after it exits XR
  46789. */
  46790. exitXRAsync(): Promise<void>;
  46791. /**
  46792. * Gets the correct render target texture to be rendered this frame for this eye
  46793. * @param eye the eye for which to get the render target
  46794. * @returns the render target for the specified eye
  46795. */
  46796. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  46797. /**
  46798. * Creates a WebXRRenderTarget object for the XR session
  46799. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  46800. * @param options optional options to provide when creating a new render target
  46801. * @returns a WebXR render target to which the session can render
  46802. */
  46803. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  46804. /**
  46805. * Initializes the manager
  46806. * After initialization enterXR can be called to start an XR session
  46807. * @returns Promise which resolves after it is initialized
  46808. */
  46809. initializeAsync(): Promise<void>;
  46810. /**
  46811. * Initializes an xr session
  46812. * @param xrSessionMode mode to initialize
  46813. * @param xrSessionInit defines optional and required values to pass to the session builder
  46814. * @returns a promise which will resolve once the session has been initialized
  46815. */
  46816. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  46817. /**
  46818. * Checks if a session would be supported for the creation options specified
  46819. * @param sessionMode session mode to check if supported eg. immersive-vr
  46820. * @returns A Promise that resolves to true if supported and false if not
  46821. */
  46822. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46823. /**
  46824. * Resets the reference space to the one started the session
  46825. */
  46826. resetReferenceSpace(): void;
  46827. /**
  46828. * Starts rendering to the xr layer
  46829. */
  46830. runXRRenderLoop(): void;
  46831. /**
  46832. * Sets the reference space on the xr session
  46833. * @param referenceSpaceType space to set
  46834. * @returns a promise that will resolve once the reference space has been set
  46835. */
  46836. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  46837. /**
  46838. * Updates the render state of the session
  46839. * @param state state to set
  46840. * @returns a promise that resolves once the render state has been updated
  46841. */
  46842. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  46843. /**
  46844. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  46845. * @param sessionMode defines the session to test
  46846. * @returns a promise with boolean as final value
  46847. */
  46848. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46849. private _createRenderTargetTexture;
  46850. }
  46851. }
  46852. declare module BABYLON {
  46853. /**
  46854. * WebXR Camera which holds the views for the xrSession
  46855. * @see https://doc.babylonjs.com/how_to/webxr_camera
  46856. */
  46857. export class WebXRCamera extends FreeCamera {
  46858. private _xrSessionManager;
  46859. private _firstFrame;
  46860. private _referenceQuaternion;
  46861. private _referencedPosition;
  46862. private _xrInvPositionCache;
  46863. private _xrInvQuaternionCache;
  46864. /**
  46865. * Observable raised before camera teleportation
  46866. */
  46867. onBeforeCameraTeleport: Observable<Vector3>;
  46868. /**
  46869. * Observable raised after camera teleportation
  46870. */
  46871. onAfterCameraTeleport: Observable<Vector3>;
  46872. /**
  46873. * Should position compensation execute on first frame.
  46874. * This is used when copying the position from a native (non XR) camera
  46875. */
  46876. compensateOnFirstFrame: boolean;
  46877. /**
  46878. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  46879. * @param name the name of the camera
  46880. * @param scene the scene to add the camera to
  46881. * @param _xrSessionManager a constructed xr session manager
  46882. */
  46883. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  46884. /**
  46885. * Return the user's height, unrelated to the current ground.
  46886. * This will be the y position of this camera, when ground level is 0.
  46887. */
  46888. get realWorldHeight(): number;
  46889. /** @hidden */
  46890. _updateForDualEyeDebugging(): void;
  46891. /**
  46892. * Sets this camera's transformation based on a non-vr camera
  46893. * @param otherCamera the non-vr camera to copy the transformation from
  46894. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  46895. */
  46896. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  46897. /**
  46898. * Gets the current instance class name ("WebXRCamera").
  46899. * @returns the class name
  46900. */
  46901. getClassName(): string;
  46902. private _rotate180;
  46903. private _updateFromXRSession;
  46904. private _updateNumberOfRigCameras;
  46905. private _updateReferenceSpace;
  46906. private _updateReferenceSpaceOffset;
  46907. }
  46908. }
  46909. declare module BABYLON {
  46910. /**
  46911. * Defining the interface required for a (webxr) feature
  46912. */
  46913. export interface IWebXRFeature extends IDisposable {
  46914. /**
  46915. * Is this feature attached
  46916. */
  46917. attached: boolean;
  46918. /**
  46919. * Should auto-attach be disabled?
  46920. */
  46921. disableAutoAttach: boolean;
  46922. /**
  46923. * Attach the feature to the session
  46924. * Will usually be called by the features manager
  46925. *
  46926. * @param force should attachment be forced (even when already attached)
  46927. * @returns true if successful.
  46928. */
  46929. attach(force?: boolean): boolean;
  46930. /**
  46931. * Detach the feature from the session
  46932. * Will usually be called by the features manager
  46933. *
  46934. * @returns true if successful.
  46935. */
  46936. detach(): boolean;
  46937. /**
  46938. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  46939. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  46940. *
  46941. * @returns whether or not the feature is compatible in this environment
  46942. */
  46943. isCompatible(): boolean;
  46944. /**
  46945. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  46946. */
  46947. xrNativeFeatureName?: string;
  46948. }
  46949. /**
  46950. * A list of the currently available features without referencing them
  46951. */
  46952. export class WebXRFeatureName {
  46953. /**
  46954. * The name of the anchor system feature
  46955. */
  46956. static ANCHOR_SYSTEM: string;
  46957. /**
  46958. * The name of the background remover feature
  46959. */
  46960. static BACKGROUND_REMOVER: string;
  46961. /**
  46962. * The name of the hit test feature
  46963. */
  46964. static HIT_TEST: string;
  46965. /**
  46966. * physics impostors for xr controllers feature
  46967. */
  46968. static PHYSICS_CONTROLLERS: string;
  46969. /**
  46970. * The name of the plane detection feature
  46971. */
  46972. static PLANE_DETECTION: string;
  46973. /**
  46974. * The name of the pointer selection feature
  46975. */
  46976. static POINTER_SELECTION: string;
  46977. /**
  46978. * The name of the teleportation feature
  46979. */
  46980. static TELEPORTATION: string;
  46981. }
  46982. /**
  46983. * Defining the constructor of a feature. Used to register the modules.
  46984. */
  46985. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  46986. /**
  46987. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  46988. * It is mainly used in AR sessions.
  46989. *
  46990. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  46991. */
  46992. export class WebXRFeaturesManager implements IDisposable {
  46993. private _xrSessionManager;
  46994. private static readonly _AvailableFeatures;
  46995. private _features;
  46996. /**
  46997. * constructs a new features manages.
  46998. *
  46999. * @param _xrSessionManager an instance of WebXRSessionManager
  47000. */
  47001. constructor(_xrSessionManager: WebXRSessionManager);
  47002. /**
  47003. * Used to register a module. After calling this function a developer can use this feature in the scene.
  47004. * Mainly used internally.
  47005. *
  47006. * @param featureName the name of the feature to register
  47007. * @param constructorFunction the function used to construct the module
  47008. * @param version the (babylon) version of the module
  47009. * @param stable is that a stable version of this module
  47010. */
  47011. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  47012. /**
  47013. * Returns a constructor of a specific feature.
  47014. *
  47015. * @param featureName the name of the feature to construct
  47016. * @param version the version of the feature to load
  47017. * @param xrSessionManager the xrSessionManager. Used to construct the module
  47018. * @param options optional options provided to the module.
  47019. * @returns a function that, when called, will return a new instance of this feature
  47020. */
  47021. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  47022. /**
  47023. * Can be used to return the list of features currently registered
  47024. *
  47025. * @returns an Array of available features
  47026. */
  47027. static GetAvailableFeatures(): string[];
  47028. /**
  47029. * Gets the versions available for a specific feature
  47030. * @param featureName the name of the feature
  47031. * @returns an array with the available versions
  47032. */
  47033. static GetAvailableVersions(featureName: string): string[];
  47034. /**
  47035. * Return the latest unstable version of this feature
  47036. * @param featureName the name of the feature to search
  47037. * @returns the version number. if not found will return -1
  47038. */
  47039. static GetLatestVersionOfFeature(featureName: string): number;
  47040. /**
  47041. * Return the latest stable version of this feature
  47042. * @param featureName the name of the feature to search
  47043. * @returns the version number. if not found will return -1
  47044. */
  47045. static GetStableVersionOfFeature(featureName: string): number;
  47046. /**
  47047. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  47048. * Can be used during a session to start a feature
  47049. * @param featureName the name of feature to attach
  47050. */
  47051. attachFeature(featureName: string): void;
  47052. /**
  47053. * Can be used inside a session or when the session ends to detach a specific feature
  47054. * @param featureName the name of the feature to detach
  47055. */
  47056. detachFeature(featureName: string): void;
  47057. /**
  47058. * Used to disable an already-enabled feature
  47059. * The feature will be disposed and will be recreated once enabled.
  47060. * @param featureName the feature to disable
  47061. * @returns true if disable was successful
  47062. */
  47063. disableFeature(featureName: string | {
  47064. Name: string;
  47065. }): boolean;
  47066. /**
  47067. * dispose this features manager
  47068. */
  47069. dispose(): void;
  47070. /**
  47071. * 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.
  47072. * 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.
  47073. *
  47074. * @param featureName the name of the feature to load or the class of the feature
  47075. * @param version optional version to load. if not provided the latest version will be enabled
  47076. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  47077. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  47078. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  47079. * @returns a new constructed feature or throws an error if feature not found.
  47080. */
  47081. enableFeature(featureName: string | {
  47082. Name: string;
  47083. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  47084. /**
  47085. * get the implementation of an enabled feature.
  47086. * @param featureName the name of the feature to load
  47087. * @returns the feature class, if found
  47088. */
  47089. getEnabledFeature(featureName: string): IWebXRFeature;
  47090. /**
  47091. * Get the list of enabled features
  47092. * @returns an array of enabled features
  47093. */
  47094. getEnabledFeatures(): string[];
  47095. /**
  47096. * This function will exten the session creation configuration object with enabled features.
  47097. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  47098. * according to the defined "required" variable, provided during enableFeature call
  47099. * @param xrSessionInit the xr Session init object to extend
  47100. *
  47101. * @returns an extended XRSessionInit object
  47102. */
  47103. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  47104. }
  47105. }
  47106. declare module BABYLON {
  47107. /**
  47108. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  47109. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  47110. */
  47111. export class WebXRExperienceHelper implements IDisposable {
  47112. private scene;
  47113. private _nonVRCamera;
  47114. private _originalSceneAutoClear;
  47115. private _supported;
  47116. /**
  47117. * Camera used to render xr content
  47118. */
  47119. camera: WebXRCamera;
  47120. /** A features manager for this xr session */
  47121. featuresManager: WebXRFeaturesManager;
  47122. /**
  47123. * Observers registered here will be triggered after the camera's initial transformation is set
  47124. * This can be used to set a different ground level or an extra rotation.
  47125. *
  47126. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  47127. * to the position set after this observable is done executing.
  47128. */
  47129. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  47130. /**
  47131. * Fires when the state of the experience helper has changed
  47132. */
  47133. onStateChangedObservable: Observable<WebXRState>;
  47134. /** Session manager used to keep track of xr session */
  47135. sessionManager: WebXRSessionManager;
  47136. /**
  47137. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  47138. */
  47139. state: WebXRState;
  47140. /**
  47141. * Creates a WebXRExperienceHelper
  47142. * @param scene The scene the helper should be created in
  47143. */
  47144. private constructor();
  47145. /**
  47146. * Creates the experience helper
  47147. * @param scene the scene to attach the experience helper to
  47148. * @returns a promise for the experience helper
  47149. */
  47150. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  47151. /**
  47152. * Disposes of the experience helper
  47153. */
  47154. dispose(): void;
  47155. /**
  47156. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  47157. * @param sessionMode options for the XR session
  47158. * @param referenceSpaceType frame of reference of the XR session
  47159. * @param renderTarget the output canvas that will be used to enter XR mode
  47160. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  47161. * @returns promise that resolves after xr mode has entered
  47162. */
  47163. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  47164. /**
  47165. * Exits XR mode and returns the scene to its original state
  47166. * @returns promise that resolves after xr mode has exited
  47167. */
  47168. exitXRAsync(): Promise<void>;
  47169. private _nonXRToXRCamera;
  47170. private _setState;
  47171. }
  47172. }
  47173. declare module BABYLON {
  47174. /**
  47175. * X-Y values for axes in WebXR
  47176. */
  47177. export interface IWebXRMotionControllerAxesValue {
  47178. /**
  47179. * The value of the x axis
  47180. */
  47181. x: number;
  47182. /**
  47183. * The value of the y-axis
  47184. */
  47185. y: number;
  47186. }
  47187. /**
  47188. * changed / previous values for the values of this component
  47189. */
  47190. export interface IWebXRMotionControllerComponentChangesValues<T> {
  47191. /**
  47192. * current (this frame) value
  47193. */
  47194. current: T;
  47195. /**
  47196. * previous (last change) value
  47197. */
  47198. previous: T;
  47199. }
  47200. /**
  47201. * Represents changes in the component between current frame and last values recorded
  47202. */
  47203. export interface IWebXRMotionControllerComponentChanges {
  47204. /**
  47205. * will be populated with previous and current values if axes changed
  47206. */
  47207. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  47208. /**
  47209. * will be populated with previous and current values if pressed changed
  47210. */
  47211. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47212. /**
  47213. * will be populated with previous and current values if touched changed
  47214. */
  47215. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47216. /**
  47217. * will be populated with previous and current values if value changed
  47218. */
  47219. value?: IWebXRMotionControllerComponentChangesValues<number>;
  47220. }
  47221. /**
  47222. * This class represents a single component (for example button or thumbstick) of a motion controller
  47223. */
  47224. export class WebXRControllerComponent implements IDisposable {
  47225. /**
  47226. * the id of this component
  47227. */
  47228. id: string;
  47229. /**
  47230. * the type of the component
  47231. */
  47232. type: MotionControllerComponentType;
  47233. private _buttonIndex;
  47234. private _axesIndices;
  47235. private _axes;
  47236. private _changes;
  47237. private _currentValue;
  47238. private _hasChanges;
  47239. private _pressed;
  47240. private _touched;
  47241. /**
  47242. * button component type
  47243. */
  47244. static BUTTON_TYPE: MotionControllerComponentType;
  47245. /**
  47246. * squeeze component type
  47247. */
  47248. static SQUEEZE_TYPE: MotionControllerComponentType;
  47249. /**
  47250. * Thumbstick component type
  47251. */
  47252. static THUMBSTICK_TYPE: MotionControllerComponentType;
  47253. /**
  47254. * Touchpad component type
  47255. */
  47256. static TOUCHPAD_TYPE: MotionControllerComponentType;
  47257. /**
  47258. * trigger component type
  47259. */
  47260. static TRIGGER_TYPE: MotionControllerComponentType;
  47261. /**
  47262. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  47263. * the axes data changes
  47264. */
  47265. onAxisValueChangedObservable: Observable<{
  47266. x: number;
  47267. y: number;
  47268. }>;
  47269. /**
  47270. * Observers registered here will be triggered when the state of a button changes
  47271. * State change is either pressed / touched / value
  47272. */
  47273. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  47274. /**
  47275. * Creates a new component for a motion controller.
  47276. * It is created by the motion controller itself
  47277. *
  47278. * @param id the id of this component
  47279. * @param type the type of the component
  47280. * @param _buttonIndex index in the buttons array of the gamepad
  47281. * @param _axesIndices indices of the values in the axes array of the gamepad
  47282. */
  47283. constructor(
  47284. /**
  47285. * the id of this component
  47286. */
  47287. id: string,
  47288. /**
  47289. * the type of the component
  47290. */
  47291. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  47292. /**
  47293. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  47294. */
  47295. get axes(): IWebXRMotionControllerAxesValue;
  47296. /**
  47297. * Get the changes. Elements will be populated only if they changed with their previous and current value
  47298. */
  47299. get changes(): IWebXRMotionControllerComponentChanges;
  47300. /**
  47301. * Return whether or not the component changed the last frame
  47302. */
  47303. get hasChanges(): boolean;
  47304. /**
  47305. * is the button currently pressed
  47306. */
  47307. get pressed(): boolean;
  47308. /**
  47309. * is the button currently touched
  47310. */
  47311. get touched(): boolean;
  47312. /**
  47313. * Get the current value of this component
  47314. */
  47315. get value(): number;
  47316. /**
  47317. * Dispose this component
  47318. */
  47319. dispose(): void;
  47320. /**
  47321. * Are there axes correlating to this component
  47322. * @return true is axes data is available
  47323. */
  47324. isAxes(): boolean;
  47325. /**
  47326. * Is this component a button (hence - pressable)
  47327. * @returns true if can be pressed
  47328. */
  47329. isButton(): boolean;
  47330. /**
  47331. * update this component using the gamepad object it is in. Called on every frame
  47332. * @param nativeController the native gamepad controller object
  47333. */
  47334. update(nativeController: IMinimalMotionControllerObject): void;
  47335. }
  47336. }
  47337. declare module BABYLON {
  47338. /**
  47339. * Interface used to represent data loading progression
  47340. */
  47341. export interface ISceneLoaderProgressEvent {
  47342. /**
  47343. * Defines if data length to load can be evaluated
  47344. */
  47345. readonly lengthComputable: boolean;
  47346. /**
  47347. * Defines the loaded data length
  47348. */
  47349. readonly loaded: number;
  47350. /**
  47351. * Defines the data length to load
  47352. */
  47353. readonly total: number;
  47354. }
  47355. /**
  47356. * Interface used by SceneLoader plugins to define supported file extensions
  47357. */
  47358. export interface ISceneLoaderPluginExtensions {
  47359. /**
  47360. * Defines the list of supported extensions
  47361. */
  47362. [extension: string]: {
  47363. isBinary: boolean;
  47364. };
  47365. }
  47366. /**
  47367. * Interface used by SceneLoader plugin factory
  47368. */
  47369. export interface ISceneLoaderPluginFactory {
  47370. /**
  47371. * Defines the name of the factory
  47372. */
  47373. name: string;
  47374. /**
  47375. * Function called to create a new plugin
  47376. * @return the new plugin
  47377. */
  47378. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  47379. /**
  47380. * The callback that returns true if the data can be directly loaded.
  47381. * @param data string containing the file data
  47382. * @returns if the data can be loaded directly
  47383. */
  47384. canDirectLoad?(data: string): boolean;
  47385. }
  47386. /**
  47387. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  47388. */
  47389. export interface ISceneLoaderPluginBase {
  47390. /**
  47391. * The friendly name of this plugin.
  47392. */
  47393. name: string;
  47394. /**
  47395. * The file extensions supported by this plugin.
  47396. */
  47397. extensions: string | ISceneLoaderPluginExtensions;
  47398. /**
  47399. * The callback called when loading from a url.
  47400. * @param scene scene loading this url
  47401. * @param url url to load
  47402. * @param onSuccess callback called when the file successfully loads
  47403. * @param onProgress callback called while file is loading (if the server supports this mode)
  47404. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  47405. * @param onError callback called when the file fails to load
  47406. * @returns a file request object
  47407. */
  47408. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47409. /**
  47410. * The callback called when loading from a file object.
  47411. * @param scene scene loading this file
  47412. * @param file defines the file to load
  47413. * @param onSuccess defines the callback to call when data is loaded
  47414. * @param onProgress defines the callback to call during loading process
  47415. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  47416. * @param onError defines the callback to call when an error occurs
  47417. * @returns a file request object
  47418. */
  47419. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47420. /**
  47421. * The callback that returns true if the data can be directly loaded.
  47422. * @param data string containing the file data
  47423. * @returns if the data can be loaded directly
  47424. */
  47425. canDirectLoad?(data: string): boolean;
  47426. /**
  47427. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  47428. * @param scene scene loading this data
  47429. * @param data string containing the data
  47430. * @returns data to pass to the plugin
  47431. */
  47432. directLoad?(scene: Scene, data: string): any;
  47433. /**
  47434. * The callback that allows custom handling of the root url based on the response url.
  47435. * @param rootUrl the original root url
  47436. * @param responseURL the response url if available
  47437. * @returns the new root url
  47438. */
  47439. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  47440. }
  47441. /**
  47442. * Interface used to define a SceneLoader plugin
  47443. */
  47444. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  47445. /**
  47446. * Import meshes into a scene.
  47447. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47448. * @param scene The scene to import into
  47449. * @param data The data to import
  47450. * @param rootUrl The root url for scene and resources
  47451. * @param meshes The meshes array to import into
  47452. * @param particleSystems The particle systems array to import into
  47453. * @param skeletons The skeletons array to import into
  47454. * @param onError The callback when import fails
  47455. * @returns True if successful or false otherwise
  47456. */
  47457. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  47458. /**
  47459. * Load into a scene.
  47460. * @param scene The scene to load into
  47461. * @param data The data to import
  47462. * @param rootUrl The root url for scene and resources
  47463. * @param onError The callback when import fails
  47464. * @returns True if successful or false otherwise
  47465. */
  47466. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  47467. /**
  47468. * Load into an asset container.
  47469. * @param scene The scene to load into
  47470. * @param data The data to import
  47471. * @param rootUrl The root url for scene and resources
  47472. * @param onError The callback when import fails
  47473. * @returns The loaded asset container
  47474. */
  47475. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  47476. }
  47477. /**
  47478. * Interface used to define an async SceneLoader plugin
  47479. */
  47480. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  47481. /**
  47482. * Import meshes into a scene.
  47483. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47484. * @param scene The scene to import into
  47485. * @param data The data to import
  47486. * @param rootUrl The root url for scene and resources
  47487. * @param onProgress The callback when the load progresses
  47488. * @param fileName Defines the name of the file to load
  47489. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  47490. */
  47491. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  47492. meshes: AbstractMesh[];
  47493. particleSystems: IParticleSystem[];
  47494. skeletons: Skeleton[];
  47495. animationGroups: AnimationGroup[];
  47496. }>;
  47497. /**
  47498. * Load into a scene.
  47499. * @param scene The scene to load into
  47500. * @param data The data to import
  47501. * @param rootUrl The root url for scene and resources
  47502. * @param onProgress The callback when the load progresses
  47503. * @param fileName Defines the name of the file to load
  47504. * @returns Nothing
  47505. */
  47506. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  47507. /**
  47508. * Load into an asset container.
  47509. * @param scene The scene to load into
  47510. * @param data The data to import
  47511. * @param rootUrl The root url for scene and resources
  47512. * @param onProgress The callback when the load progresses
  47513. * @param fileName Defines the name of the file to load
  47514. * @returns The loaded asset container
  47515. */
  47516. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  47517. }
  47518. /**
  47519. * Mode that determines how to handle old animation groups before loading new ones.
  47520. */
  47521. export enum SceneLoaderAnimationGroupLoadingMode {
  47522. /**
  47523. * Reset all old animations to initial state then dispose them.
  47524. */
  47525. Clean = 0,
  47526. /**
  47527. * Stop all old animations.
  47528. */
  47529. Stop = 1,
  47530. /**
  47531. * Restart old animations from first frame.
  47532. */
  47533. Sync = 2,
  47534. /**
  47535. * Old animations remains untouched.
  47536. */
  47537. NoSync = 3
  47538. }
  47539. /**
  47540. * Defines a plugin registered by the SceneLoader
  47541. */
  47542. interface IRegisteredPlugin {
  47543. /**
  47544. * Defines the plugin to use
  47545. */
  47546. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  47547. /**
  47548. * Defines if the plugin supports binary data
  47549. */
  47550. isBinary: boolean;
  47551. }
  47552. /**
  47553. * Class used to load scene from various file formats using registered plugins
  47554. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  47555. */
  47556. export class SceneLoader {
  47557. /**
  47558. * No logging while loading
  47559. */
  47560. static readonly NO_LOGGING: number;
  47561. /**
  47562. * Minimal logging while loading
  47563. */
  47564. static readonly MINIMAL_LOGGING: number;
  47565. /**
  47566. * Summary logging while loading
  47567. */
  47568. static readonly SUMMARY_LOGGING: number;
  47569. /**
  47570. * Detailled logging while loading
  47571. */
  47572. static readonly DETAILED_LOGGING: number;
  47573. /**
  47574. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  47575. */
  47576. static get ForceFullSceneLoadingForIncremental(): boolean;
  47577. static set ForceFullSceneLoadingForIncremental(value: boolean);
  47578. /**
  47579. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  47580. */
  47581. static get ShowLoadingScreen(): boolean;
  47582. static set ShowLoadingScreen(value: boolean);
  47583. /**
  47584. * Defines the current logging level (while loading the scene)
  47585. * @ignorenaming
  47586. */
  47587. static get loggingLevel(): number;
  47588. static set loggingLevel(value: number);
  47589. /**
  47590. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  47591. */
  47592. static get CleanBoneMatrixWeights(): boolean;
  47593. static set CleanBoneMatrixWeights(value: boolean);
  47594. /**
  47595. * Event raised when a plugin is used to load a scene
  47596. */
  47597. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  47598. private static _registeredPlugins;
  47599. private static _showingLoadingScreen;
  47600. /**
  47601. * Gets the default plugin (used to load Babylon files)
  47602. * @returns the .babylon plugin
  47603. */
  47604. static GetDefaultPlugin(): IRegisteredPlugin;
  47605. private static _GetPluginForExtension;
  47606. private static _GetPluginForDirectLoad;
  47607. private static _GetPluginForFilename;
  47608. private static _GetDirectLoad;
  47609. private static _LoadData;
  47610. private static _GetFileInfo;
  47611. /**
  47612. * Gets a plugin that can load the given extension
  47613. * @param extension defines the extension to load
  47614. * @returns a plugin or null if none works
  47615. */
  47616. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  47617. /**
  47618. * Gets a boolean indicating that the given extension can be loaded
  47619. * @param extension defines the extension to load
  47620. * @returns true if the extension is supported
  47621. */
  47622. static IsPluginForExtensionAvailable(extension: string): boolean;
  47623. /**
  47624. * Adds a new plugin to the list of registered plugins
  47625. * @param plugin defines the plugin to add
  47626. */
  47627. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  47628. /**
  47629. * Import meshes into a scene
  47630. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47631. * @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)
  47632. * @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)
  47633. * @param scene the instance of BABYLON.Scene to append to
  47634. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  47635. * @param onProgress a callback with a progress event for each file being loaded
  47636. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47637. * @param pluginExtension the extension used to determine the plugin
  47638. * @returns The loaded plugin
  47639. */
  47640. 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>;
  47641. /**
  47642. * Import meshes into a scene
  47643. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47644. * @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)
  47645. * @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)
  47646. * @param scene the instance of BABYLON.Scene to append to
  47647. * @param onProgress a callback with a progress event for each file being loaded
  47648. * @param pluginExtension the extension used to determine the plugin
  47649. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  47650. */
  47651. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  47652. meshes: AbstractMesh[];
  47653. particleSystems: IParticleSystem[];
  47654. skeletons: Skeleton[];
  47655. animationGroups: AnimationGroup[];
  47656. }>;
  47657. /**
  47658. * Load a scene
  47659. * @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)
  47660. * @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)
  47661. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47662. * @param onSuccess a callback with the scene when import succeeds
  47663. * @param onProgress a callback with a progress event for each file being loaded
  47664. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47665. * @param pluginExtension the extension used to determine the plugin
  47666. * @returns The loaded plugin
  47667. */
  47668. 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>;
  47669. /**
  47670. * Load a scene
  47671. * @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)
  47672. * @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)
  47673. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47674. * @param onProgress a callback with a progress event for each file being loaded
  47675. * @param pluginExtension the extension used to determine the plugin
  47676. * @returns The loaded scene
  47677. */
  47678. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  47679. /**
  47680. * Append a scene
  47681. * @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)
  47682. * @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)
  47683. * @param scene is the instance of BABYLON.Scene to append to
  47684. * @param onSuccess a callback with the scene when import succeeds
  47685. * @param onProgress a callback with a progress event for each file being loaded
  47686. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47687. * @param pluginExtension the extension used to determine the plugin
  47688. * @returns The loaded plugin
  47689. */
  47690. 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>;
  47691. /**
  47692. * Append a scene
  47693. * @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)
  47694. * @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)
  47695. * @param scene is the instance of BABYLON.Scene to append to
  47696. * @param onProgress a callback with a progress event for each file being loaded
  47697. * @param pluginExtension the extension used to determine the plugin
  47698. * @returns The given scene
  47699. */
  47700. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  47701. /**
  47702. * Load a scene into an asset container
  47703. * @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)
  47704. * @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)
  47705. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47706. * @param onSuccess a callback with the scene when import succeeds
  47707. * @param onProgress a callback with a progress event for each file being loaded
  47708. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47709. * @param pluginExtension the extension used to determine the plugin
  47710. * @returns The loaded plugin
  47711. */
  47712. 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>;
  47713. /**
  47714. * Load a scene into an asset container
  47715. * @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)
  47716. * @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)
  47717. * @param scene is the instance of Scene to append to
  47718. * @param onProgress a callback with a progress event for each file being loaded
  47719. * @param pluginExtension the extension used to determine the plugin
  47720. * @returns The loaded asset container
  47721. */
  47722. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  47723. /**
  47724. * Import animations from a file into a scene
  47725. * @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)
  47726. * @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)
  47727. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47728. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  47729. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  47730. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  47731. * @param onSuccess a callback with the scene when import succeeds
  47732. * @param onProgress a callback with a progress event for each file being loaded
  47733. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47734. * @param pluginExtension the extension used to determine the plugin
  47735. */
  47736. 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;
  47737. /**
  47738. * Import animations from a file into a scene
  47739. * @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)
  47740. * @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)
  47741. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47742. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  47743. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  47744. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  47745. * @param onSuccess a callback with the scene when import succeeds
  47746. * @param onProgress a callback with a progress event for each file being loaded
  47747. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47748. * @param pluginExtension the extension used to determine the plugin
  47749. * @returns the updated scene with imported animations
  47750. */
  47751. 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>;
  47752. }
  47753. }
  47754. declare module BABYLON {
  47755. /**
  47756. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  47757. */
  47758. export type MotionControllerHandedness = "none" | "left" | "right";
  47759. /**
  47760. * The type of components available in motion controllers.
  47761. * This is not the name of the component.
  47762. */
  47763. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  47764. /**
  47765. * The state of a controller component
  47766. */
  47767. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  47768. /**
  47769. * The schema of motion controller layout.
  47770. * No object will be initialized using this interface
  47771. * This is used just to define the profile.
  47772. */
  47773. export interface IMotionControllerLayout {
  47774. /**
  47775. * Path to load the assets. Usually relative to the base path
  47776. */
  47777. assetPath: string;
  47778. /**
  47779. * Available components (unsorted)
  47780. */
  47781. components: {
  47782. /**
  47783. * A map of component Ids
  47784. */
  47785. [componentId: string]: {
  47786. /**
  47787. * The type of input the component outputs
  47788. */
  47789. type: MotionControllerComponentType;
  47790. /**
  47791. * The indices of this component in the gamepad object
  47792. */
  47793. gamepadIndices: {
  47794. /**
  47795. * Index of button
  47796. */
  47797. button?: number;
  47798. /**
  47799. * If available, index of x-axis
  47800. */
  47801. xAxis?: number;
  47802. /**
  47803. * If available, index of y-axis
  47804. */
  47805. yAxis?: number;
  47806. };
  47807. /**
  47808. * The mesh's root node name
  47809. */
  47810. rootNodeName: string;
  47811. /**
  47812. * Animation definitions for this model
  47813. */
  47814. visualResponses: {
  47815. [stateKey: string]: {
  47816. /**
  47817. * What property will be animated
  47818. */
  47819. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  47820. /**
  47821. * What states influence this visual response
  47822. */
  47823. states: MotionControllerComponentStateType[];
  47824. /**
  47825. * Type of animation - movement or visibility
  47826. */
  47827. valueNodeProperty: "transform" | "visibility";
  47828. /**
  47829. * Base node name to move. Its position will be calculated according to the min and max nodes
  47830. */
  47831. valueNodeName?: string;
  47832. /**
  47833. * Minimum movement node
  47834. */
  47835. minNodeName?: string;
  47836. /**
  47837. * Max movement node
  47838. */
  47839. maxNodeName?: string;
  47840. };
  47841. };
  47842. /**
  47843. * If touch enabled, what is the name of node to display user feedback
  47844. */
  47845. touchPointNodeName?: string;
  47846. };
  47847. };
  47848. /**
  47849. * Is it xr standard mapping or not
  47850. */
  47851. gamepadMapping: "" | "xr-standard";
  47852. /**
  47853. * Base root node of this entire model
  47854. */
  47855. rootNodeName: string;
  47856. /**
  47857. * Defines the main button component id
  47858. */
  47859. selectComponentId: string;
  47860. }
  47861. /**
  47862. * A definition for the layout map in the input profile
  47863. */
  47864. export interface IMotionControllerLayoutMap {
  47865. /**
  47866. * Layouts with handedness type as a key
  47867. */
  47868. [handedness: string]: IMotionControllerLayout;
  47869. }
  47870. /**
  47871. * The XR Input profile schema
  47872. * Profiles can be found here:
  47873. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  47874. */
  47875. export interface IMotionControllerProfile {
  47876. /**
  47877. * fallback profiles for this profileId
  47878. */
  47879. fallbackProfileIds: string[];
  47880. /**
  47881. * The layout map, with handedness as key
  47882. */
  47883. layouts: IMotionControllerLayoutMap;
  47884. /**
  47885. * The id of this profile
  47886. * correlates to the profile(s) in the xrInput.profiles array
  47887. */
  47888. profileId: string;
  47889. }
  47890. /**
  47891. * A helper-interface for the 3 meshes needed for controller button animation
  47892. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  47893. */
  47894. export interface IMotionControllerButtonMeshMap {
  47895. /**
  47896. * the mesh that defines the pressed value mesh position.
  47897. * This is used to find the max-position of this button
  47898. */
  47899. pressedMesh: AbstractMesh;
  47900. /**
  47901. * the mesh that defines the unpressed value mesh position.
  47902. * This is used to find the min (or initial) position of this button
  47903. */
  47904. unpressedMesh: AbstractMesh;
  47905. /**
  47906. * The mesh that will be changed when value changes
  47907. */
  47908. valueMesh: AbstractMesh;
  47909. }
  47910. /**
  47911. * A helper-interface for the 3 meshes needed for controller axis animation.
  47912. * This will be expanded when touchpad animations are fully supported
  47913. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  47914. */
  47915. export interface IMotionControllerMeshMap {
  47916. /**
  47917. * the mesh that defines the maximum value mesh position.
  47918. */
  47919. maxMesh?: AbstractMesh;
  47920. /**
  47921. * the mesh that defines the minimum value mesh position.
  47922. */
  47923. minMesh?: AbstractMesh;
  47924. /**
  47925. * The mesh that will be changed when axis value changes
  47926. */
  47927. valueMesh: AbstractMesh;
  47928. }
  47929. /**
  47930. * The elements needed for change-detection of the gamepad objects in motion controllers
  47931. */
  47932. export interface IMinimalMotionControllerObject {
  47933. /**
  47934. * Available axes of this controller
  47935. */
  47936. axes: number[];
  47937. /**
  47938. * An array of available buttons
  47939. */
  47940. buttons: Array<{
  47941. /**
  47942. * Value of the button/trigger
  47943. */
  47944. value: number;
  47945. /**
  47946. * If the button/trigger is currently touched
  47947. */
  47948. touched: boolean;
  47949. /**
  47950. * If the button/trigger is currently pressed
  47951. */
  47952. pressed: boolean;
  47953. }>;
  47954. /**
  47955. * EXPERIMENTAL haptic support.
  47956. */
  47957. hapticActuators?: Array<{
  47958. pulse: (value: number, duration: number) => Promise<boolean>;
  47959. }>;
  47960. }
  47961. /**
  47962. * An Abstract Motion controller
  47963. * This class receives an xrInput and a profile layout and uses those to initialize the components
  47964. * Each component has an observable to check for changes in value and state
  47965. */
  47966. export abstract class WebXRAbstractMotionController implements IDisposable {
  47967. protected scene: Scene;
  47968. protected layout: IMotionControllerLayout;
  47969. /**
  47970. * The gamepad object correlating to this controller
  47971. */
  47972. gamepadObject: IMinimalMotionControllerObject;
  47973. /**
  47974. * handedness (left/right/none) of this controller
  47975. */
  47976. handedness: MotionControllerHandedness;
  47977. private _initComponent;
  47978. private _modelReady;
  47979. /**
  47980. * A map of components (WebXRControllerComponent) in this motion controller
  47981. * Components have a ComponentType and can also have both button and axis definitions
  47982. */
  47983. readonly components: {
  47984. [id: string]: WebXRControllerComponent;
  47985. };
  47986. /**
  47987. * Disable the model's animation. Can be set at any time.
  47988. */
  47989. disableAnimation: boolean;
  47990. /**
  47991. * Observers registered here will be triggered when the model of this controller is done loading
  47992. */
  47993. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  47994. /**
  47995. * The profile id of this motion controller
  47996. */
  47997. abstract profileId: string;
  47998. /**
  47999. * The root mesh of the model. It is null if the model was not yet initialized
  48000. */
  48001. rootMesh: Nullable<AbstractMesh>;
  48002. /**
  48003. * constructs a new abstract motion controller
  48004. * @param scene the scene to which the model of the controller will be added
  48005. * @param layout The profile layout to load
  48006. * @param gamepadObject The gamepad object correlating to this controller
  48007. * @param handedness handedness (left/right/none) of this controller
  48008. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  48009. */
  48010. constructor(scene: Scene, layout: IMotionControllerLayout,
  48011. /**
  48012. * The gamepad object correlating to this controller
  48013. */
  48014. gamepadObject: IMinimalMotionControllerObject,
  48015. /**
  48016. * handedness (left/right/none) of this controller
  48017. */
  48018. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  48019. /**
  48020. * Dispose this controller, the model mesh and all its components
  48021. */
  48022. dispose(): void;
  48023. /**
  48024. * Returns all components of specific type
  48025. * @param type the type to search for
  48026. * @return an array of components with this type
  48027. */
  48028. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  48029. /**
  48030. * get a component based an its component id as defined in layout.components
  48031. * @param id the id of the component
  48032. * @returns the component correlates to the id or undefined if not found
  48033. */
  48034. getComponent(id: string): WebXRControllerComponent;
  48035. /**
  48036. * Get the list of components available in this motion controller
  48037. * @returns an array of strings correlating to available components
  48038. */
  48039. getComponentIds(): string[];
  48040. /**
  48041. * Get the first component of specific type
  48042. * @param type type of component to find
  48043. * @return a controller component or null if not found
  48044. */
  48045. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  48046. /**
  48047. * Get the main (Select) component of this controller as defined in the layout
  48048. * @returns the main component of this controller
  48049. */
  48050. getMainComponent(): WebXRControllerComponent;
  48051. /**
  48052. * Loads the model correlating to this controller
  48053. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  48054. * @returns A promise fulfilled with the result of the model loading
  48055. */
  48056. loadModel(): Promise<boolean>;
  48057. /**
  48058. * Update this model using the current XRFrame
  48059. * @param xrFrame the current xr frame to use and update the model
  48060. */
  48061. updateFromXRFrame(xrFrame: XRFrame): void;
  48062. /**
  48063. * Backwards compatibility due to a deeply-integrated typo
  48064. */
  48065. get handness(): XREye;
  48066. /**
  48067. * Pulse (vibrate) this controller
  48068. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  48069. * Consecutive calls to this function will cancel the last pulse call
  48070. *
  48071. * @param value the strength of the pulse in 0.0...1.0 range
  48072. * @param duration Duration of the pulse in milliseconds
  48073. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  48074. * @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
  48075. */
  48076. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  48077. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  48078. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  48079. /**
  48080. * Moves the axis on the controller mesh based on its current state
  48081. * @param axis the index of the axis
  48082. * @param axisValue the value of the axis which determines the meshes new position
  48083. * @hidden
  48084. */
  48085. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  48086. /**
  48087. * Update the model itself with the current frame data
  48088. * @param xrFrame the frame to use for updating the model mesh
  48089. */
  48090. protected updateModel(xrFrame: XRFrame): void;
  48091. /**
  48092. * Get the filename and path for this controller's model
  48093. * @returns a map of filename and path
  48094. */
  48095. protected abstract _getFilenameAndPath(): {
  48096. filename: string;
  48097. path: string;
  48098. };
  48099. /**
  48100. * This function is called before the mesh is loaded. It checks for loading constraints.
  48101. * For example, this function can check if the GLB loader is available
  48102. * If this function returns false, the generic controller will be loaded instead
  48103. * @returns Is the client ready to load the mesh
  48104. */
  48105. protected abstract _getModelLoadingConstraints(): boolean;
  48106. /**
  48107. * This function will be called after the model was successfully loaded and can be used
  48108. * for mesh transformations before it is available for the user
  48109. * @param meshes the loaded meshes
  48110. */
  48111. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  48112. /**
  48113. * Set the root mesh for this controller. Important for the WebXR controller class
  48114. * @param meshes the loaded meshes
  48115. */
  48116. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  48117. /**
  48118. * A function executed each frame that updates the mesh (if needed)
  48119. * @param xrFrame the current xrFrame
  48120. */
  48121. protected abstract _updateModel(xrFrame: XRFrame): void;
  48122. private _getGenericFilenameAndPath;
  48123. private _getGenericParentMesh;
  48124. }
  48125. }
  48126. declare module BABYLON {
  48127. /**
  48128. * A generic trigger-only motion controller for WebXR
  48129. */
  48130. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  48131. /**
  48132. * Static version of the profile id of this controller
  48133. */
  48134. static ProfileId: string;
  48135. profileId: string;
  48136. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  48137. protected _getFilenameAndPath(): {
  48138. filename: string;
  48139. path: string;
  48140. };
  48141. protected _getModelLoadingConstraints(): boolean;
  48142. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  48143. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48144. protected _updateModel(): void;
  48145. }
  48146. }
  48147. declare module BABYLON {
  48148. /**
  48149. * Class containing static functions to help procedurally build meshes
  48150. */
  48151. export class SphereBuilder {
  48152. /**
  48153. * Creates a sphere mesh
  48154. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  48155. * * 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`)
  48156. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  48157. * * 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
  48158. * * 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)
  48159. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48160. * * 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
  48161. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48162. * @param name defines the name of the mesh
  48163. * @param options defines the options used to create the mesh
  48164. * @param scene defines the hosting scene
  48165. * @returns the sphere mesh
  48166. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  48167. */
  48168. static CreateSphere(name: string, options: {
  48169. segments?: number;
  48170. diameter?: number;
  48171. diameterX?: number;
  48172. diameterY?: number;
  48173. diameterZ?: number;
  48174. arc?: number;
  48175. slice?: number;
  48176. sideOrientation?: number;
  48177. frontUVs?: Vector4;
  48178. backUVs?: Vector4;
  48179. updatable?: boolean;
  48180. }, scene?: Nullable<Scene>): Mesh;
  48181. }
  48182. }
  48183. declare module BABYLON {
  48184. /**
  48185. * A profiled motion controller has its profile loaded from an online repository.
  48186. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  48187. */
  48188. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  48189. private _repositoryUrl;
  48190. private _buttonMeshMapping;
  48191. private _touchDots;
  48192. /**
  48193. * The profile ID of this controller. Will be populated when the controller initializes.
  48194. */
  48195. profileId: string;
  48196. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  48197. dispose(): void;
  48198. protected _getFilenameAndPath(): {
  48199. filename: string;
  48200. path: string;
  48201. };
  48202. protected _getModelLoadingConstraints(): boolean;
  48203. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  48204. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48205. protected _updateModel(_xrFrame: XRFrame): void;
  48206. }
  48207. }
  48208. declare module BABYLON {
  48209. /**
  48210. * A construction function type to create a new controller based on an xrInput object
  48211. */
  48212. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  48213. /**
  48214. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  48215. *
  48216. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  48217. * it should be replaced with auto-loaded controllers.
  48218. *
  48219. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  48220. */
  48221. export class WebXRMotionControllerManager {
  48222. private static _AvailableControllers;
  48223. private static _Fallbacks;
  48224. private static _ProfileLoadingPromises;
  48225. private static _ProfilesList;
  48226. /**
  48227. * The base URL of the online controller repository. Can be changed at any time.
  48228. */
  48229. static BaseRepositoryUrl: string;
  48230. /**
  48231. * Which repository gets priority - local or online
  48232. */
  48233. static PrioritizeOnlineRepository: boolean;
  48234. /**
  48235. * Use the online repository, or use only locally-defined controllers
  48236. */
  48237. static UseOnlineRepository: boolean;
  48238. /**
  48239. * Clear the cache used for profile loading and reload when requested again
  48240. */
  48241. static ClearProfilesCache(): void;
  48242. /**
  48243. * Register the default fallbacks.
  48244. * This function is called automatically when this file is imported.
  48245. */
  48246. static DefaultFallbacks(): void;
  48247. /**
  48248. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  48249. * @param profileId the profile to which a fallback needs to be found
  48250. * @return an array with corresponding fallback profiles
  48251. */
  48252. static FindFallbackWithProfileId(profileId: string): string[];
  48253. /**
  48254. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  48255. * The order of search:
  48256. *
  48257. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  48258. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  48259. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  48260. * 4) return the generic trigger controller if none were found
  48261. *
  48262. * @param xrInput the xrInput to which a new controller is initialized
  48263. * @param scene the scene to which the model will be added
  48264. * @param forceProfile force a certain profile for this controller
  48265. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  48266. */
  48267. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  48268. /**
  48269. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  48270. *
  48271. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  48272. *
  48273. * @param type the profile type to register
  48274. * @param constructFunction the function to be called when loading this profile
  48275. */
  48276. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  48277. /**
  48278. * Register a fallback to a specific profile.
  48279. * @param profileId the profileId that will receive the fallbacks
  48280. * @param fallbacks A list of fallback profiles
  48281. */
  48282. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  48283. /**
  48284. * Will update the list of profiles available in the repository
  48285. * @return a promise that resolves to a map of profiles available online
  48286. */
  48287. static UpdateProfilesList(): Promise<{
  48288. [profile: string]: string;
  48289. }>;
  48290. private static _LoadProfileFromRepository;
  48291. private static _LoadProfilesFromAvailableControllers;
  48292. }
  48293. }
  48294. declare module BABYLON {
  48295. /**
  48296. * Configuration options for the WebXR controller creation
  48297. */
  48298. export interface IWebXRControllerOptions {
  48299. /**
  48300. * Should the controller mesh be animated when a user interacts with it
  48301. * The pressed buttons / thumbstick and touchpad animations will be disabled
  48302. */
  48303. disableMotionControllerAnimation?: boolean;
  48304. /**
  48305. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  48306. */
  48307. doNotLoadControllerMesh?: boolean;
  48308. /**
  48309. * Force a specific controller type for this controller.
  48310. * This can be used when creating your own profile or when testing different controllers
  48311. */
  48312. forceControllerProfile?: string;
  48313. /**
  48314. * Defines a rendering group ID for meshes that will be loaded.
  48315. * This is for the default controllers only.
  48316. */
  48317. renderingGroupId?: number;
  48318. }
  48319. /**
  48320. * Represents an XR controller
  48321. */
  48322. export class WebXRInputSource {
  48323. private _scene;
  48324. /** The underlying input source for the controller */
  48325. inputSource: XRInputSource;
  48326. private _options;
  48327. private _tmpVector;
  48328. private _uniqueId;
  48329. /**
  48330. * 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
  48331. */
  48332. grip?: AbstractMesh;
  48333. /**
  48334. * If available, this is the gamepad object related to this controller.
  48335. * Using this object it is possible to get click events and trackpad changes of the
  48336. * webxr controller that is currently being used.
  48337. */
  48338. motionController?: WebXRAbstractMotionController;
  48339. /**
  48340. * Event that fires when the controller is removed/disposed.
  48341. * The object provided as event data is this controller, after associated assets were disposed.
  48342. * uniqueId is still available.
  48343. */
  48344. onDisposeObservable: Observable<WebXRInputSource>;
  48345. /**
  48346. * Will be triggered when the mesh associated with the motion controller is done loading.
  48347. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  48348. * A shortened version of controller -> motion controller -> on mesh loaded.
  48349. */
  48350. onMeshLoadedObservable: Observable<AbstractMesh>;
  48351. /**
  48352. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  48353. */
  48354. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  48355. /**
  48356. * Pointer which can be used to select objects or attach a visible laser to
  48357. */
  48358. pointer: AbstractMesh;
  48359. /**
  48360. * Creates the input source object
  48361. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  48362. * @param _scene the scene which the controller should be associated to
  48363. * @param inputSource the underlying input source for the controller
  48364. * @param _options options for this controller creation
  48365. */
  48366. constructor(_scene: Scene,
  48367. /** The underlying input source for the controller */
  48368. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  48369. /**
  48370. * Get this controllers unique id
  48371. */
  48372. get uniqueId(): string;
  48373. /**
  48374. * Disposes of the object
  48375. */
  48376. dispose(): void;
  48377. /**
  48378. * Gets a world space ray coming from the pointer or grip
  48379. * @param result the resulting ray
  48380. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  48381. */
  48382. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  48383. /**
  48384. * Updates the controller pose based on the given XRFrame
  48385. * @param xrFrame xr frame to update the pose with
  48386. * @param referenceSpace reference space to use
  48387. */
  48388. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  48389. }
  48390. }
  48391. declare module BABYLON {
  48392. /**
  48393. * The schema for initialization options of the XR Input class
  48394. */
  48395. export interface IWebXRInputOptions {
  48396. /**
  48397. * If set to true no model will be automatically loaded
  48398. */
  48399. doNotLoadControllerMeshes?: boolean;
  48400. /**
  48401. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  48402. * If not found, the xr input profile data will be used.
  48403. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  48404. */
  48405. forceInputProfile?: string;
  48406. /**
  48407. * Do not send a request to the controller repository to load the profile.
  48408. *
  48409. * Instead, use the controllers available in babylon itself.
  48410. */
  48411. disableOnlineControllerRepository?: boolean;
  48412. /**
  48413. * A custom URL for the controllers repository
  48414. */
  48415. customControllersRepositoryURL?: string;
  48416. /**
  48417. * Should the controller model's components not move according to the user input
  48418. */
  48419. disableControllerAnimation?: boolean;
  48420. /**
  48421. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  48422. */
  48423. controllerOptions?: IWebXRControllerOptions;
  48424. }
  48425. /**
  48426. * XR input used to track XR inputs such as controllers/rays
  48427. */
  48428. export class WebXRInput implements IDisposable {
  48429. /**
  48430. * the xr session manager for this session
  48431. */
  48432. xrSessionManager: WebXRSessionManager;
  48433. /**
  48434. * the WebXR camera for this session. Mainly used for teleportation
  48435. */
  48436. xrCamera: WebXRCamera;
  48437. private readonly options;
  48438. /**
  48439. * XR controllers being tracked
  48440. */
  48441. controllers: Array<WebXRInputSource>;
  48442. private _frameObserver;
  48443. private _sessionEndedObserver;
  48444. private _sessionInitObserver;
  48445. /**
  48446. * Event when a controller has been connected/added
  48447. */
  48448. onControllerAddedObservable: Observable<WebXRInputSource>;
  48449. /**
  48450. * Event when a controller has been removed/disconnected
  48451. */
  48452. onControllerRemovedObservable: Observable<WebXRInputSource>;
  48453. /**
  48454. * Initializes the WebXRInput
  48455. * @param xrSessionManager the xr session manager for this session
  48456. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  48457. * @param options = initialization options for this xr input
  48458. */
  48459. constructor(
  48460. /**
  48461. * the xr session manager for this session
  48462. */
  48463. xrSessionManager: WebXRSessionManager,
  48464. /**
  48465. * the WebXR camera for this session. Mainly used for teleportation
  48466. */
  48467. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  48468. private _onInputSourcesChange;
  48469. private _addAndRemoveControllers;
  48470. /**
  48471. * Disposes of the object
  48472. */
  48473. dispose(): void;
  48474. }
  48475. }
  48476. declare module BABYLON {
  48477. /**
  48478. * This is the base class for all WebXR features.
  48479. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  48480. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  48481. */
  48482. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  48483. protected _xrSessionManager: WebXRSessionManager;
  48484. private _attached;
  48485. private _removeOnDetach;
  48486. /**
  48487. * Should auto-attach be disabled?
  48488. */
  48489. disableAutoAttach: boolean;
  48490. /**
  48491. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  48492. */
  48493. xrNativeFeatureName: string;
  48494. /**
  48495. * Construct a new (abstract) WebXR feature
  48496. * @param _xrSessionManager the xr session manager for this feature
  48497. */
  48498. constructor(_xrSessionManager: WebXRSessionManager);
  48499. /**
  48500. * Is this feature attached
  48501. */
  48502. get attached(): boolean;
  48503. /**
  48504. * attach this feature
  48505. *
  48506. * @param force should attachment be forced (even when already attached)
  48507. * @returns true if successful, false is failed or already attached
  48508. */
  48509. attach(force?: boolean): boolean;
  48510. /**
  48511. * detach this feature.
  48512. *
  48513. * @returns true if successful, false if failed or already detached
  48514. */
  48515. detach(): boolean;
  48516. /**
  48517. * Dispose this feature and all of the resources attached
  48518. */
  48519. dispose(): void;
  48520. /**
  48521. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  48522. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  48523. *
  48524. * @returns whether or not the feature is compatible in this environment
  48525. */
  48526. isCompatible(): boolean;
  48527. /**
  48528. * This is used to register callbacks that will automatically be removed when detach is called.
  48529. * @param observable the observable to which the observer will be attached
  48530. * @param callback the callback to register
  48531. */
  48532. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  48533. /**
  48534. * Code in this function will be executed on each xrFrame received from the browser.
  48535. * This function will not execute after the feature is detached.
  48536. * @param _xrFrame the current frame
  48537. */
  48538. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  48539. }
  48540. }
  48541. declare module BABYLON {
  48542. /**
  48543. * Renders a layer on top of an existing scene
  48544. */
  48545. export class UtilityLayerRenderer implements IDisposable {
  48546. /** the original scene that will be rendered on top of */
  48547. originalScene: Scene;
  48548. private _pointerCaptures;
  48549. private _lastPointerEvents;
  48550. private static _DefaultUtilityLayer;
  48551. private static _DefaultKeepDepthUtilityLayer;
  48552. private _sharedGizmoLight;
  48553. private _renderCamera;
  48554. /**
  48555. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  48556. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  48557. * @returns the camera that is used when rendering the utility layer
  48558. */
  48559. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  48560. /**
  48561. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  48562. * @param cam the camera that should be used when rendering the utility layer
  48563. */
  48564. setRenderCamera(cam: Nullable<Camera>): void;
  48565. /**
  48566. * @hidden
  48567. * Light which used by gizmos to get light shading
  48568. */
  48569. _getSharedGizmoLight(): HemisphericLight;
  48570. /**
  48571. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  48572. */
  48573. pickUtilitySceneFirst: boolean;
  48574. /**
  48575. * 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)
  48576. */
  48577. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  48578. /**
  48579. * 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)
  48580. */
  48581. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  48582. /**
  48583. * The scene that is rendered on top of the original scene
  48584. */
  48585. utilityLayerScene: Scene;
  48586. /**
  48587. * If the utility layer should automatically be rendered on top of existing scene
  48588. */
  48589. shouldRender: boolean;
  48590. /**
  48591. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  48592. */
  48593. onlyCheckPointerDownEvents: boolean;
  48594. /**
  48595. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  48596. */
  48597. processAllEvents: boolean;
  48598. /**
  48599. * Observable raised when the pointer move from the utility layer scene to the main scene
  48600. */
  48601. onPointerOutObservable: Observable<number>;
  48602. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  48603. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  48604. private _afterRenderObserver;
  48605. private _sceneDisposeObserver;
  48606. private _originalPointerObserver;
  48607. /**
  48608. * Instantiates a UtilityLayerRenderer
  48609. * @param originalScene the original scene that will be rendered on top of
  48610. * @param handleEvents boolean indicating if the utility layer should handle events
  48611. */
  48612. constructor(
  48613. /** the original scene that will be rendered on top of */
  48614. originalScene: Scene, handleEvents?: boolean);
  48615. private _notifyObservers;
  48616. /**
  48617. * Renders the utility layers scene on top of the original scene
  48618. */
  48619. render(): void;
  48620. /**
  48621. * Disposes of the renderer
  48622. */
  48623. dispose(): void;
  48624. private _updateCamera;
  48625. }
  48626. }
  48627. declare module BABYLON {
  48628. /**
  48629. * Options interface for the pointer selection module
  48630. */
  48631. export interface IWebXRControllerPointerSelectionOptions {
  48632. /**
  48633. * if provided, this scene will be used to render meshes.
  48634. */
  48635. customUtilityLayerScene?: Scene;
  48636. /**
  48637. * 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)
  48638. * If not disabled, the last picked point will be used to execute a pointer up event
  48639. * If disabled, pointer up event will be triggered right after the pointer down event.
  48640. * Used in screen and gaze target ray mode only
  48641. */
  48642. disablePointerUpOnTouchOut: boolean;
  48643. /**
  48644. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  48645. */
  48646. forceGazeMode: boolean;
  48647. /**
  48648. * 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
  48649. * to start a new countdown to the pointer down event.
  48650. * Defaults to 1.
  48651. */
  48652. gazeModePointerMovedFactor?: number;
  48653. /**
  48654. * Different button type to use instead of the main component
  48655. */
  48656. overrideButtonId?: string;
  48657. /**
  48658. * use this rendering group id for the meshes (optional)
  48659. */
  48660. renderingGroupId?: number;
  48661. /**
  48662. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  48663. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  48664. * 3000 means 3 seconds between pointing at something and selecting it
  48665. */
  48666. timeToSelect?: number;
  48667. /**
  48668. * Should meshes created here be added to a utility layer or the main scene
  48669. */
  48670. useUtilityLayer?: boolean;
  48671. /**
  48672. * Optional WebXR camera to be used for gaze selection
  48673. */
  48674. gazeCamera?: WebXRCamera;
  48675. /**
  48676. * the xr input to use with this pointer selection
  48677. */
  48678. xrInput: WebXRInput;
  48679. }
  48680. /**
  48681. * A module that will enable pointer selection for motion controllers of XR Input Sources
  48682. */
  48683. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  48684. private readonly _options;
  48685. private static _idCounter;
  48686. private _attachController;
  48687. private _controllers;
  48688. private _scene;
  48689. private _tmpVectorForPickCompare;
  48690. /**
  48691. * The module's name
  48692. */
  48693. static readonly Name: string;
  48694. /**
  48695. * The (Babylon) version of this module.
  48696. * This is an integer representing the implementation version.
  48697. * This number does not correspond to the WebXR specs version
  48698. */
  48699. static readonly Version: number;
  48700. /**
  48701. * Disable lighting on the laser pointer (so it will always be visible)
  48702. */
  48703. disablePointerLighting: boolean;
  48704. /**
  48705. * Disable lighting on the selection mesh (so it will always be visible)
  48706. */
  48707. disableSelectionMeshLighting: boolean;
  48708. /**
  48709. * Should the laser pointer be displayed
  48710. */
  48711. displayLaserPointer: boolean;
  48712. /**
  48713. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  48714. */
  48715. displaySelectionMesh: boolean;
  48716. /**
  48717. * This color will be set to the laser pointer when selection is triggered
  48718. */
  48719. laserPointerPickedColor: Color3;
  48720. /**
  48721. * Default color of the laser pointer
  48722. */
  48723. laserPointerDefaultColor: Color3;
  48724. /**
  48725. * default color of the selection ring
  48726. */
  48727. selectionMeshDefaultColor: Color3;
  48728. /**
  48729. * This color will be applied to the selection ring when selection is triggered
  48730. */
  48731. selectionMeshPickedColor: Color3;
  48732. /**
  48733. * Optional filter to be used for ray selection. This predicate shares behavior with
  48734. * scene.pointerMovePredicate which takes priority if it is also assigned.
  48735. */
  48736. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  48737. /**
  48738. * constructs a new background remover module
  48739. * @param _xrSessionManager the session manager for this module
  48740. * @param _options read-only options to be used in this module
  48741. */
  48742. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  48743. /**
  48744. * attach this feature
  48745. * Will usually be called by the features manager
  48746. *
  48747. * @returns true if successful.
  48748. */
  48749. attach(): boolean;
  48750. /**
  48751. * detach this feature.
  48752. * Will usually be called by the features manager
  48753. *
  48754. * @returns true if successful.
  48755. */
  48756. detach(): boolean;
  48757. /**
  48758. * Will get the mesh under a specific pointer.
  48759. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  48760. * @param controllerId the controllerId to check
  48761. * @returns The mesh under pointer or null if no mesh is under the pointer
  48762. */
  48763. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  48764. /**
  48765. * Get the xr controller that correlates to the pointer id in the pointer event
  48766. *
  48767. * @param id the pointer id to search for
  48768. * @returns the controller that correlates to this id or null if not found
  48769. */
  48770. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  48771. protected _onXRFrame(_xrFrame: XRFrame): void;
  48772. private _attachGazeMode;
  48773. private _attachScreenRayMode;
  48774. private _attachTrackedPointerRayMode;
  48775. private _convertNormalToDirectionOfRay;
  48776. private _detachController;
  48777. private _generateNewMeshPair;
  48778. private _pickingMoved;
  48779. private _updatePointerDistance;
  48780. /** @hidden */
  48781. get lasterPointerDefaultColor(): Color3;
  48782. }
  48783. }
  48784. declare module BABYLON {
  48785. /**
  48786. * Button which can be used to enter a different mode of XR
  48787. */
  48788. export class WebXREnterExitUIButton {
  48789. /** button element */
  48790. element: HTMLElement;
  48791. /** XR initialization options for the button */
  48792. sessionMode: XRSessionMode;
  48793. /** Reference space type */
  48794. referenceSpaceType: XRReferenceSpaceType;
  48795. /**
  48796. * Creates a WebXREnterExitUIButton
  48797. * @param element button element
  48798. * @param sessionMode XR initialization session mode
  48799. * @param referenceSpaceType the type of reference space to be used
  48800. */
  48801. constructor(
  48802. /** button element */
  48803. element: HTMLElement,
  48804. /** XR initialization options for the button */
  48805. sessionMode: XRSessionMode,
  48806. /** Reference space type */
  48807. referenceSpaceType: XRReferenceSpaceType);
  48808. /**
  48809. * Extendable function which can be used to update the button's visuals when the state changes
  48810. * @param activeButton the current active button in the UI
  48811. */
  48812. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  48813. }
  48814. /**
  48815. * Options to create the webXR UI
  48816. */
  48817. export class WebXREnterExitUIOptions {
  48818. /**
  48819. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  48820. */
  48821. customButtons?: Array<WebXREnterExitUIButton>;
  48822. /**
  48823. * A reference space type to use when creating the default button.
  48824. * Default is local-floor
  48825. */
  48826. referenceSpaceType?: XRReferenceSpaceType;
  48827. /**
  48828. * Context to enter xr with
  48829. */
  48830. renderTarget?: Nullable<WebXRRenderTarget>;
  48831. /**
  48832. * A session mode to use when creating the default button.
  48833. * Default is immersive-vr
  48834. */
  48835. sessionMode?: XRSessionMode;
  48836. /**
  48837. * A list of optional features to init the session with
  48838. */
  48839. optionalFeatures?: string[];
  48840. /**
  48841. * A list of optional features to init the session with
  48842. */
  48843. requiredFeatures?: string[];
  48844. }
  48845. /**
  48846. * UI to allow the user to enter/exit XR mode
  48847. */
  48848. export class WebXREnterExitUI implements IDisposable {
  48849. private scene;
  48850. /** version of the options passed to this UI */
  48851. options: WebXREnterExitUIOptions;
  48852. private _activeButton;
  48853. private _buttons;
  48854. private _overlay;
  48855. /**
  48856. * Fired every time the active button is changed.
  48857. *
  48858. * When xr is entered via a button that launches xr that button will be the callback parameter
  48859. *
  48860. * When exiting xr the callback parameter will be null)
  48861. */
  48862. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  48863. /**
  48864. *
  48865. * @param scene babylon scene object to use
  48866. * @param options (read-only) version of the options passed to this UI
  48867. */
  48868. private constructor();
  48869. /**
  48870. * Creates UI to allow the user to enter/exit XR mode
  48871. * @param scene the scene to add the ui to
  48872. * @param helper the xr experience helper to enter/exit xr with
  48873. * @param options options to configure the UI
  48874. * @returns the created ui
  48875. */
  48876. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  48877. /**
  48878. * Disposes of the XR UI component
  48879. */
  48880. dispose(): void;
  48881. private _updateButtons;
  48882. }
  48883. }
  48884. declare module BABYLON {
  48885. /**
  48886. * Class containing static functions to help procedurally build meshes
  48887. */
  48888. export class LinesBuilder {
  48889. /**
  48890. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  48891. * * 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
  48892. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  48893. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  48894. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  48895. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  48896. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  48897. * * 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
  48898. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  48899. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48900. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  48901. * @param name defines the name of the new line system
  48902. * @param options defines the options used to create the line system
  48903. * @param scene defines the hosting scene
  48904. * @returns a new line system mesh
  48905. */
  48906. static CreateLineSystem(name: string, options: {
  48907. lines: Vector3[][];
  48908. updatable?: boolean;
  48909. instance?: Nullable<LinesMesh>;
  48910. colors?: Nullable<Color4[][]>;
  48911. useVertexAlpha?: boolean;
  48912. }, scene: Nullable<Scene>): LinesMesh;
  48913. /**
  48914. * Creates a line mesh
  48915. * 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
  48916. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  48917. * * The parameter `points` is an array successive Vector3
  48918. * * 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
  48919. * * The optional parameter `colors` is an array of successive Color4, one per line point
  48920. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  48921. * * When updating an instance, remember that only point positions can change, not the number of points
  48922. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48923. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  48924. * @param name defines the name of the new line system
  48925. * @param options defines the options used to create the line system
  48926. * @param scene defines the hosting scene
  48927. * @returns a new line mesh
  48928. */
  48929. static CreateLines(name: string, options: {
  48930. points: Vector3[];
  48931. updatable?: boolean;
  48932. instance?: Nullable<LinesMesh>;
  48933. colors?: Color4[];
  48934. useVertexAlpha?: boolean;
  48935. }, scene?: Nullable<Scene>): LinesMesh;
  48936. /**
  48937. * Creates a dashed line mesh
  48938. * * 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
  48939. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  48940. * * The parameter `points` is an array successive Vector3
  48941. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  48942. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  48943. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  48944. * * 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
  48945. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  48946. * * When updating an instance, remember that only point positions can change, not the number of points
  48947. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48948. * @param name defines the name of the mesh
  48949. * @param options defines the options used to create the mesh
  48950. * @param scene defines the hosting scene
  48951. * @returns the dashed line mesh
  48952. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  48953. */
  48954. static CreateDashedLines(name: string, options: {
  48955. points: Vector3[];
  48956. dashSize?: number;
  48957. gapSize?: number;
  48958. dashNb?: number;
  48959. updatable?: boolean;
  48960. instance?: LinesMesh;
  48961. useVertexAlpha?: boolean;
  48962. }, scene?: Nullable<Scene>): LinesMesh;
  48963. }
  48964. }
  48965. declare module BABYLON {
  48966. /**
  48967. * Construction options for a timer
  48968. */
  48969. export interface ITimerOptions<T> {
  48970. /**
  48971. * Time-to-end
  48972. */
  48973. timeout: number;
  48974. /**
  48975. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  48976. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  48977. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  48978. */
  48979. contextObservable: Observable<T>;
  48980. /**
  48981. * Optional parameters when adding an observer to the observable
  48982. */
  48983. observableParameters?: {
  48984. mask?: number;
  48985. insertFirst?: boolean;
  48986. scope?: any;
  48987. };
  48988. /**
  48989. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  48990. */
  48991. breakCondition?: (data?: ITimerData<T>) => boolean;
  48992. /**
  48993. * Will be triggered when the time condition has met
  48994. */
  48995. onEnded?: (data: ITimerData<any>) => void;
  48996. /**
  48997. * Will be triggered when the break condition has met (prematurely ended)
  48998. */
  48999. onAborted?: (data: ITimerData<any>) => void;
  49000. /**
  49001. * Optional function to execute on each tick (or count)
  49002. */
  49003. onTick?: (data: ITimerData<any>) => void;
  49004. }
  49005. /**
  49006. * An interface defining the data sent by the timer
  49007. */
  49008. export interface ITimerData<T> {
  49009. /**
  49010. * When did it start
  49011. */
  49012. startTime: number;
  49013. /**
  49014. * Time now
  49015. */
  49016. currentTime: number;
  49017. /**
  49018. * Time passed since started
  49019. */
  49020. deltaTime: number;
  49021. /**
  49022. * How much is completed, in [0.0...1.0].
  49023. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  49024. */
  49025. completeRate: number;
  49026. /**
  49027. * What the registered observable sent in the last count
  49028. */
  49029. payload: T;
  49030. }
  49031. /**
  49032. * The current state of the timer
  49033. */
  49034. export enum TimerState {
  49035. /**
  49036. * Timer initialized, not yet started
  49037. */
  49038. INIT = 0,
  49039. /**
  49040. * Timer started and counting
  49041. */
  49042. STARTED = 1,
  49043. /**
  49044. * Timer ended (whether aborted or time reached)
  49045. */
  49046. ENDED = 2
  49047. }
  49048. /**
  49049. * A simple version of the timer. Will take options and start the timer immediately after calling it
  49050. *
  49051. * @param options options with which to initialize this timer
  49052. */
  49053. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  49054. /**
  49055. * An advanced implementation of a timer class
  49056. */
  49057. export class AdvancedTimer<T = any> implements IDisposable {
  49058. /**
  49059. * Will notify each time the timer calculates the remaining time
  49060. */
  49061. onEachCountObservable: Observable<ITimerData<T>>;
  49062. /**
  49063. * Will trigger when the timer was aborted due to the break condition
  49064. */
  49065. onTimerAbortedObservable: Observable<ITimerData<T>>;
  49066. /**
  49067. * Will trigger when the timer ended successfully
  49068. */
  49069. onTimerEndedObservable: Observable<ITimerData<T>>;
  49070. /**
  49071. * Will trigger when the timer state has changed
  49072. */
  49073. onStateChangedObservable: Observable<TimerState>;
  49074. private _observer;
  49075. private _contextObservable;
  49076. private _observableParameters;
  49077. private _startTime;
  49078. private _timer;
  49079. private _state;
  49080. private _breakCondition;
  49081. private _timeToEnd;
  49082. private _breakOnNextTick;
  49083. /**
  49084. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  49085. * @param options construction options for this advanced timer
  49086. */
  49087. constructor(options: ITimerOptions<T>);
  49088. /**
  49089. * set a breaking condition for this timer. Default is to never break during count
  49090. * @param predicate the new break condition. Returns true to break, false otherwise
  49091. */
  49092. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  49093. /**
  49094. * Reset ALL associated observables in this advanced timer
  49095. */
  49096. clearObservables(): void;
  49097. /**
  49098. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  49099. *
  49100. * @param timeToEnd how much time to measure until timer ended
  49101. */
  49102. start(timeToEnd?: number): void;
  49103. /**
  49104. * Will force a stop on the next tick.
  49105. */
  49106. stop(): void;
  49107. /**
  49108. * Dispose this timer, clearing all resources
  49109. */
  49110. dispose(): void;
  49111. private _setState;
  49112. private _tick;
  49113. private _stop;
  49114. }
  49115. }
  49116. declare module BABYLON {
  49117. /**
  49118. * The options container for the teleportation module
  49119. */
  49120. export interface IWebXRTeleportationOptions {
  49121. /**
  49122. * if provided, this scene will be used to render meshes.
  49123. */
  49124. customUtilityLayerScene?: Scene;
  49125. /**
  49126. * Values to configure the default target mesh
  49127. */
  49128. defaultTargetMeshOptions?: {
  49129. /**
  49130. * Fill color of the teleportation area
  49131. */
  49132. teleportationFillColor?: string;
  49133. /**
  49134. * Border color for the teleportation area
  49135. */
  49136. teleportationBorderColor?: string;
  49137. /**
  49138. * Disable the mesh's animation sequence
  49139. */
  49140. disableAnimation?: boolean;
  49141. /**
  49142. * Disable lighting on the material or the ring and arrow
  49143. */
  49144. disableLighting?: boolean;
  49145. /**
  49146. * Override the default material of the torus and arrow
  49147. */
  49148. torusArrowMaterial?: Material;
  49149. };
  49150. /**
  49151. * A list of meshes to use as floor meshes.
  49152. * Meshes can be added and removed after initializing the feature using the
  49153. * addFloorMesh and removeFloorMesh functions
  49154. * If empty, rotation will still work
  49155. */
  49156. floorMeshes?: AbstractMesh[];
  49157. /**
  49158. * use this rendering group id for the meshes (optional)
  49159. */
  49160. renderingGroupId?: number;
  49161. /**
  49162. * Should teleportation move only to snap points
  49163. */
  49164. snapPointsOnly?: boolean;
  49165. /**
  49166. * An array of points to which the teleportation will snap to.
  49167. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  49168. */
  49169. snapPositions?: Vector3[];
  49170. /**
  49171. * How close should the teleportation ray be in order to snap to position.
  49172. * Default to 0.8 units (meters)
  49173. */
  49174. snapToPositionRadius?: number;
  49175. /**
  49176. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  49177. * If you want to support rotation, make sure your mesh has a direction indicator.
  49178. *
  49179. * When left untouched, the default mesh will be initialized.
  49180. */
  49181. teleportationTargetMesh?: AbstractMesh;
  49182. /**
  49183. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  49184. */
  49185. timeToTeleport?: number;
  49186. /**
  49187. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  49188. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  49189. */
  49190. useMainComponentOnly?: boolean;
  49191. /**
  49192. * Should meshes created here be added to a utility layer or the main scene
  49193. */
  49194. useUtilityLayer?: boolean;
  49195. /**
  49196. * Babylon XR Input class for controller
  49197. */
  49198. xrInput: WebXRInput;
  49199. }
  49200. /**
  49201. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  49202. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  49203. * the input of the attached controllers.
  49204. */
  49205. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  49206. private _options;
  49207. private _controllers;
  49208. private _currentTeleportationControllerId;
  49209. private _floorMeshes;
  49210. private _quadraticBezierCurve;
  49211. private _selectionFeature;
  49212. private _snapToPositions;
  49213. private _snappedToPoint;
  49214. private _teleportationRingMaterial?;
  49215. private _tmpRay;
  49216. private _tmpVector;
  49217. /**
  49218. * The module's name
  49219. */
  49220. static readonly Name: string;
  49221. /**
  49222. * The (Babylon) version of this module.
  49223. * This is an integer representing the implementation version.
  49224. * This number does not correspond to the webxr specs version
  49225. */
  49226. static readonly Version: number;
  49227. /**
  49228. * Is movement backwards enabled
  49229. */
  49230. backwardsMovementEnabled: boolean;
  49231. /**
  49232. * Distance to travel when moving backwards
  49233. */
  49234. backwardsTeleportationDistance: number;
  49235. /**
  49236. * The distance from the user to the inspection point in the direction of the controller
  49237. * A higher number will allow the user to move further
  49238. * defaults to 5 (meters, in xr units)
  49239. */
  49240. parabolicCheckRadius: number;
  49241. /**
  49242. * Should the module support parabolic ray on top of direct ray
  49243. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  49244. * Very helpful when moving between floors / different heights
  49245. */
  49246. parabolicRayEnabled: boolean;
  49247. /**
  49248. * How much rotation should be applied when rotating right and left
  49249. */
  49250. rotationAngle: number;
  49251. /**
  49252. * Is rotation enabled when moving forward?
  49253. * Disabling this feature will prevent the user from deciding the direction when teleporting
  49254. */
  49255. rotationEnabled: boolean;
  49256. /**
  49257. * constructs a new anchor system
  49258. * @param _xrSessionManager an instance of WebXRSessionManager
  49259. * @param _options configuration object for this feature
  49260. */
  49261. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  49262. /**
  49263. * Get the snapPointsOnly flag
  49264. */
  49265. get snapPointsOnly(): boolean;
  49266. /**
  49267. * Sets the snapPointsOnly flag
  49268. * @param snapToPoints should teleportation be exclusively to snap points
  49269. */
  49270. set snapPointsOnly(snapToPoints: boolean);
  49271. /**
  49272. * Add a new mesh to the floor meshes array
  49273. * @param mesh the mesh to use as floor mesh
  49274. */
  49275. addFloorMesh(mesh: AbstractMesh): void;
  49276. /**
  49277. * Add a new snap-to point to fix teleportation to this position
  49278. * @param newSnapPoint The new Snap-To point
  49279. */
  49280. addSnapPoint(newSnapPoint: Vector3): void;
  49281. attach(): boolean;
  49282. detach(): boolean;
  49283. dispose(): void;
  49284. /**
  49285. * Remove a mesh from the floor meshes array
  49286. * @param mesh the mesh to remove
  49287. */
  49288. removeFloorMesh(mesh: AbstractMesh): void;
  49289. /**
  49290. * Remove a mesh from the floor meshes array using its name
  49291. * @param name the mesh name to remove
  49292. */
  49293. removeFloorMeshByName(name: string): void;
  49294. /**
  49295. * 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
  49296. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  49297. * @returns was the point found and removed or not
  49298. */
  49299. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  49300. /**
  49301. * This function sets a selection feature that will be disabled when
  49302. * the forward ray is shown and will be reattached when hidden.
  49303. * This is used to remove the selection rays when moving.
  49304. * @param selectionFeature the feature to disable when forward movement is enabled
  49305. */
  49306. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  49307. protected _onXRFrame(_xrFrame: XRFrame): void;
  49308. private _attachController;
  49309. private _createDefaultTargetMesh;
  49310. private _detachController;
  49311. private _findClosestSnapPointWithRadius;
  49312. private _setTargetMeshPosition;
  49313. private _setTargetMeshVisibility;
  49314. private _showParabolicPath;
  49315. private _teleportForward;
  49316. }
  49317. }
  49318. declare module BABYLON {
  49319. /**
  49320. * Options for the default xr helper
  49321. */
  49322. export class WebXRDefaultExperienceOptions {
  49323. /**
  49324. * Enable or disable default UI to enter XR
  49325. */
  49326. disableDefaultUI?: boolean;
  49327. /**
  49328. * Should teleportation not initialize. defaults to false.
  49329. */
  49330. disableTeleportation?: boolean;
  49331. /**
  49332. * Floor meshes that will be used for teleport
  49333. */
  49334. floorMeshes?: Array<AbstractMesh>;
  49335. /**
  49336. * If set to true, the first frame will not be used to reset position
  49337. * The first frame is mainly used when copying transformation from the old camera
  49338. * Mainly used in AR
  49339. */
  49340. ignoreNativeCameraTransformation?: boolean;
  49341. /**
  49342. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  49343. */
  49344. inputOptions?: IWebXRInputOptions;
  49345. /**
  49346. * optional configuration for the output canvas
  49347. */
  49348. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  49349. /**
  49350. * optional UI options. This can be used among other to change session mode and reference space type
  49351. */
  49352. uiOptions?: WebXREnterExitUIOptions;
  49353. /**
  49354. * When loading teleportation and pointer select, use stable versions instead of latest.
  49355. */
  49356. useStablePlugins?: boolean;
  49357. /**
  49358. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  49359. */
  49360. renderingGroupId?: number;
  49361. /**
  49362. * A list of optional features to init the session with
  49363. * If set to true, all features we support will be added
  49364. */
  49365. optionalFeatures?: boolean | string[];
  49366. }
  49367. /**
  49368. * Default experience which provides a similar setup to the previous webVRExperience
  49369. */
  49370. export class WebXRDefaultExperience {
  49371. /**
  49372. * Base experience
  49373. */
  49374. baseExperience: WebXRExperienceHelper;
  49375. /**
  49376. * Enables ui for entering/exiting xr
  49377. */
  49378. enterExitUI: WebXREnterExitUI;
  49379. /**
  49380. * Input experience extension
  49381. */
  49382. input: WebXRInput;
  49383. /**
  49384. * Enables laser pointer and selection
  49385. */
  49386. pointerSelection: WebXRControllerPointerSelection;
  49387. /**
  49388. * Default target xr should render to
  49389. */
  49390. renderTarget: WebXRRenderTarget;
  49391. /**
  49392. * Enables teleportation
  49393. */
  49394. teleportation: WebXRMotionControllerTeleportation;
  49395. private constructor();
  49396. /**
  49397. * Creates the default xr experience
  49398. * @param scene scene
  49399. * @param options options for basic configuration
  49400. * @returns resulting WebXRDefaultExperience
  49401. */
  49402. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49403. /**
  49404. * DIsposes of the experience helper
  49405. */
  49406. dispose(): void;
  49407. }
  49408. }
  49409. declare module BABYLON {
  49410. /**
  49411. * Options to modify the vr teleportation behavior.
  49412. */
  49413. export interface VRTeleportationOptions {
  49414. /**
  49415. * The name of the mesh which should be used as the teleportation floor. (default: null)
  49416. */
  49417. floorMeshName?: string;
  49418. /**
  49419. * A list of meshes to be used as the teleportation floor. (default: empty)
  49420. */
  49421. floorMeshes?: Mesh[];
  49422. /**
  49423. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  49424. */
  49425. teleportationMode?: number;
  49426. /**
  49427. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  49428. */
  49429. teleportationTime?: number;
  49430. /**
  49431. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  49432. */
  49433. teleportationSpeed?: number;
  49434. /**
  49435. * The easing function used in the animation or null for Linear. (default CircleEase)
  49436. */
  49437. easingFunction?: EasingFunction;
  49438. }
  49439. /**
  49440. * Options to modify the vr experience helper's behavior.
  49441. */
  49442. export interface VRExperienceHelperOptions extends WebVROptions {
  49443. /**
  49444. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  49445. */
  49446. createDeviceOrientationCamera?: boolean;
  49447. /**
  49448. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  49449. */
  49450. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  49451. /**
  49452. * Uses the main button on the controller to toggle the laser casted. (default: true)
  49453. */
  49454. laserToggle?: boolean;
  49455. /**
  49456. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  49457. */
  49458. floorMeshes?: Mesh[];
  49459. /**
  49460. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  49461. */
  49462. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  49463. /**
  49464. * Defines if WebXR should be used instead of WebVR (if available)
  49465. */
  49466. useXR?: boolean;
  49467. }
  49468. /**
  49469. * Event containing information after VR has been entered
  49470. */
  49471. export class OnAfterEnteringVRObservableEvent {
  49472. /**
  49473. * If entering vr was successful
  49474. */
  49475. success: boolean;
  49476. }
  49477. /**
  49478. * Helps to quickly add VR support to an existing scene.
  49479. * See https://doc.babylonjs.com/how_to/webvr_helper
  49480. */
  49481. export class VRExperienceHelper {
  49482. /** Options to modify the vr experience helper's behavior. */
  49483. webVROptions: VRExperienceHelperOptions;
  49484. private _scene;
  49485. private _position;
  49486. private _btnVR;
  49487. private _btnVRDisplayed;
  49488. private _webVRsupported;
  49489. private _webVRready;
  49490. private _webVRrequesting;
  49491. private _webVRpresenting;
  49492. private _hasEnteredVR;
  49493. private _fullscreenVRpresenting;
  49494. private _inputElement;
  49495. private _webVRCamera;
  49496. private _vrDeviceOrientationCamera;
  49497. private _deviceOrientationCamera;
  49498. private _existingCamera;
  49499. private _onKeyDown;
  49500. private _onVrDisplayPresentChange;
  49501. private _onVRDisplayChanged;
  49502. private _onVRRequestPresentStart;
  49503. private _onVRRequestPresentComplete;
  49504. /**
  49505. * 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)
  49506. */
  49507. enableGazeEvenWhenNoPointerLock: boolean;
  49508. /**
  49509. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  49510. */
  49511. exitVROnDoubleTap: boolean;
  49512. /**
  49513. * Observable raised right before entering VR.
  49514. */
  49515. onEnteringVRObservable: Observable<VRExperienceHelper>;
  49516. /**
  49517. * Observable raised when entering VR has completed.
  49518. */
  49519. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  49520. /**
  49521. * Observable raised when exiting VR.
  49522. */
  49523. onExitingVRObservable: Observable<VRExperienceHelper>;
  49524. /**
  49525. * Observable raised when controller mesh is loaded.
  49526. */
  49527. onControllerMeshLoadedObservable: Observable<WebVRController>;
  49528. /** Return this.onEnteringVRObservable
  49529. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  49530. */
  49531. get onEnteringVR(): Observable<VRExperienceHelper>;
  49532. /** Return this.onExitingVRObservable
  49533. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  49534. */
  49535. get onExitingVR(): Observable<VRExperienceHelper>;
  49536. /** Return this.onControllerMeshLoadedObservable
  49537. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  49538. */
  49539. get onControllerMeshLoaded(): Observable<WebVRController>;
  49540. private _rayLength;
  49541. private _useCustomVRButton;
  49542. private _teleportationRequested;
  49543. private _teleportActive;
  49544. private _floorMeshName;
  49545. private _floorMeshesCollection;
  49546. private _teleportationMode;
  49547. private _teleportationTime;
  49548. private _teleportationSpeed;
  49549. private _teleportationEasing;
  49550. private _rotationAllowed;
  49551. private _teleportBackwardsVector;
  49552. private _teleportationTarget;
  49553. private _isDefaultTeleportationTarget;
  49554. private _postProcessMove;
  49555. private _teleportationFillColor;
  49556. private _teleportationBorderColor;
  49557. private _rotationAngle;
  49558. private _haloCenter;
  49559. private _cameraGazer;
  49560. private _padSensibilityUp;
  49561. private _padSensibilityDown;
  49562. private _leftController;
  49563. private _rightController;
  49564. private _gazeColor;
  49565. private _laserColor;
  49566. private _pickedLaserColor;
  49567. private _pickedGazeColor;
  49568. /**
  49569. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  49570. */
  49571. onNewMeshSelected: Observable<AbstractMesh>;
  49572. /**
  49573. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  49574. * This observable will provide the mesh and the controller used to select the mesh
  49575. */
  49576. onMeshSelectedWithController: Observable<{
  49577. mesh: AbstractMesh;
  49578. controller: WebVRController;
  49579. }>;
  49580. /**
  49581. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  49582. */
  49583. onNewMeshPicked: Observable<PickingInfo>;
  49584. private _circleEase;
  49585. /**
  49586. * Observable raised before camera teleportation
  49587. */
  49588. onBeforeCameraTeleport: Observable<Vector3>;
  49589. /**
  49590. * Observable raised after camera teleportation
  49591. */
  49592. onAfterCameraTeleport: Observable<Vector3>;
  49593. /**
  49594. * Observable raised when current selected mesh gets unselected
  49595. */
  49596. onSelectedMeshUnselected: Observable<AbstractMesh>;
  49597. private _raySelectionPredicate;
  49598. /**
  49599. * To be optionaly changed by user to define custom ray selection
  49600. */
  49601. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49602. /**
  49603. * To be optionaly changed by user to define custom selection logic (after ray selection)
  49604. */
  49605. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49606. /**
  49607. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  49608. */
  49609. teleportationEnabled: boolean;
  49610. private _defaultHeight;
  49611. private _teleportationInitialized;
  49612. private _interactionsEnabled;
  49613. private _interactionsRequested;
  49614. private _displayGaze;
  49615. private _displayLaserPointer;
  49616. /**
  49617. * The mesh used to display where the user is going to teleport.
  49618. */
  49619. get teleportationTarget(): Mesh;
  49620. /**
  49621. * Sets the mesh to be used to display where the user is going to teleport.
  49622. */
  49623. set teleportationTarget(value: Mesh);
  49624. /**
  49625. * 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
  49626. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  49627. * See https://doc.babylonjs.com/resources/baking_transformations
  49628. */
  49629. get gazeTrackerMesh(): Mesh;
  49630. set gazeTrackerMesh(value: Mesh);
  49631. /**
  49632. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  49633. */
  49634. updateGazeTrackerScale: boolean;
  49635. /**
  49636. * If the gaze trackers color should be updated when selecting meshes
  49637. */
  49638. updateGazeTrackerColor: boolean;
  49639. /**
  49640. * If the controller laser color should be updated when selecting meshes
  49641. */
  49642. updateControllerLaserColor: boolean;
  49643. /**
  49644. * The gaze tracking mesh corresponding to the left controller
  49645. */
  49646. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  49647. /**
  49648. * The gaze tracking mesh corresponding to the right controller
  49649. */
  49650. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  49651. /**
  49652. * If the ray of the gaze should be displayed.
  49653. */
  49654. get displayGaze(): boolean;
  49655. /**
  49656. * Sets if the ray of the gaze should be displayed.
  49657. */
  49658. set displayGaze(value: boolean);
  49659. /**
  49660. * If the ray of the LaserPointer should be displayed.
  49661. */
  49662. get displayLaserPointer(): boolean;
  49663. /**
  49664. * Sets if the ray of the LaserPointer should be displayed.
  49665. */
  49666. set displayLaserPointer(value: boolean);
  49667. /**
  49668. * The deviceOrientationCamera used as the camera when not in VR.
  49669. */
  49670. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  49671. /**
  49672. * Based on the current WebVR support, returns the current VR camera used.
  49673. */
  49674. get currentVRCamera(): Nullable<Camera>;
  49675. /**
  49676. * The webVRCamera which is used when in VR.
  49677. */
  49678. get webVRCamera(): WebVRFreeCamera;
  49679. /**
  49680. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  49681. */
  49682. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  49683. /**
  49684. * The html button that is used to trigger entering into VR.
  49685. */
  49686. get vrButton(): Nullable<HTMLButtonElement>;
  49687. private get _teleportationRequestInitiated();
  49688. /**
  49689. * Defines whether or not Pointer lock should be requested when switching to
  49690. * full screen.
  49691. */
  49692. requestPointerLockOnFullScreen: boolean;
  49693. /**
  49694. * If asking to force XR, this will be populated with the default xr experience
  49695. */
  49696. xr: WebXRDefaultExperience;
  49697. /**
  49698. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  49699. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  49700. */
  49701. xrTestDone: boolean;
  49702. /**
  49703. * Instantiates a VRExperienceHelper.
  49704. * Helps to quickly add VR support to an existing scene.
  49705. * @param scene The scene the VRExperienceHelper belongs to.
  49706. * @param webVROptions Options to modify the vr experience helper's behavior.
  49707. */
  49708. constructor(scene: Scene,
  49709. /** Options to modify the vr experience helper's behavior. */
  49710. webVROptions?: VRExperienceHelperOptions);
  49711. private completeVRInit;
  49712. private _onDefaultMeshLoaded;
  49713. private _onResize;
  49714. private _onFullscreenChange;
  49715. /**
  49716. * Gets a value indicating if we are currently in VR mode.
  49717. */
  49718. get isInVRMode(): boolean;
  49719. private onVrDisplayPresentChange;
  49720. private onVRDisplayChanged;
  49721. private moveButtonToBottomRight;
  49722. private displayVRButton;
  49723. private updateButtonVisibility;
  49724. private _cachedAngularSensibility;
  49725. /**
  49726. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  49727. * Otherwise, will use the fullscreen API.
  49728. */
  49729. enterVR(): void;
  49730. /**
  49731. * Attempt to exit VR, or fullscreen.
  49732. */
  49733. exitVR(): void;
  49734. /**
  49735. * The position of the vr experience helper.
  49736. */
  49737. get position(): Vector3;
  49738. /**
  49739. * Sets the position of the vr experience helper.
  49740. */
  49741. set position(value: Vector3);
  49742. /**
  49743. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  49744. */
  49745. enableInteractions(): void;
  49746. private get _noControllerIsActive();
  49747. private beforeRender;
  49748. private _isTeleportationFloor;
  49749. /**
  49750. * Adds a floor mesh to be used for teleportation.
  49751. * @param floorMesh the mesh to be used for teleportation.
  49752. */
  49753. addFloorMesh(floorMesh: Mesh): void;
  49754. /**
  49755. * Removes a floor mesh from being used for teleportation.
  49756. * @param floorMesh the mesh to be removed.
  49757. */
  49758. removeFloorMesh(floorMesh: Mesh): void;
  49759. /**
  49760. * Enables interactions and teleportation using the VR controllers and gaze.
  49761. * @param vrTeleportationOptions options to modify teleportation behavior.
  49762. */
  49763. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  49764. private _onNewGamepadConnected;
  49765. private _tryEnableInteractionOnController;
  49766. private _onNewGamepadDisconnected;
  49767. private _enableInteractionOnController;
  49768. private _checkTeleportWithRay;
  49769. private _checkRotate;
  49770. private _checkTeleportBackwards;
  49771. private _enableTeleportationOnController;
  49772. private _createTeleportationCircles;
  49773. private _displayTeleportationTarget;
  49774. private _hideTeleportationTarget;
  49775. private _rotateCamera;
  49776. private _moveTeleportationSelectorTo;
  49777. private _workingVector;
  49778. private _workingQuaternion;
  49779. private _workingMatrix;
  49780. /**
  49781. * Time Constant Teleportation Mode
  49782. */
  49783. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  49784. /**
  49785. * Speed Constant Teleportation Mode
  49786. */
  49787. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  49788. /**
  49789. * Teleports the users feet to the desired location
  49790. * @param location The location where the user's feet should be placed
  49791. */
  49792. teleportCamera(location: Vector3): void;
  49793. private _convertNormalToDirectionOfRay;
  49794. private _castRayAndSelectObject;
  49795. private _notifySelectedMeshUnselected;
  49796. /**
  49797. * Permanently set new colors for the laser pointer
  49798. * @param color the new laser color
  49799. * @param pickedColor the new laser color when picked mesh detected
  49800. */
  49801. setLaserColor(color: Color3, pickedColor?: Color3): void;
  49802. /**
  49803. * Set lighting enabled / disabled on the laser pointer of both controllers
  49804. * @param enabled should the lighting be enabled on the laser pointer
  49805. */
  49806. setLaserLightingState(enabled?: boolean): void;
  49807. /**
  49808. * Permanently set new colors for the gaze pointer
  49809. * @param color the new gaze color
  49810. * @param pickedColor the new gaze color when picked mesh detected
  49811. */
  49812. setGazeColor(color: Color3, pickedColor?: Color3): void;
  49813. /**
  49814. * Sets the color of the laser ray from the vr controllers.
  49815. * @param color new color for the ray.
  49816. */
  49817. changeLaserColor(color: Color3): void;
  49818. /**
  49819. * Sets the color of the ray from the vr headsets gaze.
  49820. * @param color new color for the ray.
  49821. */
  49822. changeGazeColor(color: Color3): void;
  49823. /**
  49824. * Exits VR and disposes of the vr experience helper
  49825. */
  49826. dispose(): void;
  49827. /**
  49828. * Gets the name of the VRExperienceHelper class
  49829. * @returns "VRExperienceHelper"
  49830. */
  49831. getClassName(): string;
  49832. }
  49833. }
  49834. declare module BABYLON {
  49835. /**
  49836. * Contains an array of blocks representing the octree
  49837. */
  49838. export interface IOctreeContainer<T> {
  49839. /**
  49840. * Blocks within the octree
  49841. */
  49842. blocks: Array<OctreeBlock<T>>;
  49843. }
  49844. /**
  49845. * Class used to store a cell in an octree
  49846. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49847. */
  49848. export class OctreeBlock<T> {
  49849. /**
  49850. * Gets the content of the current block
  49851. */
  49852. entries: T[];
  49853. /**
  49854. * Gets the list of block children
  49855. */
  49856. blocks: Array<OctreeBlock<T>>;
  49857. private _depth;
  49858. private _maxDepth;
  49859. private _capacity;
  49860. private _minPoint;
  49861. private _maxPoint;
  49862. private _boundingVectors;
  49863. private _creationFunc;
  49864. /**
  49865. * Creates a new block
  49866. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  49867. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  49868. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  49869. * @param depth defines the current depth of this block in the octree
  49870. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  49871. * @param creationFunc defines a callback to call when an element is added to the block
  49872. */
  49873. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  49874. /**
  49875. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  49876. */
  49877. get capacity(): number;
  49878. /**
  49879. * Gets the minimum vector (in world space) of the block's bounding box
  49880. */
  49881. get minPoint(): Vector3;
  49882. /**
  49883. * Gets the maximum vector (in world space) of the block's bounding box
  49884. */
  49885. get maxPoint(): Vector3;
  49886. /**
  49887. * Add a new element to this block
  49888. * @param entry defines the element to add
  49889. */
  49890. addEntry(entry: T): void;
  49891. /**
  49892. * Remove an element from this block
  49893. * @param entry defines the element to remove
  49894. */
  49895. removeEntry(entry: T): void;
  49896. /**
  49897. * Add an array of elements to this block
  49898. * @param entries defines the array of elements to add
  49899. */
  49900. addEntries(entries: T[]): void;
  49901. /**
  49902. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  49903. * @param frustumPlanes defines the frustum planes to test
  49904. * @param selection defines the array to store current content if selection is positive
  49905. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49906. */
  49907. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  49908. /**
  49909. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  49910. * @param sphereCenter defines the bounding sphere center
  49911. * @param sphereRadius defines the bounding sphere radius
  49912. * @param selection defines the array to store current content if selection is positive
  49913. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49914. */
  49915. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  49916. /**
  49917. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  49918. * @param ray defines the ray to test with
  49919. * @param selection defines the array to store current content if selection is positive
  49920. */
  49921. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  49922. /**
  49923. * Subdivide the content into child blocks (this block will then be empty)
  49924. */
  49925. createInnerBlocks(): void;
  49926. /**
  49927. * @hidden
  49928. */
  49929. 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;
  49930. }
  49931. }
  49932. declare module BABYLON {
  49933. /**
  49934. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  49935. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49936. */
  49937. export class Octree<T> {
  49938. /** 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.) */
  49939. maxDepth: number;
  49940. /**
  49941. * Blocks within the octree containing objects
  49942. */
  49943. blocks: Array<OctreeBlock<T>>;
  49944. /**
  49945. * Content stored in the octree
  49946. */
  49947. dynamicContent: T[];
  49948. private _maxBlockCapacity;
  49949. private _selectionContent;
  49950. private _creationFunc;
  49951. /**
  49952. * Creates a octree
  49953. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49954. * @param creationFunc function to be used to instatiate the octree
  49955. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  49956. * @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.)
  49957. */
  49958. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  49959. /** 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.) */
  49960. maxDepth?: number);
  49961. /**
  49962. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  49963. * @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);
  49964. * @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);
  49965. * @param entries meshes to be added to the octree blocks
  49966. */
  49967. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  49968. /**
  49969. * Adds a mesh to the octree
  49970. * @param entry Mesh to add to the octree
  49971. */
  49972. addMesh(entry: T): void;
  49973. /**
  49974. * Remove an element from the octree
  49975. * @param entry defines the element to remove
  49976. */
  49977. removeMesh(entry: T): void;
  49978. /**
  49979. * Selects an array of meshes within the frustum
  49980. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  49981. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  49982. * @returns array of meshes within the frustum
  49983. */
  49984. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  49985. /**
  49986. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  49987. * @param sphereCenter defines the bounding sphere center
  49988. * @param sphereRadius defines the bounding sphere radius
  49989. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49990. * @returns an array of objects that intersect the sphere
  49991. */
  49992. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  49993. /**
  49994. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  49995. * @param ray defines the ray to test with
  49996. * @returns array of intersected objects
  49997. */
  49998. intersectsRay(ray: Ray): SmartArray<T>;
  49999. /**
  50000. * Adds a mesh into the octree block if it intersects the block
  50001. */
  50002. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  50003. /**
  50004. * Adds a submesh into the octree block if it intersects the block
  50005. */
  50006. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  50007. }
  50008. }
  50009. declare module BABYLON {
  50010. interface Scene {
  50011. /**
  50012. * @hidden
  50013. * Backing Filed
  50014. */
  50015. _selectionOctree: Octree<AbstractMesh>;
  50016. /**
  50017. * Gets the octree used to boost mesh selection (picking)
  50018. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50019. */
  50020. selectionOctree: Octree<AbstractMesh>;
  50021. /**
  50022. * Creates or updates the octree used to boost selection (picking)
  50023. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50024. * @param maxCapacity defines the maximum capacity per leaf
  50025. * @param maxDepth defines the maximum depth of the octree
  50026. * @returns an octree of AbstractMesh
  50027. */
  50028. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  50029. }
  50030. interface AbstractMesh {
  50031. /**
  50032. * @hidden
  50033. * Backing Field
  50034. */
  50035. _submeshesOctree: Octree<SubMesh>;
  50036. /**
  50037. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  50038. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  50039. * @param maxCapacity defines the maximum size of each block (64 by default)
  50040. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  50041. * @returns the new octree
  50042. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  50043. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50044. */
  50045. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  50046. }
  50047. /**
  50048. * Defines the octree scene component responsible to manage any octrees
  50049. * in a given scene.
  50050. */
  50051. export class OctreeSceneComponent {
  50052. /**
  50053. * The component name help to identify the component in the list of scene components.
  50054. */
  50055. readonly name: string;
  50056. /**
  50057. * The scene the component belongs to.
  50058. */
  50059. scene: Scene;
  50060. /**
  50061. * Indicates if the meshes have been checked to make sure they are isEnabled()
  50062. */
  50063. readonly checksIsEnabled: boolean;
  50064. /**
  50065. * Creates a new instance of the component for the given scene
  50066. * @param scene Defines the scene to register the component in
  50067. */
  50068. constructor(scene: Scene);
  50069. /**
  50070. * Registers the component in a given scene
  50071. */
  50072. register(): void;
  50073. /**
  50074. * Return the list of active meshes
  50075. * @returns the list of active meshes
  50076. */
  50077. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  50078. /**
  50079. * Return the list of active sub meshes
  50080. * @param mesh The mesh to get the candidates sub meshes from
  50081. * @returns the list of active sub meshes
  50082. */
  50083. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  50084. private _tempRay;
  50085. /**
  50086. * Return the list of sub meshes intersecting with a given local ray
  50087. * @param mesh defines the mesh to find the submesh for
  50088. * @param localRay defines the ray in local space
  50089. * @returns the list of intersecting sub meshes
  50090. */
  50091. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  50092. /**
  50093. * Return the list of sub meshes colliding with a collider
  50094. * @param mesh defines the mesh to find the submesh for
  50095. * @param collider defines the collider to evaluate the collision against
  50096. * @returns the list of colliding sub meshes
  50097. */
  50098. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  50099. /**
  50100. * Rebuilds the elements related to this component in case of
  50101. * context lost for instance.
  50102. */
  50103. rebuild(): void;
  50104. /**
  50105. * Disposes the component and the associated ressources.
  50106. */
  50107. dispose(): void;
  50108. }
  50109. }
  50110. declare module BABYLON {
  50111. /**
  50112. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  50113. */
  50114. export class Gizmo implements IDisposable {
  50115. /** The utility layer the gizmo will be added to */
  50116. gizmoLayer: UtilityLayerRenderer;
  50117. /**
  50118. * The root mesh of the gizmo
  50119. */
  50120. _rootMesh: Mesh;
  50121. private _attachedMesh;
  50122. private _attachedNode;
  50123. /**
  50124. * Ratio for the scale of the gizmo (Default: 1)
  50125. */
  50126. scaleRatio: number;
  50127. /**
  50128. * If a custom mesh has been set (Default: false)
  50129. */
  50130. protected _customMeshSet: boolean;
  50131. /**
  50132. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  50133. * * When set, interactions will be enabled
  50134. */
  50135. get attachedMesh(): Nullable<AbstractMesh>;
  50136. set attachedMesh(value: Nullable<AbstractMesh>);
  50137. /**
  50138. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  50139. * * When set, interactions will be enabled
  50140. */
  50141. get attachedNode(): Nullable<Node>;
  50142. set attachedNode(value: Nullable<Node>);
  50143. /**
  50144. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50145. * @param mesh The mesh to replace the default mesh of the gizmo
  50146. */
  50147. setCustomMesh(mesh: Mesh): void;
  50148. /**
  50149. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  50150. */
  50151. updateGizmoRotationToMatchAttachedMesh: boolean;
  50152. /**
  50153. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  50154. */
  50155. updateGizmoPositionToMatchAttachedMesh: boolean;
  50156. /**
  50157. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  50158. */
  50159. updateScale: boolean;
  50160. protected _interactionsEnabled: boolean;
  50161. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50162. private _beforeRenderObserver;
  50163. private _tempQuaternion;
  50164. private _tempVector;
  50165. private _tempVector2;
  50166. /**
  50167. * Creates a gizmo
  50168. * @param gizmoLayer The utility layer the gizmo will be added to
  50169. */
  50170. constructor(
  50171. /** The utility layer the gizmo will be added to */
  50172. gizmoLayer?: UtilityLayerRenderer);
  50173. /**
  50174. * Updates the gizmo to match the attached mesh's position/rotation
  50175. */
  50176. protected _update(): void;
  50177. /**
  50178. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  50179. * @param value Node, TransformNode or mesh
  50180. */
  50181. protected _matrixChanged(): void;
  50182. /**
  50183. * Disposes of the gizmo
  50184. */
  50185. dispose(): void;
  50186. }
  50187. }
  50188. declare module BABYLON {
  50189. /**
  50190. * Single plane drag gizmo
  50191. */
  50192. export class PlaneDragGizmo extends Gizmo {
  50193. /**
  50194. * Drag behavior responsible for the gizmos dragging interactions
  50195. */
  50196. dragBehavior: PointerDragBehavior;
  50197. private _pointerObserver;
  50198. /**
  50199. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50200. */
  50201. snapDistance: number;
  50202. /**
  50203. * Event that fires each time the gizmo snaps to a new location.
  50204. * * snapDistance is the the change in distance
  50205. */
  50206. onSnapObservable: Observable<{
  50207. snapDistance: number;
  50208. }>;
  50209. private _plane;
  50210. private _coloredMaterial;
  50211. private _hoverMaterial;
  50212. private _isEnabled;
  50213. private _parent;
  50214. /** @hidden */
  50215. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  50216. /** @hidden */
  50217. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50218. /**
  50219. * Creates a PlaneDragGizmo
  50220. * @param gizmoLayer The utility layer the gizmo will be added to
  50221. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  50222. * @param color The color of the gizmo
  50223. */
  50224. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  50225. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50226. /**
  50227. * If the gizmo is enabled
  50228. */
  50229. set isEnabled(value: boolean);
  50230. get isEnabled(): boolean;
  50231. /**
  50232. * Disposes of the gizmo
  50233. */
  50234. dispose(): void;
  50235. }
  50236. }
  50237. declare module BABYLON {
  50238. /**
  50239. * Gizmo that enables dragging a mesh along 3 axis
  50240. */
  50241. export class PositionGizmo extends Gizmo {
  50242. /**
  50243. * Internal gizmo used for interactions on the x axis
  50244. */
  50245. xGizmo: AxisDragGizmo;
  50246. /**
  50247. * Internal gizmo used for interactions on the y axis
  50248. */
  50249. yGizmo: AxisDragGizmo;
  50250. /**
  50251. * Internal gizmo used for interactions on the z axis
  50252. */
  50253. zGizmo: AxisDragGizmo;
  50254. /**
  50255. * Internal gizmo used for interactions on the yz plane
  50256. */
  50257. xPlaneGizmo: PlaneDragGizmo;
  50258. /**
  50259. * Internal gizmo used for interactions on the xz plane
  50260. */
  50261. yPlaneGizmo: PlaneDragGizmo;
  50262. /**
  50263. * Internal gizmo used for interactions on the xy plane
  50264. */
  50265. zPlaneGizmo: PlaneDragGizmo;
  50266. /**
  50267. * private variables
  50268. */
  50269. private _meshAttached;
  50270. private _nodeAttached;
  50271. private _updateGizmoRotationToMatchAttachedMesh;
  50272. private _snapDistance;
  50273. private _scaleRatio;
  50274. /** Fires an event when any of it's sub gizmos are dragged */
  50275. onDragStartObservable: Observable<unknown>;
  50276. /** Fires an event when any of it's sub gizmos are released from dragging */
  50277. onDragEndObservable: Observable<unknown>;
  50278. /**
  50279. * If set to true, planar drag is enabled
  50280. */
  50281. private _planarGizmoEnabled;
  50282. get attachedMesh(): Nullable<AbstractMesh>;
  50283. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50284. get attachedNode(): Nullable<Node>;
  50285. set attachedNode(node: Nullable<Node>);
  50286. /**
  50287. * Creates a PositionGizmo
  50288. * @param gizmoLayer The utility layer the gizmo will be added to
  50289. @param thickness display gizmo axis thickness
  50290. */
  50291. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  50292. /**
  50293. * If the planar drag gizmo is enabled
  50294. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  50295. */
  50296. set planarGizmoEnabled(value: boolean);
  50297. get planarGizmoEnabled(): boolean;
  50298. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50299. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50300. /**
  50301. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50302. */
  50303. set snapDistance(value: number);
  50304. get snapDistance(): number;
  50305. /**
  50306. * Ratio for the scale of the gizmo (Default: 1)
  50307. */
  50308. set scaleRatio(value: number);
  50309. get scaleRatio(): number;
  50310. /**
  50311. * Disposes of the gizmo
  50312. */
  50313. dispose(): void;
  50314. /**
  50315. * CustomMeshes are not supported by this gizmo
  50316. * @param mesh The mesh to replace the default mesh of the gizmo
  50317. */
  50318. setCustomMesh(mesh: Mesh): void;
  50319. }
  50320. }
  50321. declare module BABYLON {
  50322. /**
  50323. * Single axis drag gizmo
  50324. */
  50325. export class AxisDragGizmo extends Gizmo {
  50326. /**
  50327. * Drag behavior responsible for the gizmos dragging interactions
  50328. */
  50329. dragBehavior: PointerDragBehavior;
  50330. private _pointerObserver;
  50331. /**
  50332. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50333. */
  50334. snapDistance: number;
  50335. /**
  50336. * Event that fires each time the gizmo snaps to a new location.
  50337. * * snapDistance is the the change in distance
  50338. */
  50339. onSnapObservable: Observable<{
  50340. snapDistance: number;
  50341. }>;
  50342. private _isEnabled;
  50343. private _parent;
  50344. private _arrow;
  50345. private _coloredMaterial;
  50346. private _hoverMaterial;
  50347. /** @hidden */
  50348. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  50349. /** @hidden */
  50350. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50351. /**
  50352. * Creates an AxisDragGizmo
  50353. * @param gizmoLayer The utility layer the gizmo will be added to
  50354. * @param dragAxis The axis which the gizmo will be able to drag on
  50355. * @param color The color of the gizmo
  50356. * @param thickness display gizmo axis thickness
  50357. */
  50358. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  50359. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50360. /**
  50361. * If the gizmo is enabled
  50362. */
  50363. set isEnabled(value: boolean);
  50364. get isEnabled(): boolean;
  50365. /**
  50366. * Disposes of the gizmo
  50367. */
  50368. dispose(): void;
  50369. }
  50370. }
  50371. declare module BABYLON.Debug {
  50372. /**
  50373. * The Axes viewer will show 3 axes in a specific point in space
  50374. */
  50375. export class AxesViewer {
  50376. private _xAxis;
  50377. private _yAxis;
  50378. private _zAxis;
  50379. private _scaleLinesFactor;
  50380. private _instanced;
  50381. /**
  50382. * Gets the hosting scene
  50383. */
  50384. scene: Scene;
  50385. /**
  50386. * Gets or sets a number used to scale line length
  50387. */
  50388. scaleLines: number;
  50389. /** Gets the node hierarchy used to render x-axis */
  50390. get xAxis(): TransformNode;
  50391. /** Gets the node hierarchy used to render y-axis */
  50392. get yAxis(): TransformNode;
  50393. /** Gets the node hierarchy used to render z-axis */
  50394. get zAxis(): TransformNode;
  50395. /**
  50396. * Creates a new AxesViewer
  50397. * @param scene defines the hosting scene
  50398. * @param scaleLines defines a number used to scale line length (1 by default)
  50399. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  50400. * @param xAxis defines the node hierarchy used to render the x-axis
  50401. * @param yAxis defines the node hierarchy used to render the y-axis
  50402. * @param zAxis defines the node hierarchy used to render the z-axis
  50403. */
  50404. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  50405. /**
  50406. * Force the viewer to update
  50407. * @param position defines the position of the viewer
  50408. * @param xaxis defines the x axis of the viewer
  50409. * @param yaxis defines the y axis of the viewer
  50410. * @param zaxis defines the z axis of the viewer
  50411. */
  50412. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  50413. /**
  50414. * Creates an instance of this axes viewer.
  50415. * @returns a new axes viewer with instanced meshes
  50416. */
  50417. createInstance(): AxesViewer;
  50418. /** Releases resources */
  50419. dispose(): void;
  50420. private static _SetRenderingGroupId;
  50421. }
  50422. }
  50423. declare module BABYLON.Debug {
  50424. /**
  50425. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  50426. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  50427. */
  50428. export class BoneAxesViewer extends AxesViewer {
  50429. /**
  50430. * Gets or sets the target mesh where to display the axes viewer
  50431. */
  50432. mesh: Nullable<Mesh>;
  50433. /**
  50434. * Gets or sets the target bone where to display the axes viewer
  50435. */
  50436. bone: Nullable<Bone>;
  50437. /** Gets current position */
  50438. pos: Vector3;
  50439. /** Gets direction of X axis */
  50440. xaxis: Vector3;
  50441. /** Gets direction of Y axis */
  50442. yaxis: Vector3;
  50443. /** Gets direction of Z axis */
  50444. zaxis: Vector3;
  50445. /**
  50446. * Creates a new BoneAxesViewer
  50447. * @param scene defines the hosting scene
  50448. * @param bone defines the target bone
  50449. * @param mesh defines the target mesh
  50450. * @param scaleLines defines a scaling factor for line length (1 by default)
  50451. */
  50452. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  50453. /**
  50454. * Force the viewer to update
  50455. */
  50456. update(): void;
  50457. /** Releases resources */
  50458. dispose(): void;
  50459. }
  50460. }
  50461. declare module BABYLON {
  50462. /**
  50463. * Interface used to define scene explorer extensibility option
  50464. */
  50465. export interface IExplorerExtensibilityOption {
  50466. /**
  50467. * Define the option label
  50468. */
  50469. label: string;
  50470. /**
  50471. * Defines the action to execute on click
  50472. */
  50473. action: (entity: any) => void;
  50474. }
  50475. /**
  50476. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  50477. */
  50478. export interface IExplorerExtensibilityGroup {
  50479. /**
  50480. * Defines a predicate to test if a given type mut be extended
  50481. */
  50482. predicate: (entity: any) => boolean;
  50483. /**
  50484. * Gets the list of options added to a type
  50485. */
  50486. entries: IExplorerExtensibilityOption[];
  50487. }
  50488. /**
  50489. * Interface used to define the options to use to create the Inspector
  50490. */
  50491. export interface IInspectorOptions {
  50492. /**
  50493. * Display in overlay mode (default: false)
  50494. */
  50495. overlay?: boolean;
  50496. /**
  50497. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  50498. */
  50499. globalRoot?: HTMLElement;
  50500. /**
  50501. * Display the Scene explorer
  50502. */
  50503. showExplorer?: boolean;
  50504. /**
  50505. * Display the property inspector
  50506. */
  50507. showInspector?: boolean;
  50508. /**
  50509. * Display in embed mode (both panes on the right)
  50510. */
  50511. embedMode?: boolean;
  50512. /**
  50513. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  50514. */
  50515. handleResize?: boolean;
  50516. /**
  50517. * Allow the panes to popup (default: true)
  50518. */
  50519. enablePopup?: boolean;
  50520. /**
  50521. * Allow the panes to be closed by users (default: true)
  50522. */
  50523. enableClose?: boolean;
  50524. /**
  50525. * Optional list of extensibility entries
  50526. */
  50527. explorerExtensibility?: IExplorerExtensibilityGroup[];
  50528. /**
  50529. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  50530. */
  50531. inspectorURL?: string;
  50532. /**
  50533. * Optional initial tab (default to DebugLayerTab.Properties)
  50534. */
  50535. initialTab?: DebugLayerTab;
  50536. }
  50537. interface Scene {
  50538. /**
  50539. * @hidden
  50540. * Backing field
  50541. */
  50542. _debugLayer: DebugLayer;
  50543. /**
  50544. * Gets the debug layer (aka Inspector) associated with the scene
  50545. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50546. */
  50547. debugLayer: DebugLayer;
  50548. }
  50549. /**
  50550. * Enum of inspector action tab
  50551. */
  50552. export enum DebugLayerTab {
  50553. /**
  50554. * Properties tag (default)
  50555. */
  50556. Properties = 0,
  50557. /**
  50558. * Debug tab
  50559. */
  50560. Debug = 1,
  50561. /**
  50562. * Statistics tab
  50563. */
  50564. Statistics = 2,
  50565. /**
  50566. * Tools tab
  50567. */
  50568. Tools = 3,
  50569. /**
  50570. * Settings tab
  50571. */
  50572. Settings = 4
  50573. }
  50574. /**
  50575. * The debug layer (aka Inspector) is the go to tool in order to better understand
  50576. * what is happening in your scene
  50577. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50578. */
  50579. export class DebugLayer {
  50580. /**
  50581. * Define the url to get the inspector script from.
  50582. * By default it uses the babylonjs CDN.
  50583. * @ignoreNaming
  50584. */
  50585. static InspectorURL: string;
  50586. private _scene;
  50587. private BJSINSPECTOR;
  50588. private _onPropertyChangedObservable?;
  50589. /**
  50590. * Observable triggered when a property is changed through the inspector.
  50591. */
  50592. get onPropertyChangedObservable(): any;
  50593. /**
  50594. * Instantiates a new debug layer.
  50595. * The debug layer (aka Inspector) is the go to tool in order to better understand
  50596. * what is happening in your scene
  50597. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50598. * @param scene Defines the scene to inspect
  50599. */
  50600. constructor(scene: Scene);
  50601. /** Creates the inspector window. */
  50602. private _createInspector;
  50603. /**
  50604. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  50605. * @param entity defines the entity to select
  50606. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  50607. */
  50608. select(entity: any, lineContainerTitles?: string | string[]): void;
  50609. /** Get the inspector from bundle or global */
  50610. private _getGlobalInspector;
  50611. /**
  50612. * Get if the inspector is visible or not.
  50613. * @returns true if visible otherwise, false
  50614. */
  50615. isVisible(): boolean;
  50616. /**
  50617. * Hide the inspector and close its window.
  50618. */
  50619. hide(): void;
  50620. /**
  50621. * Update the scene in the inspector
  50622. */
  50623. setAsActiveScene(): void;
  50624. /**
  50625. * Launch the debugLayer.
  50626. * @param config Define the configuration of the inspector
  50627. * @return a promise fulfilled when the debug layer is visible
  50628. */
  50629. show(config?: IInspectorOptions): Promise<DebugLayer>;
  50630. }
  50631. }
  50632. declare module BABYLON {
  50633. /**
  50634. * Class containing static functions to help procedurally build meshes
  50635. */
  50636. export class BoxBuilder {
  50637. /**
  50638. * Creates a box mesh
  50639. * * The parameter `size` sets the size (float) of each box side (default 1)
  50640. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50641. * * 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)
  50642. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50643. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50644. * * 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
  50645. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50646. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50647. * @param name defines the name of the mesh
  50648. * @param options defines the options used to create the mesh
  50649. * @param scene defines the hosting scene
  50650. * @returns the box mesh
  50651. */
  50652. static CreateBox(name: string, options: {
  50653. size?: number;
  50654. width?: number;
  50655. height?: number;
  50656. depth?: number;
  50657. faceUV?: Vector4[];
  50658. faceColors?: Color4[];
  50659. sideOrientation?: number;
  50660. frontUVs?: Vector4;
  50661. backUVs?: Vector4;
  50662. wrap?: boolean;
  50663. topBaseAt?: number;
  50664. bottomBaseAt?: number;
  50665. updatable?: boolean;
  50666. }, scene?: Nullable<Scene>): Mesh;
  50667. }
  50668. }
  50669. declare module BABYLON.Debug {
  50670. /**
  50671. * Used to show the physics impostor around the specific mesh
  50672. */
  50673. export class PhysicsViewer {
  50674. /** @hidden */
  50675. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  50676. /** @hidden */
  50677. protected _meshes: Array<Nullable<AbstractMesh>>;
  50678. /** @hidden */
  50679. protected _scene: Nullable<Scene>;
  50680. /** @hidden */
  50681. protected _numMeshes: number;
  50682. /** @hidden */
  50683. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  50684. private _renderFunction;
  50685. private _utilityLayer;
  50686. private _debugBoxMesh;
  50687. private _debugSphereMesh;
  50688. private _debugCylinderMesh;
  50689. private _debugMaterial;
  50690. private _debugMeshMeshes;
  50691. /**
  50692. * Creates a new PhysicsViewer
  50693. * @param scene defines the hosting scene
  50694. */
  50695. constructor(scene: Scene);
  50696. /** @hidden */
  50697. protected _updateDebugMeshes(): void;
  50698. /**
  50699. * Renders a specified physic impostor
  50700. * @param impostor defines the impostor to render
  50701. * @param targetMesh defines the mesh represented by the impostor
  50702. * @returns the new debug mesh used to render the impostor
  50703. */
  50704. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  50705. /**
  50706. * Hides a specified physic impostor
  50707. * @param impostor defines the impostor to hide
  50708. */
  50709. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  50710. private _getDebugMaterial;
  50711. private _getDebugBoxMesh;
  50712. private _getDebugSphereMesh;
  50713. private _getDebugCylinderMesh;
  50714. private _getDebugMeshMesh;
  50715. private _getDebugMesh;
  50716. /** Releases all resources */
  50717. dispose(): void;
  50718. }
  50719. }
  50720. declare module BABYLON {
  50721. /**
  50722. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  50723. * in order to better appreciate the issue one might have.
  50724. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  50725. */
  50726. export class RayHelper {
  50727. /**
  50728. * Defines the ray we are currently tryin to visualize.
  50729. */
  50730. ray: Nullable<Ray>;
  50731. private _renderPoints;
  50732. private _renderLine;
  50733. private _renderFunction;
  50734. private _scene;
  50735. private _updateToMeshFunction;
  50736. private _attachedToMesh;
  50737. private _meshSpaceDirection;
  50738. private _meshSpaceOrigin;
  50739. /**
  50740. * Helper function to create a colored helper in a scene in one line.
  50741. * @param ray Defines the ray we are currently tryin to visualize
  50742. * @param scene Defines the scene the ray is used in
  50743. * @param color Defines the color we want to see the ray in
  50744. * @returns The newly created ray helper.
  50745. */
  50746. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  50747. /**
  50748. * Instantiate a new ray helper.
  50749. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  50750. * in order to better appreciate the issue one might have.
  50751. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  50752. * @param ray Defines the ray we are currently tryin to visualize
  50753. */
  50754. constructor(ray: Ray);
  50755. /**
  50756. * Shows the ray we are willing to debug.
  50757. * @param scene Defines the scene the ray needs to be rendered in
  50758. * @param color Defines the color the ray needs to be rendered in
  50759. */
  50760. show(scene: Scene, color?: Color3): void;
  50761. /**
  50762. * Hides the ray we are debugging.
  50763. */
  50764. hide(): void;
  50765. private _render;
  50766. /**
  50767. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  50768. * @param mesh Defines the mesh we want the helper attached to
  50769. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  50770. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  50771. * @param length Defines the length of the ray
  50772. */
  50773. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  50774. /**
  50775. * Detach the ray helper from the mesh it has previously been attached to.
  50776. */
  50777. detachFromMesh(): void;
  50778. private _updateToMesh;
  50779. /**
  50780. * Dispose the helper and release its associated resources.
  50781. */
  50782. dispose(): void;
  50783. }
  50784. }
  50785. declare module BABYLON {
  50786. /**
  50787. * Defines the options associated with the creation of a SkeletonViewer.
  50788. */
  50789. export interface ISkeletonViewerOptions {
  50790. /** Should the system pause animations before building the Viewer? */
  50791. pauseAnimations: boolean;
  50792. /** Should the system return the skeleton to rest before building? */
  50793. returnToRest: boolean;
  50794. /** public Display Mode of the Viewer */
  50795. displayMode: number;
  50796. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  50797. displayOptions: ISkeletonViewerDisplayOptions;
  50798. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  50799. computeBonesUsingShaders: boolean;
  50800. }
  50801. /**
  50802. * Defines how to display the various bone meshes for the viewer.
  50803. */
  50804. export interface ISkeletonViewerDisplayOptions {
  50805. /** How far down to start tapering the bone spurs */
  50806. midStep?: number;
  50807. /** How big is the midStep? */
  50808. midStepFactor?: number;
  50809. /** Base for the Sphere Size */
  50810. sphereBaseSize?: number;
  50811. /** The ratio of the sphere to the longest bone in units */
  50812. sphereScaleUnit?: number;
  50813. /** Ratio for the Sphere Size */
  50814. sphereFactor?: number;
  50815. }
  50816. }
  50817. declare module BABYLON {
  50818. /**
  50819. * Class containing static functions to help procedurally build meshes
  50820. */
  50821. export class RibbonBuilder {
  50822. /**
  50823. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50824. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50825. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50826. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50827. * * 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
  50828. * * 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
  50829. * * 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
  50830. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50831. * * 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
  50832. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50833. * * 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
  50834. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50835. * * 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
  50836. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50837. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50838. * @param name defines the name of the mesh
  50839. * @param options defines the options used to create the mesh
  50840. * @param scene defines the hosting scene
  50841. * @returns the ribbon mesh
  50842. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50843. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50844. */
  50845. static CreateRibbon(name: string, options: {
  50846. pathArray: Vector3[][];
  50847. closeArray?: boolean;
  50848. closePath?: boolean;
  50849. offset?: number;
  50850. updatable?: boolean;
  50851. sideOrientation?: number;
  50852. frontUVs?: Vector4;
  50853. backUVs?: Vector4;
  50854. instance?: Mesh;
  50855. invertUV?: boolean;
  50856. uvs?: Vector2[];
  50857. colors?: Color4[];
  50858. }, scene?: Nullable<Scene>): Mesh;
  50859. }
  50860. }
  50861. declare module BABYLON {
  50862. /**
  50863. * Class containing static functions to help procedurally build meshes
  50864. */
  50865. export class ShapeBuilder {
  50866. /**
  50867. * 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.
  50868. * * 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.
  50869. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50870. * * 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.
  50871. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50872. * * 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
  50873. * * 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
  50874. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50875. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50876. * * 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
  50877. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50878. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50879. * @param name defines the name of the mesh
  50880. * @param options defines the options used to create the mesh
  50881. * @param scene defines the hosting scene
  50882. * @returns the extruded shape mesh
  50883. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50884. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50885. */
  50886. static ExtrudeShape(name: string, options: {
  50887. shape: Vector3[];
  50888. path: Vector3[];
  50889. scale?: number;
  50890. rotation?: number;
  50891. cap?: number;
  50892. updatable?: boolean;
  50893. sideOrientation?: number;
  50894. frontUVs?: Vector4;
  50895. backUVs?: Vector4;
  50896. instance?: Mesh;
  50897. invertUV?: boolean;
  50898. }, scene?: Nullable<Scene>): Mesh;
  50899. /**
  50900. * Creates an custom extruded shape mesh.
  50901. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50902. * * 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.
  50903. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50904. * * 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
  50905. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50906. * * 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
  50907. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50908. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50909. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50910. * * 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
  50911. * * 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
  50912. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50913. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50914. * * 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
  50915. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50916. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50917. * @param name defines the name of the mesh
  50918. * @param options defines the options used to create the mesh
  50919. * @param scene defines the hosting scene
  50920. * @returns the custom extruded shape mesh
  50921. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50922. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50923. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50924. */
  50925. static ExtrudeShapeCustom(name: string, options: {
  50926. shape: Vector3[];
  50927. path: Vector3[];
  50928. scaleFunction?: any;
  50929. rotationFunction?: any;
  50930. ribbonCloseArray?: boolean;
  50931. ribbonClosePath?: boolean;
  50932. cap?: number;
  50933. updatable?: boolean;
  50934. sideOrientation?: number;
  50935. frontUVs?: Vector4;
  50936. backUVs?: Vector4;
  50937. instance?: Mesh;
  50938. invertUV?: boolean;
  50939. }, scene?: Nullable<Scene>): Mesh;
  50940. private static _ExtrudeShapeGeneric;
  50941. }
  50942. }
  50943. declare module BABYLON.Debug {
  50944. /**
  50945. * Class used to render a debug view of a given skeleton
  50946. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  50947. */
  50948. export class SkeletonViewer {
  50949. /** defines the skeleton to render */
  50950. skeleton: Skeleton;
  50951. /** defines the mesh attached to the skeleton */
  50952. mesh: AbstractMesh;
  50953. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  50954. autoUpdateBonesMatrices: boolean;
  50955. /** defines the rendering group id to use with the viewer */
  50956. renderingGroupId: number;
  50957. /** is the options for the viewer */
  50958. options: Partial<ISkeletonViewerOptions>;
  50959. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  50960. static readonly DISPLAY_LINES: number;
  50961. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  50962. static readonly DISPLAY_SPHERES: number;
  50963. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  50964. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  50965. /** If SkeletonViewer scene scope. */
  50966. private _scene;
  50967. /** Gets or sets the color used to render the skeleton */
  50968. color: Color3;
  50969. /** Array of the points of the skeleton fo the line view. */
  50970. private _debugLines;
  50971. /** The SkeletonViewers Mesh. */
  50972. private _debugMesh;
  50973. /** If SkeletonViewer is enabled. */
  50974. private _isEnabled;
  50975. /** If SkeletonViewer is ready. */
  50976. private _ready;
  50977. /** SkeletonViewer render observable. */
  50978. private _obs;
  50979. /** The Utility Layer to render the gizmos in. */
  50980. private _utilityLayer;
  50981. private _boneIndices;
  50982. /** Gets the Scene. */
  50983. get scene(): Scene;
  50984. /** Gets the utilityLayer. */
  50985. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  50986. /** Checks Ready Status. */
  50987. get isReady(): Boolean;
  50988. /** Sets Ready Status. */
  50989. set ready(value: boolean);
  50990. /** Gets the debugMesh */
  50991. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  50992. /** Sets the debugMesh */
  50993. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  50994. /** Gets the material */
  50995. get material(): StandardMaterial;
  50996. /** Sets the material */
  50997. set material(value: StandardMaterial);
  50998. /** Gets the material */
  50999. get displayMode(): number;
  51000. /** Sets the material */
  51001. set displayMode(value: number);
  51002. /**
  51003. * Creates a new SkeletonViewer
  51004. * @param skeleton defines the skeleton to render
  51005. * @param mesh defines the mesh attached to the skeleton
  51006. * @param scene defines the hosting scene
  51007. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  51008. * @param renderingGroupId defines the rendering group id to use with the viewer
  51009. * @param options All of the extra constructor options for the SkeletonViewer
  51010. */
  51011. constructor(
  51012. /** defines the skeleton to render */
  51013. skeleton: Skeleton,
  51014. /** defines the mesh attached to the skeleton */
  51015. mesh: AbstractMesh,
  51016. /** The Scene scope*/
  51017. scene: Scene,
  51018. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51019. autoUpdateBonesMatrices?: boolean,
  51020. /** defines the rendering group id to use with the viewer */
  51021. renderingGroupId?: number,
  51022. /** is the options for the viewer */
  51023. options?: Partial<ISkeletonViewerOptions>);
  51024. /** The Dynamic bindings for the update functions */
  51025. private _bindObs;
  51026. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  51027. update(): void;
  51028. /** Gets or sets a boolean indicating if the viewer is enabled */
  51029. set isEnabled(value: boolean);
  51030. get isEnabled(): boolean;
  51031. private _getBonePosition;
  51032. private _getLinesForBonesWithLength;
  51033. private _getLinesForBonesNoLength;
  51034. /** function to revert the mesh and scene back to the initial state. */
  51035. private _revert;
  51036. /** function to build and bind sphere joint points and spur bone representations. */
  51037. private _buildSpheresAndSpurs;
  51038. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  51039. private _displayLinesUpdate;
  51040. /** Changes the displayMode of the skeleton viewer
  51041. * @param mode The displayMode numerical value
  51042. */
  51043. changeDisplayMode(mode: number): void;
  51044. /** Changes the displayMode of the skeleton viewer
  51045. * @param option String of the option name
  51046. * @param value The numerical option value
  51047. */
  51048. changeDisplayOptions(option: string, value: number): void;
  51049. /** Release associated resources */
  51050. dispose(): void;
  51051. }
  51052. }
  51053. declare module BABYLON {
  51054. /**
  51055. * Enum for Device Types
  51056. */
  51057. export enum DeviceType {
  51058. /** Generic */
  51059. Generic = 0,
  51060. /** Keyboard */
  51061. Keyboard = 1,
  51062. /** Mouse */
  51063. Mouse = 2,
  51064. /** Touch Pointers */
  51065. Touch = 3,
  51066. /** PS4 Dual Shock */
  51067. DualShock = 4,
  51068. /** Xbox */
  51069. Xbox = 5,
  51070. /** Switch Controller */
  51071. Switch = 6
  51072. }
  51073. /**
  51074. * Enum for All Pointers (Touch/Mouse)
  51075. */
  51076. export enum PointerInput {
  51077. /** Horizontal Axis */
  51078. Horizontal = 0,
  51079. /** Vertical Axis */
  51080. Vertical = 1,
  51081. /** Left Click or Touch */
  51082. LeftClick = 2,
  51083. /** Middle Click */
  51084. MiddleClick = 3,
  51085. /** Right Click */
  51086. RightClick = 4,
  51087. /** Browser Back */
  51088. BrowserBack = 5,
  51089. /** Browser Forward */
  51090. BrowserForward = 6
  51091. }
  51092. /**
  51093. * Enum for Dual Shock Gamepad
  51094. */
  51095. export enum DualShockInput {
  51096. /** Cross */
  51097. Cross = 0,
  51098. /** Circle */
  51099. Circle = 1,
  51100. /** Square */
  51101. Square = 2,
  51102. /** Triangle */
  51103. Triangle = 3,
  51104. /** L1 */
  51105. L1 = 4,
  51106. /** R1 */
  51107. R1 = 5,
  51108. /** L2 */
  51109. L2 = 6,
  51110. /** R2 */
  51111. R2 = 7,
  51112. /** Share */
  51113. Share = 8,
  51114. /** Options */
  51115. Options = 9,
  51116. /** L3 */
  51117. L3 = 10,
  51118. /** R3 */
  51119. R3 = 11,
  51120. /** DPadUp */
  51121. DPadUp = 12,
  51122. /** DPadDown */
  51123. DPadDown = 13,
  51124. /** DPadLeft */
  51125. DPadLeft = 14,
  51126. /** DRight */
  51127. DPadRight = 15,
  51128. /** Home */
  51129. Home = 16,
  51130. /** TouchPad */
  51131. TouchPad = 17,
  51132. /** LStickXAxis */
  51133. LStickXAxis = 18,
  51134. /** LStickYAxis */
  51135. LStickYAxis = 19,
  51136. /** RStickXAxis */
  51137. RStickXAxis = 20,
  51138. /** RStickYAxis */
  51139. RStickYAxis = 21
  51140. }
  51141. /**
  51142. * Enum for Xbox Gamepad
  51143. */
  51144. export enum XboxInput {
  51145. /** A */
  51146. A = 0,
  51147. /** B */
  51148. B = 1,
  51149. /** X */
  51150. X = 2,
  51151. /** Y */
  51152. Y = 3,
  51153. /** LB */
  51154. LB = 4,
  51155. /** RB */
  51156. RB = 5,
  51157. /** LT */
  51158. LT = 6,
  51159. /** RT */
  51160. RT = 7,
  51161. /** Back */
  51162. Back = 8,
  51163. /** Start */
  51164. Start = 9,
  51165. /** LS */
  51166. LS = 10,
  51167. /** RS */
  51168. RS = 11,
  51169. /** DPadUp */
  51170. DPadUp = 12,
  51171. /** DPadDown */
  51172. DPadDown = 13,
  51173. /** DPadLeft */
  51174. DPadLeft = 14,
  51175. /** DRight */
  51176. DPadRight = 15,
  51177. /** Home */
  51178. Home = 16,
  51179. /** LStickXAxis */
  51180. LStickXAxis = 17,
  51181. /** LStickYAxis */
  51182. LStickYAxis = 18,
  51183. /** RStickXAxis */
  51184. RStickXAxis = 19,
  51185. /** RStickYAxis */
  51186. RStickYAxis = 20
  51187. }
  51188. /**
  51189. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  51190. */
  51191. export enum SwitchInput {
  51192. /** B */
  51193. B = 0,
  51194. /** A */
  51195. A = 1,
  51196. /** Y */
  51197. Y = 2,
  51198. /** X */
  51199. X = 3,
  51200. /** L */
  51201. L = 4,
  51202. /** R */
  51203. R = 5,
  51204. /** ZL */
  51205. ZL = 6,
  51206. /** ZR */
  51207. ZR = 7,
  51208. /** Minus */
  51209. Minus = 8,
  51210. /** Plus */
  51211. Plus = 9,
  51212. /** LS */
  51213. LS = 10,
  51214. /** RS */
  51215. RS = 11,
  51216. /** DPadUp */
  51217. DPadUp = 12,
  51218. /** DPadDown */
  51219. DPadDown = 13,
  51220. /** DPadLeft */
  51221. DPadLeft = 14,
  51222. /** DRight */
  51223. DPadRight = 15,
  51224. /** Home */
  51225. Home = 16,
  51226. /** Capture */
  51227. Capture = 17,
  51228. /** LStickXAxis */
  51229. LStickXAxis = 18,
  51230. /** LStickYAxis */
  51231. LStickYAxis = 19,
  51232. /** RStickXAxis */
  51233. RStickXAxis = 20,
  51234. /** RStickYAxis */
  51235. RStickYAxis = 21
  51236. }
  51237. }
  51238. declare module BABYLON {
  51239. /**
  51240. * This class will take all inputs from Keyboard, Pointer, and
  51241. * any Gamepads and provide a polling system that all devices
  51242. * will use. This class assumes that there will only be one
  51243. * pointer device and one keyboard.
  51244. */
  51245. export class DeviceInputSystem implements IDisposable {
  51246. /**
  51247. * Callback to be triggered when a device is connected
  51248. */
  51249. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51250. /**
  51251. * Callback to be triggered when a device is disconnected
  51252. */
  51253. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51254. /**
  51255. * Callback to be triggered when event driven input is updated
  51256. */
  51257. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  51258. private _inputs;
  51259. private _gamepads;
  51260. private _keyboardActive;
  51261. private _pointerActive;
  51262. private _elementToAttachTo;
  51263. private _keyboardDownEvent;
  51264. private _keyboardUpEvent;
  51265. private _pointerMoveEvent;
  51266. private _pointerDownEvent;
  51267. private _pointerUpEvent;
  51268. private _gamepadConnectedEvent;
  51269. private _gamepadDisconnectedEvent;
  51270. private static _MAX_KEYCODES;
  51271. private static _MAX_POINTER_INPUTS;
  51272. private constructor();
  51273. /**
  51274. * Creates a new DeviceInputSystem instance
  51275. * @param engine Engine to pull input element from
  51276. * @returns The new instance
  51277. */
  51278. static Create(engine: Engine): DeviceInputSystem;
  51279. /**
  51280. * Checks for current device input value, given an id and input index
  51281. * @param deviceName Id of connected device
  51282. * @param inputIndex Index of device input
  51283. * @returns Current value of input
  51284. */
  51285. /**
  51286. * Checks for current device input value, given an id and input index
  51287. * @param deviceType Enum specifiying device type
  51288. * @param deviceSlot "Slot" or index that device is referenced in
  51289. * @param inputIndex Id of input to be checked
  51290. * @returns Current value of input
  51291. */
  51292. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  51293. /**
  51294. * Dispose of all the eventlisteners
  51295. */
  51296. dispose(): void;
  51297. /**
  51298. * Add device and inputs to device array
  51299. * @param deviceType Enum specifiying device type
  51300. * @param deviceSlot "Slot" or index that device is referenced in
  51301. * @param numberOfInputs Number of input entries to create for given device
  51302. */
  51303. private _registerDevice;
  51304. /**
  51305. * Given a specific device name, remove that device from the device map
  51306. * @param deviceType Enum specifiying device type
  51307. * @param deviceSlot "Slot" or index that device is referenced in
  51308. */
  51309. private _unregisterDevice;
  51310. /**
  51311. * Handle all actions that come from keyboard interaction
  51312. */
  51313. private _handleKeyActions;
  51314. /**
  51315. * Handle all actions that come from pointer interaction
  51316. */
  51317. private _handlePointerActions;
  51318. /**
  51319. * Handle all actions that come from gamepad interaction
  51320. */
  51321. private _handleGamepadActions;
  51322. /**
  51323. * Update all non-event based devices with each frame
  51324. * @param deviceType Enum specifiying device type
  51325. * @param deviceSlot "Slot" or index that device is referenced in
  51326. * @param inputIndex Id of input to be checked
  51327. */
  51328. private _updateDevice;
  51329. /**
  51330. * Gets DeviceType from the device name
  51331. * @param deviceName Name of Device from DeviceInputSystem
  51332. * @returns DeviceType enum value
  51333. */
  51334. private _getGamepadDeviceType;
  51335. }
  51336. }
  51337. declare module BABYLON {
  51338. /**
  51339. * Type to handle enforcement of inputs
  51340. */
  51341. 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;
  51342. }
  51343. declare module BABYLON {
  51344. /**
  51345. * Class that handles all input for a specific device
  51346. */
  51347. export class DeviceSource<T extends DeviceType> {
  51348. /** Type of device */
  51349. readonly deviceType: DeviceType;
  51350. /** "Slot" or index that device is referenced in */
  51351. readonly deviceSlot: number;
  51352. /**
  51353. * Observable to handle device input changes per device
  51354. */
  51355. readonly onInputChangedObservable: Observable<{
  51356. inputIndex: DeviceInput<T>;
  51357. previousState: Nullable<number>;
  51358. currentState: Nullable<number>;
  51359. }>;
  51360. private readonly _deviceInputSystem;
  51361. /**
  51362. * Default Constructor
  51363. * @param deviceInputSystem Reference to DeviceInputSystem
  51364. * @param deviceType Type of device
  51365. * @param deviceSlot "Slot" or index that device is referenced in
  51366. */
  51367. constructor(deviceInputSystem: DeviceInputSystem,
  51368. /** Type of device */
  51369. deviceType: DeviceType,
  51370. /** "Slot" or index that device is referenced in */
  51371. deviceSlot?: number);
  51372. /**
  51373. * Get input for specific input
  51374. * @param inputIndex index of specific input on device
  51375. * @returns Input value from DeviceInputSystem
  51376. */
  51377. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  51378. }
  51379. /**
  51380. * Class to keep track of devices
  51381. */
  51382. export class DeviceSourceManager implements IDisposable {
  51383. /**
  51384. * Observable to be triggered when before a device is connected
  51385. */
  51386. readonly onBeforeDeviceConnectedObservable: Observable<{
  51387. deviceType: DeviceType;
  51388. deviceSlot: number;
  51389. }>;
  51390. /**
  51391. * Observable to be triggered when before a device is disconnected
  51392. */
  51393. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  51394. deviceType: DeviceType;
  51395. deviceSlot: number;
  51396. }>;
  51397. /**
  51398. * Observable to be triggered when after a device is connected
  51399. */
  51400. readonly onAfterDeviceConnectedObservable: Observable<{
  51401. deviceType: DeviceType;
  51402. deviceSlot: number;
  51403. }>;
  51404. /**
  51405. * Observable to be triggered when after a device is disconnected
  51406. */
  51407. readonly onAfterDeviceDisconnectedObservable: Observable<{
  51408. deviceType: DeviceType;
  51409. deviceSlot: number;
  51410. }>;
  51411. private readonly _devices;
  51412. private readonly _firstDevice;
  51413. private readonly _deviceInputSystem;
  51414. /**
  51415. * Default Constructor
  51416. * @param engine engine to pull input element from
  51417. */
  51418. constructor(engine: Engine);
  51419. /**
  51420. * Gets a DeviceSource, given a type and slot
  51421. * @param deviceType Enum specifying device type
  51422. * @param deviceSlot "Slot" or index that device is referenced in
  51423. * @returns DeviceSource object
  51424. */
  51425. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  51426. /**
  51427. * Gets an array of DeviceSource objects for a given device type
  51428. * @param deviceType Enum specifying device type
  51429. * @returns Array of DeviceSource objects
  51430. */
  51431. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  51432. /**
  51433. * Dispose of DeviceInputSystem and other parts
  51434. */
  51435. dispose(): void;
  51436. /**
  51437. * Function to add device name to device list
  51438. * @param deviceType Enum specifying device type
  51439. * @param deviceSlot "Slot" or index that device is referenced in
  51440. */
  51441. private _addDevice;
  51442. /**
  51443. * Function to remove device name to device list
  51444. * @param deviceType Enum specifying device type
  51445. * @param deviceSlot "Slot" or index that device is referenced in
  51446. */
  51447. private _removeDevice;
  51448. /**
  51449. * Updates array storing first connected device of each type
  51450. * @param type Type of Device
  51451. */
  51452. private _updateFirstDevices;
  51453. }
  51454. }
  51455. declare module BABYLON {
  51456. /**
  51457. * Options to create the null engine
  51458. */
  51459. export class NullEngineOptions {
  51460. /**
  51461. * Render width (Default: 512)
  51462. */
  51463. renderWidth: number;
  51464. /**
  51465. * Render height (Default: 256)
  51466. */
  51467. renderHeight: number;
  51468. /**
  51469. * Texture size (Default: 512)
  51470. */
  51471. textureSize: number;
  51472. /**
  51473. * If delta time between frames should be constant
  51474. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51475. */
  51476. deterministicLockstep: boolean;
  51477. /**
  51478. * Maximum about of steps between frames (Default: 4)
  51479. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51480. */
  51481. lockstepMaxSteps: number;
  51482. /**
  51483. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  51484. */
  51485. useHighPrecisionMatrix?: boolean;
  51486. }
  51487. /**
  51488. * The null engine class provides support for headless version of babylon.js.
  51489. * This can be used in server side scenario or for testing purposes
  51490. */
  51491. export class NullEngine extends Engine {
  51492. private _options;
  51493. /**
  51494. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  51495. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51496. * @returns true if engine is in deterministic lock step mode
  51497. */
  51498. isDeterministicLockStep(): boolean;
  51499. /**
  51500. * Gets the max steps when engine is running in deterministic lock step
  51501. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51502. * @returns the max steps
  51503. */
  51504. getLockstepMaxSteps(): number;
  51505. /**
  51506. * Gets the current hardware scaling level.
  51507. * By default the hardware scaling level is computed from the window device ratio.
  51508. * 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.
  51509. * @returns a number indicating the current hardware scaling level
  51510. */
  51511. getHardwareScalingLevel(): number;
  51512. constructor(options?: NullEngineOptions);
  51513. /**
  51514. * Creates a vertex buffer
  51515. * @param vertices the data for the vertex buffer
  51516. * @returns the new WebGL static buffer
  51517. */
  51518. createVertexBuffer(vertices: FloatArray): DataBuffer;
  51519. /**
  51520. * Creates a new index buffer
  51521. * @param indices defines the content of the index buffer
  51522. * @param updatable defines if the index buffer must be updatable
  51523. * @returns a new webGL buffer
  51524. */
  51525. createIndexBuffer(indices: IndicesArray): DataBuffer;
  51526. /**
  51527. * Clear the current render buffer or the current render target (if any is set up)
  51528. * @param color defines the color to use
  51529. * @param backBuffer defines if the back buffer must be cleared
  51530. * @param depth defines if the depth buffer must be cleared
  51531. * @param stencil defines if the stencil buffer must be cleared
  51532. */
  51533. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51534. /**
  51535. * Gets the current render width
  51536. * @param useScreen defines if screen size must be used (or the current render target if any)
  51537. * @returns a number defining the current render width
  51538. */
  51539. getRenderWidth(useScreen?: boolean): number;
  51540. /**
  51541. * Gets the current render height
  51542. * @param useScreen defines if screen size must be used (or the current render target if any)
  51543. * @returns a number defining the current render height
  51544. */
  51545. getRenderHeight(useScreen?: boolean): number;
  51546. /**
  51547. * Set the WebGL's viewport
  51548. * @param viewport defines the viewport element to be used
  51549. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  51550. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  51551. */
  51552. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  51553. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  51554. /**
  51555. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  51556. * @param pipelineContext defines the pipeline context to use
  51557. * @param uniformsNames defines the list of uniform names
  51558. * @returns an array of webGL uniform locations
  51559. */
  51560. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  51561. /**
  51562. * Gets the lsit of active attributes for a given webGL program
  51563. * @param pipelineContext defines the pipeline context to use
  51564. * @param attributesNames defines the list of attribute names to get
  51565. * @returns an array of indices indicating the offset of each attribute
  51566. */
  51567. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  51568. /**
  51569. * Binds an effect to the webGL context
  51570. * @param effect defines the effect to bind
  51571. */
  51572. bindSamplers(effect: Effect): void;
  51573. /**
  51574. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  51575. * @param effect defines the effect to activate
  51576. */
  51577. enableEffect(effect: Effect): void;
  51578. /**
  51579. * Set various states to the webGL context
  51580. * @param culling defines backface culling state
  51581. * @param zOffset defines the value to apply to zOffset (0 by default)
  51582. * @param force defines if states must be applied even if cache is up to date
  51583. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  51584. */
  51585. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  51586. /**
  51587. * Set the value of an uniform to an array of int32
  51588. * @param uniform defines the webGL uniform location where to store the value
  51589. * @param array defines the array of int32 to store
  51590. */
  51591. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  51592. /**
  51593. * Set the value of an uniform to an array of int32 (stored as vec2)
  51594. * @param uniform defines the webGL uniform location where to store the value
  51595. * @param array defines the array of int32 to store
  51596. */
  51597. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  51598. /**
  51599. * Set the value of an uniform to an array of int32 (stored as vec3)
  51600. * @param uniform defines the webGL uniform location where to store the value
  51601. * @param array defines the array of int32 to store
  51602. */
  51603. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  51604. /**
  51605. * Set the value of an uniform to an array of int32 (stored as vec4)
  51606. * @param uniform defines the webGL uniform location where to store the value
  51607. * @param array defines the array of int32 to store
  51608. */
  51609. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  51610. /**
  51611. * Set the value of an uniform to an array of float32
  51612. * @param uniform defines the webGL uniform location where to store the value
  51613. * @param array defines the array of float32 to store
  51614. */
  51615. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  51616. /**
  51617. * Set the value of an uniform to an array of float32 (stored as vec2)
  51618. * @param uniform defines the webGL uniform location where to store the value
  51619. * @param array defines the array of float32 to store
  51620. */
  51621. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  51622. /**
  51623. * Set the value of an uniform to an array of float32 (stored as vec3)
  51624. * @param uniform defines the webGL uniform location where to store the value
  51625. * @param array defines the array of float32 to store
  51626. */
  51627. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  51628. /**
  51629. * Set the value of an uniform to an array of float32 (stored as vec4)
  51630. * @param uniform defines the webGL uniform location where to store the value
  51631. * @param array defines the array of float32 to store
  51632. */
  51633. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  51634. /**
  51635. * Set the value of an uniform to an array of number
  51636. * @param uniform defines the webGL uniform location where to store the value
  51637. * @param array defines the array of number to store
  51638. */
  51639. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  51640. /**
  51641. * Set the value of an uniform to an array of number (stored as vec2)
  51642. * @param uniform defines the webGL uniform location where to store the value
  51643. * @param array defines the array of number to store
  51644. */
  51645. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  51646. /**
  51647. * Set the value of an uniform to an array of number (stored as vec3)
  51648. * @param uniform defines the webGL uniform location where to store the value
  51649. * @param array defines the array of number to store
  51650. */
  51651. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  51652. /**
  51653. * Set the value of an uniform to an array of number (stored as vec4)
  51654. * @param uniform defines the webGL uniform location where to store the value
  51655. * @param array defines the array of number to store
  51656. */
  51657. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  51658. /**
  51659. * Set the value of an uniform to an array of float32 (stored as matrices)
  51660. * @param uniform defines the webGL uniform location where to store the value
  51661. * @param matrices defines the array of float32 to store
  51662. */
  51663. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  51664. /**
  51665. * Set the value of an uniform to a matrix (3x3)
  51666. * @param uniform defines the webGL uniform location where to store the value
  51667. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  51668. */
  51669. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51670. /**
  51671. * Set the value of an uniform to a matrix (2x2)
  51672. * @param uniform defines the webGL uniform location where to store the value
  51673. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  51674. */
  51675. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51676. /**
  51677. * Set the value of an uniform to a number (float)
  51678. * @param uniform defines the webGL uniform location where to store the value
  51679. * @param value defines the float number to store
  51680. */
  51681. setFloat(uniform: WebGLUniformLocation, value: number): void;
  51682. /**
  51683. * Set the value of an uniform to a vec2
  51684. * @param uniform defines the webGL uniform location where to store the value
  51685. * @param x defines the 1st component of the value
  51686. * @param y defines the 2nd component of the value
  51687. */
  51688. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  51689. /**
  51690. * Set the value of an uniform to a vec3
  51691. * @param uniform defines the webGL uniform location where to store the value
  51692. * @param x defines the 1st component of the value
  51693. * @param y defines the 2nd component of the value
  51694. * @param z defines the 3rd component of the value
  51695. */
  51696. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  51697. /**
  51698. * Set the value of an uniform to a boolean
  51699. * @param uniform defines the webGL uniform location where to store the value
  51700. * @param bool defines the boolean to store
  51701. */
  51702. setBool(uniform: WebGLUniformLocation, bool: number): void;
  51703. /**
  51704. * Set the value of an uniform to a vec4
  51705. * @param uniform defines the webGL uniform location where to store the value
  51706. * @param x defines the 1st component of the value
  51707. * @param y defines the 2nd component of the value
  51708. * @param z defines the 3rd component of the value
  51709. * @param w defines the 4th component of the value
  51710. */
  51711. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  51712. /**
  51713. * Sets the current alpha mode
  51714. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  51715. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  51716. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51717. */
  51718. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  51719. /**
  51720. * Bind webGl buffers directly to the webGL context
  51721. * @param vertexBuffers defines the vertex buffer to bind
  51722. * @param indexBuffer defines the index buffer to bind
  51723. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  51724. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  51725. * @param effect defines the effect associated with the vertex buffer
  51726. */
  51727. bindBuffers(vertexBuffers: {
  51728. [key: string]: VertexBuffer;
  51729. }, indexBuffer: DataBuffer, effect: Effect): void;
  51730. /**
  51731. * Force the entire cache to be cleared
  51732. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  51733. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  51734. */
  51735. wipeCaches(bruteForce?: boolean): void;
  51736. /**
  51737. * Send a draw order
  51738. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  51739. * @param indexStart defines the starting index
  51740. * @param indexCount defines the number of index to draw
  51741. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51742. */
  51743. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  51744. /**
  51745. * Draw a list of indexed primitives
  51746. * @param fillMode defines the primitive to use
  51747. * @param indexStart defines the starting index
  51748. * @param indexCount defines the number of index to draw
  51749. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51750. */
  51751. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  51752. /**
  51753. * Draw a list of unindexed primitives
  51754. * @param fillMode defines the primitive to use
  51755. * @param verticesStart defines the index of first vertex to draw
  51756. * @param verticesCount defines the count of vertices to draw
  51757. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51758. */
  51759. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  51760. /** @hidden */
  51761. _createTexture(): WebGLTexture;
  51762. /** @hidden */
  51763. _releaseTexture(texture: InternalTexture): void;
  51764. /**
  51765. * Usually called from Texture.ts.
  51766. * Passed information to create a WebGLTexture
  51767. * @param urlArg defines a value which contains one of the following:
  51768. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  51769. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  51770. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  51771. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  51772. * @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)
  51773. * @param scene needed for loading to the correct scene
  51774. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  51775. * @param onLoad optional callback to be called upon successful completion
  51776. * @param onError optional callback to be called upon failure
  51777. * @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
  51778. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  51779. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  51780. * @param forcedExtension defines the extension to use to pick the right loader
  51781. * @param mimeType defines an optional mime type
  51782. * @returns a InternalTexture for assignment back into BABYLON.Texture
  51783. */
  51784. 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;
  51785. /**
  51786. * Creates a new render target texture
  51787. * @param size defines the size of the texture
  51788. * @param options defines the options used to create the texture
  51789. * @returns a new render target texture stored in an InternalTexture
  51790. */
  51791. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  51792. /**
  51793. * Update the sampling mode of a given texture
  51794. * @param samplingMode defines the required sampling mode
  51795. * @param texture defines the texture to update
  51796. */
  51797. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  51798. /**
  51799. * Binds the frame buffer to the specified texture.
  51800. * @param texture The texture to render to or null for the default canvas
  51801. * @param faceIndex The face of the texture to render to in case of cube texture
  51802. * @param requiredWidth The width of the target to render to
  51803. * @param requiredHeight The height of the target to render to
  51804. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  51805. * @param lodLevel defines le lod level to bind to the frame buffer
  51806. */
  51807. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  51808. /**
  51809. * Unbind the current render target texture from the webGL context
  51810. * @param texture defines the render target texture to unbind
  51811. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  51812. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  51813. */
  51814. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  51815. /**
  51816. * Creates a dynamic vertex buffer
  51817. * @param vertices the data for the dynamic vertex buffer
  51818. * @returns the new WebGL dynamic buffer
  51819. */
  51820. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  51821. /**
  51822. * Update the content of a dynamic texture
  51823. * @param texture defines the texture to update
  51824. * @param canvas defines the canvas containing the source
  51825. * @param invertY defines if data must be stored with Y axis inverted
  51826. * @param premulAlpha defines if alpha is stored as premultiplied
  51827. * @param format defines the format of the data
  51828. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  51829. */
  51830. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  51831. /**
  51832. * Gets a boolean indicating if all created effects are ready
  51833. * @returns true if all effects are ready
  51834. */
  51835. areAllEffectsReady(): boolean;
  51836. /**
  51837. * @hidden
  51838. * Get the current error code of the webGL context
  51839. * @returns the error code
  51840. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  51841. */
  51842. getError(): number;
  51843. /** @hidden */
  51844. _getUnpackAlignement(): number;
  51845. /** @hidden */
  51846. _unpackFlipY(value: boolean): void;
  51847. /**
  51848. * Update a dynamic index buffer
  51849. * @param indexBuffer defines the target index buffer
  51850. * @param indices defines the data to update
  51851. * @param offset defines the offset in the target index buffer where update should start
  51852. */
  51853. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  51854. /**
  51855. * Updates a dynamic vertex buffer.
  51856. * @param vertexBuffer the vertex buffer to update
  51857. * @param vertices the data used to update the vertex buffer
  51858. * @param byteOffset the byte offset of the data (optional)
  51859. * @param byteLength the byte length of the data (optional)
  51860. */
  51861. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  51862. /** @hidden */
  51863. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  51864. /** @hidden */
  51865. _bindTexture(channel: number, texture: InternalTexture): void;
  51866. protected _deleteBuffer(buffer: WebGLBuffer): void;
  51867. /**
  51868. * 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
  51869. */
  51870. releaseEffects(): void;
  51871. displayLoadingUI(): void;
  51872. hideLoadingUI(): void;
  51873. /** @hidden */
  51874. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51875. /** @hidden */
  51876. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51877. /** @hidden */
  51878. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51879. /** @hidden */
  51880. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  51881. }
  51882. }
  51883. declare module BABYLON {
  51884. /**
  51885. * @hidden
  51886. **/
  51887. export class _TimeToken {
  51888. _startTimeQuery: Nullable<WebGLQuery>;
  51889. _endTimeQuery: Nullable<WebGLQuery>;
  51890. _timeElapsedQuery: Nullable<WebGLQuery>;
  51891. _timeElapsedQueryEnded: boolean;
  51892. }
  51893. }
  51894. declare module BABYLON {
  51895. /** @hidden */
  51896. export class _OcclusionDataStorage {
  51897. /** @hidden */
  51898. occlusionInternalRetryCounter: number;
  51899. /** @hidden */
  51900. isOcclusionQueryInProgress: boolean;
  51901. /** @hidden */
  51902. isOccluded: boolean;
  51903. /** @hidden */
  51904. occlusionRetryCount: number;
  51905. /** @hidden */
  51906. occlusionType: number;
  51907. /** @hidden */
  51908. occlusionQueryAlgorithmType: number;
  51909. }
  51910. interface Engine {
  51911. /**
  51912. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  51913. * @return the new query
  51914. */
  51915. createQuery(): WebGLQuery;
  51916. /**
  51917. * Delete and release a webGL query
  51918. * @param query defines the query to delete
  51919. * @return the current engine
  51920. */
  51921. deleteQuery(query: WebGLQuery): Engine;
  51922. /**
  51923. * Check if a given query has resolved and got its value
  51924. * @param query defines the query to check
  51925. * @returns true if the query got its value
  51926. */
  51927. isQueryResultAvailable(query: WebGLQuery): boolean;
  51928. /**
  51929. * Gets the value of a given query
  51930. * @param query defines the query to check
  51931. * @returns the value of the query
  51932. */
  51933. getQueryResult(query: WebGLQuery): number;
  51934. /**
  51935. * Initiates an occlusion query
  51936. * @param algorithmType defines the algorithm to use
  51937. * @param query defines the query to use
  51938. * @returns the current engine
  51939. * @see https://doc.babylonjs.com/features/occlusionquery
  51940. */
  51941. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  51942. /**
  51943. * Ends an occlusion query
  51944. * @see https://doc.babylonjs.com/features/occlusionquery
  51945. * @param algorithmType defines the algorithm to use
  51946. * @returns the current engine
  51947. */
  51948. endOcclusionQuery(algorithmType: number): Engine;
  51949. /**
  51950. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  51951. * Please note that only one query can be issued at a time
  51952. * @returns a time token used to track the time span
  51953. */
  51954. startTimeQuery(): Nullable<_TimeToken>;
  51955. /**
  51956. * Ends a time query
  51957. * @param token defines the token used to measure the time span
  51958. * @returns the time spent (in ns)
  51959. */
  51960. endTimeQuery(token: _TimeToken): int;
  51961. /** @hidden */
  51962. _currentNonTimestampToken: Nullable<_TimeToken>;
  51963. /** @hidden */
  51964. _createTimeQuery(): WebGLQuery;
  51965. /** @hidden */
  51966. _deleteTimeQuery(query: WebGLQuery): void;
  51967. /** @hidden */
  51968. _getGlAlgorithmType(algorithmType: number): number;
  51969. /** @hidden */
  51970. _getTimeQueryResult(query: WebGLQuery): any;
  51971. /** @hidden */
  51972. _getTimeQueryAvailability(query: WebGLQuery): any;
  51973. }
  51974. interface AbstractMesh {
  51975. /**
  51976. * Backing filed
  51977. * @hidden
  51978. */
  51979. __occlusionDataStorage: _OcclusionDataStorage;
  51980. /**
  51981. * Access property
  51982. * @hidden
  51983. */
  51984. _occlusionDataStorage: _OcclusionDataStorage;
  51985. /**
  51986. * 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.
  51987. * The default value is -1 which means don't break the query and wait till the result
  51988. * @see https://doc.babylonjs.com/features/occlusionquery
  51989. */
  51990. occlusionRetryCount: number;
  51991. /**
  51992. * 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:
  51993. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  51994. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  51995. * * 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.
  51996. * @see https://doc.babylonjs.com/features/occlusionquery
  51997. */
  51998. occlusionType: number;
  51999. /**
  52000. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  52001. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  52002. * * 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.
  52003. * @see https://doc.babylonjs.com/features/occlusionquery
  52004. */
  52005. occlusionQueryAlgorithmType: number;
  52006. /**
  52007. * 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
  52008. * @see https://doc.babylonjs.com/features/occlusionquery
  52009. */
  52010. isOccluded: boolean;
  52011. /**
  52012. * Flag to check the progress status of the query
  52013. * @see https://doc.babylonjs.com/features/occlusionquery
  52014. */
  52015. isOcclusionQueryInProgress: boolean;
  52016. }
  52017. }
  52018. declare module BABYLON {
  52019. /** @hidden */
  52020. export var _forceTransformFeedbackToBundle: boolean;
  52021. interface Engine {
  52022. /**
  52023. * Creates a webGL transform feedback object
  52024. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  52025. * @returns the webGL transform feedback object
  52026. */
  52027. createTransformFeedback(): WebGLTransformFeedback;
  52028. /**
  52029. * Delete a webGL transform feedback object
  52030. * @param value defines the webGL transform feedback object to delete
  52031. */
  52032. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  52033. /**
  52034. * Bind a webGL transform feedback object to the webgl context
  52035. * @param value defines the webGL transform feedback object to bind
  52036. */
  52037. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  52038. /**
  52039. * Begins a transform feedback operation
  52040. * @param usePoints defines if points or triangles must be used
  52041. */
  52042. beginTransformFeedback(usePoints: boolean): void;
  52043. /**
  52044. * Ends a transform feedback operation
  52045. */
  52046. endTransformFeedback(): void;
  52047. /**
  52048. * Specify the varyings to use with transform feedback
  52049. * @param program defines the associated webGL program
  52050. * @param value defines the list of strings representing the varying names
  52051. */
  52052. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  52053. /**
  52054. * Bind a webGL buffer for a transform feedback operation
  52055. * @param value defines the webGL buffer to bind
  52056. */
  52057. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  52058. }
  52059. }
  52060. declare module BABYLON {
  52061. /**
  52062. * Class used to define an additional view for the engine
  52063. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52064. */
  52065. export class EngineView {
  52066. /** Defines the canvas where to render the view */
  52067. target: HTMLCanvasElement;
  52068. /** Defines an optional camera used to render the view (will use active camera else) */
  52069. camera?: Camera;
  52070. }
  52071. interface Engine {
  52072. /**
  52073. * Gets or sets the HTML element to use for attaching events
  52074. */
  52075. inputElement: Nullable<HTMLElement>;
  52076. /**
  52077. * Gets the current engine view
  52078. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52079. */
  52080. activeView: Nullable<EngineView>;
  52081. /** Gets or sets the list of views */
  52082. views: EngineView[];
  52083. /**
  52084. * Register a new child canvas
  52085. * @param canvas defines the canvas to register
  52086. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  52087. * @returns the associated view
  52088. */
  52089. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  52090. /**
  52091. * Remove a registered child canvas
  52092. * @param canvas defines the canvas to remove
  52093. * @returns the current engine
  52094. */
  52095. unRegisterView(canvas: HTMLCanvasElement): Engine;
  52096. }
  52097. }
  52098. declare module BABYLON {
  52099. interface Engine {
  52100. /** @hidden */
  52101. _excludedCompressedTextures: string[];
  52102. /** @hidden */
  52103. _textureFormatInUse: string;
  52104. /**
  52105. * Gets the list of texture formats supported
  52106. */
  52107. readonly texturesSupported: Array<string>;
  52108. /**
  52109. * Gets the texture format in use
  52110. */
  52111. readonly textureFormatInUse: Nullable<string>;
  52112. /**
  52113. * Set the compressed texture extensions or file names to skip.
  52114. *
  52115. * @param skippedFiles defines the list of those texture files you want to skip
  52116. * Example: [".dds", ".env", "myfile.png"]
  52117. */
  52118. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  52119. /**
  52120. * Set the compressed texture format to use, based on the formats you have, and the formats
  52121. * supported by the hardware / browser.
  52122. *
  52123. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  52124. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  52125. * to API arguments needed to compressed textures. This puts the burden on the container
  52126. * generator to house the arcane code for determining these for current & future formats.
  52127. *
  52128. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52129. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52130. *
  52131. * Note: The result of this call is not taken into account when a texture is base64.
  52132. *
  52133. * @param formatsAvailable defines the list of those format families you have created
  52134. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  52135. *
  52136. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  52137. * @returns The extension selected.
  52138. */
  52139. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  52140. }
  52141. }
  52142. declare module BABYLON {
  52143. /**
  52144. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  52145. */
  52146. export interface CubeMapInfo {
  52147. /**
  52148. * The pixel array for the front face.
  52149. * This is stored in format, left to right, up to down format.
  52150. */
  52151. front: Nullable<ArrayBufferView>;
  52152. /**
  52153. * The pixel array for the back face.
  52154. * This is stored in format, left to right, up to down format.
  52155. */
  52156. back: Nullable<ArrayBufferView>;
  52157. /**
  52158. * The pixel array for the left face.
  52159. * This is stored in format, left to right, up to down format.
  52160. */
  52161. left: Nullable<ArrayBufferView>;
  52162. /**
  52163. * The pixel array for the right face.
  52164. * This is stored in format, left to right, up to down format.
  52165. */
  52166. right: Nullable<ArrayBufferView>;
  52167. /**
  52168. * The pixel array for the up face.
  52169. * This is stored in format, left to right, up to down format.
  52170. */
  52171. up: Nullable<ArrayBufferView>;
  52172. /**
  52173. * The pixel array for the down face.
  52174. * This is stored in format, left to right, up to down format.
  52175. */
  52176. down: Nullable<ArrayBufferView>;
  52177. /**
  52178. * The size of the cubemap stored.
  52179. *
  52180. * Each faces will be size * size pixels.
  52181. */
  52182. size: number;
  52183. /**
  52184. * The format of the texture.
  52185. *
  52186. * RGBA, RGB.
  52187. */
  52188. format: number;
  52189. /**
  52190. * The type of the texture data.
  52191. *
  52192. * UNSIGNED_INT, FLOAT.
  52193. */
  52194. type: number;
  52195. /**
  52196. * Specifies whether the texture is in gamma space.
  52197. */
  52198. gammaSpace: boolean;
  52199. }
  52200. /**
  52201. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  52202. */
  52203. export class PanoramaToCubeMapTools {
  52204. private static FACE_LEFT;
  52205. private static FACE_RIGHT;
  52206. private static FACE_FRONT;
  52207. private static FACE_BACK;
  52208. private static FACE_DOWN;
  52209. private static FACE_UP;
  52210. /**
  52211. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  52212. *
  52213. * @param float32Array The source data.
  52214. * @param inputWidth The width of the input panorama.
  52215. * @param inputHeight The height of the input panorama.
  52216. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  52217. * @return The cubemap data
  52218. */
  52219. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  52220. private static CreateCubemapTexture;
  52221. private static CalcProjectionSpherical;
  52222. }
  52223. }
  52224. declare module BABYLON {
  52225. /**
  52226. * Helper class dealing with the extraction of spherical polynomial dataArray
  52227. * from a cube map.
  52228. */
  52229. export class CubeMapToSphericalPolynomialTools {
  52230. private static FileFaces;
  52231. /**
  52232. * Converts a texture to the according Spherical Polynomial data.
  52233. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52234. *
  52235. * @param texture The texture to extract the information from.
  52236. * @return The Spherical Polynomial data.
  52237. */
  52238. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  52239. /**
  52240. * Converts a cubemap to the according Spherical Polynomial data.
  52241. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52242. *
  52243. * @param cubeInfo The Cube map to extract the information from.
  52244. * @return The Spherical Polynomial data.
  52245. */
  52246. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  52247. }
  52248. }
  52249. declare module BABYLON {
  52250. interface BaseTexture {
  52251. /**
  52252. * Get the polynomial representation of the texture data.
  52253. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  52254. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  52255. */
  52256. sphericalPolynomial: Nullable<SphericalPolynomial>;
  52257. }
  52258. }
  52259. declare module BABYLON {
  52260. /** @hidden */
  52261. export var rgbdEncodePixelShader: {
  52262. name: string;
  52263. shader: string;
  52264. };
  52265. }
  52266. declare module BABYLON {
  52267. /** @hidden */
  52268. export var rgbdDecodePixelShader: {
  52269. name: string;
  52270. shader: string;
  52271. };
  52272. }
  52273. declare module BABYLON {
  52274. /**
  52275. * Raw texture data and descriptor sufficient for WebGL texture upload
  52276. */
  52277. export interface EnvironmentTextureInfo {
  52278. /**
  52279. * Version of the environment map
  52280. */
  52281. version: number;
  52282. /**
  52283. * Width of image
  52284. */
  52285. width: number;
  52286. /**
  52287. * Irradiance information stored in the file.
  52288. */
  52289. irradiance: any;
  52290. /**
  52291. * Specular information stored in the file.
  52292. */
  52293. specular: any;
  52294. }
  52295. /**
  52296. * Defines One Image in the file. It requires only the position in the file
  52297. * as well as the length.
  52298. */
  52299. interface BufferImageData {
  52300. /**
  52301. * Length of the image data.
  52302. */
  52303. length: number;
  52304. /**
  52305. * Position of the data from the null terminator delimiting the end of the JSON.
  52306. */
  52307. position: number;
  52308. }
  52309. /**
  52310. * Defines the specular data enclosed in the file.
  52311. * This corresponds to the version 1 of the data.
  52312. */
  52313. export interface EnvironmentTextureSpecularInfoV1 {
  52314. /**
  52315. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  52316. */
  52317. specularDataPosition?: number;
  52318. /**
  52319. * This contains all the images data needed to reconstruct the cubemap.
  52320. */
  52321. mipmaps: Array<BufferImageData>;
  52322. /**
  52323. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  52324. */
  52325. lodGenerationScale: number;
  52326. }
  52327. /**
  52328. * Sets of helpers addressing the serialization and deserialization of environment texture
  52329. * stored in a BabylonJS env file.
  52330. * Those files are usually stored as .env files.
  52331. */
  52332. export class EnvironmentTextureTools {
  52333. /**
  52334. * Magic number identifying the env file.
  52335. */
  52336. private static _MagicBytes;
  52337. /**
  52338. * Gets the environment info from an env file.
  52339. * @param data The array buffer containing the .env bytes.
  52340. * @returns the environment file info (the json header) if successfully parsed.
  52341. */
  52342. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  52343. /**
  52344. * Creates an environment texture from a loaded cube texture.
  52345. * @param texture defines the cube texture to convert in env file
  52346. * @return a promise containing the environment data if succesfull.
  52347. */
  52348. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  52349. /**
  52350. * Creates a JSON representation of the spherical data.
  52351. * @param texture defines the texture containing the polynomials
  52352. * @return the JSON representation of the spherical info
  52353. */
  52354. private static _CreateEnvTextureIrradiance;
  52355. /**
  52356. * Creates the ArrayBufferViews used for initializing environment texture image data.
  52357. * @param data the image data
  52358. * @param info parameters that determine what views will be created for accessing the underlying buffer
  52359. * @return the views described by info providing access to the underlying buffer
  52360. */
  52361. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  52362. /**
  52363. * Uploads the texture info contained in the env file to the GPU.
  52364. * @param texture defines the internal texture to upload to
  52365. * @param data defines the data to load
  52366. * @param info defines the texture info retrieved through the GetEnvInfo method
  52367. * @returns a promise
  52368. */
  52369. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  52370. private static _OnImageReadyAsync;
  52371. /**
  52372. * Uploads the levels of image data to the GPU.
  52373. * @param texture defines the internal texture to upload to
  52374. * @param imageData defines the array buffer views of image data [mipmap][face]
  52375. * @returns a promise
  52376. */
  52377. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  52378. /**
  52379. * Uploads spherical polynomials information to the texture.
  52380. * @param texture defines the texture we are trying to upload the information to
  52381. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  52382. */
  52383. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  52384. /** @hidden */
  52385. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52386. }
  52387. }
  52388. declare module BABYLON {
  52389. /**
  52390. * Class used to inline functions in shader code
  52391. */
  52392. export class ShaderCodeInliner {
  52393. private static readonly _RegexpFindFunctionNameAndType;
  52394. private _sourceCode;
  52395. private _functionDescr;
  52396. private _numMaxIterations;
  52397. /** Gets or sets the token used to mark the functions to inline */
  52398. inlineToken: string;
  52399. /** Gets or sets the debug mode */
  52400. debug: boolean;
  52401. /** Gets the code after the inlining process */
  52402. get code(): string;
  52403. /**
  52404. * Initializes the inliner
  52405. * @param sourceCode shader code source to inline
  52406. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  52407. */
  52408. constructor(sourceCode: string, numMaxIterations?: number);
  52409. /**
  52410. * Start the processing of the shader code
  52411. */
  52412. processCode(): void;
  52413. private _collectFunctions;
  52414. private _processInlining;
  52415. private _extractBetweenMarkers;
  52416. private _skipWhitespaces;
  52417. private _removeComments;
  52418. private _replaceFunctionCallsByCode;
  52419. private _findBackward;
  52420. private _escapeRegExp;
  52421. private _replaceNames;
  52422. }
  52423. }
  52424. declare module BABYLON {
  52425. /**
  52426. * Container for accessors for natively-stored mesh data buffers.
  52427. */
  52428. class NativeDataBuffer extends DataBuffer {
  52429. /**
  52430. * Accessor value used to identify/retrieve a natively-stored index buffer.
  52431. */
  52432. nativeIndexBuffer?: any;
  52433. /**
  52434. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  52435. */
  52436. nativeVertexBuffer?: any;
  52437. }
  52438. /** @hidden */
  52439. class NativeTexture extends InternalTexture {
  52440. getInternalTexture(): InternalTexture;
  52441. getViewCount(): number;
  52442. }
  52443. /** @hidden */
  52444. export class NativeEngine extends Engine {
  52445. private readonly _native;
  52446. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  52447. private readonly INVALID_HANDLE;
  52448. private _boundBuffersVertexArray;
  52449. getHardwareScalingLevel(): number;
  52450. constructor();
  52451. dispose(): void;
  52452. /**
  52453. * Can be used to override the current requestAnimationFrame requester.
  52454. * @hidden
  52455. */
  52456. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  52457. /**
  52458. * Override default engine behavior.
  52459. * @param color
  52460. * @param backBuffer
  52461. * @param depth
  52462. * @param stencil
  52463. */
  52464. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  52465. /**
  52466. * Gets host document
  52467. * @returns the host document object
  52468. */
  52469. getHostDocument(): Nullable<Document>;
  52470. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  52471. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  52472. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  52473. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  52474. [key: string]: VertexBuffer;
  52475. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  52476. bindBuffers(vertexBuffers: {
  52477. [key: string]: VertexBuffer;
  52478. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  52479. recordVertexArrayObject(vertexBuffers: {
  52480. [key: string]: VertexBuffer;
  52481. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  52482. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  52483. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  52484. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  52485. /**
  52486. * Draw a list of indexed primitives
  52487. * @param fillMode defines the primitive to use
  52488. * @param indexStart defines the starting index
  52489. * @param indexCount defines the number of index to draw
  52490. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52491. */
  52492. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52493. /**
  52494. * Draw a list of unindexed primitives
  52495. * @param fillMode defines the primitive to use
  52496. * @param verticesStart defines the index of first vertex to draw
  52497. * @param verticesCount defines the count of vertices to draw
  52498. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52499. */
  52500. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52501. createPipelineContext(): IPipelineContext;
  52502. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  52503. /** @hidden */
  52504. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  52505. /** @hidden */
  52506. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  52507. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  52508. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  52509. protected _setProgram(program: WebGLProgram): void;
  52510. _releaseEffect(effect: Effect): void;
  52511. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  52512. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  52513. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  52514. bindSamplers(effect: Effect): void;
  52515. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  52516. getRenderWidth(useScreen?: boolean): number;
  52517. getRenderHeight(useScreen?: boolean): number;
  52518. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  52519. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52520. /**
  52521. * Set the z offset to apply to current rendering
  52522. * @param value defines the offset to apply
  52523. */
  52524. setZOffset(value: number): void;
  52525. /**
  52526. * Gets the current value of the zOffset
  52527. * @returns the current zOffset state
  52528. */
  52529. getZOffset(): number;
  52530. /**
  52531. * Enable or disable depth buffering
  52532. * @param enable defines the state to set
  52533. */
  52534. setDepthBuffer(enable: boolean): void;
  52535. /**
  52536. * Gets a boolean indicating if depth writing is enabled
  52537. * @returns the current depth writing state
  52538. */
  52539. getDepthWrite(): boolean;
  52540. /**
  52541. * Enable or disable depth writing
  52542. * @param enable defines the state to set
  52543. */
  52544. setDepthWrite(enable: boolean): void;
  52545. /**
  52546. * Enable or disable color writing
  52547. * @param enable defines the state to set
  52548. */
  52549. setColorWrite(enable: boolean): void;
  52550. /**
  52551. * Gets a boolean indicating if color writing is enabled
  52552. * @returns the current color writing state
  52553. */
  52554. getColorWrite(): boolean;
  52555. /**
  52556. * Sets alpha constants used by some alpha blending modes
  52557. * @param r defines the red component
  52558. * @param g defines the green component
  52559. * @param b defines the blue component
  52560. * @param a defines the alpha component
  52561. */
  52562. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  52563. /**
  52564. * Sets the current alpha mode
  52565. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  52566. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  52567. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52568. */
  52569. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  52570. /**
  52571. * Gets the current alpha mode
  52572. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52573. * @returns the current alpha mode
  52574. */
  52575. getAlphaMode(): number;
  52576. setInt(uniform: WebGLUniformLocation, int: number): void;
  52577. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  52578. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  52579. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  52580. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  52581. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  52582. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  52583. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  52584. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  52585. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  52586. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  52587. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  52588. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  52589. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  52590. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52591. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52592. setFloat(uniform: WebGLUniformLocation, value: number): void;
  52593. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  52594. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  52595. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  52596. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  52597. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  52598. wipeCaches(bruteForce?: boolean): void;
  52599. _createTexture(): WebGLTexture;
  52600. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  52601. /**
  52602. * Usually called from Texture.ts.
  52603. * Passed information to create a WebGLTexture
  52604. * @param url defines a value which contains one of the following:
  52605. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  52606. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  52607. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  52608. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  52609. * @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)
  52610. * @param scene needed for loading to the correct scene
  52611. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  52612. * @param onLoad optional callback to be called upon successful completion
  52613. * @param onError optional callback to be called upon failure
  52614. * @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
  52615. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  52616. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  52617. * @param forcedExtension defines the extension to use to pick the right loader
  52618. * @param mimeType defines an optional mime type
  52619. * @returns a InternalTexture for assignment back into BABYLON.Texture
  52620. */
  52621. 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;
  52622. /**
  52623. * Creates a cube texture
  52624. * @param rootUrl defines the url where the files to load is located
  52625. * @param scene defines the current scene
  52626. * @param files defines the list of files to load (1 per face)
  52627. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  52628. * @param onLoad defines an optional callback raised when the texture is loaded
  52629. * @param onError defines an optional callback raised if there is an issue to load the texture
  52630. * @param format defines the format of the data
  52631. * @param forcedExtension defines the extension to use to pick the right loader
  52632. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  52633. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52634. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52635. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  52636. * @returns the cube texture as an InternalTexture
  52637. */
  52638. 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;
  52639. private _getSamplingFilter;
  52640. private static _GetNativeTextureFormat;
  52641. createRenderTargetTexture(size: number | {
  52642. width: number;
  52643. height: number;
  52644. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  52645. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  52646. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  52647. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  52648. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  52649. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  52650. /**
  52651. * Updates a dynamic vertex buffer.
  52652. * @param vertexBuffer the vertex buffer to update
  52653. * @param data the data used to update the vertex buffer
  52654. * @param byteOffset the byte offset of the data (optional)
  52655. * @param byteLength the byte length of the data (optional)
  52656. */
  52657. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  52658. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  52659. private _updateAnisotropicLevel;
  52660. private _getAddressMode;
  52661. /** @hidden */
  52662. _bindTexture(channel: number, texture: InternalTexture): void;
  52663. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  52664. releaseEffects(): void;
  52665. /** @hidden */
  52666. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52667. /** @hidden */
  52668. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52669. /** @hidden */
  52670. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52671. /** @hidden */
  52672. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  52673. }
  52674. }
  52675. declare module BABYLON {
  52676. /**
  52677. * Gather the list of clipboard event types as constants.
  52678. */
  52679. export class ClipboardEventTypes {
  52680. /**
  52681. * The clipboard event is fired when a copy command is active (pressed).
  52682. */
  52683. static readonly COPY: number;
  52684. /**
  52685. * The clipboard event is fired when a cut command is active (pressed).
  52686. */
  52687. static readonly CUT: number;
  52688. /**
  52689. * The clipboard event is fired when a paste command is active (pressed).
  52690. */
  52691. static readonly PASTE: number;
  52692. }
  52693. /**
  52694. * This class is used to store clipboard related info for the onClipboardObservable event.
  52695. */
  52696. export class ClipboardInfo {
  52697. /**
  52698. * Defines the type of event (BABYLON.ClipboardEventTypes)
  52699. */
  52700. type: number;
  52701. /**
  52702. * Defines the related dom event
  52703. */
  52704. event: ClipboardEvent;
  52705. /**
  52706. *Creates an instance of ClipboardInfo.
  52707. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  52708. * @param event Defines the related dom event
  52709. */
  52710. constructor(
  52711. /**
  52712. * Defines the type of event (BABYLON.ClipboardEventTypes)
  52713. */
  52714. type: number,
  52715. /**
  52716. * Defines the related dom event
  52717. */
  52718. event: ClipboardEvent);
  52719. /**
  52720. * Get the clipboard event's type from the keycode.
  52721. * @param keyCode Defines the keyCode for the current keyboard event.
  52722. * @return {number}
  52723. */
  52724. static GetTypeFromCharacter(keyCode: number): number;
  52725. }
  52726. }
  52727. declare module BABYLON {
  52728. /**
  52729. * Google Daydream controller
  52730. */
  52731. export class DaydreamController extends WebVRController {
  52732. /**
  52733. * Base Url for the controller model.
  52734. */
  52735. static MODEL_BASE_URL: string;
  52736. /**
  52737. * File name for the controller model.
  52738. */
  52739. static MODEL_FILENAME: string;
  52740. /**
  52741. * Gamepad Id prefix used to identify Daydream Controller.
  52742. */
  52743. static readonly GAMEPAD_ID_PREFIX: string;
  52744. /**
  52745. * Creates a new DaydreamController from a gamepad
  52746. * @param vrGamepad the gamepad that the controller should be created from
  52747. */
  52748. constructor(vrGamepad: any);
  52749. /**
  52750. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52751. * @param scene scene in which to add meshes
  52752. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52753. */
  52754. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52755. /**
  52756. * Called once for each button that changed state since the last frame
  52757. * @param buttonIdx Which button index changed
  52758. * @param state New state of the button
  52759. * @param changes Which properties on the state changed since last frame
  52760. */
  52761. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52762. }
  52763. }
  52764. declare module BABYLON {
  52765. /**
  52766. * Gear VR Controller
  52767. */
  52768. export class GearVRController extends WebVRController {
  52769. /**
  52770. * Base Url for the controller model.
  52771. */
  52772. static MODEL_BASE_URL: string;
  52773. /**
  52774. * File name for the controller model.
  52775. */
  52776. static MODEL_FILENAME: string;
  52777. /**
  52778. * Gamepad Id prefix used to identify this controller.
  52779. */
  52780. static readonly GAMEPAD_ID_PREFIX: string;
  52781. private readonly _buttonIndexToObservableNameMap;
  52782. /**
  52783. * Creates a new GearVRController from a gamepad
  52784. * @param vrGamepad the gamepad that the controller should be created from
  52785. */
  52786. constructor(vrGamepad: any);
  52787. /**
  52788. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52789. * @param scene scene in which to add meshes
  52790. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52791. */
  52792. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52793. /**
  52794. * Called once for each button that changed state since the last frame
  52795. * @param buttonIdx Which button index changed
  52796. * @param state New state of the button
  52797. * @param changes Which properties on the state changed since last frame
  52798. */
  52799. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52800. }
  52801. }
  52802. declare module BABYLON {
  52803. /**
  52804. * Generic Controller
  52805. */
  52806. export class GenericController extends WebVRController {
  52807. /**
  52808. * Base Url for the controller model.
  52809. */
  52810. static readonly MODEL_BASE_URL: string;
  52811. /**
  52812. * File name for the controller model.
  52813. */
  52814. static readonly MODEL_FILENAME: string;
  52815. /**
  52816. * Creates a new GenericController from a gamepad
  52817. * @param vrGamepad the gamepad that the controller should be created from
  52818. */
  52819. constructor(vrGamepad: any);
  52820. /**
  52821. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52822. * @param scene scene in which to add meshes
  52823. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52824. */
  52825. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52826. /**
  52827. * Called once for each button that changed state since the last frame
  52828. * @param buttonIdx Which button index changed
  52829. * @param state New state of the button
  52830. * @param changes Which properties on the state changed since last frame
  52831. */
  52832. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52833. }
  52834. }
  52835. declare module BABYLON {
  52836. /**
  52837. * Oculus Touch Controller
  52838. */
  52839. export class OculusTouchController extends WebVRController {
  52840. /**
  52841. * Base Url for the controller model.
  52842. */
  52843. static MODEL_BASE_URL: string;
  52844. /**
  52845. * File name for the left controller model.
  52846. */
  52847. static MODEL_LEFT_FILENAME: string;
  52848. /**
  52849. * File name for the right controller model.
  52850. */
  52851. static MODEL_RIGHT_FILENAME: string;
  52852. /**
  52853. * Base Url for the Quest controller model.
  52854. */
  52855. static QUEST_MODEL_BASE_URL: string;
  52856. /**
  52857. * @hidden
  52858. * If the controllers are running on a device that needs the updated Quest controller models
  52859. */
  52860. static _IsQuest: boolean;
  52861. /**
  52862. * Fired when the secondary trigger on this controller is modified
  52863. */
  52864. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  52865. /**
  52866. * Fired when the thumb rest on this controller is modified
  52867. */
  52868. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  52869. /**
  52870. * Creates a new OculusTouchController from a gamepad
  52871. * @param vrGamepad the gamepad that the controller should be created from
  52872. */
  52873. constructor(vrGamepad: any);
  52874. /**
  52875. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52876. * @param scene scene in which to add meshes
  52877. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52878. */
  52879. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52880. /**
  52881. * Fired when the A button on this controller is modified
  52882. */
  52883. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52884. /**
  52885. * Fired when the B button on this controller is modified
  52886. */
  52887. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52888. /**
  52889. * Fired when the X button on this controller is modified
  52890. */
  52891. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52892. /**
  52893. * Fired when the Y button on this controller is modified
  52894. */
  52895. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52896. /**
  52897. * Called once for each button that changed state since the last frame
  52898. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  52899. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  52900. * 2) secondary trigger (same)
  52901. * 3) A (right) X (left), touch, pressed = value
  52902. * 4) B / Y
  52903. * 5) thumb rest
  52904. * @param buttonIdx Which button index changed
  52905. * @param state New state of the button
  52906. * @param changes Which properties on the state changed since last frame
  52907. */
  52908. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52909. }
  52910. }
  52911. declare module BABYLON {
  52912. /**
  52913. * Vive Controller
  52914. */
  52915. export class ViveController extends WebVRController {
  52916. /**
  52917. * Base Url for the controller model.
  52918. */
  52919. static MODEL_BASE_URL: string;
  52920. /**
  52921. * File name for the controller model.
  52922. */
  52923. static MODEL_FILENAME: string;
  52924. /**
  52925. * Creates a new ViveController from a gamepad
  52926. * @param vrGamepad the gamepad that the controller should be created from
  52927. */
  52928. constructor(vrGamepad: any);
  52929. /**
  52930. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52931. * @param scene scene in which to add meshes
  52932. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52933. */
  52934. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52935. /**
  52936. * Fired when the left button on this controller is modified
  52937. */
  52938. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52939. /**
  52940. * Fired when the right button on this controller is modified
  52941. */
  52942. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52943. /**
  52944. * Fired when the menu button on this controller is modified
  52945. */
  52946. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52947. /**
  52948. * Called once for each button that changed state since the last frame
  52949. * Vive mapping:
  52950. * 0: touchpad
  52951. * 1: trigger
  52952. * 2: left AND right buttons
  52953. * 3: menu button
  52954. * @param buttonIdx Which button index changed
  52955. * @param state New state of the button
  52956. * @param changes Which properties on the state changed since last frame
  52957. */
  52958. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52959. }
  52960. }
  52961. declare module BABYLON {
  52962. /**
  52963. * Defines the WindowsMotionController object that the state of the windows motion controller
  52964. */
  52965. export class WindowsMotionController extends WebVRController {
  52966. /**
  52967. * The base url used to load the left and right controller models
  52968. */
  52969. static MODEL_BASE_URL: string;
  52970. /**
  52971. * The name of the left controller model file
  52972. */
  52973. static MODEL_LEFT_FILENAME: string;
  52974. /**
  52975. * The name of the right controller model file
  52976. */
  52977. static MODEL_RIGHT_FILENAME: string;
  52978. /**
  52979. * The controller name prefix for this controller type
  52980. */
  52981. static readonly GAMEPAD_ID_PREFIX: string;
  52982. /**
  52983. * The controller id pattern for this controller type
  52984. */
  52985. private static readonly GAMEPAD_ID_PATTERN;
  52986. private _loadedMeshInfo;
  52987. protected readonly _mapping: {
  52988. buttons: string[];
  52989. buttonMeshNames: {
  52990. trigger: string;
  52991. menu: string;
  52992. grip: string;
  52993. thumbstick: string;
  52994. trackpad: string;
  52995. };
  52996. buttonObservableNames: {
  52997. trigger: string;
  52998. menu: string;
  52999. grip: string;
  53000. thumbstick: string;
  53001. trackpad: string;
  53002. };
  53003. axisMeshNames: string[];
  53004. pointingPoseMeshName: string;
  53005. };
  53006. /**
  53007. * Fired when the trackpad on this controller is clicked
  53008. */
  53009. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53010. /**
  53011. * Fired when the trackpad on this controller is modified
  53012. */
  53013. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53014. /**
  53015. * The current x and y values of this controller's trackpad
  53016. */
  53017. trackpad: StickValues;
  53018. /**
  53019. * Creates a new WindowsMotionController from a gamepad
  53020. * @param vrGamepad the gamepad that the controller should be created from
  53021. */
  53022. constructor(vrGamepad: any);
  53023. /**
  53024. * Fired when the trigger on this controller is modified
  53025. */
  53026. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53027. /**
  53028. * Fired when the menu button on this controller is modified
  53029. */
  53030. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53031. /**
  53032. * Fired when the grip button on this controller is modified
  53033. */
  53034. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53035. /**
  53036. * Fired when the thumbstick button on this controller is modified
  53037. */
  53038. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53039. /**
  53040. * Fired when the touchpad button on this controller is modified
  53041. */
  53042. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53043. /**
  53044. * Fired when the touchpad values on this controller are modified
  53045. */
  53046. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  53047. protected _updateTrackpad(): void;
  53048. /**
  53049. * Called once per frame by the engine.
  53050. */
  53051. update(): void;
  53052. /**
  53053. * Called once for each button that changed state since the last frame
  53054. * @param buttonIdx Which button index changed
  53055. * @param state New state of the button
  53056. * @param changes Which properties on the state changed since last frame
  53057. */
  53058. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53059. /**
  53060. * Moves the buttons on the controller mesh based on their current state
  53061. * @param buttonName the name of the button to move
  53062. * @param buttonValue the value of the button which determines the buttons new position
  53063. */
  53064. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  53065. /**
  53066. * Moves the axis on the controller mesh based on its current state
  53067. * @param axis the index of the axis
  53068. * @param axisValue the value of the axis which determines the meshes new position
  53069. * @hidden
  53070. */
  53071. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  53072. /**
  53073. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53074. * @param scene scene in which to add meshes
  53075. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53076. */
  53077. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  53078. /**
  53079. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  53080. * can be transformed by button presses and axes values, based on this._mapping.
  53081. *
  53082. * @param scene scene in which the meshes exist
  53083. * @param meshes list of meshes that make up the controller model to process
  53084. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  53085. */
  53086. private processModel;
  53087. private createMeshInfo;
  53088. /**
  53089. * Gets the ray of the controller in the direction the controller is pointing
  53090. * @param length the length the resulting ray should be
  53091. * @returns a ray in the direction the controller is pointing
  53092. */
  53093. getForwardRay(length?: number): Ray;
  53094. /**
  53095. * Disposes of the controller
  53096. */
  53097. dispose(): void;
  53098. }
  53099. /**
  53100. * This class represents a new windows motion controller in XR.
  53101. */
  53102. export class XRWindowsMotionController extends WindowsMotionController {
  53103. /**
  53104. * Changing the original WIndowsMotionController mapping to fir the new mapping
  53105. */
  53106. protected readonly _mapping: {
  53107. buttons: string[];
  53108. buttonMeshNames: {
  53109. trigger: string;
  53110. menu: string;
  53111. grip: string;
  53112. thumbstick: string;
  53113. trackpad: string;
  53114. };
  53115. buttonObservableNames: {
  53116. trigger: string;
  53117. menu: string;
  53118. grip: string;
  53119. thumbstick: string;
  53120. trackpad: string;
  53121. };
  53122. axisMeshNames: string[];
  53123. pointingPoseMeshName: string;
  53124. };
  53125. /**
  53126. * Construct a new XR-Based windows motion controller
  53127. *
  53128. * @param gamepadInfo the gamepad object from the browser
  53129. */
  53130. constructor(gamepadInfo: any);
  53131. /**
  53132. * holds the thumbstick values (X,Y)
  53133. */
  53134. thumbstickValues: StickValues;
  53135. /**
  53136. * Fired when the thumbstick on this controller is clicked
  53137. */
  53138. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  53139. /**
  53140. * Fired when the thumbstick on this controller is modified
  53141. */
  53142. onThumbstickValuesChangedObservable: Observable<StickValues>;
  53143. /**
  53144. * Fired when the touchpad button on this controller is modified
  53145. */
  53146. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53147. /**
  53148. * Fired when the touchpad values on this controller are modified
  53149. */
  53150. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53151. /**
  53152. * Fired when the thumbstick button on this controller is modified
  53153. * here to prevent breaking changes
  53154. */
  53155. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53156. /**
  53157. * updating the thumbstick(!) and not the trackpad.
  53158. * This is named this way due to the difference between WebVR and XR and to avoid
  53159. * changing the parent class.
  53160. */
  53161. protected _updateTrackpad(): void;
  53162. /**
  53163. * Disposes the class with joy
  53164. */
  53165. dispose(): void;
  53166. }
  53167. }
  53168. declare module BABYLON {
  53169. /**
  53170. * Class containing static functions to help procedurally build meshes
  53171. */
  53172. export class PolyhedronBuilder {
  53173. /**
  53174. * Creates a polyhedron mesh
  53175. * * 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
  53176. * * The parameter `size` (positive float, default 1) sets the polygon size
  53177. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  53178. * * 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`
  53179. * * 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
  53180. * * 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)`)
  53181. * * 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
  53182. * * 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
  53183. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53184. * * 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
  53185. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53186. * @param name defines the name of the mesh
  53187. * @param options defines the options used to create the mesh
  53188. * @param scene defines the hosting scene
  53189. * @returns the polyhedron mesh
  53190. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  53191. */
  53192. static CreatePolyhedron(name: string, options: {
  53193. type?: number;
  53194. size?: number;
  53195. sizeX?: number;
  53196. sizeY?: number;
  53197. sizeZ?: number;
  53198. custom?: any;
  53199. faceUV?: Vector4[];
  53200. faceColors?: Color4[];
  53201. flat?: boolean;
  53202. updatable?: boolean;
  53203. sideOrientation?: number;
  53204. frontUVs?: Vector4;
  53205. backUVs?: Vector4;
  53206. }, scene?: Nullable<Scene>): Mesh;
  53207. }
  53208. }
  53209. declare module BABYLON {
  53210. /**
  53211. * Gizmo that enables scaling a mesh along 3 axis
  53212. */
  53213. export class ScaleGizmo extends Gizmo {
  53214. /**
  53215. * Internal gizmo used for interactions on the x axis
  53216. */
  53217. xGizmo: AxisScaleGizmo;
  53218. /**
  53219. * Internal gizmo used for interactions on the y axis
  53220. */
  53221. yGizmo: AxisScaleGizmo;
  53222. /**
  53223. * Internal gizmo used for interactions on the z axis
  53224. */
  53225. zGizmo: AxisScaleGizmo;
  53226. /**
  53227. * Internal gizmo used to scale all axis equally
  53228. */
  53229. uniformScaleGizmo: AxisScaleGizmo;
  53230. private _meshAttached;
  53231. private _nodeAttached;
  53232. private _updateGizmoRotationToMatchAttachedMesh;
  53233. private _snapDistance;
  53234. private _scaleRatio;
  53235. private _uniformScalingMesh;
  53236. private _octahedron;
  53237. private _sensitivity;
  53238. /** Fires an event when any of it's sub gizmos are dragged */
  53239. onDragStartObservable: Observable<unknown>;
  53240. /** Fires an event when any of it's sub gizmos are released from dragging */
  53241. onDragEndObservable: Observable<unknown>;
  53242. get attachedMesh(): Nullable<AbstractMesh>;
  53243. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53244. get attachedNode(): Nullable<Node>;
  53245. set attachedNode(node: Nullable<Node>);
  53246. /**
  53247. * Creates a ScaleGizmo
  53248. * @param gizmoLayer The utility layer the gizmo will be added to
  53249. * @param thickness display gizmo axis thickness
  53250. */
  53251. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  53252. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53253. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53254. /**
  53255. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53256. */
  53257. set snapDistance(value: number);
  53258. get snapDistance(): number;
  53259. /**
  53260. * Ratio for the scale of the gizmo (Default: 1)
  53261. */
  53262. set scaleRatio(value: number);
  53263. get scaleRatio(): number;
  53264. /**
  53265. * Sensitivity factor for dragging (Default: 1)
  53266. */
  53267. set sensitivity(value: number);
  53268. get sensitivity(): number;
  53269. /**
  53270. * Disposes of the gizmo
  53271. */
  53272. dispose(): void;
  53273. }
  53274. }
  53275. declare module BABYLON {
  53276. /**
  53277. * Single axis scale gizmo
  53278. */
  53279. export class AxisScaleGizmo extends Gizmo {
  53280. /**
  53281. * Drag behavior responsible for the gizmos dragging interactions
  53282. */
  53283. dragBehavior: PointerDragBehavior;
  53284. private _pointerObserver;
  53285. /**
  53286. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53287. */
  53288. snapDistance: number;
  53289. /**
  53290. * Event that fires each time the gizmo snaps to a new location.
  53291. * * snapDistance is the the change in distance
  53292. */
  53293. onSnapObservable: Observable<{
  53294. snapDistance: number;
  53295. }>;
  53296. /**
  53297. * If the scaling operation should be done on all axis (default: false)
  53298. */
  53299. uniformScaling: boolean;
  53300. /**
  53301. * Custom sensitivity value for the drag strength
  53302. */
  53303. sensitivity: number;
  53304. private _isEnabled;
  53305. private _parent;
  53306. private _arrow;
  53307. private _coloredMaterial;
  53308. private _hoverMaterial;
  53309. /**
  53310. * Creates an AxisScaleGizmo
  53311. * @param gizmoLayer The utility layer the gizmo will be added to
  53312. * @param dragAxis The axis which the gizmo will be able to scale on
  53313. * @param color The color of the gizmo
  53314. * @param thickness display gizmo axis thickness
  53315. */
  53316. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  53317. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53318. /**
  53319. * If the gizmo is enabled
  53320. */
  53321. set isEnabled(value: boolean);
  53322. get isEnabled(): boolean;
  53323. /**
  53324. * Disposes of the gizmo
  53325. */
  53326. dispose(): void;
  53327. /**
  53328. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  53329. * @param mesh The mesh to replace the default mesh of the gizmo
  53330. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  53331. */
  53332. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  53333. }
  53334. }
  53335. declare module BABYLON {
  53336. /**
  53337. * Bounding box gizmo
  53338. */
  53339. export class BoundingBoxGizmo extends Gizmo {
  53340. private _lineBoundingBox;
  53341. private _rotateSpheresParent;
  53342. private _scaleBoxesParent;
  53343. private _boundingDimensions;
  53344. private _renderObserver;
  53345. private _pointerObserver;
  53346. private _scaleDragSpeed;
  53347. private _tmpQuaternion;
  53348. private _tmpVector;
  53349. private _tmpRotationMatrix;
  53350. /**
  53351. * 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)
  53352. */
  53353. ignoreChildren: boolean;
  53354. /**
  53355. * 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)
  53356. */
  53357. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  53358. /**
  53359. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  53360. */
  53361. rotationSphereSize: number;
  53362. /**
  53363. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  53364. */
  53365. scaleBoxSize: number;
  53366. /**
  53367. * 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)
  53368. */
  53369. fixedDragMeshScreenSize: boolean;
  53370. /**
  53371. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  53372. */
  53373. fixedDragMeshScreenSizeDistanceFactor: number;
  53374. /**
  53375. * Fired when a rotation sphere or scale box is dragged
  53376. */
  53377. onDragStartObservable: Observable<{}>;
  53378. /**
  53379. * Fired when a scale box is dragged
  53380. */
  53381. onScaleBoxDragObservable: Observable<{}>;
  53382. /**
  53383. * Fired when a scale box drag is ended
  53384. */
  53385. onScaleBoxDragEndObservable: Observable<{}>;
  53386. /**
  53387. * Fired when a rotation sphere is dragged
  53388. */
  53389. onRotationSphereDragObservable: Observable<{}>;
  53390. /**
  53391. * Fired when a rotation sphere drag is ended
  53392. */
  53393. onRotationSphereDragEndObservable: Observable<{}>;
  53394. /**
  53395. * 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)
  53396. */
  53397. scalePivot: Nullable<Vector3>;
  53398. /**
  53399. * Mesh used as a pivot to rotate the attached node
  53400. */
  53401. private _anchorMesh;
  53402. private _existingMeshScale;
  53403. private _dragMesh;
  53404. private pointerDragBehavior;
  53405. private coloredMaterial;
  53406. private hoverColoredMaterial;
  53407. /**
  53408. * Sets the color of the bounding box gizmo
  53409. * @param color the color to set
  53410. */
  53411. setColor(color: Color3): void;
  53412. /**
  53413. * Creates an BoundingBoxGizmo
  53414. * @param gizmoLayer The utility layer the gizmo will be added to
  53415. * @param color The color of the gizmo
  53416. */
  53417. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  53418. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  53419. private _selectNode;
  53420. /**
  53421. * Updates the bounding box information for the Gizmo
  53422. */
  53423. updateBoundingBox(): void;
  53424. private _updateRotationSpheres;
  53425. private _updateScaleBoxes;
  53426. /**
  53427. * Enables rotation on the specified axis and disables rotation on the others
  53428. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  53429. */
  53430. setEnabledRotationAxis(axis: string): void;
  53431. /**
  53432. * Enables/disables scaling
  53433. * @param enable if scaling should be enabled
  53434. * @param homogeneousScaling defines if scaling should only be homogeneous
  53435. */
  53436. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  53437. private _updateDummy;
  53438. /**
  53439. * Enables a pointer drag behavior on the bounding box of the gizmo
  53440. */
  53441. enableDragBehavior(): void;
  53442. /**
  53443. * Disposes of the gizmo
  53444. */
  53445. dispose(): void;
  53446. /**
  53447. * 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)
  53448. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  53449. * @returns the bounding box mesh with the passed in mesh as a child
  53450. */
  53451. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  53452. /**
  53453. * CustomMeshes are not supported by this gizmo
  53454. * @param mesh The mesh to replace the default mesh of the gizmo
  53455. */
  53456. setCustomMesh(mesh: Mesh): void;
  53457. }
  53458. }
  53459. declare module BABYLON {
  53460. /**
  53461. * Single plane rotation gizmo
  53462. */
  53463. export class PlaneRotationGizmo extends Gizmo {
  53464. /**
  53465. * Drag behavior responsible for the gizmos dragging interactions
  53466. */
  53467. dragBehavior: PointerDragBehavior;
  53468. private _pointerObserver;
  53469. /**
  53470. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  53471. */
  53472. snapDistance: number;
  53473. /**
  53474. * Event that fires each time the gizmo snaps to a new location.
  53475. * * snapDistance is the the change in distance
  53476. */
  53477. onSnapObservable: Observable<{
  53478. snapDistance: number;
  53479. }>;
  53480. private _isEnabled;
  53481. private _parent;
  53482. /**
  53483. * Creates a PlaneRotationGizmo
  53484. * @param gizmoLayer The utility layer the gizmo will be added to
  53485. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  53486. * @param color The color of the gizmo
  53487. * @param tessellation Amount of tessellation to be used when creating rotation circles
  53488. * @param useEulerRotation Use and update Euler angle instead of quaternion
  53489. * @param thickness display gizmo axis thickness
  53490. */
  53491. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  53492. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53493. /**
  53494. * If the gizmo is enabled
  53495. */
  53496. set isEnabled(value: boolean);
  53497. get isEnabled(): boolean;
  53498. /**
  53499. * Disposes of the gizmo
  53500. */
  53501. dispose(): void;
  53502. }
  53503. }
  53504. declare module BABYLON {
  53505. /**
  53506. * Gizmo that enables rotating a mesh along 3 axis
  53507. */
  53508. export class RotationGizmo extends Gizmo {
  53509. /**
  53510. * Internal gizmo used for interactions on the x axis
  53511. */
  53512. xGizmo: PlaneRotationGizmo;
  53513. /**
  53514. * Internal gizmo used for interactions on the y axis
  53515. */
  53516. yGizmo: PlaneRotationGizmo;
  53517. /**
  53518. * Internal gizmo used for interactions on the z axis
  53519. */
  53520. zGizmo: PlaneRotationGizmo;
  53521. /** Fires an event when any of it's sub gizmos are dragged */
  53522. onDragStartObservable: Observable<unknown>;
  53523. /** Fires an event when any of it's sub gizmos are released from dragging */
  53524. onDragEndObservable: Observable<unknown>;
  53525. private _meshAttached;
  53526. private _nodeAttached;
  53527. get attachedMesh(): Nullable<AbstractMesh>;
  53528. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53529. get attachedNode(): Nullable<Node>;
  53530. set attachedNode(node: Nullable<Node>);
  53531. /**
  53532. * Creates a RotationGizmo
  53533. * @param gizmoLayer The utility layer the gizmo will be added to
  53534. * @param tessellation Amount of tessellation to be used when creating rotation circles
  53535. * @param useEulerRotation Use and update Euler angle instead of quaternion
  53536. * @param thickness display gizmo axis thickness
  53537. */
  53538. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  53539. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53540. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53541. /**
  53542. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53543. */
  53544. set snapDistance(value: number);
  53545. get snapDistance(): number;
  53546. /**
  53547. * Ratio for the scale of the gizmo (Default: 1)
  53548. */
  53549. set scaleRatio(value: number);
  53550. get scaleRatio(): number;
  53551. /**
  53552. * Disposes of the gizmo
  53553. */
  53554. dispose(): void;
  53555. /**
  53556. * CustomMeshes are not supported by this gizmo
  53557. * @param mesh The mesh to replace the default mesh of the gizmo
  53558. */
  53559. setCustomMesh(mesh: Mesh): void;
  53560. }
  53561. }
  53562. declare module BABYLON {
  53563. /**
  53564. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  53565. */
  53566. export class GizmoManager implements IDisposable {
  53567. private scene;
  53568. /**
  53569. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  53570. */
  53571. gizmos: {
  53572. positionGizmo: Nullable<PositionGizmo>;
  53573. rotationGizmo: Nullable<RotationGizmo>;
  53574. scaleGizmo: Nullable<ScaleGizmo>;
  53575. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  53576. };
  53577. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  53578. clearGizmoOnEmptyPointerEvent: boolean;
  53579. /** Fires an event when the manager is attached to a mesh */
  53580. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  53581. private _gizmosEnabled;
  53582. private _pointerObserver;
  53583. private _attachedMesh;
  53584. private _boundingBoxColor;
  53585. private _defaultUtilityLayer;
  53586. private _defaultKeepDepthUtilityLayer;
  53587. private _thickness;
  53588. /**
  53589. * When bounding box gizmo is enabled, this can be used to track drag/end events
  53590. */
  53591. boundingBoxDragBehavior: SixDofDragBehavior;
  53592. /**
  53593. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  53594. */
  53595. attachableMeshes: Nullable<Array<AbstractMesh>>;
  53596. /**
  53597. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  53598. */
  53599. usePointerToAttachGizmos: boolean;
  53600. /**
  53601. * Utility layer that the bounding box gizmo belongs to
  53602. */
  53603. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  53604. /**
  53605. * Utility layer that all gizmos besides bounding box belong to
  53606. */
  53607. get utilityLayer(): UtilityLayerRenderer;
  53608. /**
  53609. * Instatiates a gizmo manager
  53610. * @param scene the scene to overlay the gizmos on top of
  53611. * @param thickness display gizmo axis thickness
  53612. */
  53613. constructor(scene: Scene, thickness?: number);
  53614. /**
  53615. * Attaches a set of gizmos to the specified mesh
  53616. * @param mesh The mesh the gizmo's should be attached to
  53617. */
  53618. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53619. /**
  53620. * If the position gizmo is enabled
  53621. */
  53622. set positionGizmoEnabled(value: boolean);
  53623. get positionGizmoEnabled(): boolean;
  53624. /**
  53625. * If the rotation gizmo is enabled
  53626. */
  53627. set rotationGizmoEnabled(value: boolean);
  53628. get rotationGizmoEnabled(): boolean;
  53629. /**
  53630. * If the scale gizmo is enabled
  53631. */
  53632. set scaleGizmoEnabled(value: boolean);
  53633. get scaleGizmoEnabled(): boolean;
  53634. /**
  53635. * If the boundingBox gizmo is enabled
  53636. */
  53637. set boundingBoxGizmoEnabled(value: boolean);
  53638. get boundingBoxGizmoEnabled(): boolean;
  53639. /**
  53640. * Disposes of the gizmo manager
  53641. */
  53642. dispose(): void;
  53643. }
  53644. }
  53645. declare module BABYLON {
  53646. /**
  53647. * A directional light is defined by a direction (what a surprise!).
  53648. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  53649. * 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.
  53650. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53651. */
  53652. export class DirectionalLight extends ShadowLight {
  53653. private _shadowFrustumSize;
  53654. /**
  53655. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  53656. */
  53657. get shadowFrustumSize(): number;
  53658. /**
  53659. * Specifies a fix frustum size for the shadow generation.
  53660. */
  53661. set shadowFrustumSize(value: number);
  53662. private _shadowOrthoScale;
  53663. /**
  53664. * Gets the shadow projection scale against the optimal computed one.
  53665. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  53666. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  53667. */
  53668. get shadowOrthoScale(): number;
  53669. /**
  53670. * Sets the shadow projection scale against the optimal computed one.
  53671. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  53672. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  53673. */
  53674. set shadowOrthoScale(value: number);
  53675. /**
  53676. * Automatically compute the projection matrix to best fit (including all the casters)
  53677. * on each frame.
  53678. */
  53679. autoUpdateExtends: boolean;
  53680. /**
  53681. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  53682. * on each frame. autoUpdateExtends must be set to true for this to work
  53683. */
  53684. autoCalcShadowZBounds: boolean;
  53685. private _orthoLeft;
  53686. private _orthoRight;
  53687. private _orthoTop;
  53688. private _orthoBottom;
  53689. /**
  53690. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  53691. * The directional light is emitted from everywhere in the given direction.
  53692. * It can cast shadows.
  53693. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53694. * @param name The friendly name of the light
  53695. * @param direction The direction of the light
  53696. * @param scene The scene the light belongs to
  53697. */
  53698. constructor(name: string, direction: Vector3, scene: Scene);
  53699. /**
  53700. * Returns the string "DirectionalLight".
  53701. * @return The class name
  53702. */
  53703. getClassName(): string;
  53704. /**
  53705. * Returns the integer 1.
  53706. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53707. */
  53708. getTypeID(): number;
  53709. /**
  53710. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  53711. * Returns the DirectionalLight Shadow projection matrix.
  53712. */
  53713. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53714. /**
  53715. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  53716. * Returns the DirectionalLight Shadow projection matrix.
  53717. */
  53718. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  53719. /**
  53720. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  53721. * Returns the DirectionalLight Shadow projection matrix.
  53722. */
  53723. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53724. protected _buildUniformLayout(): void;
  53725. /**
  53726. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  53727. * @param effect The effect to update
  53728. * @param lightIndex The index of the light in the effect to update
  53729. * @returns The directional light
  53730. */
  53731. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  53732. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  53733. /**
  53734. * Gets the minZ used for shadow according to both the scene and the light.
  53735. *
  53736. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  53737. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  53738. * @param activeCamera The camera we are returning the min for
  53739. * @returns the depth min z
  53740. */
  53741. getDepthMinZ(activeCamera: Camera): number;
  53742. /**
  53743. * Gets the maxZ used for shadow according to both the scene and the light.
  53744. *
  53745. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  53746. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  53747. * @param activeCamera The camera we are returning the max for
  53748. * @returns the depth max z
  53749. */
  53750. getDepthMaxZ(activeCamera: Camera): number;
  53751. /**
  53752. * Prepares the list of defines specific to the light type.
  53753. * @param defines the list of defines
  53754. * @param lightIndex defines the index of the light for the effect
  53755. */
  53756. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53757. }
  53758. }
  53759. declare module BABYLON {
  53760. /**
  53761. * Class containing static functions to help procedurally build meshes
  53762. */
  53763. export class HemisphereBuilder {
  53764. /**
  53765. * Creates a hemisphere mesh
  53766. * @param name defines the name of the mesh
  53767. * @param options defines the options used to create the mesh
  53768. * @param scene defines the hosting scene
  53769. * @returns the hemisphere mesh
  53770. */
  53771. static CreateHemisphere(name: string, options: {
  53772. segments?: number;
  53773. diameter?: number;
  53774. sideOrientation?: number;
  53775. }, scene: any): Mesh;
  53776. }
  53777. }
  53778. declare module BABYLON {
  53779. /**
  53780. * A spot light is defined by a position, a direction, an angle, and an exponent.
  53781. * These values define a cone of light starting from the position, emitting toward the direction.
  53782. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  53783. * and the exponent defines the speed of the decay of the light with distance (reach).
  53784. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53785. */
  53786. export class SpotLight extends ShadowLight {
  53787. private _angle;
  53788. private _innerAngle;
  53789. private _cosHalfAngle;
  53790. private _lightAngleScale;
  53791. private _lightAngleOffset;
  53792. /**
  53793. * Gets the cone angle of the spot light in Radians.
  53794. */
  53795. get angle(): number;
  53796. /**
  53797. * Sets the cone angle of the spot light in Radians.
  53798. */
  53799. set angle(value: number);
  53800. /**
  53801. * Only used in gltf falloff mode, this defines the angle where
  53802. * the directional falloff will start before cutting at angle which could be seen
  53803. * as outer angle.
  53804. */
  53805. get innerAngle(): number;
  53806. /**
  53807. * Only used in gltf falloff mode, this defines the angle where
  53808. * the directional falloff will start before cutting at angle which could be seen
  53809. * as outer angle.
  53810. */
  53811. set innerAngle(value: number);
  53812. private _shadowAngleScale;
  53813. /**
  53814. * Allows scaling the angle of the light for shadow generation only.
  53815. */
  53816. get shadowAngleScale(): number;
  53817. /**
  53818. * Allows scaling the angle of the light for shadow generation only.
  53819. */
  53820. set shadowAngleScale(value: number);
  53821. /**
  53822. * The light decay speed with the distance from the emission spot.
  53823. */
  53824. exponent: number;
  53825. private _projectionTextureMatrix;
  53826. /**
  53827. * Allows reading the projecton texture
  53828. */
  53829. get projectionTextureMatrix(): Matrix;
  53830. protected _projectionTextureLightNear: number;
  53831. /**
  53832. * Gets the near clip of the Spotlight for texture projection.
  53833. */
  53834. get projectionTextureLightNear(): number;
  53835. /**
  53836. * Sets the near clip of the Spotlight for texture projection.
  53837. */
  53838. set projectionTextureLightNear(value: number);
  53839. protected _projectionTextureLightFar: number;
  53840. /**
  53841. * Gets the far clip of the Spotlight for texture projection.
  53842. */
  53843. get projectionTextureLightFar(): number;
  53844. /**
  53845. * Sets the far clip of the Spotlight for texture projection.
  53846. */
  53847. set projectionTextureLightFar(value: number);
  53848. protected _projectionTextureUpDirection: Vector3;
  53849. /**
  53850. * Gets the Up vector of the Spotlight for texture projection.
  53851. */
  53852. get projectionTextureUpDirection(): Vector3;
  53853. /**
  53854. * Sets the Up vector of the Spotlight for texture projection.
  53855. */
  53856. set projectionTextureUpDirection(value: Vector3);
  53857. private _projectionTexture;
  53858. /**
  53859. * Gets the projection texture of the light.
  53860. */
  53861. get projectionTexture(): Nullable<BaseTexture>;
  53862. /**
  53863. * Sets the projection texture of the light.
  53864. */
  53865. set projectionTexture(value: Nullable<BaseTexture>);
  53866. private _projectionTextureViewLightDirty;
  53867. private _projectionTextureProjectionLightDirty;
  53868. private _projectionTextureDirty;
  53869. private _projectionTextureViewTargetVector;
  53870. private _projectionTextureViewLightMatrix;
  53871. private _projectionTextureProjectionLightMatrix;
  53872. private _projectionTextureScalingMatrix;
  53873. /**
  53874. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  53875. * It can cast shadows.
  53876. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53877. * @param name The light friendly name
  53878. * @param position The position of the spot light in the scene
  53879. * @param direction The direction of the light in the scene
  53880. * @param angle The cone angle of the light in Radians
  53881. * @param exponent The light decay speed with the distance from the emission spot
  53882. * @param scene The scene the lights belongs to
  53883. */
  53884. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  53885. /**
  53886. * Returns the string "SpotLight".
  53887. * @returns the class name
  53888. */
  53889. getClassName(): string;
  53890. /**
  53891. * Returns the integer 2.
  53892. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53893. */
  53894. getTypeID(): number;
  53895. /**
  53896. * Overrides the direction setter to recompute the projection texture view light Matrix.
  53897. */
  53898. protected _setDirection(value: Vector3): void;
  53899. /**
  53900. * Overrides the position setter to recompute the projection texture view light Matrix.
  53901. */
  53902. protected _setPosition(value: Vector3): void;
  53903. /**
  53904. * 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.
  53905. * Returns the SpotLight.
  53906. */
  53907. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53908. protected _computeProjectionTextureViewLightMatrix(): void;
  53909. protected _computeProjectionTextureProjectionLightMatrix(): void;
  53910. /**
  53911. * Main function for light texture projection matrix computing.
  53912. */
  53913. protected _computeProjectionTextureMatrix(): void;
  53914. protected _buildUniformLayout(): void;
  53915. private _computeAngleValues;
  53916. /**
  53917. * Sets the passed Effect "effect" with the Light textures.
  53918. * @param effect The effect to update
  53919. * @param lightIndex The index of the light in the effect to update
  53920. * @returns The light
  53921. */
  53922. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  53923. /**
  53924. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  53925. * @param effect The effect to update
  53926. * @param lightIndex The index of the light in the effect to update
  53927. * @returns The spot light
  53928. */
  53929. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  53930. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  53931. /**
  53932. * Disposes the light and the associated resources.
  53933. */
  53934. dispose(): void;
  53935. /**
  53936. * Prepares the list of defines specific to the light type.
  53937. * @param defines the list of defines
  53938. * @param lightIndex defines the index of the light for the effect
  53939. */
  53940. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53941. }
  53942. }
  53943. declare module BABYLON {
  53944. /**
  53945. * Gizmo that enables viewing a light
  53946. */
  53947. export class LightGizmo extends Gizmo {
  53948. private _lightMesh;
  53949. private _material;
  53950. private _cachedPosition;
  53951. private _cachedForward;
  53952. private _attachedMeshParent;
  53953. /**
  53954. * Creates a LightGizmo
  53955. * @param gizmoLayer The utility layer the gizmo will be added to
  53956. */
  53957. constructor(gizmoLayer?: UtilityLayerRenderer);
  53958. private _light;
  53959. /**
  53960. * The light that the gizmo is attached to
  53961. */
  53962. set light(light: Nullable<Light>);
  53963. get light(): Nullable<Light>;
  53964. /**
  53965. * Gets the material used to render the light gizmo
  53966. */
  53967. get material(): StandardMaterial;
  53968. /**
  53969. * @hidden
  53970. * Updates the gizmo to match the attached mesh's position/rotation
  53971. */
  53972. protected _update(): void;
  53973. private static _Scale;
  53974. /**
  53975. * Creates the lines for a light mesh
  53976. */
  53977. private static _CreateLightLines;
  53978. /**
  53979. * Disposes of the light gizmo
  53980. */
  53981. dispose(): void;
  53982. private static _CreateHemisphericLightMesh;
  53983. private static _CreatePointLightMesh;
  53984. private static _CreateSpotLightMesh;
  53985. private static _CreateDirectionalLightMesh;
  53986. }
  53987. }
  53988. declare module BABYLON {
  53989. /** @hidden */
  53990. export var backgroundFragmentDeclaration: {
  53991. name: string;
  53992. shader: string;
  53993. };
  53994. }
  53995. declare module BABYLON {
  53996. /** @hidden */
  53997. export var backgroundUboDeclaration: {
  53998. name: string;
  53999. shader: string;
  54000. };
  54001. }
  54002. declare module BABYLON {
  54003. /** @hidden */
  54004. export var backgroundPixelShader: {
  54005. name: string;
  54006. shader: string;
  54007. };
  54008. }
  54009. declare module BABYLON {
  54010. /** @hidden */
  54011. export var backgroundVertexDeclaration: {
  54012. name: string;
  54013. shader: string;
  54014. };
  54015. }
  54016. declare module BABYLON {
  54017. /** @hidden */
  54018. export var backgroundVertexShader: {
  54019. name: string;
  54020. shader: string;
  54021. };
  54022. }
  54023. declare module BABYLON {
  54024. /**
  54025. * Background material used to create an efficient environement around your scene.
  54026. */
  54027. export class BackgroundMaterial extends PushMaterial {
  54028. /**
  54029. * Standard reflectance value at parallel view angle.
  54030. */
  54031. static StandardReflectance0: number;
  54032. /**
  54033. * Standard reflectance value at grazing angle.
  54034. */
  54035. static StandardReflectance90: number;
  54036. protected _primaryColor: Color3;
  54037. /**
  54038. * Key light Color (multiply against the environement texture)
  54039. */
  54040. primaryColor: Color3;
  54041. protected __perceptualColor: Nullable<Color3>;
  54042. /**
  54043. * Experimental Internal Use Only.
  54044. *
  54045. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  54046. * This acts as a helper to set the primary color to a more "human friendly" value.
  54047. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  54048. * output color as close as possible from the chosen value.
  54049. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  54050. * part of lighting setup.)
  54051. */
  54052. get _perceptualColor(): Nullable<Color3>;
  54053. set _perceptualColor(value: Nullable<Color3>);
  54054. protected _primaryColorShadowLevel: float;
  54055. /**
  54056. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  54057. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  54058. */
  54059. get primaryColorShadowLevel(): float;
  54060. set primaryColorShadowLevel(value: float);
  54061. protected _primaryColorHighlightLevel: float;
  54062. /**
  54063. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  54064. * The primary color is used at the level chosen to define what the white area would look.
  54065. */
  54066. get primaryColorHighlightLevel(): float;
  54067. set primaryColorHighlightLevel(value: float);
  54068. protected _reflectionTexture: Nullable<BaseTexture>;
  54069. /**
  54070. * Reflection Texture used in the material.
  54071. * Should be author in a specific way for the best result (refer to the documentation).
  54072. */
  54073. reflectionTexture: Nullable<BaseTexture>;
  54074. protected _reflectionBlur: float;
  54075. /**
  54076. * Reflection Texture level of blur.
  54077. *
  54078. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  54079. * texture twice.
  54080. */
  54081. reflectionBlur: float;
  54082. protected _diffuseTexture: Nullable<BaseTexture>;
  54083. /**
  54084. * Diffuse Texture used in the material.
  54085. * Should be author in a specific way for the best result (refer to the documentation).
  54086. */
  54087. diffuseTexture: Nullable<BaseTexture>;
  54088. protected _shadowLights: Nullable<IShadowLight[]>;
  54089. /**
  54090. * Specify the list of lights casting shadow on the material.
  54091. * All scene shadow lights will be included if null.
  54092. */
  54093. shadowLights: Nullable<IShadowLight[]>;
  54094. protected _shadowLevel: float;
  54095. /**
  54096. * Helps adjusting the shadow to a softer level if required.
  54097. * 0 means black shadows and 1 means no shadows.
  54098. */
  54099. shadowLevel: float;
  54100. protected _sceneCenter: Vector3;
  54101. /**
  54102. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  54103. * It is usually zero but might be interesting to modify according to your setup.
  54104. */
  54105. sceneCenter: Vector3;
  54106. protected _opacityFresnel: boolean;
  54107. /**
  54108. * This helps specifying that the material is falling off to the sky box at grazing angle.
  54109. * This helps ensuring a nice transition when the camera goes under the ground.
  54110. */
  54111. opacityFresnel: boolean;
  54112. protected _reflectionFresnel: boolean;
  54113. /**
  54114. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  54115. * This helps adding a mirror texture on the ground.
  54116. */
  54117. reflectionFresnel: boolean;
  54118. protected _reflectionFalloffDistance: number;
  54119. /**
  54120. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  54121. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  54122. */
  54123. reflectionFalloffDistance: number;
  54124. protected _reflectionAmount: number;
  54125. /**
  54126. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  54127. */
  54128. reflectionAmount: number;
  54129. protected _reflectionReflectance0: number;
  54130. /**
  54131. * This specifies the weight of the reflection at grazing angle.
  54132. */
  54133. reflectionReflectance0: number;
  54134. protected _reflectionReflectance90: number;
  54135. /**
  54136. * This specifies the weight of the reflection at a perpendicular point of view.
  54137. */
  54138. reflectionReflectance90: number;
  54139. /**
  54140. * Sets the reflection reflectance fresnel values according to the default standard
  54141. * empirically know to work well :-)
  54142. */
  54143. set reflectionStandardFresnelWeight(value: number);
  54144. protected _useRGBColor: boolean;
  54145. /**
  54146. * Helps to directly use the maps channels instead of their level.
  54147. */
  54148. useRGBColor: boolean;
  54149. protected _enableNoise: boolean;
  54150. /**
  54151. * This helps reducing the banding effect that could occur on the background.
  54152. */
  54153. enableNoise: boolean;
  54154. /**
  54155. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54156. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  54157. * Recommended to be keep at 1.0 except for special cases.
  54158. */
  54159. get fovMultiplier(): number;
  54160. set fovMultiplier(value: number);
  54161. private _fovMultiplier;
  54162. /**
  54163. * Enable the FOV adjustment feature controlled by fovMultiplier.
  54164. */
  54165. useEquirectangularFOV: boolean;
  54166. private _maxSimultaneousLights;
  54167. /**
  54168. * Number of Simultaneous lights allowed on the material.
  54169. */
  54170. maxSimultaneousLights: int;
  54171. private _shadowOnly;
  54172. /**
  54173. * Make the material only render shadows
  54174. */
  54175. shadowOnly: boolean;
  54176. /**
  54177. * Default configuration related to image processing available in the Background Material.
  54178. */
  54179. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54180. /**
  54181. * Keep track of the image processing observer to allow dispose and replace.
  54182. */
  54183. private _imageProcessingObserver;
  54184. /**
  54185. * Attaches a new image processing configuration to the PBR Material.
  54186. * @param configuration (if null the scene configuration will be use)
  54187. */
  54188. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54189. /**
  54190. * Gets the image processing configuration used either in this material.
  54191. */
  54192. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  54193. /**
  54194. * Sets the Default image processing configuration used either in the this material.
  54195. *
  54196. * If sets to null, the scene one is in use.
  54197. */
  54198. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  54199. /**
  54200. * Gets wether the color curves effect is enabled.
  54201. */
  54202. get cameraColorCurvesEnabled(): boolean;
  54203. /**
  54204. * Sets wether the color curves effect is enabled.
  54205. */
  54206. set cameraColorCurvesEnabled(value: boolean);
  54207. /**
  54208. * Gets wether the color grading effect is enabled.
  54209. */
  54210. get cameraColorGradingEnabled(): boolean;
  54211. /**
  54212. * Gets wether the color grading effect is enabled.
  54213. */
  54214. set cameraColorGradingEnabled(value: boolean);
  54215. /**
  54216. * Gets wether tonemapping is enabled or not.
  54217. */
  54218. get cameraToneMappingEnabled(): boolean;
  54219. /**
  54220. * Sets wether tonemapping is enabled or not
  54221. */
  54222. set cameraToneMappingEnabled(value: boolean);
  54223. /**
  54224. * The camera exposure used on this material.
  54225. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54226. * This corresponds to a photographic exposure.
  54227. */
  54228. get cameraExposure(): float;
  54229. /**
  54230. * The camera exposure used on this material.
  54231. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54232. * This corresponds to a photographic exposure.
  54233. */
  54234. set cameraExposure(value: float);
  54235. /**
  54236. * Gets The camera contrast used on this material.
  54237. */
  54238. get cameraContrast(): float;
  54239. /**
  54240. * Sets The camera contrast used on this material.
  54241. */
  54242. set cameraContrast(value: float);
  54243. /**
  54244. * Gets the Color Grading 2D Lookup Texture.
  54245. */
  54246. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54247. /**
  54248. * Sets the Color Grading 2D Lookup Texture.
  54249. */
  54250. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54251. /**
  54252. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54253. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54254. * 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;
  54255. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54256. */
  54257. get cameraColorCurves(): Nullable<ColorCurves>;
  54258. /**
  54259. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54260. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54261. * 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;
  54262. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54263. */
  54264. set cameraColorCurves(value: Nullable<ColorCurves>);
  54265. /**
  54266. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  54267. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  54268. */
  54269. switchToBGR: boolean;
  54270. private _renderTargets;
  54271. private _reflectionControls;
  54272. private _white;
  54273. private _primaryShadowColor;
  54274. private _primaryHighlightColor;
  54275. /**
  54276. * Instantiates a Background Material in the given scene
  54277. * @param name The friendly name of the material
  54278. * @param scene The scene to add the material to
  54279. */
  54280. constructor(name: string, scene: Scene);
  54281. /**
  54282. * Gets a boolean indicating that current material needs to register RTT
  54283. */
  54284. get hasRenderTargetTextures(): boolean;
  54285. /**
  54286. * The entire material has been created in order to prevent overdraw.
  54287. * @returns false
  54288. */
  54289. needAlphaTesting(): boolean;
  54290. /**
  54291. * The entire material has been created in order to prevent overdraw.
  54292. * @returns true if blending is enable
  54293. */
  54294. needAlphaBlending(): boolean;
  54295. /**
  54296. * Checks wether the material is ready to be rendered for a given mesh.
  54297. * @param mesh The mesh to render
  54298. * @param subMesh The submesh to check against
  54299. * @param useInstances Specify wether or not the material is used with instances
  54300. * @returns true if all the dependencies are ready (Textures, Effects...)
  54301. */
  54302. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54303. /**
  54304. * Compute the primary color according to the chosen perceptual color.
  54305. */
  54306. private _computePrimaryColorFromPerceptualColor;
  54307. /**
  54308. * Compute the highlights and shadow colors according to their chosen levels.
  54309. */
  54310. private _computePrimaryColors;
  54311. /**
  54312. * Build the uniform buffer used in the material.
  54313. */
  54314. buildUniformLayout(): void;
  54315. /**
  54316. * Unbind the material.
  54317. */
  54318. unbind(): void;
  54319. /**
  54320. * Bind only the world matrix to the material.
  54321. * @param world The world matrix to bind.
  54322. */
  54323. bindOnlyWorldMatrix(world: Matrix): void;
  54324. /**
  54325. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  54326. * @param world The world matrix to bind.
  54327. * @param subMesh The submesh to bind for.
  54328. */
  54329. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54330. /**
  54331. * Checks to see if a texture is used in the material.
  54332. * @param texture - Base texture to use.
  54333. * @returns - Boolean specifying if a texture is used in the material.
  54334. */
  54335. hasTexture(texture: BaseTexture): boolean;
  54336. /**
  54337. * Dispose the material.
  54338. * @param forceDisposeEffect Force disposal of the associated effect.
  54339. * @param forceDisposeTextures Force disposal of the associated textures.
  54340. */
  54341. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  54342. /**
  54343. * Clones the material.
  54344. * @param name The cloned name.
  54345. * @returns The cloned material.
  54346. */
  54347. clone(name: string): BackgroundMaterial;
  54348. /**
  54349. * Serializes the current material to its JSON representation.
  54350. * @returns The JSON representation.
  54351. */
  54352. serialize(): any;
  54353. /**
  54354. * Gets the class name of the material
  54355. * @returns "BackgroundMaterial"
  54356. */
  54357. getClassName(): string;
  54358. /**
  54359. * Parse a JSON input to create back a background material.
  54360. * @param source The JSON data to parse
  54361. * @param scene The scene to create the parsed material in
  54362. * @param rootUrl The root url of the assets the material depends upon
  54363. * @returns the instantiated BackgroundMaterial.
  54364. */
  54365. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  54366. }
  54367. }
  54368. declare module BABYLON {
  54369. /**
  54370. * Represents the different options available during the creation of
  54371. * a Environment helper.
  54372. *
  54373. * This can control the default ground, skybox and image processing setup of your scene.
  54374. */
  54375. export interface IEnvironmentHelperOptions {
  54376. /**
  54377. * Specifies whether or not to create a ground.
  54378. * True by default.
  54379. */
  54380. createGround: boolean;
  54381. /**
  54382. * Specifies the ground size.
  54383. * 15 by default.
  54384. */
  54385. groundSize: number;
  54386. /**
  54387. * The texture used on the ground for the main color.
  54388. * Comes from the BabylonJS CDN by default.
  54389. *
  54390. * Remarks: Can be either a texture or a url.
  54391. */
  54392. groundTexture: string | BaseTexture;
  54393. /**
  54394. * The color mixed in the ground texture by default.
  54395. * BabylonJS clearColor by default.
  54396. */
  54397. groundColor: Color3;
  54398. /**
  54399. * Specifies the ground opacity.
  54400. * 1 by default.
  54401. */
  54402. groundOpacity: number;
  54403. /**
  54404. * Enables the ground to receive shadows.
  54405. * True by default.
  54406. */
  54407. enableGroundShadow: boolean;
  54408. /**
  54409. * Helps preventing the shadow to be fully black on the ground.
  54410. * 0.5 by default.
  54411. */
  54412. groundShadowLevel: number;
  54413. /**
  54414. * Creates a mirror texture attach to the ground.
  54415. * false by default.
  54416. */
  54417. enableGroundMirror: boolean;
  54418. /**
  54419. * Specifies the ground mirror size ratio.
  54420. * 0.3 by default as the default kernel is 64.
  54421. */
  54422. groundMirrorSizeRatio: number;
  54423. /**
  54424. * Specifies the ground mirror blur kernel size.
  54425. * 64 by default.
  54426. */
  54427. groundMirrorBlurKernel: number;
  54428. /**
  54429. * Specifies the ground mirror visibility amount.
  54430. * 1 by default
  54431. */
  54432. groundMirrorAmount: number;
  54433. /**
  54434. * Specifies the ground mirror reflectance weight.
  54435. * This uses the standard weight of the background material to setup the fresnel effect
  54436. * of the mirror.
  54437. * 1 by default.
  54438. */
  54439. groundMirrorFresnelWeight: number;
  54440. /**
  54441. * Specifies the ground mirror Falloff distance.
  54442. * This can helps reducing the size of the reflection.
  54443. * 0 by Default.
  54444. */
  54445. groundMirrorFallOffDistance: number;
  54446. /**
  54447. * Specifies the ground mirror texture type.
  54448. * Unsigned Int by Default.
  54449. */
  54450. groundMirrorTextureType: number;
  54451. /**
  54452. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  54453. * the shown objects.
  54454. */
  54455. groundYBias: number;
  54456. /**
  54457. * Specifies whether or not to create a skybox.
  54458. * True by default.
  54459. */
  54460. createSkybox: boolean;
  54461. /**
  54462. * Specifies the skybox size.
  54463. * 20 by default.
  54464. */
  54465. skyboxSize: number;
  54466. /**
  54467. * The texture used on the skybox for the main color.
  54468. * Comes from the BabylonJS CDN by default.
  54469. *
  54470. * Remarks: Can be either a texture or a url.
  54471. */
  54472. skyboxTexture: string | BaseTexture;
  54473. /**
  54474. * The color mixed in the skybox texture by default.
  54475. * BabylonJS clearColor by default.
  54476. */
  54477. skyboxColor: Color3;
  54478. /**
  54479. * The background rotation around the Y axis of the scene.
  54480. * This helps aligning the key lights of your scene with the background.
  54481. * 0 by default.
  54482. */
  54483. backgroundYRotation: number;
  54484. /**
  54485. * Compute automatically the size of the elements to best fit with the scene.
  54486. */
  54487. sizeAuto: boolean;
  54488. /**
  54489. * Default position of the rootMesh if autoSize is not true.
  54490. */
  54491. rootPosition: Vector3;
  54492. /**
  54493. * Sets up the image processing in the scene.
  54494. * true by default.
  54495. */
  54496. setupImageProcessing: boolean;
  54497. /**
  54498. * The texture used as your environment texture in the scene.
  54499. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  54500. *
  54501. * Remarks: Can be either a texture or a url.
  54502. */
  54503. environmentTexture: string | BaseTexture;
  54504. /**
  54505. * The value of the exposure to apply to the scene.
  54506. * 0.6 by default if setupImageProcessing is true.
  54507. */
  54508. cameraExposure: number;
  54509. /**
  54510. * The value of the contrast to apply to the scene.
  54511. * 1.6 by default if setupImageProcessing is true.
  54512. */
  54513. cameraContrast: number;
  54514. /**
  54515. * Specifies whether or not tonemapping should be enabled in the scene.
  54516. * true by default if setupImageProcessing is true.
  54517. */
  54518. toneMappingEnabled: boolean;
  54519. }
  54520. /**
  54521. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  54522. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  54523. * It also helps with the default setup of your imageProcessing configuration.
  54524. */
  54525. export class EnvironmentHelper {
  54526. /**
  54527. * Default ground texture URL.
  54528. */
  54529. private static _groundTextureCDNUrl;
  54530. /**
  54531. * Default skybox texture URL.
  54532. */
  54533. private static _skyboxTextureCDNUrl;
  54534. /**
  54535. * Default environment texture URL.
  54536. */
  54537. private static _environmentTextureCDNUrl;
  54538. /**
  54539. * Creates the default options for the helper.
  54540. */
  54541. private static _getDefaultOptions;
  54542. private _rootMesh;
  54543. /**
  54544. * Gets the root mesh created by the helper.
  54545. */
  54546. get rootMesh(): Mesh;
  54547. private _skybox;
  54548. /**
  54549. * Gets the skybox created by the helper.
  54550. */
  54551. get skybox(): Nullable<Mesh>;
  54552. private _skyboxTexture;
  54553. /**
  54554. * Gets the skybox texture created by the helper.
  54555. */
  54556. get skyboxTexture(): Nullable<BaseTexture>;
  54557. private _skyboxMaterial;
  54558. /**
  54559. * Gets the skybox material created by the helper.
  54560. */
  54561. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  54562. private _ground;
  54563. /**
  54564. * Gets the ground mesh created by the helper.
  54565. */
  54566. get ground(): Nullable<Mesh>;
  54567. private _groundTexture;
  54568. /**
  54569. * Gets the ground texture created by the helper.
  54570. */
  54571. get groundTexture(): Nullable<BaseTexture>;
  54572. private _groundMirror;
  54573. /**
  54574. * Gets the ground mirror created by the helper.
  54575. */
  54576. get groundMirror(): Nullable<MirrorTexture>;
  54577. /**
  54578. * Gets the ground mirror render list to helps pushing the meshes
  54579. * you wish in the ground reflection.
  54580. */
  54581. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  54582. private _groundMaterial;
  54583. /**
  54584. * Gets the ground material created by the helper.
  54585. */
  54586. get groundMaterial(): Nullable<BackgroundMaterial>;
  54587. /**
  54588. * Stores the creation options.
  54589. */
  54590. private readonly _scene;
  54591. private _options;
  54592. /**
  54593. * This observable will be notified with any error during the creation of the environment,
  54594. * mainly texture creation errors.
  54595. */
  54596. onErrorObservable: Observable<{
  54597. message?: string;
  54598. exception?: any;
  54599. }>;
  54600. /**
  54601. * constructor
  54602. * @param options Defines the options we want to customize the helper
  54603. * @param scene The scene to add the material to
  54604. */
  54605. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  54606. /**
  54607. * Updates the background according to the new options
  54608. * @param options
  54609. */
  54610. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  54611. /**
  54612. * Sets the primary color of all the available elements.
  54613. * @param color the main color to affect to the ground and the background
  54614. */
  54615. setMainColor(color: Color3): void;
  54616. /**
  54617. * Setup the image processing according to the specified options.
  54618. */
  54619. private _setupImageProcessing;
  54620. /**
  54621. * Setup the environment texture according to the specified options.
  54622. */
  54623. private _setupEnvironmentTexture;
  54624. /**
  54625. * Setup the background according to the specified options.
  54626. */
  54627. private _setupBackground;
  54628. /**
  54629. * Get the scene sizes according to the setup.
  54630. */
  54631. private _getSceneSize;
  54632. /**
  54633. * Setup the ground according to the specified options.
  54634. */
  54635. private _setupGround;
  54636. /**
  54637. * Setup the ground material according to the specified options.
  54638. */
  54639. private _setupGroundMaterial;
  54640. /**
  54641. * Setup the ground diffuse texture according to the specified options.
  54642. */
  54643. private _setupGroundDiffuseTexture;
  54644. /**
  54645. * Setup the ground mirror texture according to the specified options.
  54646. */
  54647. private _setupGroundMirrorTexture;
  54648. /**
  54649. * Setup the ground to receive the mirror texture.
  54650. */
  54651. private _setupMirrorInGroundMaterial;
  54652. /**
  54653. * Setup the skybox according to the specified options.
  54654. */
  54655. private _setupSkybox;
  54656. /**
  54657. * Setup the skybox material according to the specified options.
  54658. */
  54659. private _setupSkyboxMaterial;
  54660. /**
  54661. * Setup the skybox reflection texture according to the specified options.
  54662. */
  54663. private _setupSkyboxReflectionTexture;
  54664. private _errorHandler;
  54665. /**
  54666. * Dispose all the elements created by the Helper.
  54667. */
  54668. dispose(): void;
  54669. }
  54670. }
  54671. declare module BABYLON {
  54672. /**
  54673. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  54674. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  54675. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  54676. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  54677. */
  54678. export class PhotoDome extends TransformNode {
  54679. /**
  54680. * Define the image as a Monoscopic panoramic 360 image.
  54681. */
  54682. static readonly MODE_MONOSCOPIC: number;
  54683. /**
  54684. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  54685. */
  54686. static readonly MODE_TOPBOTTOM: number;
  54687. /**
  54688. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  54689. */
  54690. static readonly MODE_SIDEBYSIDE: number;
  54691. private _useDirectMapping;
  54692. /**
  54693. * The texture being displayed on the sphere
  54694. */
  54695. protected _photoTexture: Texture;
  54696. /**
  54697. * Gets or sets the texture being displayed on the sphere
  54698. */
  54699. get photoTexture(): Texture;
  54700. set photoTexture(value: Texture);
  54701. /**
  54702. * Observable raised when an error occured while loading the 360 image
  54703. */
  54704. onLoadErrorObservable: Observable<string>;
  54705. /**
  54706. * The skybox material
  54707. */
  54708. protected _material: BackgroundMaterial;
  54709. /**
  54710. * The surface used for the skybox
  54711. */
  54712. protected _mesh: Mesh;
  54713. /**
  54714. * Gets the mesh used for the skybox.
  54715. */
  54716. get mesh(): Mesh;
  54717. /**
  54718. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54719. * Also see the options.resolution property.
  54720. */
  54721. get fovMultiplier(): number;
  54722. set fovMultiplier(value: number);
  54723. private _imageMode;
  54724. /**
  54725. * Gets or set the current video mode for the video. It can be:
  54726. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  54727. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  54728. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  54729. */
  54730. get imageMode(): number;
  54731. set imageMode(value: number);
  54732. /**
  54733. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  54734. * @param name Element's name, child elements will append suffixes for their own names.
  54735. * @param urlsOfPhoto defines the url of the photo to display
  54736. * @param options defines an object containing optional or exposed sub element properties
  54737. * @param onError defines a callback called when an error occured while loading the texture
  54738. */
  54739. constructor(name: string, urlOfPhoto: string, options: {
  54740. resolution?: number;
  54741. size?: number;
  54742. useDirectMapping?: boolean;
  54743. faceForward?: boolean;
  54744. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  54745. private _onBeforeCameraRenderObserver;
  54746. private _changeImageMode;
  54747. /**
  54748. * Releases resources associated with this node.
  54749. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  54750. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  54751. */
  54752. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  54753. }
  54754. }
  54755. declare module BABYLON {
  54756. /**
  54757. * Class used to host RGBD texture specific utilities
  54758. */
  54759. export class RGBDTextureTools {
  54760. /**
  54761. * Expand the RGBD Texture from RGBD to Half Float if possible.
  54762. * @param texture the texture to expand.
  54763. */
  54764. static ExpandRGBDTexture(texture: Texture): void;
  54765. }
  54766. }
  54767. declare module BABYLON {
  54768. /**
  54769. * Class used to host texture specific utilities
  54770. */
  54771. export class BRDFTextureTools {
  54772. /**
  54773. * Prevents texture cache collision
  54774. */
  54775. private static _instanceNumber;
  54776. /**
  54777. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  54778. * @param scene defines the hosting scene
  54779. * @returns the environment BRDF texture
  54780. */
  54781. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  54782. private static _environmentBRDFBase64Texture;
  54783. }
  54784. }
  54785. declare module BABYLON {
  54786. /**
  54787. * @hidden
  54788. */
  54789. export interface IMaterialClearCoatDefines {
  54790. CLEARCOAT: boolean;
  54791. CLEARCOAT_DEFAULTIOR: boolean;
  54792. CLEARCOAT_TEXTURE: boolean;
  54793. CLEARCOAT_TEXTUREDIRECTUV: number;
  54794. CLEARCOAT_BUMP: boolean;
  54795. CLEARCOAT_BUMPDIRECTUV: number;
  54796. CLEARCOAT_TINT: boolean;
  54797. CLEARCOAT_TINT_TEXTURE: boolean;
  54798. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  54799. /** @hidden */
  54800. _areTexturesDirty: boolean;
  54801. }
  54802. /**
  54803. * Define the code related to the clear coat parameters of the pbr material.
  54804. */
  54805. export class PBRClearCoatConfiguration {
  54806. /**
  54807. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  54808. * The default fits with a polyurethane material.
  54809. */
  54810. private static readonly _DefaultIndexOfRefraction;
  54811. private _isEnabled;
  54812. /**
  54813. * Defines if the clear coat is enabled in the material.
  54814. */
  54815. isEnabled: boolean;
  54816. /**
  54817. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  54818. */
  54819. intensity: number;
  54820. /**
  54821. * Defines the clear coat layer roughness.
  54822. */
  54823. roughness: number;
  54824. private _indexOfRefraction;
  54825. /**
  54826. * Defines the index of refraction of the clear coat.
  54827. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  54828. * The default fits with a polyurethane material.
  54829. * Changing the default value is more performance intensive.
  54830. */
  54831. indexOfRefraction: number;
  54832. private _texture;
  54833. /**
  54834. * Stores the clear coat values in a texture.
  54835. */
  54836. texture: Nullable<BaseTexture>;
  54837. private _bumpTexture;
  54838. /**
  54839. * Define the clear coat specific bump texture.
  54840. */
  54841. bumpTexture: Nullable<BaseTexture>;
  54842. private _isTintEnabled;
  54843. /**
  54844. * Defines if the clear coat tint is enabled in the material.
  54845. */
  54846. isTintEnabled: boolean;
  54847. /**
  54848. * Defines the clear coat tint of the material.
  54849. * This is only use if tint is enabled
  54850. */
  54851. tintColor: Color3;
  54852. /**
  54853. * Defines the distance at which the tint color should be found in the
  54854. * clear coat media.
  54855. * This is only use if tint is enabled
  54856. */
  54857. tintColorAtDistance: number;
  54858. /**
  54859. * Defines the clear coat layer thickness.
  54860. * This is only use if tint is enabled
  54861. */
  54862. tintThickness: number;
  54863. private _tintTexture;
  54864. /**
  54865. * Stores the clear tint values in a texture.
  54866. * rgb is tint
  54867. * a is a thickness factor
  54868. */
  54869. tintTexture: Nullable<BaseTexture>;
  54870. /** @hidden */
  54871. private _internalMarkAllSubMeshesAsTexturesDirty;
  54872. /** @hidden */
  54873. _markAllSubMeshesAsTexturesDirty(): void;
  54874. /**
  54875. * Instantiate a new istance of clear coat configuration.
  54876. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54877. */
  54878. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54879. /**
  54880. * Gets wehter the submesh is ready to be used or not.
  54881. * @param defines the list of "defines" to update.
  54882. * @param scene defines the scene the material belongs to.
  54883. * @param engine defines the engine the material belongs to.
  54884. * @param disableBumpMap defines wether the material disables bump or not.
  54885. * @returns - boolean indicating that the submesh is ready or not.
  54886. */
  54887. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  54888. /**
  54889. * Checks to see if a texture is used in the material.
  54890. * @param defines the list of "defines" to update.
  54891. * @param scene defines the scene to the material belongs to.
  54892. */
  54893. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  54894. /**
  54895. * Binds the material data.
  54896. * @param uniformBuffer defines the Uniform buffer to fill in.
  54897. * @param scene defines the scene the material belongs to.
  54898. * @param engine defines the engine the material belongs to.
  54899. * @param disableBumpMap defines wether the material disables bump or not.
  54900. * @param isFrozen defines wether the material is frozen or not.
  54901. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  54902. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  54903. */
  54904. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  54905. /**
  54906. * Checks to see if a texture is used in the material.
  54907. * @param texture - Base texture to use.
  54908. * @returns - Boolean specifying if a texture is used in the material.
  54909. */
  54910. hasTexture(texture: BaseTexture): boolean;
  54911. /**
  54912. * Returns an array of the actively used textures.
  54913. * @param activeTextures Array of BaseTextures
  54914. */
  54915. getActiveTextures(activeTextures: BaseTexture[]): void;
  54916. /**
  54917. * Returns the animatable textures.
  54918. * @param animatables Array of animatable textures.
  54919. */
  54920. getAnimatables(animatables: IAnimatable[]): void;
  54921. /**
  54922. * Disposes the resources of the material.
  54923. * @param forceDisposeTextures - Forces the disposal of all textures.
  54924. */
  54925. dispose(forceDisposeTextures?: boolean): void;
  54926. /**
  54927. * Get the current class name of the texture useful for serialization or dynamic coding.
  54928. * @returns "PBRClearCoatConfiguration"
  54929. */
  54930. getClassName(): string;
  54931. /**
  54932. * Add fallbacks to the effect fallbacks list.
  54933. * @param defines defines the Base texture to use.
  54934. * @param fallbacks defines the current fallback list.
  54935. * @param currentRank defines the current fallback rank.
  54936. * @returns the new fallback rank.
  54937. */
  54938. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54939. /**
  54940. * Add the required uniforms to the current list.
  54941. * @param uniforms defines the current uniform list.
  54942. */
  54943. static AddUniforms(uniforms: string[]): void;
  54944. /**
  54945. * Add the required samplers to the current list.
  54946. * @param samplers defines the current sampler list.
  54947. */
  54948. static AddSamplers(samplers: string[]): void;
  54949. /**
  54950. * Add the required uniforms to the current buffer.
  54951. * @param uniformBuffer defines the current uniform buffer.
  54952. */
  54953. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54954. /**
  54955. * Makes a duplicate of the current configuration into another one.
  54956. * @param clearCoatConfiguration define the config where to copy the info
  54957. */
  54958. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  54959. /**
  54960. * Serializes this clear coat configuration.
  54961. * @returns - An object with the serialized config.
  54962. */
  54963. serialize(): any;
  54964. /**
  54965. * Parses a anisotropy Configuration from a serialized object.
  54966. * @param source - Serialized object.
  54967. * @param scene Defines the scene we are parsing for
  54968. * @param rootUrl Defines the rootUrl to load from
  54969. */
  54970. parse(source: any, scene: Scene, rootUrl: string): void;
  54971. }
  54972. }
  54973. declare module BABYLON {
  54974. /**
  54975. * @hidden
  54976. */
  54977. export interface IMaterialAnisotropicDefines {
  54978. ANISOTROPIC: boolean;
  54979. ANISOTROPIC_TEXTURE: boolean;
  54980. ANISOTROPIC_TEXTUREDIRECTUV: number;
  54981. MAINUV1: boolean;
  54982. _areTexturesDirty: boolean;
  54983. _needUVs: boolean;
  54984. }
  54985. /**
  54986. * Define the code related to the anisotropic parameters of the pbr material.
  54987. */
  54988. export class PBRAnisotropicConfiguration {
  54989. private _isEnabled;
  54990. /**
  54991. * Defines if the anisotropy is enabled in the material.
  54992. */
  54993. isEnabled: boolean;
  54994. /**
  54995. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  54996. */
  54997. intensity: number;
  54998. /**
  54999. * Defines if the effect is along the tangents, bitangents or in between.
  55000. * By default, the effect is "strectching" the highlights along the tangents.
  55001. */
  55002. direction: Vector2;
  55003. private _texture;
  55004. /**
  55005. * Stores the anisotropy values in a texture.
  55006. * rg is direction (like normal from -1 to 1)
  55007. * b is a intensity
  55008. */
  55009. texture: Nullable<BaseTexture>;
  55010. /** @hidden */
  55011. private _internalMarkAllSubMeshesAsTexturesDirty;
  55012. /** @hidden */
  55013. _markAllSubMeshesAsTexturesDirty(): void;
  55014. /**
  55015. * Instantiate a new istance of anisotropy configuration.
  55016. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55017. */
  55018. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55019. /**
  55020. * Specifies that the submesh is ready to be used.
  55021. * @param defines the list of "defines" to update.
  55022. * @param scene defines the scene the material belongs to.
  55023. * @returns - boolean indicating that the submesh is ready or not.
  55024. */
  55025. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  55026. /**
  55027. * Checks to see if a texture is used in the material.
  55028. * @param defines the list of "defines" to update.
  55029. * @param mesh the mesh we are preparing the defines for.
  55030. * @param scene defines the scene the material belongs to.
  55031. */
  55032. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  55033. /**
  55034. * Binds the material data.
  55035. * @param uniformBuffer defines the Uniform buffer to fill in.
  55036. * @param scene defines the scene the material belongs to.
  55037. * @param isFrozen defines wether the material is frozen or not.
  55038. */
  55039. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  55040. /**
  55041. * Checks to see if a texture is used in the material.
  55042. * @param texture - Base texture to use.
  55043. * @returns - Boolean specifying if a texture is used in the material.
  55044. */
  55045. hasTexture(texture: BaseTexture): boolean;
  55046. /**
  55047. * Returns an array of the actively used textures.
  55048. * @param activeTextures Array of BaseTextures
  55049. */
  55050. getActiveTextures(activeTextures: BaseTexture[]): void;
  55051. /**
  55052. * Returns the animatable textures.
  55053. * @param animatables Array of animatable textures.
  55054. */
  55055. getAnimatables(animatables: IAnimatable[]): void;
  55056. /**
  55057. * Disposes the resources of the material.
  55058. * @param forceDisposeTextures - Forces the disposal of all textures.
  55059. */
  55060. dispose(forceDisposeTextures?: boolean): void;
  55061. /**
  55062. * Get the current class name of the texture useful for serialization or dynamic coding.
  55063. * @returns "PBRAnisotropicConfiguration"
  55064. */
  55065. getClassName(): string;
  55066. /**
  55067. * Add fallbacks to the effect fallbacks list.
  55068. * @param defines defines the Base texture to use.
  55069. * @param fallbacks defines the current fallback list.
  55070. * @param currentRank defines the current fallback rank.
  55071. * @returns the new fallback rank.
  55072. */
  55073. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55074. /**
  55075. * Add the required uniforms to the current list.
  55076. * @param uniforms defines the current uniform list.
  55077. */
  55078. static AddUniforms(uniforms: string[]): void;
  55079. /**
  55080. * Add the required uniforms to the current buffer.
  55081. * @param uniformBuffer defines the current uniform buffer.
  55082. */
  55083. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55084. /**
  55085. * Add the required samplers to the current list.
  55086. * @param samplers defines the current sampler list.
  55087. */
  55088. static AddSamplers(samplers: string[]): void;
  55089. /**
  55090. * Makes a duplicate of the current configuration into another one.
  55091. * @param anisotropicConfiguration define the config where to copy the info
  55092. */
  55093. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  55094. /**
  55095. * Serializes this anisotropy configuration.
  55096. * @returns - An object with the serialized config.
  55097. */
  55098. serialize(): any;
  55099. /**
  55100. * Parses a anisotropy Configuration from a serialized object.
  55101. * @param source - Serialized object.
  55102. * @param scene Defines the scene we are parsing for
  55103. * @param rootUrl Defines the rootUrl to load from
  55104. */
  55105. parse(source: any, scene: Scene, rootUrl: string): void;
  55106. }
  55107. }
  55108. declare module BABYLON {
  55109. /**
  55110. * @hidden
  55111. */
  55112. export interface IMaterialBRDFDefines {
  55113. BRDF_V_HEIGHT_CORRELATED: boolean;
  55114. MS_BRDF_ENERGY_CONSERVATION: boolean;
  55115. SPHERICAL_HARMONICS: boolean;
  55116. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  55117. /** @hidden */
  55118. _areMiscDirty: boolean;
  55119. }
  55120. /**
  55121. * Define the code related to the BRDF parameters of the pbr material.
  55122. */
  55123. export class PBRBRDFConfiguration {
  55124. /**
  55125. * Default value used for the energy conservation.
  55126. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  55127. */
  55128. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  55129. /**
  55130. * Default value used for the Smith Visibility Height Correlated mode.
  55131. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  55132. */
  55133. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  55134. /**
  55135. * Default value used for the IBL diffuse part.
  55136. * This can help switching back to the polynomials mode globally which is a tiny bit
  55137. * less GPU intensive at the drawback of a lower quality.
  55138. */
  55139. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  55140. /**
  55141. * Default value used for activating energy conservation for the specular workflow.
  55142. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  55143. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  55144. */
  55145. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  55146. private _useEnergyConservation;
  55147. /**
  55148. * Defines if the material uses energy conservation.
  55149. */
  55150. useEnergyConservation: boolean;
  55151. private _useSmithVisibilityHeightCorrelated;
  55152. /**
  55153. * LEGACY Mode set to false
  55154. * Defines if the material uses height smith correlated visibility term.
  55155. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  55156. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  55157. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  55158. * Not relying on height correlated will also disable energy conservation.
  55159. */
  55160. useSmithVisibilityHeightCorrelated: boolean;
  55161. private _useSphericalHarmonics;
  55162. /**
  55163. * LEGACY Mode set to false
  55164. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  55165. * diffuse part of the IBL.
  55166. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  55167. * to the ground truth.
  55168. */
  55169. useSphericalHarmonics: boolean;
  55170. private _useSpecularGlossinessInputEnergyConservation;
  55171. /**
  55172. * Defines if the material uses energy conservation, when the specular workflow is active.
  55173. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  55174. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  55175. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  55176. */
  55177. useSpecularGlossinessInputEnergyConservation: boolean;
  55178. /** @hidden */
  55179. private _internalMarkAllSubMeshesAsMiscDirty;
  55180. /** @hidden */
  55181. _markAllSubMeshesAsMiscDirty(): void;
  55182. /**
  55183. * Instantiate a new istance of clear coat configuration.
  55184. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  55185. */
  55186. constructor(markAllSubMeshesAsMiscDirty: () => void);
  55187. /**
  55188. * Checks to see if a texture is used in the material.
  55189. * @param defines the list of "defines" to update.
  55190. */
  55191. prepareDefines(defines: IMaterialBRDFDefines): void;
  55192. /**
  55193. * Get the current class name of the texture useful for serialization or dynamic coding.
  55194. * @returns "PBRClearCoatConfiguration"
  55195. */
  55196. getClassName(): string;
  55197. /**
  55198. * Makes a duplicate of the current configuration into another one.
  55199. * @param brdfConfiguration define the config where to copy the info
  55200. */
  55201. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  55202. /**
  55203. * Serializes this BRDF configuration.
  55204. * @returns - An object with the serialized config.
  55205. */
  55206. serialize(): any;
  55207. /**
  55208. * Parses a anisotropy Configuration from a serialized object.
  55209. * @param source - Serialized object.
  55210. * @param scene Defines the scene we are parsing for
  55211. * @param rootUrl Defines the rootUrl to load from
  55212. */
  55213. parse(source: any, scene: Scene, rootUrl: string): void;
  55214. }
  55215. }
  55216. declare module BABYLON {
  55217. /**
  55218. * @hidden
  55219. */
  55220. export interface IMaterialSheenDefines {
  55221. SHEEN: boolean;
  55222. SHEEN_TEXTURE: boolean;
  55223. SHEEN_TEXTUREDIRECTUV: number;
  55224. SHEEN_LINKWITHALBEDO: boolean;
  55225. SHEEN_ROUGHNESS: boolean;
  55226. SHEEN_ALBEDOSCALING: boolean;
  55227. /** @hidden */
  55228. _areTexturesDirty: boolean;
  55229. }
  55230. /**
  55231. * Define the code related to the Sheen parameters of the pbr material.
  55232. */
  55233. export class PBRSheenConfiguration {
  55234. private _isEnabled;
  55235. /**
  55236. * Defines if the material uses sheen.
  55237. */
  55238. isEnabled: boolean;
  55239. private _linkSheenWithAlbedo;
  55240. /**
  55241. * Defines if the sheen is linked to the sheen color.
  55242. */
  55243. linkSheenWithAlbedo: boolean;
  55244. /**
  55245. * Defines the sheen intensity.
  55246. */
  55247. intensity: number;
  55248. /**
  55249. * Defines the sheen color.
  55250. */
  55251. color: Color3;
  55252. private _texture;
  55253. /**
  55254. * Stores the sheen tint values in a texture.
  55255. * rgb is tint
  55256. * a is a intensity or roughness if roughness has been defined
  55257. */
  55258. texture: Nullable<BaseTexture>;
  55259. private _roughness;
  55260. /**
  55261. * Defines the sheen roughness.
  55262. * It is not taken into account if linkSheenWithAlbedo is true.
  55263. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  55264. */
  55265. roughness: Nullable<number>;
  55266. private _albedoScaling;
  55267. /**
  55268. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  55269. * It allows the strength of the sheen effect to not depend on the base color of the material,
  55270. * making it easier to setup and tweak the effect
  55271. */
  55272. albedoScaling: boolean;
  55273. /** @hidden */
  55274. private _internalMarkAllSubMeshesAsTexturesDirty;
  55275. /** @hidden */
  55276. _markAllSubMeshesAsTexturesDirty(): void;
  55277. /**
  55278. * Instantiate a new istance of clear coat configuration.
  55279. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55280. */
  55281. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55282. /**
  55283. * Specifies that the submesh is ready to be used.
  55284. * @param defines the list of "defines" to update.
  55285. * @param scene defines the scene the material belongs to.
  55286. * @returns - boolean indicating that the submesh is ready or not.
  55287. */
  55288. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  55289. /**
  55290. * Checks to see if a texture is used in the material.
  55291. * @param defines the list of "defines" to update.
  55292. * @param scene defines the scene the material belongs to.
  55293. */
  55294. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  55295. /**
  55296. * Binds the material data.
  55297. * @param uniformBuffer defines the Uniform buffer to fill in.
  55298. * @param scene defines the scene the material belongs to.
  55299. * @param isFrozen defines wether the material is frozen or not.
  55300. */
  55301. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  55302. /**
  55303. * Checks to see if a texture is used in the material.
  55304. * @param texture - Base texture to use.
  55305. * @returns - Boolean specifying if a texture is used in the material.
  55306. */
  55307. hasTexture(texture: BaseTexture): boolean;
  55308. /**
  55309. * Returns an array of the actively used textures.
  55310. * @param activeTextures Array of BaseTextures
  55311. */
  55312. getActiveTextures(activeTextures: BaseTexture[]): void;
  55313. /**
  55314. * Returns the animatable textures.
  55315. * @param animatables Array of animatable textures.
  55316. */
  55317. getAnimatables(animatables: IAnimatable[]): void;
  55318. /**
  55319. * Disposes the resources of the material.
  55320. * @param forceDisposeTextures - Forces the disposal of all textures.
  55321. */
  55322. dispose(forceDisposeTextures?: boolean): void;
  55323. /**
  55324. * Get the current class name of the texture useful for serialization or dynamic coding.
  55325. * @returns "PBRSheenConfiguration"
  55326. */
  55327. getClassName(): string;
  55328. /**
  55329. * Add fallbacks to the effect fallbacks list.
  55330. * @param defines defines the Base texture to use.
  55331. * @param fallbacks defines the current fallback list.
  55332. * @param currentRank defines the current fallback rank.
  55333. * @returns the new fallback rank.
  55334. */
  55335. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55336. /**
  55337. * Add the required uniforms to the current list.
  55338. * @param uniforms defines the current uniform list.
  55339. */
  55340. static AddUniforms(uniforms: string[]): void;
  55341. /**
  55342. * Add the required uniforms to the current buffer.
  55343. * @param uniformBuffer defines the current uniform buffer.
  55344. */
  55345. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55346. /**
  55347. * Add the required samplers to the current list.
  55348. * @param samplers defines the current sampler list.
  55349. */
  55350. static AddSamplers(samplers: string[]): void;
  55351. /**
  55352. * Makes a duplicate of the current configuration into another one.
  55353. * @param sheenConfiguration define the config where to copy the info
  55354. */
  55355. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  55356. /**
  55357. * Serializes this BRDF configuration.
  55358. * @returns - An object with the serialized config.
  55359. */
  55360. serialize(): any;
  55361. /**
  55362. * Parses a anisotropy Configuration from a serialized object.
  55363. * @param source - Serialized object.
  55364. * @param scene Defines the scene we are parsing for
  55365. * @param rootUrl Defines the rootUrl to load from
  55366. */
  55367. parse(source: any, scene: Scene, rootUrl: string): void;
  55368. }
  55369. }
  55370. declare module BABYLON {
  55371. /**
  55372. * @hidden
  55373. */
  55374. export interface IMaterialSubSurfaceDefines {
  55375. SUBSURFACE: boolean;
  55376. SS_REFRACTION: boolean;
  55377. SS_TRANSLUCENCY: boolean;
  55378. SS_SCATTERING: boolean;
  55379. SS_THICKNESSANDMASK_TEXTURE: boolean;
  55380. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  55381. SS_REFRACTIONMAP_3D: boolean;
  55382. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  55383. SS_LODINREFRACTIONALPHA: boolean;
  55384. SS_GAMMAREFRACTION: boolean;
  55385. SS_RGBDREFRACTION: boolean;
  55386. SS_LINEARSPECULARREFRACTION: boolean;
  55387. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  55388. SS_ALBEDOFORREFRACTIONTINT: boolean;
  55389. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  55390. /** @hidden */
  55391. _areTexturesDirty: boolean;
  55392. }
  55393. /**
  55394. * Define the code related to the sub surface parameters of the pbr material.
  55395. */
  55396. export class PBRSubSurfaceConfiguration {
  55397. private _isRefractionEnabled;
  55398. /**
  55399. * Defines if the refraction is enabled in the material.
  55400. */
  55401. isRefractionEnabled: boolean;
  55402. private _isTranslucencyEnabled;
  55403. /**
  55404. * Defines if the translucency is enabled in the material.
  55405. */
  55406. isTranslucencyEnabled: boolean;
  55407. private _isScatteringEnabled;
  55408. /**
  55409. * Defines if the sub surface scattering is enabled in the material.
  55410. */
  55411. isScatteringEnabled: boolean;
  55412. private _scatteringDiffusionProfileIndex;
  55413. /**
  55414. * Diffusion profile for subsurface scattering.
  55415. * Useful for better scattering in the skins or foliages.
  55416. */
  55417. get scatteringDiffusionProfile(): Nullable<Color3>;
  55418. set scatteringDiffusionProfile(c: Nullable<Color3>);
  55419. /**
  55420. * Defines the refraction intensity of the material.
  55421. * The refraction when enabled replaces the Diffuse part of the material.
  55422. * The intensity helps transitionning between diffuse and refraction.
  55423. */
  55424. refractionIntensity: number;
  55425. /**
  55426. * Defines the translucency intensity of the material.
  55427. * When translucency has been enabled, this defines how much of the "translucency"
  55428. * is addded to the diffuse part of the material.
  55429. */
  55430. translucencyIntensity: number;
  55431. /**
  55432. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  55433. */
  55434. useAlbedoToTintRefraction: boolean;
  55435. private _thicknessTexture;
  55436. /**
  55437. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  55438. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  55439. * 0 would mean minimumThickness
  55440. * 1 would mean maximumThickness
  55441. * The other channels might be use as a mask to vary the different effects intensity.
  55442. */
  55443. thicknessTexture: Nullable<BaseTexture>;
  55444. private _refractionTexture;
  55445. /**
  55446. * Defines the texture to use for refraction.
  55447. */
  55448. refractionTexture: Nullable<BaseTexture>;
  55449. private _indexOfRefraction;
  55450. /**
  55451. * Index of refraction of the material base layer.
  55452. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55453. *
  55454. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  55455. *
  55456. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  55457. */
  55458. indexOfRefraction: number;
  55459. private _volumeIndexOfRefraction;
  55460. /**
  55461. * Index of refraction of the material's volume.
  55462. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55463. *
  55464. * This ONLY impacts refraction. If not provided or given a non-valid value,
  55465. * the volume will use the same IOR as the surface.
  55466. */
  55467. get volumeIndexOfRefraction(): number;
  55468. set volumeIndexOfRefraction(value: number);
  55469. private _invertRefractionY;
  55470. /**
  55471. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  55472. */
  55473. invertRefractionY: boolean;
  55474. private _linkRefractionWithTransparency;
  55475. /**
  55476. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  55477. * Materials half opaque for instance using refraction could benefit from this control.
  55478. */
  55479. linkRefractionWithTransparency: boolean;
  55480. /**
  55481. * Defines the minimum thickness stored in the thickness map.
  55482. * If no thickness map is defined, this value will be used to simulate thickness.
  55483. */
  55484. minimumThickness: number;
  55485. /**
  55486. * Defines the maximum thickness stored in the thickness map.
  55487. */
  55488. maximumThickness: number;
  55489. /**
  55490. * Defines the volume tint of the material.
  55491. * This is used for both translucency and scattering.
  55492. */
  55493. tintColor: Color3;
  55494. /**
  55495. * Defines the distance at which the tint color should be found in the media.
  55496. * This is used for refraction only.
  55497. */
  55498. tintColorAtDistance: number;
  55499. /**
  55500. * Defines how far each channel transmit through the media.
  55501. * It is defined as a color to simplify it selection.
  55502. */
  55503. diffusionDistance: Color3;
  55504. private _useMaskFromThicknessTexture;
  55505. /**
  55506. * Stores the intensity of the different subsurface effects in the thickness texture.
  55507. * * the green channel is the translucency intensity.
  55508. * * the blue channel is the scattering intensity.
  55509. * * the alpha channel is the refraction intensity.
  55510. */
  55511. useMaskFromThicknessTexture: boolean;
  55512. private _scene;
  55513. /** @hidden */
  55514. private _internalMarkAllSubMeshesAsTexturesDirty;
  55515. private _internalMarkScenePrePassDirty;
  55516. /** @hidden */
  55517. _markAllSubMeshesAsTexturesDirty(): void;
  55518. /** @hidden */
  55519. _markScenePrePassDirty(): void;
  55520. /**
  55521. * Instantiate a new istance of sub surface configuration.
  55522. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55523. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  55524. * @param scene The scene
  55525. */
  55526. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  55527. /**
  55528. * Gets wehter the submesh is ready to be used or not.
  55529. * @param defines the list of "defines" to update.
  55530. * @param scene defines the scene the material belongs to.
  55531. * @returns - boolean indicating that the submesh is ready or not.
  55532. */
  55533. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  55534. /**
  55535. * Checks to see if a texture is used in the material.
  55536. * @param defines the list of "defines" to update.
  55537. * @param scene defines the scene to the material belongs to.
  55538. */
  55539. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  55540. /**
  55541. * Binds the material data.
  55542. * @param uniformBuffer defines the Uniform buffer to fill in.
  55543. * @param scene defines the scene the material belongs to.
  55544. * @param engine defines the engine the material belongs to.
  55545. * @param isFrozen defines whether the material is frozen or not.
  55546. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  55547. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  55548. */
  55549. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  55550. /**
  55551. * Unbinds the material from the mesh.
  55552. * @param activeEffect defines the effect that should be unbound from.
  55553. * @returns true if unbound, otherwise false
  55554. */
  55555. unbind(activeEffect: Effect): boolean;
  55556. /**
  55557. * Returns the texture used for refraction or null if none is used.
  55558. * @param scene defines the scene the material belongs to.
  55559. * @returns - Refraction texture if present. If no refraction texture and refraction
  55560. * is linked with transparency, returns environment texture. Otherwise, returns null.
  55561. */
  55562. private _getRefractionTexture;
  55563. /**
  55564. * Returns true if alpha blending should be disabled.
  55565. */
  55566. get disableAlphaBlending(): boolean;
  55567. /**
  55568. * Fills the list of render target textures.
  55569. * @param renderTargets the list of render targets to update
  55570. */
  55571. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  55572. /**
  55573. * Checks to see if a texture is used in the material.
  55574. * @param texture - Base texture to use.
  55575. * @returns - Boolean specifying if a texture is used in the material.
  55576. */
  55577. hasTexture(texture: BaseTexture): boolean;
  55578. /**
  55579. * Gets a boolean indicating that current material needs to register RTT
  55580. * @returns true if this uses a render target otherwise false.
  55581. */
  55582. hasRenderTargetTextures(): boolean;
  55583. /**
  55584. * Returns an array of the actively used textures.
  55585. * @param activeTextures Array of BaseTextures
  55586. */
  55587. getActiveTextures(activeTextures: BaseTexture[]): void;
  55588. /**
  55589. * Returns the animatable textures.
  55590. * @param animatables Array of animatable textures.
  55591. */
  55592. getAnimatables(animatables: IAnimatable[]): void;
  55593. /**
  55594. * Disposes the resources of the material.
  55595. * @param forceDisposeTextures - Forces the disposal of all textures.
  55596. */
  55597. dispose(forceDisposeTextures?: boolean): void;
  55598. /**
  55599. * Get the current class name of the texture useful for serialization or dynamic coding.
  55600. * @returns "PBRSubSurfaceConfiguration"
  55601. */
  55602. getClassName(): string;
  55603. /**
  55604. * Add fallbacks to the effect fallbacks list.
  55605. * @param defines defines the Base texture to use.
  55606. * @param fallbacks defines the current fallback list.
  55607. * @param currentRank defines the current fallback rank.
  55608. * @returns the new fallback rank.
  55609. */
  55610. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55611. /**
  55612. * Add the required uniforms to the current list.
  55613. * @param uniforms defines the current uniform list.
  55614. */
  55615. static AddUniforms(uniforms: string[]): void;
  55616. /**
  55617. * Add the required samplers to the current list.
  55618. * @param samplers defines the current sampler list.
  55619. */
  55620. static AddSamplers(samplers: string[]): void;
  55621. /**
  55622. * Add the required uniforms to the current buffer.
  55623. * @param uniformBuffer defines the current uniform buffer.
  55624. */
  55625. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55626. /**
  55627. * Makes a duplicate of the current configuration into another one.
  55628. * @param configuration define the config where to copy the info
  55629. */
  55630. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  55631. /**
  55632. * Serializes this Sub Surface configuration.
  55633. * @returns - An object with the serialized config.
  55634. */
  55635. serialize(): any;
  55636. /**
  55637. * Parses a anisotropy Configuration from a serialized object.
  55638. * @param source - Serialized object.
  55639. * @param scene Defines the scene we are parsing for
  55640. * @param rootUrl Defines the rootUrl to load from
  55641. */
  55642. parse(source: any, scene: Scene, rootUrl: string): void;
  55643. }
  55644. }
  55645. declare module BABYLON {
  55646. /** @hidden */
  55647. export var pbrFragmentDeclaration: {
  55648. name: string;
  55649. shader: string;
  55650. };
  55651. }
  55652. declare module BABYLON {
  55653. /** @hidden */
  55654. export var pbrUboDeclaration: {
  55655. name: string;
  55656. shader: string;
  55657. };
  55658. }
  55659. declare module BABYLON {
  55660. /** @hidden */
  55661. export var pbrFragmentExtraDeclaration: {
  55662. name: string;
  55663. shader: string;
  55664. };
  55665. }
  55666. declare module BABYLON {
  55667. /** @hidden */
  55668. export var pbrFragmentSamplersDeclaration: {
  55669. name: string;
  55670. shader: string;
  55671. };
  55672. }
  55673. declare module BABYLON {
  55674. /** @hidden */
  55675. export var importanceSampling: {
  55676. name: string;
  55677. shader: string;
  55678. };
  55679. }
  55680. declare module BABYLON {
  55681. /** @hidden */
  55682. export var pbrHelperFunctions: {
  55683. name: string;
  55684. shader: string;
  55685. };
  55686. }
  55687. declare module BABYLON {
  55688. /** @hidden */
  55689. export var harmonicsFunctions: {
  55690. name: string;
  55691. shader: string;
  55692. };
  55693. }
  55694. declare module BABYLON {
  55695. /** @hidden */
  55696. export var pbrDirectLightingSetupFunctions: {
  55697. name: string;
  55698. shader: string;
  55699. };
  55700. }
  55701. declare module BABYLON {
  55702. /** @hidden */
  55703. export var pbrDirectLightingFalloffFunctions: {
  55704. name: string;
  55705. shader: string;
  55706. };
  55707. }
  55708. declare module BABYLON {
  55709. /** @hidden */
  55710. export var pbrBRDFFunctions: {
  55711. name: string;
  55712. shader: string;
  55713. };
  55714. }
  55715. declare module BABYLON {
  55716. /** @hidden */
  55717. export var hdrFilteringFunctions: {
  55718. name: string;
  55719. shader: string;
  55720. };
  55721. }
  55722. declare module BABYLON {
  55723. /** @hidden */
  55724. export var pbrDirectLightingFunctions: {
  55725. name: string;
  55726. shader: string;
  55727. };
  55728. }
  55729. declare module BABYLON {
  55730. /** @hidden */
  55731. export var pbrIBLFunctions: {
  55732. name: string;
  55733. shader: string;
  55734. };
  55735. }
  55736. declare module BABYLON {
  55737. /** @hidden */
  55738. export var pbrBlockAlbedoOpacity: {
  55739. name: string;
  55740. shader: string;
  55741. };
  55742. }
  55743. declare module BABYLON {
  55744. /** @hidden */
  55745. export var pbrBlockReflectivity: {
  55746. name: string;
  55747. shader: string;
  55748. };
  55749. }
  55750. declare module BABYLON {
  55751. /** @hidden */
  55752. export var pbrBlockAmbientOcclusion: {
  55753. name: string;
  55754. shader: string;
  55755. };
  55756. }
  55757. declare module BABYLON {
  55758. /** @hidden */
  55759. export var pbrBlockAlphaFresnel: {
  55760. name: string;
  55761. shader: string;
  55762. };
  55763. }
  55764. declare module BABYLON {
  55765. /** @hidden */
  55766. export var pbrBlockAnisotropic: {
  55767. name: string;
  55768. shader: string;
  55769. };
  55770. }
  55771. declare module BABYLON {
  55772. /** @hidden */
  55773. export var pbrBlockReflection: {
  55774. name: string;
  55775. shader: string;
  55776. };
  55777. }
  55778. declare module BABYLON {
  55779. /** @hidden */
  55780. export var pbrBlockSheen: {
  55781. name: string;
  55782. shader: string;
  55783. };
  55784. }
  55785. declare module BABYLON {
  55786. /** @hidden */
  55787. export var pbrBlockClearcoat: {
  55788. name: string;
  55789. shader: string;
  55790. };
  55791. }
  55792. declare module BABYLON {
  55793. /** @hidden */
  55794. export var pbrBlockSubSurface: {
  55795. name: string;
  55796. shader: string;
  55797. };
  55798. }
  55799. declare module BABYLON {
  55800. /** @hidden */
  55801. export var pbrBlockNormalGeometric: {
  55802. name: string;
  55803. shader: string;
  55804. };
  55805. }
  55806. declare module BABYLON {
  55807. /** @hidden */
  55808. export var pbrBlockNormalFinal: {
  55809. name: string;
  55810. shader: string;
  55811. };
  55812. }
  55813. declare module BABYLON {
  55814. /** @hidden */
  55815. export var pbrBlockLightmapInit: {
  55816. name: string;
  55817. shader: string;
  55818. };
  55819. }
  55820. declare module BABYLON {
  55821. /** @hidden */
  55822. export var pbrBlockGeometryInfo: {
  55823. name: string;
  55824. shader: string;
  55825. };
  55826. }
  55827. declare module BABYLON {
  55828. /** @hidden */
  55829. export var pbrBlockReflectance0: {
  55830. name: string;
  55831. shader: string;
  55832. };
  55833. }
  55834. declare module BABYLON {
  55835. /** @hidden */
  55836. export var pbrBlockReflectance: {
  55837. name: string;
  55838. shader: string;
  55839. };
  55840. }
  55841. declare module BABYLON {
  55842. /** @hidden */
  55843. export var pbrBlockDirectLighting: {
  55844. name: string;
  55845. shader: string;
  55846. };
  55847. }
  55848. declare module BABYLON {
  55849. /** @hidden */
  55850. export var pbrBlockFinalLitComponents: {
  55851. name: string;
  55852. shader: string;
  55853. };
  55854. }
  55855. declare module BABYLON {
  55856. /** @hidden */
  55857. export var pbrBlockFinalUnlitComponents: {
  55858. name: string;
  55859. shader: string;
  55860. };
  55861. }
  55862. declare module BABYLON {
  55863. /** @hidden */
  55864. export var pbrBlockFinalColorComposition: {
  55865. name: string;
  55866. shader: string;
  55867. };
  55868. }
  55869. declare module BABYLON {
  55870. /** @hidden */
  55871. export var pbrBlockImageProcessing: {
  55872. name: string;
  55873. shader: string;
  55874. };
  55875. }
  55876. declare module BABYLON {
  55877. /** @hidden */
  55878. export var pbrDebug: {
  55879. name: string;
  55880. shader: string;
  55881. };
  55882. }
  55883. declare module BABYLON {
  55884. /** @hidden */
  55885. export var pbrPixelShader: {
  55886. name: string;
  55887. shader: string;
  55888. };
  55889. }
  55890. declare module BABYLON {
  55891. /** @hidden */
  55892. export var pbrVertexDeclaration: {
  55893. name: string;
  55894. shader: string;
  55895. };
  55896. }
  55897. declare module BABYLON {
  55898. /** @hidden */
  55899. export var pbrVertexShader: {
  55900. name: string;
  55901. shader: string;
  55902. };
  55903. }
  55904. declare module BABYLON {
  55905. /**
  55906. * Manages the defines for the PBR Material.
  55907. * @hidden
  55908. */
  55909. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  55910. PBR: boolean;
  55911. NUM_SAMPLES: string;
  55912. REALTIME_FILTERING: boolean;
  55913. MAINUV1: boolean;
  55914. MAINUV2: boolean;
  55915. UV1: boolean;
  55916. UV2: boolean;
  55917. ALBEDO: boolean;
  55918. GAMMAALBEDO: boolean;
  55919. ALBEDODIRECTUV: number;
  55920. VERTEXCOLOR: boolean;
  55921. DETAIL: boolean;
  55922. DETAILDIRECTUV: number;
  55923. DETAIL_NORMALBLENDMETHOD: number;
  55924. AMBIENT: boolean;
  55925. AMBIENTDIRECTUV: number;
  55926. AMBIENTINGRAYSCALE: boolean;
  55927. OPACITY: boolean;
  55928. VERTEXALPHA: boolean;
  55929. OPACITYDIRECTUV: number;
  55930. OPACITYRGB: boolean;
  55931. ALPHATEST: boolean;
  55932. DEPTHPREPASS: boolean;
  55933. ALPHABLEND: boolean;
  55934. ALPHAFROMALBEDO: boolean;
  55935. ALPHATESTVALUE: string;
  55936. SPECULAROVERALPHA: boolean;
  55937. RADIANCEOVERALPHA: boolean;
  55938. ALPHAFRESNEL: boolean;
  55939. LINEARALPHAFRESNEL: boolean;
  55940. PREMULTIPLYALPHA: boolean;
  55941. EMISSIVE: boolean;
  55942. EMISSIVEDIRECTUV: number;
  55943. REFLECTIVITY: boolean;
  55944. REFLECTIVITYDIRECTUV: number;
  55945. SPECULARTERM: boolean;
  55946. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  55947. MICROSURFACEAUTOMATIC: boolean;
  55948. LODBASEDMICROSFURACE: boolean;
  55949. MICROSURFACEMAP: boolean;
  55950. MICROSURFACEMAPDIRECTUV: number;
  55951. METALLICWORKFLOW: boolean;
  55952. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  55953. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  55954. METALLNESSSTOREINMETALMAPBLUE: boolean;
  55955. AOSTOREINMETALMAPRED: boolean;
  55956. METALLIC_REFLECTANCE: boolean;
  55957. METALLIC_REFLECTANCEDIRECTUV: number;
  55958. ENVIRONMENTBRDF: boolean;
  55959. ENVIRONMENTBRDF_RGBD: boolean;
  55960. NORMAL: boolean;
  55961. TANGENT: boolean;
  55962. BUMP: boolean;
  55963. BUMPDIRECTUV: number;
  55964. OBJECTSPACE_NORMALMAP: boolean;
  55965. PARALLAX: boolean;
  55966. PARALLAXOCCLUSION: boolean;
  55967. NORMALXYSCALE: boolean;
  55968. LIGHTMAP: boolean;
  55969. LIGHTMAPDIRECTUV: number;
  55970. USELIGHTMAPASSHADOWMAP: boolean;
  55971. GAMMALIGHTMAP: boolean;
  55972. RGBDLIGHTMAP: boolean;
  55973. REFLECTION: boolean;
  55974. REFLECTIONMAP_3D: boolean;
  55975. REFLECTIONMAP_SPHERICAL: boolean;
  55976. REFLECTIONMAP_PLANAR: boolean;
  55977. REFLECTIONMAP_CUBIC: boolean;
  55978. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  55979. REFLECTIONMAP_PROJECTION: boolean;
  55980. REFLECTIONMAP_SKYBOX: boolean;
  55981. REFLECTIONMAP_EXPLICIT: boolean;
  55982. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  55983. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  55984. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  55985. INVERTCUBICMAP: boolean;
  55986. USESPHERICALFROMREFLECTIONMAP: boolean;
  55987. USEIRRADIANCEMAP: boolean;
  55988. SPHERICAL_HARMONICS: boolean;
  55989. USESPHERICALINVERTEX: boolean;
  55990. REFLECTIONMAP_OPPOSITEZ: boolean;
  55991. LODINREFLECTIONALPHA: boolean;
  55992. GAMMAREFLECTION: boolean;
  55993. RGBDREFLECTION: boolean;
  55994. LINEARSPECULARREFLECTION: boolean;
  55995. RADIANCEOCCLUSION: boolean;
  55996. HORIZONOCCLUSION: boolean;
  55997. INSTANCES: boolean;
  55998. THIN_INSTANCES: boolean;
  55999. PREPASS: boolean;
  56000. SCENE_MRT_COUNT: number;
  56001. NUM_BONE_INFLUENCERS: number;
  56002. BonesPerMesh: number;
  56003. BONETEXTURE: boolean;
  56004. NONUNIFORMSCALING: boolean;
  56005. MORPHTARGETS: boolean;
  56006. MORPHTARGETS_NORMAL: boolean;
  56007. MORPHTARGETS_TANGENT: boolean;
  56008. MORPHTARGETS_UV: boolean;
  56009. NUM_MORPH_INFLUENCERS: number;
  56010. IMAGEPROCESSING: boolean;
  56011. VIGNETTE: boolean;
  56012. VIGNETTEBLENDMODEMULTIPLY: boolean;
  56013. VIGNETTEBLENDMODEOPAQUE: boolean;
  56014. TONEMAPPING: boolean;
  56015. TONEMAPPING_ACES: boolean;
  56016. CONTRAST: boolean;
  56017. COLORCURVES: boolean;
  56018. COLORGRADING: boolean;
  56019. COLORGRADING3D: boolean;
  56020. SAMPLER3DGREENDEPTH: boolean;
  56021. SAMPLER3DBGRMAP: boolean;
  56022. IMAGEPROCESSINGPOSTPROCESS: boolean;
  56023. EXPOSURE: boolean;
  56024. MULTIVIEW: boolean;
  56025. USEPHYSICALLIGHTFALLOFF: boolean;
  56026. USEGLTFLIGHTFALLOFF: boolean;
  56027. TWOSIDEDLIGHTING: boolean;
  56028. SHADOWFLOAT: boolean;
  56029. CLIPPLANE: boolean;
  56030. CLIPPLANE2: boolean;
  56031. CLIPPLANE3: boolean;
  56032. CLIPPLANE4: boolean;
  56033. CLIPPLANE5: boolean;
  56034. CLIPPLANE6: boolean;
  56035. POINTSIZE: boolean;
  56036. FOG: boolean;
  56037. LOGARITHMICDEPTH: boolean;
  56038. FORCENORMALFORWARD: boolean;
  56039. SPECULARAA: boolean;
  56040. CLEARCOAT: boolean;
  56041. CLEARCOAT_DEFAULTIOR: boolean;
  56042. CLEARCOAT_TEXTURE: boolean;
  56043. CLEARCOAT_TEXTUREDIRECTUV: number;
  56044. CLEARCOAT_BUMP: boolean;
  56045. CLEARCOAT_BUMPDIRECTUV: number;
  56046. CLEARCOAT_TINT: boolean;
  56047. CLEARCOAT_TINT_TEXTURE: boolean;
  56048. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  56049. ANISOTROPIC: boolean;
  56050. ANISOTROPIC_TEXTURE: boolean;
  56051. ANISOTROPIC_TEXTUREDIRECTUV: number;
  56052. BRDF_V_HEIGHT_CORRELATED: boolean;
  56053. MS_BRDF_ENERGY_CONSERVATION: boolean;
  56054. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  56055. SHEEN: boolean;
  56056. SHEEN_TEXTURE: boolean;
  56057. SHEEN_TEXTUREDIRECTUV: number;
  56058. SHEEN_LINKWITHALBEDO: boolean;
  56059. SHEEN_ROUGHNESS: boolean;
  56060. SHEEN_ALBEDOSCALING: boolean;
  56061. SUBSURFACE: boolean;
  56062. SS_REFRACTION: boolean;
  56063. SS_TRANSLUCENCY: boolean;
  56064. SS_SCATTERING: boolean;
  56065. SS_THICKNESSANDMASK_TEXTURE: boolean;
  56066. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  56067. SS_REFRACTIONMAP_3D: boolean;
  56068. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  56069. SS_LODINREFRACTIONALPHA: boolean;
  56070. SS_GAMMAREFRACTION: boolean;
  56071. SS_RGBDREFRACTION: boolean;
  56072. SS_LINEARSPECULARREFRACTION: boolean;
  56073. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  56074. SS_ALBEDOFORREFRACTIONTINT: boolean;
  56075. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  56076. UNLIT: boolean;
  56077. DEBUGMODE: number;
  56078. /**
  56079. * Initializes the PBR Material defines.
  56080. */
  56081. constructor();
  56082. /**
  56083. * Resets the PBR Material defines.
  56084. */
  56085. reset(): void;
  56086. }
  56087. /**
  56088. * The Physically based material base class of BJS.
  56089. *
  56090. * This offers the main features of a standard PBR material.
  56091. * For more information, please refer to the documentation :
  56092. * https://doc.babylonjs.com/how_to/physically_based_rendering
  56093. */
  56094. export abstract class PBRBaseMaterial extends PushMaterial {
  56095. /**
  56096. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  56097. */
  56098. static readonly PBRMATERIAL_OPAQUE: number;
  56099. /**
  56100. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  56101. */
  56102. static readonly PBRMATERIAL_ALPHATEST: number;
  56103. /**
  56104. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56105. */
  56106. static readonly PBRMATERIAL_ALPHABLEND: number;
  56107. /**
  56108. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56109. * They are also discarded below the alpha cutoff threshold to improve performances.
  56110. */
  56111. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  56112. /**
  56113. * Defines the default value of how much AO map is occluding the analytical lights
  56114. * (point spot...).
  56115. */
  56116. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  56117. /**
  56118. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  56119. */
  56120. static readonly LIGHTFALLOFF_PHYSICAL: number;
  56121. /**
  56122. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  56123. * to enhance interoperability with other engines.
  56124. */
  56125. static readonly LIGHTFALLOFF_GLTF: number;
  56126. /**
  56127. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  56128. * to enhance interoperability with other materials.
  56129. */
  56130. static readonly LIGHTFALLOFF_STANDARD: number;
  56131. /**
  56132. * Intensity of the direct lights e.g. the four lights available in your scene.
  56133. * This impacts both the direct diffuse and specular highlights.
  56134. */
  56135. protected _directIntensity: number;
  56136. /**
  56137. * Intensity of the emissive part of the material.
  56138. * This helps controlling the emissive effect without modifying the emissive color.
  56139. */
  56140. protected _emissiveIntensity: number;
  56141. /**
  56142. * Intensity of the environment e.g. how much the environment will light the object
  56143. * either through harmonics for rough material or through the refelction for shiny ones.
  56144. */
  56145. protected _environmentIntensity: number;
  56146. /**
  56147. * This is a special control allowing the reduction of the specular highlights coming from the
  56148. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  56149. */
  56150. protected _specularIntensity: number;
  56151. /**
  56152. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  56153. */
  56154. private _lightingInfos;
  56155. /**
  56156. * Debug Control allowing disabling the bump map on this material.
  56157. */
  56158. protected _disableBumpMap: boolean;
  56159. /**
  56160. * AKA Diffuse Texture in standard nomenclature.
  56161. */
  56162. protected _albedoTexture: Nullable<BaseTexture>;
  56163. /**
  56164. * AKA Occlusion Texture in other nomenclature.
  56165. */
  56166. protected _ambientTexture: Nullable<BaseTexture>;
  56167. /**
  56168. * AKA Occlusion Texture Intensity in other nomenclature.
  56169. */
  56170. protected _ambientTextureStrength: number;
  56171. /**
  56172. * Defines how much the AO map is occluding the analytical lights (point spot...).
  56173. * 1 means it completely occludes it
  56174. * 0 mean it has no impact
  56175. */
  56176. protected _ambientTextureImpactOnAnalyticalLights: number;
  56177. /**
  56178. * Stores the alpha values in a texture.
  56179. */
  56180. protected _opacityTexture: Nullable<BaseTexture>;
  56181. /**
  56182. * Stores the reflection values in a texture.
  56183. */
  56184. protected _reflectionTexture: Nullable<BaseTexture>;
  56185. /**
  56186. * Stores the emissive values in a texture.
  56187. */
  56188. protected _emissiveTexture: Nullable<BaseTexture>;
  56189. /**
  56190. * AKA Specular texture in other nomenclature.
  56191. */
  56192. protected _reflectivityTexture: Nullable<BaseTexture>;
  56193. /**
  56194. * Used to switch from specular/glossiness to metallic/roughness workflow.
  56195. */
  56196. protected _metallicTexture: Nullable<BaseTexture>;
  56197. /**
  56198. * Specifies the metallic scalar of the metallic/roughness workflow.
  56199. * Can also be used to scale the metalness values of the metallic texture.
  56200. */
  56201. protected _metallic: Nullable<number>;
  56202. /**
  56203. * Specifies the roughness scalar of the metallic/roughness workflow.
  56204. * Can also be used to scale the roughness values of the metallic texture.
  56205. */
  56206. protected _roughness: Nullable<number>;
  56207. /**
  56208. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  56209. * By default the indexOfrefraction is used to compute F0;
  56210. *
  56211. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  56212. *
  56213. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  56214. * F90 = metallicReflectanceColor;
  56215. */
  56216. protected _metallicF0Factor: number;
  56217. /**
  56218. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  56219. * By default the F90 is always 1;
  56220. *
  56221. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  56222. *
  56223. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  56224. * F90 = metallicReflectanceColor;
  56225. */
  56226. protected _metallicReflectanceColor: Color3;
  56227. /**
  56228. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  56229. * This is multiply against the scalar values defined in the material.
  56230. */
  56231. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  56232. /**
  56233. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  56234. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  56235. */
  56236. protected _microSurfaceTexture: Nullable<BaseTexture>;
  56237. /**
  56238. * Stores surface normal data used to displace a mesh in a texture.
  56239. */
  56240. protected _bumpTexture: Nullable<BaseTexture>;
  56241. /**
  56242. * Stores the pre-calculated light information of a mesh in a texture.
  56243. */
  56244. protected _lightmapTexture: Nullable<BaseTexture>;
  56245. /**
  56246. * The color of a material in ambient lighting.
  56247. */
  56248. protected _ambientColor: Color3;
  56249. /**
  56250. * AKA Diffuse Color in other nomenclature.
  56251. */
  56252. protected _albedoColor: Color3;
  56253. /**
  56254. * AKA Specular Color in other nomenclature.
  56255. */
  56256. protected _reflectivityColor: Color3;
  56257. /**
  56258. * The color applied when light is reflected from a material.
  56259. */
  56260. protected _reflectionColor: Color3;
  56261. /**
  56262. * The color applied when light is emitted from a material.
  56263. */
  56264. protected _emissiveColor: Color3;
  56265. /**
  56266. * AKA Glossiness in other nomenclature.
  56267. */
  56268. protected _microSurface: number;
  56269. /**
  56270. * Specifies that the material will use the light map as a show map.
  56271. */
  56272. protected _useLightmapAsShadowmap: boolean;
  56273. /**
  56274. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  56275. * makes the reflect vector face the model (under horizon).
  56276. */
  56277. protected _useHorizonOcclusion: boolean;
  56278. /**
  56279. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  56280. * too much the area relying on ambient texture to define their ambient occlusion.
  56281. */
  56282. protected _useRadianceOcclusion: boolean;
  56283. /**
  56284. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  56285. */
  56286. protected _useAlphaFromAlbedoTexture: boolean;
  56287. /**
  56288. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  56289. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  56290. */
  56291. protected _useSpecularOverAlpha: boolean;
  56292. /**
  56293. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  56294. */
  56295. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  56296. /**
  56297. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  56298. */
  56299. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  56300. /**
  56301. * Specifies if the metallic texture contains the roughness information in its green channel.
  56302. */
  56303. protected _useRoughnessFromMetallicTextureGreen: boolean;
  56304. /**
  56305. * Specifies if the metallic texture contains the metallness information in its blue channel.
  56306. */
  56307. protected _useMetallnessFromMetallicTextureBlue: boolean;
  56308. /**
  56309. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  56310. */
  56311. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  56312. /**
  56313. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  56314. */
  56315. protected _useAmbientInGrayScale: boolean;
  56316. /**
  56317. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  56318. * The material will try to infer what glossiness each pixel should be.
  56319. */
  56320. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  56321. /**
  56322. * Defines the falloff type used in this material.
  56323. * It by default is Physical.
  56324. */
  56325. protected _lightFalloff: number;
  56326. /**
  56327. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  56328. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  56329. */
  56330. protected _useRadianceOverAlpha: boolean;
  56331. /**
  56332. * Allows using an object space normal map (instead of tangent space).
  56333. */
  56334. protected _useObjectSpaceNormalMap: boolean;
  56335. /**
  56336. * Allows using the bump map in parallax mode.
  56337. */
  56338. protected _useParallax: boolean;
  56339. /**
  56340. * Allows using the bump map in parallax occlusion mode.
  56341. */
  56342. protected _useParallaxOcclusion: boolean;
  56343. /**
  56344. * Controls the scale bias of the parallax mode.
  56345. */
  56346. protected _parallaxScaleBias: number;
  56347. /**
  56348. * If sets to true, disables all the lights affecting the material.
  56349. */
  56350. protected _disableLighting: boolean;
  56351. /**
  56352. * Number of Simultaneous lights allowed on the material.
  56353. */
  56354. protected _maxSimultaneousLights: number;
  56355. /**
  56356. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  56357. */
  56358. protected _invertNormalMapX: boolean;
  56359. /**
  56360. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  56361. */
  56362. protected _invertNormalMapY: boolean;
  56363. /**
  56364. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56365. */
  56366. protected _twoSidedLighting: boolean;
  56367. /**
  56368. * Defines the alpha limits in alpha test mode.
  56369. */
  56370. protected _alphaCutOff: number;
  56371. /**
  56372. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  56373. */
  56374. protected _forceAlphaTest: boolean;
  56375. /**
  56376. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56377. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  56378. */
  56379. protected _useAlphaFresnel: boolean;
  56380. /**
  56381. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56382. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  56383. */
  56384. protected _useLinearAlphaFresnel: boolean;
  56385. /**
  56386. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  56387. * from cos thetav and roughness:
  56388. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  56389. */
  56390. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  56391. /**
  56392. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  56393. */
  56394. protected _forceIrradianceInFragment: boolean;
  56395. private _realTimeFiltering;
  56396. /**
  56397. * Enables realtime filtering on the texture.
  56398. */
  56399. get realTimeFiltering(): boolean;
  56400. set realTimeFiltering(b: boolean);
  56401. private _realTimeFilteringQuality;
  56402. /**
  56403. * Quality switch for realtime filtering
  56404. */
  56405. get realTimeFilteringQuality(): number;
  56406. set realTimeFilteringQuality(n: number);
  56407. /**
  56408. * Can this material render to several textures at once
  56409. */
  56410. get canRenderToMRT(): boolean;
  56411. /**
  56412. * Force normal to face away from face.
  56413. */
  56414. protected _forceNormalForward: boolean;
  56415. /**
  56416. * Enables specular anti aliasing in the PBR shader.
  56417. * It will both interacts on the Geometry for analytical and IBL lighting.
  56418. * It also prefilter the roughness map based on the bump values.
  56419. */
  56420. protected _enableSpecularAntiAliasing: boolean;
  56421. /**
  56422. * Default configuration related to image processing available in the PBR Material.
  56423. */
  56424. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56425. /**
  56426. * Keep track of the image processing observer to allow dispose and replace.
  56427. */
  56428. private _imageProcessingObserver;
  56429. /**
  56430. * Attaches a new image processing configuration to the PBR Material.
  56431. * @param configuration
  56432. */
  56433. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56434. /**
  56435. * Stores the available render targets.
  56436. */
  56437. private _renderTargets;
  56438. /**
  56439. * Sets the global ambient color for the material used in lighting calculations.
  56440. */
  56441. private _globalAmbientColor;
  56442. /**
  56443. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  56444. */
  56445. private _useLogarithmicDepth;
  56446. /**
  56447. * If set to true, no lighting calculations will be applied.
  56448. */
  56449. private _unlit;
  56450. private _debugMode;
  56451. /**
  56452. * @hidden
  56453. * This is reserved for the inspector.
  56454. * Defines the material debug mode.
  56455. * It helps seeing only some components of the material while troubleshooting.
  56456. */
  56457. debugMode: number;
  56458. /**
  56459. * @hidden
  56460. * This is reserved for the inspector.
  56461. * Specify from where on screen the debug mode should start.
  56462. * The value goes from -1 (full screen) to 1 (not visible)
  56463. * It helps with side by side comparison against the final render
  56464. * This defaults to -1
  56465. */
  56466. private debugLimit;
  56467. /**
  56468. * @hidden
  56469. * This is reserved for the inspector.
  56470. * As the default viewing range might not be enough (if the ambient is really small for instance)
  56471. * You can use the factor to better multiply the final value.
  56472. */
  56473. private debugFactor;
  56474. /**
  56475. * Defines the clear coat layer parameters for the material.
  56476. */
  56477. readonly clearCoat: PBRClearCoatConfiguration;
  56478. /**
  56479. * Defines the anisotropic parameters for the material.
  56480. */
  56481. readonly anisotropy: PBRAnisotropicConfiguration;
  56482. /**
  56483. * Defines the BRDF parameters for the material.
  56484. */
  56485. readonly brdf: PBRBRDFConfiguration;
  56486. /**
  56487. * Defines the Sheen parameters for the material.
  56488. */
  56489. readonly sheen: PBRSheenConfiguration;
  56490. /**
  56491. * Defines the SubSurface parameters for the material.
  56492. */
  56493. readonly subSurface: PBRSubSurfaceConfiguration;
  56494. /**
  56495. * Defines the detail map parameters for the material.
  56496. */
  56497. readonly detailMap: DetailMapConfiguration;
  56498. protected _rebuildInParallel: boolean;
  56499. /**
  56500. * Instantiates a new PBRMaterial instance.
  56501. *
  56502. * @param name The material name
  56503. * @param scene The scene the material will be use in.
  56504. */
  56505. constructor(name: string, scene: Scene);
  56506. /**
  56507. * Gets a boolean indicating that current material needs to register RTT
  56508. */
  56509. get hasRenderTargetTextures(): boolean;
  56510. /**
  56511. * Gets the name of the material class.
  56512. */
  56513. getClassName(): string;
  56514. /**
  56515. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  56516. */
  56517. get useLogarithmicDepth(): boolean;
  56518. /**
  56519. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  56520. */
  56521. set useLogarithmicDepth(value: boolean);
  56522. /**
  56523. * Returns true if alpha blending should be disabled.
  56524. */
  56525. protected get _disableAlphaBlending(): boolean;
  56526. /**
  56527. * Specifies whether or not this material should be rendered in alpha blend mode.
  56528. */
  56529. needAlphaBlending(): boolean;
  56530. /**
  56531. * Specifies whether or not this material should be rendered in alpha test mode.
  56532. */
  56533. needAlphaTesting(): boolean;
  56534. /**
  56535. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  56536. */
  56537. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  56538. /**
  56539. * Gets the texture used for the alpha test.
  56540. */
  56541. getAlphaTestTexture(): Nullable<BaseTexture>;
  56542. /**
  56543. * Specifies that the submesh is ready to be used.
  56544. * @param mesh - BJS mesh.
  56545. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  56546. * @param useInstances - Specifies that instances should be used.
  56547. * @returns - boolean indicating that the submesh is ready or not.
  56548. */
  56549. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56550. /**
  56551. * Specifies if the material uses metallic roughness workflow.
  56552. * @returns boolean specifiying if the material uses metallic roughness workflow.
  56553. */
  56554. isMetallicWorkflow(): boolean;
  56555. private _prepareEffect;
  56556. private _prepareDefines;
  56557. /**
  56558. * Force shader compilation
  56559. */
  56560. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  56561. /**
  56562. * Initializes the uniform buffer layout for the shader.
  56563. */
  56564. buildUniformLayout(): void;
  56565. /**
  56566. * Unbinds the material from the mesh
  56567. */
  56568. unbind(): void;
  56569. /**
  56570. * Binds the submesh data.
  56571. * @param world - The world matrix.
  56572. * @param mesh - The BJS mesh.
  56573. * @param subMesh - A submesh of the BJS mesh.
  56574. */
  56575. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56576. /**
  56577. * Returns the animatable textures.
  56578. * @returns - Array of animatable textures.
  56579. */
  56580. getAnimatables(): IAnimatable[];
  56581. /**
  56582. * Returns the texture used for reflections.
  56583. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  56584. */
  56585. private _getReflectionTexture;
  56586. /**
  56587. * Returns an array of the actively used textures.
  56588. * @returns - Array of BaseTextures
  56589. */
  56590. getActiveTextures(): BaseTexture[];
  56591. /**
  56592. * Checks to see if a texture is used in the material.
  56593. * @param texture - Base texture to use.
  56594. * @returns - Boolean specifying if a texture is used in the material.
  56595. */
  56596. hasTexture(texture: BaseTexture): boolean;
  56597. /**
  56598. * Sets the required values to the prepass renderer.
  56599. * @param prePassRenderer defines the prepass renderer to setup
  56600. */
  56601. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  56602. /**
  56603. * Disposes the resources of the material.
  56604. * @param forceDisposeEffect - Forces the disposal of effects.
  56605. * @param forceDisposeTextures - Forces the disposal of all textures.
  56606. */
  56607. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  56608. }
  56609. }
  56610. declare module BABYLON {
  56611. /**
  56612. * The Physically based material of BJS.
  56613. *
  56614. * This offers the main features of a standard PBR material.
  56615. * For more information, please refer to the documentation :
  56616. * https://doc.babylonjs.com/how_to/physically_based_rendering
  56617. */
  56618. export class PBRMaterial extends PBRBaseMaterial {
  56619. /**
  56620. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  56621. */
  56622. static readonly PBRMATERIAL_OPAQUE: number;
  56623. /**
  56624. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  56625. */
  56626. static readonly PBRMATERIAL_ALPHATEST: number;
  56627. /**
  56628. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56629. */
  56630. static readonly PBRMATERIAL_ALPHABLEND: number;
  56631. /**
  56632. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56633. * They are also discarded below the alpha cutoff threshold to improve performances.
  56634. */
  56635. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  56636. /**
  56637. * Defines the default value of how much AO map is occluding the analytical lights
  56638. * (point spot...).
  56639. */
  56640. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  56641. /**
  56642. * Intensity of the direct lights e.g. the four lights available in your scene.
  56643. * This impacts both the direct diffuse and specular highlights.
  56644. */
  56645. directIntensity: number;
  56646. /**
  56647. * Intensity of the emissive part of the material.
  56648. * This helps controlling the emissive effect without modifying the emissive color.
  56649. */
  56650. emissiveIntensity: number;
  56651. /**
  56652. * Intensity of the environment e.g. how much the environment will light the object
  56653. * either through harmonics for rough material or through the refelction for shiny ones.
  56654. */
  56655. environmentIntensity: number;
  56656. /**
  56657. * This is a special control allowing the reduction of the specular highlights coming from the
  56658. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  56659. */
  56660. specularIntensity: number;
  56661. /**
  56662. * Debug Control allowing disabling the bump map on this material.
  56663. */
  56664. disableBumpMap: boolean;
  56665. /**
  56666. * AKA Diffuse Texture in standard nomenclature.
  56667. */
  56668. albedoTexture: BaseTexture;
  56669. /**
  56670. * AKA Occlusion Texture in other nomenclature.
  56671. */
  56672. ambientTexture: BaseTexture;
  56673. /**
  56674. * AKA Occlusion Texture Intensity in other nomenclature.
  56675. */
  56676. ambientTextureStrength: number;
  56677. /**
  56678. * Defines how much the AO map is occluding the analytical lights (point spot...).
  56679. * 1 means it completely occludes it
  56680. * 0 mean it has no impact
  56681. */
  56682. ambientTextureImpactOnAnalyticalLights: number;
  56683. /**
  56684. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  56685. */
  56686. opacityTexture: BaseTexture;
  56687. /**
  56688. * Stores the reflection values in a texture.
  56689. */
  56690. reflectionTexture: Nullable<BaseTexture>;
  56691. /**
  56692. * Stores the emissive values in a texture.
  56693. */
  56694. emissiveTexture: BaseTexture;
  56695. /**
  56696. * AKA Specular texture in other nomenclature.
  56697. */
  56698. reflectivityTexture: BaseTexture;
  56699. /**
  56700. * Used to switch from specular/glossiness to metallic/roughness workflow.
  56701. */
  56702. metallicTexture: BaseTexture;
  56703. /**
  56704. * Specifies the metallic scalar of the metallic/roughness workflow.
  56705. * Can also be used to scale the metalness values of the metallic texture.
  56706. */
  56707. metallic: Nullable<number>;
  56708. /**
  56709. * Specifies the roughness scalar of the metallic/roughness workflow.
  56710. * Can also be used to scale the roughness values of the metallic texture.
  56711. */
  56712. roughness: Nullable<number>;
  56713. /**
  56714. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  56715. * By default the indexOfrefraction is used to compute F0;
  56716. *
  56717. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  56718. *
  56719. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  56720. * F90 = metallicReflectanceColor;
  56721. */
  56722. metallicF0Factor: number;
  56723. /**
  56724. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  56725. * By default the F90 is always 1;
  56726. *
  56727. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  56728. *
  56729. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  56730. * F90 = metallicReflectanceColor;
  56731. */
  56732. metallicReflectanceColor: Color3;
  56733. /**
  56734. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  56735. * This is multiply against the scalar values defined in the material.
  56736. */
  56737. metallicReflectanceTexture: Nullable<BaseTexture>;
  56738. /**
  56739. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  56740. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  56741. */
  56742. microSurfaceTexture: BaseTexture;
  56743. /**
  56744. * Stores surface normal data used to displace a mesh in a texture.
  56745. */
  56746. bumpTexture: BaseTexture;
  56747. /**
  56748. * Stores the pre-calculated light information of a mesh in a texture.
  56749. */
  56750. lightmapTexture: BaseTexture;
  56751. /**
  56752. * Stores the refracted light information in a texture.
  56753. */
  56754. get refractionTexture(): Nullable<BaseTexture>;
  56755. set refractionTexture(value: Nullable<BaseTexture>);
  56756. /**
  56757. * The color of a material in ambient lighting.
  56758. */
  56759. ambientColor: Color3;
  56760. /**
  56761. * AKA Diffuse Color in other nomenclature.
  56762. */
  56763. albedoColor: Color3;
  56764. /**
  56765. * AKA Specular Color in other nomenclature.
  56766. */
  56767. reflectivityColor: Color3;
  56768. /**
  56769. * The color reflected from the material.
  56770. */
  56771. reflectionColor: Color3;
  56772. /**
  56773. * The color emitted from the material.
  56774. */
  56775. emissiveColor: Color3;
  56776. /**
  56777. * AKA Glossiness in other nomenclature.
  56778. */
  56779. microSurface: number;
  56780. /**
  56781. * Index of refraction of the material base layer.
  56782. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  56783. *
  56784. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  56785. *
  56786. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  56787. */
  56788. get indexOfRefraction(): number;
  56789. set indexOfRefraction(value: number);
  56790. /**
  56791. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  56792. */
  56793. get invertRefractionY(): boolean;
  56794. set invertRefractionY(value: boolean);
  56795. /**
  56796. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  56797. * Materials half opaque for instance using refraction could benefit from this control.
  56798. */
  56799. get linkRefractionWithTransparency(): boolean;
  56800. set linkRefractionWithTransparency(value: boolean);
  56801. /**
  56802. * If true, the light map contains occlusion information instead of lighting info.
  56803. */
  56804. useLightmapAsShadowmap: boolean;
  56805. /**
  56806. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  56807. */
  56808. useAlphaFromAlbedoTexture: boolean;
  56809. /**
  56810. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  56811. */
  56812. forceAlphaTest: boolean;
  56813. /**
  56814. * Defines the alpha limits in alpha test mode.
  56815. */
  56816. alphaCutOff: number;
  56817. /**
  56818. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  56819. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  56820. */
  56821. useSpecularOverAlpha: boolean;
  56822. /**
  56823. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  56824. */
  56825. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  56826. /**
  56827. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  56828. */
  56829. useRoughnessFromMetallicTextureAlpha: boolean;
  56830. /**
  56831. * Specifies if the metallic texture contains the roughness information in its green channel.
  56832. */
  56833. useRoughnessFromMetallicTextureGreen: boolean;
  56834. /**
  56835. * Specifies if the metallic texture contains the metallness information in its blue channel.
  56836. */
  56837. useMetallnessFromMetallicTextureBlue: boolean;
  56838. /**
  56839. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  56840. */
  56841. useAmbientOcclusionFromMetallicTextureRed: boolean;
  56842. /**
  56843. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  56844. */
  56845. useAmbientInGrayScale: boolean;
  56846. /**
  56847. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  56848. * The material will try to infer what glossiness each pixel should be.
  56849. */
  56850. useAutoMicroSurfaceFromReflectivityMap: boolean;
  56851. /**
  56852. * BJS is using an harcoded light falloff based on a manually sets up range.
  56853. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  56854. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  56855. */
  56856. get usePhysicalLightFalloff(): boolean;
  56857. /**
  56858. * BJS is using an harcoded light falloff based on a manually sets up range.
  56859. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  56860. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  56861. */
  56862. set usePhysicalLightFalloff(value: boolean);
  56863. /**
  56864. * In order to support the falloff compatibility with gltf, a special mode has been added
  56865. * to reproduce the gltf light falloff.
  56866. */
  56867. get useGLTFLightFalloff(): boolean;
  56868. /**
  56869. * In order to support the falloff compatibility with gltf, a special mode has been added
  56870. * to reproduce the gltf light falloff.
  56871. */
  56872. set useGLTFLightFalloff(value: boolean);
  56873. /**
  56874. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  56875. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  56876. */
  56877. useRadianceOverAlpha: boolean;
  56878. /**
  56879. * Allows using an object space normal map (instead of tangent space).
  56880. */
  56881. useObjectSpaceNormalMap: boolean;
  56882. /**
  56883. * Allows using the bump map in parallax mode.
  56884. */
  56885. useParallax: boolean;
  56886. /**
  56887. * Allows using the bump map in parallax occlusion mode.
  56888. */
  56889. useParallaxOcclusion: boolean;
  56890. /**
  56891. * Controls the scale bias of the parallax mode.
  56892. */
  56893. parallaxScaleBias: number;
  56894. /**
  56895. * If sets to true, disables all the lights affecting the material.
  56896. */
  56897. disableLighting: boolean;
  56898. /**
  56899. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  56900. */
  56901. forceIrradianceInFragment: boolean;
  56902. /**
  56903. * Number of Simultaneous lights allowed on the material.
  56904. */
  56905. maxSimultaneousLights: number;
  56906. /**
  56907. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  56908. */
  56909. invertNormalMapX: boolean;
  56910. /**
  56911. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  56912. */
  56913. invertNormalMapY: boolean;
  56914. /**
  56915. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56916. */
  56917. twoSidedLighting: boolean;
  56918. /**
  56919. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56920. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  56921. */
  56922. useAlphaFresnel: boolean;
  56923. /**
  56924. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56925. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  56926. */
  56927. useLinearAlphaFresnel: boolean;
  56928. /**
  56929. * Let user defines the brdf lookup texture used for IBL.
  56930. * A default 8bit version is embedded but you could point at :
  56931. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  56932. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  56933. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  56934. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  56935. */
  56936. environmentBRDFTexture: Nullable<BaseTexture>;
  56937. /**
  56938. * Force normal to face away from face.
  56939. */
  56940. forceNormalForward: boolean;
  56941. /**
  56942. * Enables specular anti aliasing in the PBR shader.
  56943. * It will both interacts on the Geometry for analytical and IBL lighting.
  56944. * It also prefilter the roughness map based on the bump values.
  56945. */
  56946. enableSpecularAntiAliasing: boolean;
  56947. /**
  56948. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  56949. * makes the reflect vector face the model (under horizon).
  56950. */
  56951. useHorizonOcclusion: boolean;
  56952. /**
  56953. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  56954. * too much the area relying on ambient texture to define their ambient occlusion.
  56955. */
  56956. useRadianceOcclusion: boolean;
  56957. /**
  56958. * If set to true, no lighting calculations will be applied.
  56959. */
  56960. unlit: boolean;
  56961. /**
  56962. * Gets the image processing configuration used either in this material.
  56963. */
  56964. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  56965. /**
  56966. * Sets the Default image processing configuration used either in the this material.
  56967. *
  56968. * If sets to null, the scene one is in use.
  56969. */
  56970. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  56971. /**
  56972. * Gets wether the color curves effect is enabled.
  56973. */
  56974. get cameraColorCurvesEnabled(): boolean;
  56975. /**
  56976. * Sets wether the color curves effect is enabled.
  56977. */
  56978. set cameraColorCurvesEnabled(value: boolean);
  56979. /**
  56980. * Gets wether the color grading effect is enabled.
  56981. */
  56982. get cameraColorGradingEnabled(): boolean;
  56983. /**
  56984. * Gets wether the color grading effect is enabled.
  56985. */
  56986. set cameraColorGradingEnabled(value: boolean);
  56987. /**
  56988. * Gets wether tonemapping is enabled or not.
  56989. */
  56990. get cameraToneMappingEnabled(): boolean;
  56991. /**
  56992. * Sets wether tonemapping is enabled or not
  56993. */
  56994. set cameraToneMappingEnabled(value: boolean);
  56995. /**
  56996. * The camera exposure used on this material.
  56997. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56998. * This corresponds to a photographic exposure.
  56999. */
  57000. get cameraExposure(): number;
  57001. /**
  57002. * The camera exposure used on this material.
  57003. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57004. * This corresponds to a photographic exposure.
  57005. */
  57006. set cameraExposure(value: number);
  57007. /**
  57008. * Gets The camera contrast used on this material.
  57009. */
  57010. get cameraContrast(): number;
  57011. /**
  57012. * Sets The camera contrast used on this material.
  57013. */
  57014. set cameraContrast(value: number);
  57015. /**
  57016. * Gets the Color Grading 2D Lookup Texture.
  57017. */
  57018. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  57019. /**
  57020. * Sets the Color Grading 2D Lookup Texture.
  57021. */
  57022. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  57023. /**
  57024. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57025. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57026. * 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;
  57027. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57028. */
  57029. get cameraColorCurves(): Nullable<ColorCurves>;
  57030. /**
  57031. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57032. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57033. * 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;
  57034. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57035. */
  57036. set cameraColorCurves(value: Nullable<ColorCurves>);
  57037. /**
  57038. * Instantiates a new PBRMaterial instance.
  57039. *
  57040. * @param name The material name
  57041. * @param scene The scene the material will be use in.
  57042. */
  57043. constructor(name: string, scene: Scene);
  57044. /**
  57045. * Returns the name of this material class.
  57046. */
  57047. getClassName(): string;
  57048. /**
  57049. * Makes a duplicate of the current material.
  57050. * @param name - name to use for the new material.
  57051. */
  57052. clone(name: string): PBRMaterial;
  57053. /**
  57054. * Serializes this PBR Material.
  57055. * @returns - An object with the serialized material.
  57056. */
  57057. serialize(): any;
  57058. /**
  57059. * Parses a PBR Material from a serialized object.
  57060. * @param source - Serialized object.
  57061. * @param scene - BJS scene instance.
  57062. * @param rootUrl - url for the scene object
  57063. * @returns - PBRMaterial
  57064. */
  57065. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  57066. }
  57067. }
  57068. declare module BABYLON {
  57069. /**
  57070. * Direct draw surface info
  57071. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  57072. */
  57073. export interface DDSInfo {
  57074. /**
  57075. * Width of the texture
  57076. */
  57077. width: number;
  57078. /**
  57079. * Width of the texture
  57080. */
  57081. height: number;
  57082. /**
  57083. * Number of Mipmaps for the texture
  57084. * @see https://en.wikipedia.org/wiki/Mipmap
  57085. */
  57086. mipmapCount: number;
  57087. /**
  57088. * If the textures format is a known fourCC format
  57089. * @see https://www.fourcc.org/
  57090. */
  57091. isFourCC: boolean;
  57092. /**
  57093. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  57094. */
  57095. isRGB: boolean;
  57096. /**
  57097. * If the texture is a lumincance format
  57098. */
  57099. isLuminance: boolean;
  57100. /**
  57101. * If this is a cube texture
  57102. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  57103. */
  57104. isCube: boolean;
  57105. /**
  57106. * If the texture is a compressed format eg. FOURCC_DXT1
  57107. */
  57108. isCompressed: boolean;
  57109. /**
  57110. * The dxgiFormat of the texture
  57111. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  57112. */
  57113. dxgiFormat: number;
  57114. /**
  57115. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  57116. */
  57117. textureType: number;
  57118. /**
  57119. * Sphericle polynomial created for the dds texture
  57120. */
  57121. sphericalPolynomial?: SphericalPolynomial;
  57122. }
  57123. /**
  57124. * Class used to provide DDS decompression tools
  57125. */
  57126. export class DDSTools {
  57127. /**
  57128. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  57129. */
  57130. static StoreLODInAlphaChannel: boolean;
  57131. /**
  57132. * Gets DDS information from an array buffer
  57133. * @param data defines the array buffer view to read data from
  57134. * @returns the DDS information
  57135. */
  57136. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  57137. private static _FloatView;
  57138. private static _Int32View;
  57139. private static _ToHalfFloat;
  57140. private static _FromHalfFloat;
  57141. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  57142. private static _GetHalfFloatRGBAArrayBuffer;
  57143. private static _GetFloatRGBAArrayBuffer;
  57144. private static _GetFloatAsUIntRGBAArrayBuffer;
  57145. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  57146. private static _GetRGBAArrayBuffer;
  57147. private static _ExtractLongWordOrder;
  57148. private static _GetRGBArrayBuffer;
  57149. private static _GetLuminanceArrayBuffer;
  57150. /**
  57151. * Uploads DDS Levels to a Babylon Texture
  57152. * @hidden
  57153. */
  57154. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  57155. }
  57156. interface ThinEngine {
  57157. /**
  57158. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  57159. * @param rootUrl defines the url where the file to load is located
  57160. * @param scene defines the current scene
  57161. * @param lodScale defines scale to apply to the mip map selection
  57162. * @param lodOffset defines offset to apply to the mip map selection
  57163. * @param onLoad defines an optional callback raised when the texture is loaded
  57164. * @param onError defines an optional callback raised if there is an issue to load the texture
  57165. * @param format defines the format of the data
  57166. * @param forcedExtension defines the extension to use to pick the right loader
  57167. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  57168. * @returns the cube texture as an InternalTexture
  57169. */
  57170. 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;
  57171. }
  57172. }
  57173. declare module BABYLON {
  57174. /**
  57175. * Implementation of the DDS Texture Loader.
  57176. * @hidden
  57177. */
  57178. export class _DDSTextureLoader implements IInternalTextureLoader {
  57179. /**
  57180. * Defines wether the loader supports cascade loading the different faces.
  57181. */
  57182. readonly supportCascades: boolean;
  57183. /**
  57184. * This returns if the loader support the current file information.
  57185. * @param extension defines the file extension of the file being loaded
  57186. * @returns true if the loader can load the specified file
  57187. */
  57188. canLoad(extension: string): boolean;
  57189. /**
  57190. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57191. * @param data contains the texture data
  57192. * @param texture defines the BabylonJS internal texture
  57193. * @param createPolynomials will be true if polynomials have been requested
  57194. * @param onLoad defines the callback to trigger once the texture is ready
  57195. * @param onError defines the callback to trigger in case of error
  57196. */
  57197. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57198. /**
  57199. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57200. * @param data contains the texture data
  57201. * @param texture defines the BabylonJS internal texture
  57202. * @param callback defines the method to call once ready to upload
  57203. */
  57204. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57205. }
  57206. }
  57207. declare module BABYLON {
  57208. /**
  57209. * Implementation of the ENV Texture Loader.
  57210. * @hidden
  57211. */
  57212. export class _ENVTextureLoader implements IInternalTextureLoader {
  57213. /**
  57214. * Defines wether the loader supports cascade loading the different faces.
  57215. */
  57216. readonly supportCascades: boolean;
  57217. /**
  57218. * This returns if the loader support the current file information.
  57219. * @param extension defines the file extension of the file being loaded
  57220. * @returns true if the loader can load the specified file
  57221. */
  57222. canLoad(extension: string): boolean;
  57223. /**
  57224. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57225. * @param data contains the texture data
  57226. * @param texture defines the BabylonJS internal texture
  57227. * @param createPolynomials will be true if polynomials have been requested
  57228. * @param onLoad defines the callback to trigger once the texture is ready
  57229. * @param onError defines the callback to trigger in case of error
  57230. */
  57231. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57232. /**
  57233. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57234. * @param data contains the texture data
  57235. * @param texture defines the BabylonJS internal texture
  57236. * @param callback defines the method to call once ready to upload
  57237. */
  57238. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57239. }
  57240. }
  57241. declare module BABYLON {
  57242. /**
  57243. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  57244. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  57245. */
  57246. export class KhronosTextureContainer {
  57247. /** contents of the KTX container file */
  57248. data: ArrayBufferView;
  57249. private static HEADER_LEN;
  57250. private static COMPRESSED_2D;
  57251. private static COMPRESSED_3D;
  57252. private static TEX_2D;
  57253. private static TEX_3D;
  57254. /**
  57255. * Gets the openGL type
  57256. */
  57257. glType: number;
  57258. /**
  57259. * Gets the openGL type size
  57260. */
  57261. glTypeSize: number;
  57262. /**
  57263. * Gets the openGL format
  57264. */
  57265. glFormat: number;
  57266. /**
  57267. * Gets the openGL internal format
  57268. */
  57269. glInternalFormat: number;
  57270. /**
  57271. * Gets the base internal format
  57272. */
  57273. glBaseInternalFormat: number;
  57274. /**
  57275. * Gets image width in pixel
  57276. */
  57277. pixelWidth: number;
  57278. /**
  57279. * Gets image height in pixel
  57280. */
  57281. pixelHeight: number;
  57282. /**
  57283. * Gets image depth in pixels
  57284. */
  57285. pixelDepth: number;
  57286. /**
  57287. * Gets the number of array elements
  57288. */
  57289. numberOfArrayElements: number;
  57290. /**
  57291. * Gets the number of faces
  57292. */
  57293. numberOfFaces: number;
  57294. /**
  57295. * Gets the number of mipmap levels
  57296. */
  57297. numberOfMipmapLevels: number;
  57298. /**
  57299. * Gets the bytes of key value data
  57300. */
  57301. bytesOfKeyValueData: number;
  57302. /**
  57303. * Gets the load type
  57304. */
  57305. loadType: number;
  57306. /**
  57307. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  57308. */
  57309. isInvalid: boolean;
  57310. /**
  57311. * Creates a new KhronosTextureContainer
  57312. * @param data contents of the KTX container file
  57313. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  57314. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  57315. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  57316. */
  57317. constructor(
  57318. /** contents of the KTX container file */
  57319. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  57320. /**
  57321. * Uploads KTX content to a Babylon Texture.
  57322. * It is assumed that the texture has already been created & is currently bound
  57323. * @hidden
  57324. */
  57325. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  57326. private _upload2DCompressedLevels;
  57327. /**
  57328. * Checks if the given data starts with a KTX file identifier.
  57329. * @param data the data to check
  57330. * @returns true if the data is a KTX file or false otherwise
  57331. */
  57332. static IsValid(data: ArrayBufferView): boolean;
  57333. }
  57334. }
  57335. declare module BABYLON {
  57336. /**
  57337. * Class for loading KTX2 files
  57338. * !!! Experimental Extension Subject to Changes !!!
  57339. * @hidden
  57340. */
  57341. export class KhronosTextureContainer2 {
  57342. private static _ModulePromise;
  57343. private static _TranscodeFormat;
  57344. constructor(engine: ThinEngine);
  57345. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  57346. private _determineTranscodeFormat;
  57347. /**
  57348. * Checks if the given data starts with a KTX2 file identifier.
  57349. * @param data the data to check
  57350. * @returns true if the data is a KTX2 file or false otherwise
  57351. */
  57352. static IsValid(data: ArrayBufferView): boolean;
  57353. }
  57354. }
  57355. declare module BABYLON {
  57356. /**
  57357. * Implementation of the KTX Texture Loader.
  57358. * @hidden
  57359. */
  57360. export class _KTXTextureLoader implements IInternalTextureLoader {
  57361. /**
  57362. * Defines wether the loader supports cascade loading the different faces.
  57363. */
  57364. readonly supportCascades: boolean;
  57365. /**
  57366. * This returns if the loader support the current file information.
  57367. * @param extension defines the file extension of the file being loaded
  57368. * @param mimeType defines the optional mime type of the file being loaded
  57369. * @returns true if the loader can load the specified file
  57370. */
  57371. canLoad(extension: string, mimeType?: string): boolean;
  57372. /**
  57373. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57374. * @param data contains the texture data
  57375. * @param texture defines the BabylonJS internal texture
  57376. * @param createPolynomials will be true if polynomials have been requested
  57377. * @param onLoad defines the callback to trigger once the texture is ready
  57378. * @param onError defines the callback to trigger in case of error
  57379. */
  57380. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57381. /**
  57382. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57383. * @param data contains the texture data
  57384. * @param texture defines the BabylonJS internal texture
  57385. * @param callback defines the method to call once ready to upload
  57386. */
  57387. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  57388. }
  57389. }
  57390. declare module BABYLON {
  57391. /** @hidden */
  57392. export var _forceSceneHelpersToBundle: boolean;
  57393. interface Scene {
  57394. /**
  57395. * Creates a default light for the scene.
  57396. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  57397. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  57398. */
  57399. createDefaultLight(replace?: boolean): void;
  57400. /**
  57401. * Creates a default camera for the scene.
  57402. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  57403. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  57404. * @param replace has default false, when true replaces the active camera in the scene
  57405. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  57406. */
  57407. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  57408. /**
  57409. * Creates a default camera and a default light.
  57410. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  57411. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  57412. * @param replace has the default false, when true replaces the active camera/light in the scene
  57413. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  57414. */
  57415. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  57416. /**
  57417. * Creates a new sky box
  57418. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  57419. * @param environmentTexture defines the texture to use as environment texture
  57420. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  57421. * @param scale defines the overall scale of the skybox
  57422. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  57423. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  57424. * @returns a new mesh holding the sky box
  57425. */
  57426. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  57427. /**
  57428. * Creates a new environment
  57429. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  57430. * @param options defines the options you can use to configure the environment
  57431. * @returns the new EnvironmentHelper
  57432. */
  57433. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  57434. /**
  57435. * Creates a new VREXperienceHelper
  57436. * @see https://doc.babylonjs.com/how_to/webvr_helper
  57437. * @param webVROptions defines the options used to create the new VREXperienceHelper
  57438. * @returns a new VREXperienceHelper
  57439. */
  57440. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  57441. /**
  57442. * Creates a new WebXRDefaultExperience
  57443. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  57444. * @param options experience options
  57445. * @returns a promise for a new WebXRDefaultExperience
  57446. */
  57447. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  57448. }
  57449. }
  57450. declare module BABYLON {
  57451. /**
  57452. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  57453. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  57454. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  57455. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57456. */
  57457. export class VideoDome extends TransformNode {
  57458. /**
  57459. * Define the video source as a Monoscopic panoramic 360 video.
  57460. */
  57461. static readonly MODE_MONOSCOPIC: number;
  57462. /**
  57463. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  57464. */
  57465. static readonly MODE_TOPBOTTOM: number;
  57466. /**
  57467. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  57468. */
  57469. static readonly MODE_SIDEBYSIDE: number;
  57470. private _halfDome;
  57471. private _useDirectMapping;
  57472. /**
  57473. * The video texture being displayed on the sphere
  57474. */
  57475. protected _videoTexture: VideoTexture;
  57476. /**
  57477. * Gets the video texture being displayed on the sphere
  57478. */
  57479. get videoTexture(): VideoTexture;
  57480. /**
  57481. * The skybox material
  57482. */
  57483. protected _material: BackgroundMaterial;
  57484. /**
  57485. * The surface used for the video dome
  57486. */
  57487. protected _mesh: Mesh;
  57488. /**
  57489. * Gets the mesh used for the video dome.
  57490. */
  57491. get mesh(): Mesh;
  57492. /**
  57493. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  57494. */
  57495. private _halfDomeMask;
  57496. /**
  57497. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57498. * Also see the options.resolution property.
  57499. */
  57500. get fovMultiplier(): number;
  57501. set fovMultiplier(value: number);
  57502. private _videoMode;
  57503. /**
  57504. * Gets or set the current video mode for the video. It can be:
  57505. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  57506. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  57507. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  57508. */
  57509. get videoMode(): number;
  57510. set videoMode(value: number);
  57511. /**
  57512. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  57513. *
  57514. */
  57515. get halfDome(): boolean;
  57516. /**
  57517. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  57518. */
  57519. set halfDome(enabled: boolean);
  57520. /**
  57521. * Oberserver used in Stereoscopic VR Mode.
  57522. */
  57523. private _onBeforeCameraRenderObserver;
  57524. /**
  57525. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  57526. * @param name Element's name, child elements will append suffixes for their own names.
  57527. * @param urlsOrVideo defines the url(s) or the video element to use
  57528. * @param options An object containing optional or exposed sub element properties
  57529. */
  57530. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  57531. resolution?: number;
  57532. clickToPlay?: boolean;
  57533. autoPlay?: boolean;
  57534. loop?: boolean;
  57535. size?: number;
  57536. poster?: string;
  57537. faceForward?: boolean;
  57538. useDirectMapping?: boolean;
  57539. halfDomeMode?: boolean;
  57540. }, scene: Scene);
  57541. private _changeVideoMode;
  57542. /**
  57543. * Releases resources associated with this node.
  57544. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  57545. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  57546. */
  57547. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  57548. }
  57549. }
  57550. declare module BABYLON {
  57551. /**
  57552. * This class can be used to get instrumentation data from a Babylon engine
  57553. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  57554. */
  57555. export class EngineInstrumentation implements IDisposable {
  57556. /**
  57557. * Define the instrumented engine.
  57558. */
  57559. engine: Engine;
  57560. private _captureGPUFrameTime;
  57561. private _gpuFrameTimeToken;
  57562. private _gpuFrameTime;
  57563. private _captureShaderCompilationTime;
  57564. private _shaderCompilationTime;
  57565. private _onBeginFrameObserver;
  57566. private _onEndFrameObserver;
  57567. private _onBeforeShaderCompilationObserver;
  57568. private _onAfterShaderCompilationObserver;
  57569. /**
  57570. * Gets the perf counter used for GPU frame time
  57571. */
  57572. get gpuFrameTimeCounter(): PerfCounter;
  57573. /**
  57574. * Gets the GPU frame time capture status
  57575. */
  57576. get captureGPUFrameTime(): boolean;
  57577. /**
  57578. * Enable or disable the GPU frame time capture
  57579. */
  57580. set captureGPUFrameTime(value: boolean);
  57581. /**
  57582. * Gets the perf counter used for shader compilation time
  57583. */
  57584. get shaderCompilationTimeCounter(): PerfCounter;
  57585. /**
  57586. * Gets the shader compilation time capture status
  57587. */
  57588. get captureShaderCompilationTime(): boolean;
  57589. /**
  57590. * Enable or disable the shader compilation time capture
  57591. */
  57592. set captureShaderCompilationTime(value: boolean);
  57593. /**
  57594. * Instantiates a new engine instrumentation.
  57595. * This class can be used to get instrumentation data from a Babylon engine
  57596. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  57597. * @param engine Defines the engine to instrument
  57598. */
  57599. constructor(
  57600. /**
  57601. * Define the instrumented engine.
  57602. */
  57603. engine: Engine);
  57604. /**
  57605. * Dispose and release associated resources.
  57606. */
  57607. dispose(): void;
  57608. }
  57609. }
  57610. declare module BABYLON {
  57611. /**
  57612. * This class can be used to get instrumentation data from a Babylon engine
  57613. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  57614. */
  57615. export class SceneInstrumentation implements IDisposable {
  57616. /**
  57617. * Defines the scene to instrument
  57618. */
  57619. scene: Scene;
  57620. private _captureActiveMeshesEvaluationTime;
  57621. private _activeMeshesEvaluationTime;
  57622. private _captureRenderTargetsRenderTime;
  57623. private _renderTargetsRenderTime;
  57624. private _captureFrameTime;
  57625. private _frameTime;
  57626. private _captureRenderTime;
  57627. private _renderTime;
  57628. private _captureInterFrameTime;
  57629. private _interFrameTime;
  57630. private _captureParticlesRenderTime;
  57631. private _particlesRenderTime;
  57632. private _captureSpritesRenderTime;
  57633. private _spritesRenderTime;
  57634. private _capturePhysicsTime;
  57635. private _physicsTime;
  57636. private _captureAnimationsTime;
  57637. private _animationsTime;
  57638. private _captureCameraRenderTime;
  57639. private _cameraRenderTime;
  57640. private _onBeforeActiveMeshesEvaluationObserver;
  57641. private _onAfterActiveMeshesEvaluationObserver;
  57642. private _onBeforeRenderTargetsRenderObserver;
  57643. private _onAfterRenderTargetsRenderObserver;
  57644. private _onAfterRenderObserver;
  57645. private _onBeforeDrawPhaseObserver;
  57646. private _onAfterDrawPhaseObserver;
  57647. private _onBeforeAnimationsObserver;
  57648. private _onBeforeParticlesRenderingObserver;
  57649. private _onAfterParticlesRenderingObserver;
  57650. private _onBeforeSpritesRenderingObserver;
  57651. private _onAfterSpritesRenderingObserver;
  57652. private _onBeforePhysicsObserver;
  57653. private _onAfterPhysicsObserver;
  57654. private _onAfterAnimationsObserver;
  57655. private _onBeforeCameraRenderObserver;
  57656. private _onAfterCameraRenderObserver;
  57657. /**
  57658. * Gets the perf counter used for active meshes evaluation time
  57659. */
  57660. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  57661. /**
  57662. * Gets the active meshes evaluation time capture status
  57663. */
  57664. get captureActiveMeshesEvaluationTime(): boolean;
  57665. /**
  57666. * Enable or disable the active meshes evaluation time capture
  57667. */
  57668. set captureActiveMeshesEvaluationTime(value: boolean);
  57669. /**
  57670. * Gets the perf counter used for render targets render time
  57671. */
  57672. get renderTargetsRenderTimeCounter(): PerfCounter;
  57673. /**
  57674. * Gets the render targets render time capture status
  57675. */
  57676. get captureRenderTargetsRenderTime(): boolean;
  57677. /**
  57678. * Enable or disable the render targets render time capture
  57679. */
  57680. set captureRenderTargetsRenderTime(value: boolean);
  57681. /**
  57682. * Gets the perf counter used for particles render time
  57683. */
  57684. get particlesRenderTimeCounter(): PerfCounter;
  57685. /**
  57686. * Gets the particles render time capture status
  57687. */
  57688. get captureParticlesRenderTime(): boolean;
  57689. /**
  57690. * Enable or disable the particles render time capture
  57691. */
  57692. set captureParticlesRenderTime(value: boolean);
  57693. /**
  57694. * Gets the perf counter used for sprites render time
  57695. */
  57696. get spritesRenderTimeCounter(): PerfCounter;
  57697. /**
  57698. * Gets the sprites render time capture status
  57699. */
  57700. get captureSpritesRenderTime(): boolean;
  57701. /**
  57702. * Enable or disable the sprites render time capture
  57703. */
  57704. set captureSpritesRenderTime(value: boolean);
  57705. /**
  57706. * Gets the perf counter used for physics time
  57707. */
  57708. get physicsTimeCounter(): PerfCounter;
  57709. /**
  57710. * Gets the physics time capture status
  57711. */
  57712. get capturePhysicsTime(): boolean;
  57713. /**
  57714. * Enable or disable the physics time capture
  57715. */
  57716. set capturePhysicsTime(value: boolean);
  57717. /**
  57718. * Gets the perf counter used for animations time
  57719. */
  57720. get animationsTimeCounter(): PerfCounter;
  57721. /**
  57722. * Gets the animations time capture status
  57723. */
  57724. get captureAnimationsTime(): boolean;
  57725. /**
  57726. * Enable or disable the animations time capture
  57727. */
  57728. set captureAnimationsTime(value: boolean);
  57729. /**
  57730. * Gets the perf counter used for frame time capture
  57731. */
  57732. get frameTimeCounter(): PerfCounter;
  57733. /**
  57734. * Gets the frame time capture status
  57735. */
  57736. get captureFrameTime(): boolean;
  57737. /**
  57738. * Enable or disable the frame time capture
  57739. */
  57740. set captureFrameTime(value: boolean);
  57741. /**
  57742. * Gets the perf counter used for inter-frames time capture
  57743. */
  57744. get interFrameTimeCounter(): PerfCounter;
  57745. /**
  57746. * Gets the inter-frames time capture status
  57747. */
  57748. get captureInterFrameTime(): boolean;
  57749. /**
  57750. * Enable or disable the inter-frames time capture
  57751. */
  57752. set captureInterFrameTime(value: boolean);
  57753. /**
  57754. * Gets the perf counter used for render time capture
  57755. */
  57756. get renderTimeCounter(): PerfCounter;
  57757. /**
  57758. * Gets the render time capture status
  57759. */
  57760. get captureRenderTime(): boolean;
  57761. /**
  57762. * Enable or disable the render time capture
  57763. */
  57764. set captureRenderTime(value: boolean);
  57765. /**
  57766. * Gets the perf counter used for camera render time capture
  57767. */
  57768. get cameraRenderTimeCounter(): PerfCounter;
  57769. /**
  57770. * Gets the camera render time capture status
  57771. */
  57772. get captureCameraRenderTime(): boolean;
  57773. /**
  57774. * Enable or disable the camera render time capture
  57775. */
  57776. set captureCameraRenderTime(value: boolean);
  57777. /**
  57778. * Gets the perf counter used for draw calls
  57779. */
  57780. get drawCallsCounter(): PerfCounter;
  57781. /**
  57782. * Instantiates a new scene instrumentation.
  57783. * This class can be used to get instrumentation data from a Babylon engine
  57784. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  57785. * @param scene Defines the scene to instrument
  57786. */
  57787. constructor(
  57788. /**
  57789. * Defines the scene to instrument
  57790. */
  57791. scene: Scene);
  57792. /**
  57793. * Dispose and release associated resources.
  57794. */
  57795. dispose(): void;
  57796. }
  57797. }
  57798. declare module BABYLON {
  57799. /** @hidden */
  57800. export var glowMapGenerationPixelShader: {
  57801. name: string;
  57802. shader: string;
  57803. };
  57804. }
  57805. declare module BABYLON {
  57806. /** @hidden */
  57807. export var glowMapGenerationVertexShader: {
  57808. name: string;
  57809. shader: string;
  57810. };
  57811. }
  57812. declare module BABYLON {
  57813. /**
  57814. * Effect layer options. This helps customizing the behaviour
  57815. * of the effect layer.
  57816. */
  57817. export interface IEffectLayerOptions {
  57818. /**
  57819. * Multiplication factor apply to the canvas size to compute the render target size
  57820. * used to generated the objects (the smaller the faster).
  57821. */
  57822. mainTextureRatio: number;
  57823. /**
  57824. * Enforces a fixed size texture to ensure effect stability across devices.
  57825. */
  57826. mainTextureFixedSize?: number;
  57827. /**
  57828. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  57829. */
  57830. alphaBlendingMode: number;
  57831. /**
  57832. * The camera attached to the layer.
  57833. */
  57834. camera: Nullable<Camera>;
  57835. /**
  57836. * The rendering group to draw the layer in.
  57837. */
  57838. renderingGroupId: number;
  57839. }
  57840. /**
  57841. * The effect layer Helps adding post process effect blended with the main pass.
  57842. *
  57843. * This can be for instance use to generate glow or higlight effects on the scene.
  57844. *
  57845. * The effect layer class can not be used directly and is intented to inherited from to be
  57846. * customized per effects.
  57847. */
  57848. export abstract class EffectLayer {
  57849. private _vertexBuffers;
  57850. private _indexBuffer;
  57851. private _cachedDefines;
  57852. private _effectLayerMapGenerationEffect;
  57853. private _effectLayerOptions;
  57854. private _mergeEffect;
  57855. protected _scene: Scene;
  57856. protected _engine: Engine;
  57857. protected _maxSize: number;
  57858. protected _mainTextureDesiredSize: ISize;
  57859. protected _mainTexture: RenderTargetTexture;
  57860. protected _shouldRender: boolean;
  57861. protected _postProcesses: PostProcess[];
  57862. protected _textures: BaseTexture[];
  57863. protected _emissiveTextureAndColor: {
  57864. texture: Nullable<BaseTexture>;
  57865. color: Color4;
  57866. };
  57867. /**
  57868. * The name of the layer
  57869. */
  57870. name: string;
  57871. /**
  57872. * The clear color of the texture used to generate the glow map.
  57873. */
  57874. neutralColor: Color4;
  57875. /**
  57876. * Specifies whether the highlight layer is enabled or not.
  57877. */
  57878. isEnabled: boolean;
  57879. /**
  57880. * Gets the camera attached to the layer.
  57881. */
  57882. get camera(): Nullable<Camera>;
  57883. /**
  57884. * Gets the rendering group id the layer should render in.
  57885. */
  57886. get renderingGroupId(): number;
  57887. set renderingGroupId(renderingGroupId: number);
  57888. /**
  57889. * An event triggered when the effect layer has been disposed.
  57890. */
  57891. onDisposeObservable: Observable<EffectLayer>;
  57892. /**
  57893. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  57894. */
  57895. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  57896. /**
  57897. * An event triggered when the generated texture is being merged in the scene.
  57898. */
  57899. onBeforeComposeObservable: Observable<EffectLayer>;
  57900. /**
  57901. * An event triggered when the mesh is rendered into the effect render target.
  57902. */
  57903. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  57904. /**
  57905. * An event triggered after the mesh has been rendered into the effect render target.
  57906. */
  57907. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  57908. /**
  57909. * An event triggered when the generated texture has been merged in the scene.
  57910. */
  57911. onAfterComposeObservable: Observable<EffectLayer>;
  57912. /**
  57913. * An event triggered when the efffect layer changes its size.
  57914. */
  57915. onSizeChangedObservable: Observable<EffectLayer>;
  57916. /** @hidden */
  57917. static _SceneComponentInitialization: (scene: Scene) => void;
  57918. /**
  57919. * Instantiates a new effect Layer and references it in the scene.
  57920. * @param name The name of the layer
  57921. * @param scene The scene to use the layer in
  57922. */
  57923. constructor(
  57924. /** The Friendly of the effect in the scene */
  57925. name: string, scene: Scene);
  57926. /**
  57927. * Get the effect name of the layer.
  57928. * @return The effect name
  57929. */
  57930. abstract getEffectName(): string;
  57931. /**
  57932. * Checks for the readiness of the element composing the layer.
  57933. * @param subMesh the mesh to check for
  57934. * @param useInstances specify whether or not to use instances to render the mesh
  57935. * @return true if ready otherwise, false
  57936. */
  57937. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57938. /**
  57939. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  57940. * @returns true if the effect requires stencil during the main canvas render pass.
  57941. */
  57942. abstract needStencil(): boolean;
  57943. /**
  57944. * Create the merge effect. This is the shader use to blit the information back
  57945. * to the main canvas at the end of the scene rendering.
  57946. * @returns The effect containing the shader used to merge the effect on the main canvas
  57947. */
  57948. protected abstract _createMergeEffect(): Effect;
  57949. /**
  57950. * Creates the render target textures and post processes used in the effect layer.
  57951. */
  57952. protected abstract _createTextureAndPostProcesses(): void;
  57953. /**
  57954. * Implementation specific of rendering the generating effect on the main canvas.
  57955. * @param effect The effect used to render through
  57956. */
  57957. protected abstract _internalRender(effect: Effect): void;
  57958. /**
  57959. * Sets the required values for both the emissive texture and and the main color.
  57960. */
  57961. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57962. /**
  57963. * Free any resources and references associated to a mesh.
  57964. * Internal use
  57965. * @param mesh The mesh to free.
  57966. */
  57967. abstract _disposeMesh(mesh: Mesh): void;
  57968. /**
  57969. * Serializes this layer (Glow or Highlight for example)
  57970. * @returns a serialized layer object
  57971. */
  57972. abstract serialize?(): any;
  57973. /**
  57974. * Initializes the effect layer with the required options.
  57975. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  57976. */
  57977. protected _init(options: Partial<IEffectLayerOptions>): void;
  57978. /**
  57979. * Generates the index buffer of the full screen quad blending to the main canvas.
  57980. */
  57981. private _generateIndexBuffer;
  57982. /**
  57983. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  57984. */
  57985. private _generateVertexBuffer;
  57986. /**
  57987. * Sets the main texture desired size which is the closest power of two
  57988. * of the engine canvas size.
  57989. */
  57990. private _setMainTextureSize;
  57991. /**
  57992. * Creates the main texture for the effect layer.
  57993. */
  57994. protected _createMainTexture(): void;
  57995. /**
  57996. * Adds specific effects defines.
  57997. * @param defines The defines to add specifics to.
  57998. */
  57999. protected _addCustomEffectDefines(defines: string[]): void;
  58000. /**
  58001. * Checks for the readiness of the element composing the layer.
  58002. * @param subMesh the mesh to check for
  58003. * @param useInstances specify whether or not to use instances to render the mesh
  58004. * @param emissiveTexture the associated emissive texture used to generate the glow
  58005. * @return true if ready otherwise, false
  58006. */
  58007. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  58008. /**
  58009. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  58010. */
  58011. render(): void;
  58012. /**
  58013. * Determine if a given mesh will be used in the current effect.
  58014. * @param mesh mesh to test
  58015. * @returns true if the mesh will be used
  58016. */
  58017. hasMesh(mesh: AbstractMesh): boolean;
  58018. /**
  58019. * Returns true if the layer contains information to display, otherwise false.
  58020. * @returns true if the glow layer should be rendered
  58021. */
  58022. shouldRender(): boolean;
  58023. /**
  58024. * Returns true if the mesh should render, otherwise false.
  58025. * @param mesh The mesh to render
  58026. * @returns true if it should render otherwise false
  58027. */
  58028. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  58029. /**
  58030. * Returns true if the mesh can be rendered, otherwise false.
  58031. * @param mesh The mesh to render
  58032. * @param material The material used on the mesh
  58033. * @returns true if it can be rendered otherwise false
  58034. */
  58035. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58036. /**
  58037. * Returns true if the mesh should render, otherwise false.
  58038. * @param mesh The mesh to render
  58039. * @returns true if it should render otherwise false
  58040. */
  58041. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  58042. /**
  58043. * Renders the submesh passed in parameter to the generation map.
  58044. */
  58045. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  58046. /**
  58047. * Defines whether the current material of the mesh should be use to render the effect.
  58048. * @param mesh defines the current mesh to render
  58049. */
  58050. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  58051. /**
  58052. * Rebuild the required buffers.
  58053. * @hidden Internal use only.
  58054. */
  58055. _rebuild(): void;
  58056. /**
  58057. * Dispose only the render target textures and post process.
  58058. */
  58059. private _disposeTextureAndPostProcesses;
  58060. /**
  58061. * Dispose the highlight layer and free resources.
  58062. */
  58063. dispose(): void;
  58064. /**
  58065. * Gets the class name of the effect layer
  58066. * @returns the string with the class name of the effect layer
  58067. */
  58068. getClassName(): string;
  58069. /**
  58070. * Creates an effect layer from parsed effect layer data
  58071. * @param parsedEffectLayer defines effect layer data
  58072. * @param scene defines the current scene
  58073. * @param rootUrl defines the root URL containing the effect layer information
  58074. * @returns a parsed effect Layer
  58075. */
  58076. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  58077. }
  58078. }
  58079. declare module BABYLON {
  58080. interface AbstractScene {
  58081. /**
  58082. * The list of effect layers (highlights/glow) added to the scene
  58083. * @see https://doc.babylonjs.com/how_to/highlight_layer
  58084. * @see https://doc.babylonjs.com/how_to/glow_layer
  58085. */
  58086. effectLayers: Array<EffectLayer>;
  58087. /**
  58088. * Removes the given effect layer from this scene.
  58089. * @param toRemove defines the effect layer to remove
  58090. * @returns the index of the removed effect layer
  58091. */
  58092. removeEffectLayer(toRemove: EffectLayer): number;
  58093. /**
  58094. * Adds the given effect layer to this scene
  58095. * @param newEffectLayer defines the effect layer to add
  58096. */
  58097. addEffectLayer(newEffectLayer: EffectLayer): void;
  58098. }
  58099. /**
  58100. * Defines the layer scene component responsible to manage any effect layers
  58101. * in a given scene.
  58102. */
  58103. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  58104. /**
  58105. * The component name helpfull to identify the component in the list of scene components.
  58106. */
  58107. readonly name: string;
  58108. /**
  58109. * The scene the component belongs to.
  58110. */
  58111. scene: Scene;
  58112. private _engine;
  58113. private _renderEffects;
  58114. private _needStencil;
  58115. private _previousStencilState;
  58116. /**
  58117. * Creates a new instance of the component for the given scene
  58118. * @param scene Defines the scene to register the component in
  58119. */
  58120. constructor(scene: Scene);
  58121. /**
  58122. * Registers the component in a given scene
  58123. */
  58124. register(): void;
  58125. /**
  58126. * Rebuilds the elements related to this component in case of
  58127. * context lost for instance.
  58128. */
  58129. rebuild(): void;
  58130. /**
  58131. * Serializes the component data to the specified json object
  58132. * @param serializationObject The object to serialize to
  58133. */
  58134. serialize(serializationObject: any): void;
  58135. /**
  58136. * Adds all the elements from the container to the scene
  58137. * @param container the container holding the elements
  58138. */
  58139. addFromContainer(container: AbstractScene): void;
  58140. /**
  58141. * Removes all the elements in the container from the scene
  58142. * @param container contains the elements to remove
  58143. * @param dispose if the removed element should be disposed (default: false)
  58144. */
  58145. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58146. /**
  58147. * Disposes the component and the associated ressources.
  58148. */
  58149. dispose(): void;
  58150. private _isReadyForMesh;
  58151. private _renderMainTexture;
  58152. private _setStencil;
  58153. private _setStencilBack;
  58154. private _draw;
  58155. private _drawCamera;
  58156. private _drawRenderingGroup;
  58157. }
  58158. }
  58159. declare module BABYLON {
  58160. /** @hidden */
  58161. export var glowMapMergePixelShader: {
  58162. name: string;
  58163. shader: string;
  58164. };
  58165. }
  58166. declare module BABYLON {
  58167. /** @hidden */
  58168. export var glowMapMergeVertexShader: {
  58169. name: string;
  58170. shader: string;
  58171. };
  58172. }
  58173. declare module BABYLON {
  58174. interface AbstractScene {
  58175. /**
  58176. * Return a the first highlight layer of the scene with a given name.
  58177. * @param name The name of the highlight layer to look for.
  58178. * @return The highlight layer if found otherwise null.
  58179. */
  58180. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  58181. }
  58182. /**
  58183. * Glow layer options. This helps customizing the behaviour
  58184. * of the glow layer.
  58185. */
  58186. export interface IGlowLayerOptions {
  58187. /**
  58188. * Multiplication factor apply to the canvas size to compute the render target size
  58189. * used to generated the glowing objects (the smaller the faster).
  58190. */
  58191. mainTextureRatio: number;
  58192. /**
  58193. * Enforces a fixed size texture to ensure resize independant blur.
  58194. */
  58195. mainTextureFixedSize?: number;
  58196. /**
  58197. * How big is the kernel of the blur texture.
  58198. */
  58199. blurKernelSize: number;
  58200. /**
  58201. * The camera attached to the layer.
  58202. */
  58203. camera: Nullable<Camera>;
  58204. /**
  58205. * Enable MSAA by chosing the number of samples.
  58206. */
  58207. mainTextureSamples?: number;
  58208. /**
  58209. * The rendering group to draw the layer in.
  58210. */
  58211. renderingGroupId: number;
  58212. }
  58213. /**
  58214. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  58215. *
  58216. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  58217. *
  58218. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  58219. */
  58220. export class GlowLayer extends EffectLayer {
  58221. /**
  58222. * Effect Name of the layer.
  58223. */
  58224. static readonly EffectName: string;
  58225. /**
  58226. * The default blur kernel size used for the glow.
  58227. */
  58228. static DefaultBlurKernelSize: number;
  58229. /**
  58230. * The default texture size ratio used for the glow.
  58231. */
  58232. static DefaultTextureRatio: number;
  58233. /**
  58234. * Sets the kernel size of the blur.
  58235. */
  58236. set blurKernelSize(value: number);
  58237. /**
  58238. * Gets the kernel size of the blur.
  58239. */
  58240. get blurKernelSize(): number;
  58241. /**
  58242. * Sets the glow intensity.
  58243. */
  58244. set intensity(value: number);
  58245. /**
  58246. * Gets the glow intensity.
  58247. */
  58248. get intensity(): number;
  58249. private _options;
  58250. private _intensity;
  58251. private _horizontalBlurPostprocess1;
  58252. private _verticalBlurPostprocess1;
  58253. private _horizontalBlurPostprocess2;
  58254. private _verticalBlurPostprocess2;
  58255. private _blurTexture1;
  58256. private _blurTexture2;
  58257. private _postProcesses1;
  58258. private _postProcesses2;
  58259. private _includedOnlyMeshes;
  58260. private _excludedMeshes;
  58261. private _meshesUsingTheirOwnMaterials;
  58262. /**
  58263. * Callback used to let the user override the color selection on a per mesh basis
  58264. */
  58265. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  58266. /**
  58267. * Callback used to let the user override the texture selection on a per mesh basis
  58268. */
  58269. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  58270. /**
  58271. * Instantiates a new glow Layer and references it to the scene.
  58272. * @param name The name of the layer
  58273. * @param scene The scene to use the layer in
  58274. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  58275. */
  58276. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  58277. /**
  58278. * Get the effect name of the layer.
  58279. * @return The effect name
  58280. */
  58281. getEffectName(): string;
  58282. /**
  58283. * Create the merge effect. This is the shader use to blit the information back
  58284. * to the main canvas at the end of the scene rendering.
  58285. */
  58286. protected _createMergeEffect(): Effect;
  58287. /**
  58288. * Creates the render target textures and post processes used in the glow layer.
  58289. */
  58290. protected _createTextureAndPostProcesses(): void;
  58291. /**
  58292. * Checks for the readiness of the element composing the layer.
  58293. * @param subMesh the mesh to check for
  58294. * @param useInstances specify wether or not to use instances to render the mesh
  58295. * @param emissiveTexture the associated emissive texture used to generate the glow
  58296. * @return true if ready otherwise, false
  58297. */
  58298. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58299. /**
  58300. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  58301. */
  58302. needStencil(): boolean;
  58303. /**
  58304. * Returns true if the mesh can be rendered, otherwise false.
  58305. * @param mesh The mesh to render
  58306. * @param material The material used on the mesh
  58307. * @returns true if it can be rendered otherwise false
  58308. */
  58309. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58310. /**
  58311. * Implementation specific of rendering the generating effect on the main canvas.
  58312. * @param effect The effect used to render through
  58313. */
  58314. protected _internalRender(effect: Effect): void;
  58315. /**
  58316. * Sets the required values for both the emissive texture and and the main color.
  58317. */
  58318. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58319. /**
  58320. * Returns true if the mesh should render, otherwise false.
  58321. * @param mesh The mesh to render
  58322. * @returns true if it should render otherwise false
  58323. */
  58324. protected _shouldRenderMesh(mesh: Mesh): boolean;
  58325. /**
  58326. * Adds specific effects defines.
  58327. * @param defines The defines to add specifics to.
  58328. */
  58329. protected _addCustomEffectDefines(defines: string[]): void;
  58330. /**
  58331. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  58332. * @param mesh The mesh to exclude from the glow layer
  58333. */
  58334. addExcludedMesh(mesh: Mesh): void;
  58335. /**
  58336. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  58337. * @param mesh The mesh to remove
  58338. */
  58339. removeExcludedMesh(mesh: Mesh): void;
  58340. /**
  58341. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  58342. * @param mesh The mesh to include in the glow layer
  58343. */
  58344. addIncludedOnlyMesh(mesh: Mesh): void;
  58345. /**
  58346. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  58347. * @param mesh The mesh to remove
  58348. */
  58349. removeIncludedOnlyMesh(mesh: Mesh): void;
  58350. /**
  58351. * Determine if a given mesh will be used in the glow layer
  58352. * @param mesh The mesh to test
  58353. * @returns true if the mesh will be highlighted by the current glow layer
  58354. */
  58355. hasMesh(mesh: AbstractMesh): boolean;
  58356. /**
  58357. * Defines whether the current material of the mesh should be use to render the effect.
  58358. * @param mesh defines the current mesh to render
  58359. */
  58360. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  58361. /**
  58362. * Add a mesh to be rendered through its own material and not with emissive only.
  58363. * @param mesh The mesh for which we need to use its material
  58364. */
  58365. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  58366. /**
  58367. * Remove a mesh from being rendered through its own material and not with emissive only.
  58368. * @param mesh The mesh for which we need to not use its material
  58369. */
  58370. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  58371. /**
  58372. * Free any resources and references associated to a mesh.
  58373. * Internal use
  58374. * @param mesh The mesh to free.
  58375. * @hidden
  58376. */
  58377. _disposeMesh(mesh: Mesh): void;
  58378. /**
  58379. * Gets the class name of the effect layer
  58380. * @returns the string with the class name of the effect layer
  58381. */
  58382. getClassName(): string;
  58383. /**
  58384. * Serializes this glow layer
  58385. * @returns a serialized glow layer object
  58386. */
  58387. serialize(): any;
  58388. /**
  58389. * Creates a Glow Layer from parsed glow layer data
  58390. * @param parsedGlowLayer defines glow layer data
  58391. * @param scene defines the current scene
  58392. * @param rootUrl defines the root URL containing the glow layer information
  58393. * @returns a parsed Glow Layer
  58394. */
  58395. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  58396. }
  58397. }
  58398. declare module BABYLON {
  58399. /** @hidden */
  58400. export var glowBlurPostProcessPixelShader: {
  58401. name: string;
  58402. shader: string;
  58403. };
  58404. }
  58405. declare module BABYLON {
  58406. interface AbstractScene {
  58407. /**
  58408. * Return a the first highlight layer of the scene with a given name.
  58409. * @param name The name of the highlight layer to look for.
  58410. * @return The highlight layer if found otherwise null.
  58411. */
  58412. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  58413. }
  58414. /**
  58415. * Highlight layer options. This helps customizing the behaviour
  58416. * of the highlight layer.
  58417. */
  58418. export interface IHighlightLayerOptions {
  58419. /**
  58420. * Multiplication factor apply to the canvas size to compute the render target size
  58421. * used to generated the glowing objects (the smaller the faster).
  58422. */
  58423. mainTextureRatio: number;
  58424. /**
  58425. * Enforces a fixed size texture to ensure resize independant blur.
  58426. */
  58427. mainTextureFixedSize?: number;
  58428. /**
  58429. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  58430. * of the picture to blur (the smaller the faster).
  58431. */
  58432. blurTextureSizeRatio: number;
  58433. /**
  58434. * How big in texel of the blur texture is the vertical blur.
  58435. */
  58436. blurVerticalSize: number;
  58437. /**
  58438. * How big in texel of the blur texture is the horizontal blur.
  58439. */
  58440. blurHorizontalSize: number;
  58441. /**
  58442. * Alpha blending mode used to apply the blur. Default is combine.
  58443. */
  58444. alphaBlendingMode: number;
  58445. /**
  58446. * The camera attached to the layer.
  58447. */
  58448. camera: Nullable<Camera>;
  58449. /**
  58450. * Should we display highlight as a solid stroke?
  58451. */
  58452. isStroke?: boolean;
  58453. /**
  58454. * The rendering group to draw the layer in.
  58455. */
  58456. renderingGroupId: number;
  58457. }
  58458. /**
  58459. * The highlight layer Helps adding a glow effect around a mesh.
  58460. *
  58461. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  58462. * glowy meshes to your scene.
  58463. *
  58464. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  58465. */
  58466. export class HighlightLayer extends EffectLayer {
  58467. name: string;
  58468. /**
  58469. * Effect Name of the highlight layer.
  58470. */
  58471. static readonly EffectName: string;
  58472. /**
  58473. * The neutral color used during the preparation of the glow effect.
  58474. * This is black by default as the blend operation is a blend operation.
  58475. */
  58476. static NeutralColor: Color4;
  58477. /**
  58478. * Stencil value used for glowing meshes.
  58479. */
  58480. static GlowingMeshStencilReference: number;
  58481. /**
  58482. * Stencil value used for the other meshes in the scene.
  58483. */
  58484. static NormalMeshStencilReference: number;
  58485. /**
  58486. * Specifies whether or not the inner glow is ACTIVE in the layer.
  58487. */
  58488. innerGlow: boolean;
  58489. /**
  58490. * Specifies whether or not the outer glow is ACTIVE in the layer.
  58491. */
  58492. outerGlow: boolean;
  58493. /**
  58494. * Specifies the horizontal size of the blur.
  58495. */
  58496. set blurHorizontalSize(value: number);
  58497. /**
  58498. * Specifies the vertical size of the blur.
  58499. */
  58500. set blurVerticalSize(value: number);
  58501. /**
  58502. * Gets the horizontal size of the blur.
  58503. */
  58504. get blurHorizontalSize(): number;
  58505. /**
  58506. * Gets the vertical size of the blur.
  58507. */
  58508. get blurVerticalSize(): number;
  58509. /**
  58510. * An event triggered when the highlight layer is being blurred.
  58511. */
  58512. onBeforeBlurObservable: Observable<HighlightLayer>;
  58513. /**
  58514. * An event triggered when the highlight layer has been blurred.
  58515. */
  58516. onAfterBlurObservable: Observable<HighlightLayer>;
  58517. private _instanceGlowingMeshStencilReference;
  58518. private _options;
  58519. private _downSamplePostprocess;
  58520. private _horizontalBlurPostprocess;
  58521. private _verticalBlurPostprocess;
  58522. private _blurTexture;
  58523. private _meshes;
  58524. private _excludedMeshes;
  58525. /**
  58526. * Instantiates a new highlight Layer and references it to the scene..
  58527. * @param name The name of the layer
  58528. * @param scene The scene to use the layer in
  58529. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  58530. */
  58531. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  58532. /**
  58533. * Get the effect name of the layer.
  58534. * @return The effect name
  58535. */
  58536. getEffectName(): string;
  58537. /**
  58538. * Create the merge effect. This is the shader use to blit the information back
  58539. * to the main canvas at the end of the scene rendering.
  58540. */
  58541. protected _createMergeEffect(): Effect;
  58542. /**
  58543. * Creates the render target textures and post processes used in the highlight layer.
  58544. */
  58545. protected _createTextureAndPostProcesses(): void;
  58546. /**
  58547. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  58548. */
  58549. needStencil(): boolean;
  58550. /**
  58551. * Checks for the readiness of the element composing the layer.
  58552. * @param subMesh the mesh to check for
  58553. * @param useInstances specify wether or not to use instances to render the mesh
  58554. * @param emissiveTexture the associated emissive texture used to generate the glow
  58555. * @return true if ready otherwise, false
  58556. */
  58557. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58558. /**
  58559. * Implementation specific of rendering the generating effect on the main canvas.
  58560. * @param effect The effect used to render through
  58561. */
  58562. protected _internalRender(effect: Effect): void;
  58563. /**
  58564. * Returns true if the layer contains information to display, otherwise false.
  58565. */
  58566. shouldRender(): boolean;
  58567. /**
  58568. * Returns true if the mesh should render, otherwise false.
  58569. * @param mesh The mesh to render
  58570. * @returns true if it should render otherwise false
  58571. */
  58572. protected _shouldRenderMesh(mesh: Mesh): boolean;
  58573. /**
  58574. * Returns true if the mesh can be rendered, otherwise false.
  58575. * @param mesh The mesh to render
  58576. * @param material The material used on the mesh
  58577. * @returns true if it can be rendered otherwise false
  58578. */
  58579. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58580. /**
  58581. * Adds specific effects defines.
  58582. * @param defines The defines to add specifics to.
  58583. */
  58584. protected _addCustomEffectDefines(defines: string[]): void;
  58585. /**
  58586. * Sets the required values for both the emissive texture and and the main color.
  58587. */
  58588. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58589. /**
  58590. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  58591. * @param mesh The mesh to exclude from the highlight layer
  58592. */
  58593. addExcludedMesh(mesh: Mesh): void;
  58594. /**
  58595. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  58596. * @param mesh The mesh to highlight
  58597. */
  58598. removeExcludedMesh(mesh: Mesh): void;
  58599. /**
  58600. * Determine if a given mesh will be highlighted by the current HighlightLayer
  58601. * @param mesh mesh to test
  58602. * @returns true if the mesh will be highlighted by the current HighlightLayer
  58603. */
  58604. hasMesh(mesh: AbstractMesh): boolean;
  58605. /**
  58606. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  58607. * @param mesh The mesh to highlight
  58608. * @param color The color of the highlight
  58609. * @param glowEmissiveOnly Extract the glow from the emissive texture
  58610. */
  58611. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  58612. /**
  58613. * Remove a mesh from the highlight layer in order to make it stop glowing.
  58614. * @param mesh The mesh to highlight
  58615. */
  58616. removeMesh(mesh: Mesh): void;
  58617. /**
  58618. * Remove all the meshes currently referenced in the highlight layer
  58619. */
  58620. removeAllMeshes(): void;
  58621. /**
  58622. * Force the stencil to the normal expected value for none glowing parts
  58623. */
  58624. private _defaultStencilReference;
  58625. /**
  58626. * Free any resources and references associated to a mesh.
  58627. * Internal use
  58628. * @param mesh The mesh to free.
  58629. * @hidden
  58630. */
  58631. _disposeMesh(mesh: Mesh): void;
  58632. /**
  58633. * Dispose the highlight layer and free resources.
  58634. */
  58635. dispose(): void;
  58636. /**
  58637. * Gets the class name of the effect layer
  58638. * @returns the string with the class name of the effect layer
  58639. */
  58640. getClassName(): string;
  58641. /**
  58642. * Serializes this Highlight layer
  58643. * @returns a serialized Highlight layer object
  58644. */
  58645. serialize(): any;
  58646. /**
  58647. * Creates a Highlight layer from parsed Highlight layer data
  58648. * @param parsedHightlightLayer defines the Highlight layer data
  58649. * @param scene defines the current scene
  58650. * @param rootUrl defines the root URL containing the Highlight layer information
  58651. * @returns a parsed Highlight layer
  58652. */
  58653. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  58654. }
  58655. }
  58656. declare module BABYLON {
  58657. interface AbstractScene {
  58658. /**
  58659. * The list of layers (background and foreground) of the scene
  58660. */
  58661. layers: Array<Layer>;
  58662. }
  58663. /**
  58664. * Defines the layer scene component responsible to manage any layers
  58665. * in a given scene.
  58666. */
  58667. export class LayerSceneComponent implements ISceneComponent {
  58668. /**
  58669. * The component name helpfull to identify the component in the list of scene components.
  58670. */
  58671. readonly name: string;
  58672. /**
  58673. * The scene the component belongs to.
  58674. */
  58675. scene: Scene;
  58676. private _engine;
  58677. /**
  58678. * Creates a new instance of the component for the given scene
  58679. * @param scene Defines the scene to register the component in
  58680. */
  58681. constructor(scene: Scene);
  58682. /**
  58683. * Registers the component in a given scene
  58684. */
  58685. register(): void;
  58686. /**
  58687. * Rebuilds the elements related to this component in case of
  58688. * context lost for instance.
  58689. */
  58690. rebuild(): void;
  58691. /**
  58692. * Disposes the component and the associated ressources.
  58693. */
  58694. dispose(): void;
  58695. private _draw;
  58696. private _drawCameraPredicate;
  58697. private _drawCameraBackground;
  58698. private _drawCameraForeground;
  58699. private _drawRenderTargetPredicate;
  58700. private _drawRenderTargetBackground;
  58701. private _drawRenderTargetForeground;
  58702. /**
  58703. * Adds all the elements from the container to the scene
  58704. * @param container the container holding the elements
  58705. */
  58706. addFromContainer(container: AbstractScene): void;
  58707. /**
  58708. * Removes all the elements in the container from the scene
  58709. * @param container contains the elements to remove
  58710. * @param dispose if the removed element should be disposed (default: false)
  58711. */
  58712. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58713. }
  58714. }
  58715. declare module BABYLON {
  58716. /** @hidden */
  58717. export var layerPixelShader: {
  58718. name: string;
  58719. shader: string;
  58720. };
  58721. }
  58722. declare module BABYLON {
  58723. /** @hidden */
  58724. export var layerVertexShader: {
  58725. name: string;
  58726. shader: string;
  58727. };
  58728. }
  58729. declare module BABYLON {
  58730. /**
  58731. * This represents a full screen 2d layer.
  58732. * This can be useful to display a picture in the background of your scene for instance.
  58733. * @see https://www.babylonjs-playground.com/#08A2BS#1
  58734. */
  58735. export class Layer {
  58736. /**
  58737. * Define the name of the layer.
  58738. */
  58739. name: string;
  58740. /**
  58741. * Define the texture the layer should display.
  58742. */
  58743. texture: Nullable<Texture>;
  58744. /**
  58745. * Is the layer in background or foreground.
  58746. */
  58747. isBackground: boolean;
  58748. /**
  58749. * Define the color of the layer (instead of texture).
  58750. */
  58751. color: Color4;
  58752. /**
  58753. * Define the scale of the layer in order to zoom in out of the texture.
  58754. */
  58755. scale: Vector2;
  58756. /**
  58757. * Define an offset for the layer in order to shift the texture.
  58758. */
  58759. offset: Vector2;
  58760. /**
  58761. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  58762. */
  58763. alphaBlendingMode: number;
  58764. /**
  58765. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  58766. * Alpha test will not mix with the background color in case of transparency.
  58767. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  58768. */
  58769. alphaTest: boolean;
  58770. /**
  58771. * Define a mask to restrict the layer to only some of the scene cameras.
  58772. */
  58773. layerMask: number;
  58774. /**
  58775. * Define the list of render target the layer is visible into.
  58776. */
  58777. renderTargetTextures: RenderTargetTexture[];
  58778. /**
  58779. * Define if the layer is only used in renderTarget or if it also
  58780. * renders in the main frame buffer of the canvas.
  58781. */
  58782. renderOnlyInRenderTargetTextures: boolean;
  58783. private _scene;
  58784. private _vertexBuffers;
  58785. private _indexBuffer;
  58786. private _effect;
  58787. private _previousDefines;
  58788. /**
  58789. * An event triggered when the layer is disposed.
  58790. */
  58791. onDisposeObservable: Observable<Layer>;
  58792. private _onDisposeObserver;
  58793. /**
  58794. * Back compatibility with callback before the onDisposeObservable existed.
  58795. * The set callback will be triggered when the layer has been disposed.
  58796. */
  58797. set onDispose(callback: () => void);
  58798. /**
  58799. * An event triggered before rendering the scene
  58800. */
  58801. onBeforeRenderObservable: Observable<Layer>;
  58802. private _onBeforeRenderObserver;
  58803. /**
  58804. * Back compatibility with callback before the onBeforeRenderObservable existed.
  58805. * The set callback will be triggered just before rendering the layer.
  58806. */
  58807. set onBeforeRender(callback: () => void);
  58808. /**
  58809. * An event triggered after rendering the scene
  58810. */
  58811. onAfterRenderObservable: Observable<Layer>;
  58812. private _onAfterRenderObserver;
  58813. /**
  58814. * Back compatibility with callback before the onAfterRenderObservable existed.
  58815. * The set callback will be triggered just after rendering the layer.
  58816. */
  58817. set onAfterRender(callback: () => void);
  58818. /**
  58819. * Instantiates a new layer.
  58820. * This represents a full screen 2d layer.
  58821. * This can be useful to display a picture in the background of your scene for instance.
  58822. * @see https://www.babylonjs-playground.com/#08A2BS#1
  58823. * @param name Define the name of the layer in the scene
  58824. * @param imgUrl Define the url of the texture to display in the layer
  58825. * @param scene Define the scene the layer belongs to
  58826. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  58827. * @param color Defines a color for the layer
  58828. */
  58829. constructor(
  58830. /**
  58831. * Define the name of the layer.
  58832. */
  58833. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  58834. private _createIndexBuffer;
  58835. /** @hidden */
  58836. _rebuild(): void;
  58837. /**
  58838. * Renders the layer in the scene.
  58839. */
  58840. render(): void;
  58841. /**
  58842. * Disposes and releases the associated ressources.
  58843. */
  58844. dispose(): void;
  58845. }
  58846. }
  58847. declare module BABYLON {
  58848. /** @hidden */
  58849. export var lensFlarePixelShader: {
  58850. name: string;
  58851. shader: string;
  58852. };
  58853. }
  58854. declare module BABYLON {
  58855. /** @hidden */
  58856. export var lensFlareVertexShader: {
  58857. name: string;
  58858. shader: string;
  58859. };
  58860. }
  58861. declare module BABYLON {
  58862. /**
  58863. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  58864. * It is usually composed of several `lensFlare`.
  58865. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58866. */
  58867. export class LensFlareSystem {
  58868. /**
  58869. * Define the name of the lens flare system
  58870. */
  58871. name: string;
  58872. /**
  58873. * List of lens flares used in this system.
  58874. */
  58875. lensFlares: LensFlare[];
  58876. /**
  58877. * Define a limit from the border the lens flare can be visible.
  58878. */
  58879. borderLimit: number;
  58880. /**
  58881. * Define a viewport border we do not want to see the lens flare in.
  58882. */
  58883. viewportBorder: number;
  58884. /**
  58885. * Define a predicate which could limit the list of meshes able to occlude the effect.
  58886. */
  58887. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  58888. /**
  58889. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  58890. */
  58891. layerMask: number;
  58892. /**
  58893. * Define the id of the lens flare system in the scene.
  58894. * (equal to name by default)
  58895. */
  58896. id: string;
  58897. private _scene;
  58898. private _emitter;
  58899. private _vertexBuffers;
  58900. private _indexBuffer;
  58901. private _effect;
  58902. private _positionX;
  58903. private _positionY;
  58904. private _isEnabled;
  58905. /** @hidden */
  58906. static _SceneComponentInitialization: (scene: Scene) => void;
  58907. /**
  58908. * Instantiates a lens flare system.
  58909. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  58910. * It is usually composed of several `lensFlare`.
  58911. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58912. * @param name Define the name of the lens flare system in the scene
  58913. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  58914. * @param scene Define the scene the lens flare system belongs to
  58915. */
  58916. constructor(
  58917. /**
  58918. * Define the name of the lens flare system
  58919. */
  58920. name: string, emitter: any, scene: Scene);
  58921. /**
  58922. * Define if the lens flare system is enabled.
  58923. */
  58924. get isEnabled(): boolean;
  58925. set isEnabled(value: boolean);
  58926. /**
  58927. * Get the scene the effects belongs to.
  58928. * @returns the scene holding the lens flare system
  58929. */
  58930. getScene(): Scene;
  58931. /**
  58932. * Get the emitter of the lens flare system.
  58933. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  58934. * @returns the emitter of the lens flare system
  58935. */
  58936. getEmitter(): any;
  58937. /**
  58938. * Set the emitter of the lens flare system.
  58939. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  58940. * @param newEmitter Define the new emitter of the system
  58941. */
  58942. setEmitter(newEmitter: any): void;
  58943. /**
  58944. * Get the lens flare system emitter position.
  58945. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  58946. * @returns the position
  58947. */
  58948. getEmitterPosition(): Vector3;
  58949. /**
  58950. * @hidden
  58951. */
  58952. computeEffectivePosition(globalViewport: Viewport): boolean;
  58953. /** @hidden */
  58954. _isVisible(): boolean;
  58955. /**
  58956. * @hidden
  58957. */
  58958. render(): boolean;
  58959. /**
  58960. * Dispose and release the lens flare with its associated resources.
  58961. */
  58962. dispose(): void;
  58963. /**
  58964. * Parse a lens flare system from a JSON repressentation
  58965. * @param parsedLensFlareSystem Define the JSON to parse
  58966. * @param scene Define the scene the parsed system should be instantiated in
  58967. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  58968. * @returns the parsed system
  58969. */
  58970. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  58971. /**
  58972. * Serialize the current Lens Flare System into a JSON representation.
  58973. * @returns the serialized JSON
  58974. */
  58975. serialize(): any;
  58976. }
  58977. }
  58978. declare module BABYLON {
  58979. /**
  58980. * This represents one of the lens effect in a `lensFlareSystem`.
  58981. * It controls one of the indiviual texture used in the effect.
  58982. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58983. */
  58984. export class LensFlare {
  58985. /**
  58986. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  58987. */
  58988. size: number;
  58989. /**
  58990. * 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.
  58991. */
  58992. position: number;
  58993. /**
  58994. * Define the lens color.
  58995. */
  58996. color: Color3;
  58997. /**
  58998. * Define the lens texture.
  58999. */
  59000. texture: Nullable<Texture>;
  59001. /**
  59002. * Define the alpha mode to render this particular lens.
  59003. */
  59004. alphaMode: number;
  59005. private _system;
  59006. /**
  59007. * Creates a new Lens Flare.
  59008. * This represents one of the lens effect in a `lensFlareSystem`.
  59009. * It controls one of the indiviual texture used in the effect.
  59010. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59011. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  59012. * @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.
  59013. * @param color Define the lens color
  59014. * @param imgUrl Define the lens texture url
  59015. * @param system Define the `lensFlareSystem` this flare is part of
  59016. * @returns The newly created Lens Flare
  59017. */
  59018. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  59019. /**
  59020. * Instantiates a new Lens Flare.
  59021. * This represents one of the lens effect in a `lensFlareSystem`.
  59022. * It controls one of the indiviual texture used in the effect.
  59023. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59024. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  59025. * @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.
  59026. * @param color Define the lens color
  59027. * @param imgUrl Define the lens texture url
  59028. * @param system Define the `lensFlareSystem` this flare is part of
  59029. */
  59030. constructor(
  59031. /**
  59032. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  59033. */
  59034. size: number,
  59035. /**
  59036. * 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.
  59037. */
  59038. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  59039. /**
  59040. * Dispose and release the lens flare with its associated resources.
  59041. */
  59042. dispose(): void;
  59043. }
  59044. }
  59045. declare module BABYLON {
  59046. interface AbstractScene {
  59047. /**
  59048. * The list of lens flare system added to the scene
  59049. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59050. */
  59051. lensFlareSystems: Array<LensFlareSystem>;
  59052. /**
  59053. * Removes the given lens flare system from this scene.
  59054. * @param toRemove The lens flare system to remove
  59055. * @returns The index of the removed lens flare system
  59056. */
  59057. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  59058. /**
  59059. * Adds the given lens flare system to this scene
  59060. * @param newLensFlareSystem The lens flare system to add
  59061. */
  59062. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  59063. /**
  59064. * Gets a lens flare system using its name
  59065. * @param name defines the name to look for
  59066. * @returns the lens flare system or null if not found
  59067. */
  59068. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  59069. /**
  59070. * Gets a lens flare system using its id
  59071. * @param id defines the id to look for
  59072. * @returns the lens flare system or null if not found
  59073. */
  59074. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  59075. }
  59076. /**
  59077. * Defines the lens flare scene component responsible to manage any lens flares
  59078. * in a given scene.
  59079. */
  59080. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  59081. /**
  59082. * The component name helpfull to identify the component in the list of scene components.
  59083. */
  59084. readonly name: string;
  59085. /**
  59086. * The scene the component belongs to.
  59087. */
  59088. scene: Scene;
  59089. /**
  59090. * Creates a new instance of the component for the given scene
  59091. * @param scene Defines the scene to register the component in
  59092. */
  59093. constructor(scene: Scene);
  59094. /**
  59095. * Registers the component in a given scene
  59096. */
  59097. register(): void;
  59098. /**
  59099. * Rebuilds the elements related to this component in case of
  59100. * context lost for instance.
  59101. */
  59102. rebuild(): void;
  59103. /**
  59104. * Adds all the elements from the container to the scene
  59105. * @param container the container holding the elements
  59106. */
  59107. addFromContainer(container: AbstractScene): void;
  59108. /**
  59109. * Removes all the elements in the container from the scene
  59110. * @param container contains the elements to remove
  59111. * @param dispose if the removed element should be disposed (default: false)
  59112. */
  59113. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59114. /**
  59115. * Serializes the component data to the specified json object
  59116. * @param serializationObject The object to serialize to
  59117. */
  59118. serialize(serializationObject: any): void;
  59119. /**
  59120. * Disposes the component and the associated ressources.
  59121. */
  59122. dispose(): void;
  59123. private _draw;
  59124. }
  59125. }
  59126. declare module BABYLON {
  59127. /** @hidden */
  59128. export var depthPixelShader: {
  59129. name: string;
  59130. shader: string;
  59131. };
  59132. }
  59133. declare module BABYLON {
  59134. /** @hidden */
  59135. export var depthVertexShader: {
  59136. name: string;
  59137. shader: string;
  59138. };
  59139. }
  59140. declare module BABYLON {
  59141. /**
  59142. * This represents a depth renderer in Babylon.
  59143. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  59144. */
  59145. export class DepthRenderer {
  59146. private _scene;
  59147. private _depthMap;
  59148. private _effect;
  59149. private readonly _storeNonLinearDepth;
  59150. private readonly _clearColor;
  59151. /** Get if the depth renderer is using packed depth or not */
  59152. readonly isPacked: boolean;
  59153. private _cachedDefines;
  59154. private _camera;
  59155. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  59156. enabled: boolean;
  59157. /**
  59158. * Specifiess that the depth renderer will only be used within
  59159. * the camera it is created for.
  59160. * This can help forcing its rendering during the camera processing.
  59161. */
  59162. useOnlyInActiveCamera: boolean;
  59163. /** @hidden */
  59164. static _SceneComponentInitialization: (scene: Scene) => void;
  59165. /**
  59166. * Instantiates a depth renderer
  59167. * @param scene The scene the renderer belongs to
  59168. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  59169. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  59170. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  59171. */
  59172. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  59173. /**
  59174. * Creates the depth rendering effect and checks if the effect is ready.
  59175. * @param subMesh The submesh to be used to render the depth map of
  59176. * @param useInstances If multiple world instances should be used
  59177. * @returns if the depth renderer is ready to render the depth map
  59178. */
  59179. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59180. /**
  59181. * Gets the texture which the depth map will be written to.
  59182. * @returns The depth map texture
  59183. */
  59184. getDepthMap(): RenderTargetTexture;
  59185. /**
  59186. * Disposes of the depth renderer.
  59187. */
  59188. dispose(): void;
  59189. }
  59190. }
  59191. declare module BABYLON {
  59192. /** @hidden */
  59193. export var minmaxReduxPixelShader: {
  59194. name: string;
  59195. shader: string;
  59196. };
  59197. }
  59198. declare module BABYLON {
  59199. /**
  59200. * This class computes a min/max reduction from a texture: it means it computes the minimum
  59201. * and maximum values from all values of the texture.
  59202. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  59203. * The source values are read from the red channel of the texture.
  59204. */
  59205. export class MinMaxReducer {
  59206. /**
  59207. * Observable triggered when the computation has been performed
  59208. */
  59209. onAfterReductionPerformed: Observable<{
  59210. min: number;
  59211. max: number;
  59212. }>;
  59213. protected _camera: Camera;
  59214. protected _sourceTexture: Nullable<RenderTargetTexture>;
  59215. protected _reductionSteps: Nullable<Array<PostProcess>>;
  59216. protected _postProcessManager: PostProcessManager;
  59217. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  59218. protected _forceFullscreenViewport: boolean;
  59219. /**
  59220. * Creates a min/max reducer
  59221. * @param camera The camera to use for the post processes
  59222. */
  59223. constructor(camera: Camera);
  59224. /**
  59225. * Gets the texture used to read the values from.
  59226. */
  59227. get sourceTexture(): Nullable<RenderTargetTexture>;
  59228. /**
  59229. * Sets the source texture to read the values from.
  59230. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  59231. * because in such textures '1' value must not be taken into account to compute the maximum
  59232. * as this value is used to clear the texture.
  59233. * Note that the computation is not activated by calling this function, you must call activate() for that!
  59234. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  59235. * @param depthRedux Indicates if the texture is a depth texture or not
  59236. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  59237. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  59238. */
  59239. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  59240. /**
  59241. * Defines the refresh rate of the computation.
  59242. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  59243. */
  59244. get refreshRate(): number;
  59245. set refreshRate(value: number);
  59246. protected _activated: boolean;
  59247. /**
  59248. * Gets the activation status of the reducer
  59249. */
  59250. get activated(): boolean;
  59251. /**
  59252. * Activates the reduction computation.
  59253. * When activated, the observers registered in onAfterReductionPerformed are
  59254. * called after the compuation is performed
  59255. */
  59256. activate(): void;
  59257. /**
  59258. * Deactivates the reduction computation.
  59259. */
  59260. deactivate(): void;
  59261. /**
  59262. * Disposes the min/max reducer
  59263. * @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.
  59264. */
  59265. dispose(disposeAll?: boolean): void;
  59266. }
  59267. }
  59268. declare module BABYLON {
  59269. /**
  59270. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  59271. */
  59272. export class DepthReducer extends MinMaxReducer {
  59273. private _depthRenderer;
  59274. private _depthRendererId;
  59275. /**
  59276. * Gets the depth renderer used for the computation.
  59277. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  59278. */
  59279. get depthRenderer(): Nullable<DepthRenderer>;
  59280. /**
  59281. * Creates a depth reducer
  59282. * @param camera The camera used to render the depth texture
  59283. */
  59284. constructor(camera: Camera);
  59285. /**
  59286. * Sets the depth renderer to use to generate the depth map
  59287. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  59288. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  59289. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  59290. */
  59291. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  59292. /** @hidden */
  59293. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  59294. /**
  59295. * Activates the reduction computation.
  59296. * When activated, the observers registered in onAfterReductionPerformed are
  59297. * called after the compuation is performed
  59298. */
  59299. activate(): void;
  59300. /**
  59301. * Deactivates the reduction computation.
  59302. */
  59303. deactivate(): void;
  59304. /**
  59305. * Disposes the depth reducer
  59306. * @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.
  59307. */
  59308. dispose(disposeAll?: boolean): void;
  59309. }
  59310. }
  59311. declare module BABYLON {
  59312. /**
  59313. * A CSM implementation allowing casting shadows on large scenes.
  59314. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  59315. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  59316. */
  59317. export class CascadedShadowGenerator extends ShadowGenerator {
  59318. private static readonly frustumCornersNDCSpace;
  59319. /**
  59320. * Name of the CSM class
  59321. */
  59322. static CLASSNAME: string;
  59323. /**
  59324. * Defines the default number of cascades used by the CSM.
  59325. */
  59326. static readonly DEFAULT_CASCADES_COUNT: number;
  59327. /**
  59328. * Defines the minimum number of cascades used by the CSM.
  59329. */
  59330. static readonly MIN_CASCADES_COUNT: number;
  59331. /**
  59332. * Defines the maximum number of cascades used by the CSM.
  59333. */
  59334. static readonly MAX_CASCADES_COUNT: number;
  59335. protected _validateFilter(filter: number): number;
  59336. /**
  59337. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  59338. */
  59339. penumbraDarkness: number;
  59340. private _numCascades;
  59341. /**
  59342. * Gets or set the number of cascades used by the CSM.
  59343. */
  59344. get numCascades(): number;
  59345. set numCascades(value: number);
  59346. /**
  59347. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  59348. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  59349. */
  59350. stabilizeCascades: boolean;
  59351. private _freezeShadowCastersBoundingInfo;
  59352. private _freezeShadowCastersBoundingInfoObservable;
  59353. /**
  59354. * Enables or disables the shadow casters bounding info computation.
  59355. * If your shadow casters don't move, you can disable this feature.
  59356. * If it is enabled, the bounding box computation is done every frame.
  59357. */
  59358. get freezeShadowCastersBoundingInfo(): boolean;
  59359. set freezeShadowCastersBoundingInfo(freeze: boolean);
  59360. private _scbiMin;
  59361. private _scbiMax;
  59362. protected _computeShadowCastersBoundingInfo(): void;
  59363. protected _shadowCastersBoundingInfo: BoundingInfo;
  59364. /**
  59365. * Gets or sets the shadow casters bounding info.
  59366. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  59367. * so that the system won't overwrite the bounds you provide
  59368. */
  59369. get shadowCastersBoundingInfo(): BoundingInfo;
  59370. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  59371. protected _breaksAreDirty: boolean;
  59372. protected _minDistance: number;
  59373. protected _maxDistance: number;
  59374. /**
  59375. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  59376. *
  59377. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  59378. * If you don't know these values, simply leave them to their defaults and don't call this function.
  59379. * @param min minimal distance for the breaks (default to 0.)
  59380. * @param max maximal distance for the breaks (default to 1.)
  59381. */
  59382. setMinMaxDistance(min: number, max: number): void;
  59383. /** Gets the minimal distance used in the cascade break computation */
  59384. get minDistance(): number;
  59385. /** Gets the maximal distance used in the cascade break computation */
  59386. get maxDistance(): number;
  59387. /**
  59388. * Gets the class name of that object
  59389. * @returns "CascadedShadowGenerator"
  59390. */
  59391. getClassName(): string;
  59392. private _cascadeMinExtents;
  59393. private _cascadeMaxExtents;
  59394. /**
  59395. * Gets a cascade minimum extents
  59396. * @param cascadeIndex index of the cascade
  59397. * @returns the minimum cascade extents
  59398. */
  59399. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  59400. /**
  59401. * Gets a cascade maximum extents
  59402. * @param cascadeIndex index of the cascade
  59403. * @returns the maximum cascade extents
  59404. */
  59405. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  59406. private _cascades;
  59407. private _currentLayer;
  59408. private _viewSpaceFrustumsZ;
  59409. private _viewMatrices;
  59410. private _projectionMatrices;
  59411. private _transformMatrices;
  59412. private _transformMatricesAsArray;
  59413. private _frustumLengths;
  59414. private _lightSizeUVCorrection;
  59415. private _depthCorrection;
  59416. private _frustumCornersWorldSpace;
  59417. private _frustumCenter;
  59418. private _shadowCameraPos;
  59419. private _shadowMaxZ;
  59420. /**
  59421. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  59422. * It defaults to camera.maxZ
  59423. */
  59424. get shadowMaxZ(): number;
  59425. /**
  59426. * Sets the shadow max z distance.
  59427. */
  59428. set shadowMaxZ(value: number);
  59429. protected _debug: boolean;
  59430. /**
  59431. * Gets or sets the debug flag.
  59432. * When enabled, the cascades are materialized by different colors on the screen.
  59433. */
  59434. get debug(): boolean;
  59435. set debug(dbg: boolean);
  59436. private _depthClamp;
  59437. /**
  59438. * Gets or sets the depth clamping value.
  59439. *
  59440. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  59441. * to account for the shadow casters far away.
  59442. *
  59443. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  59444. */
  59445. get depthClamp(): boolean;
  59446. set depthClamp(value: boolean);
  59447. private _cascadeBlendPercentage;
  59448. /**
  59449. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  59450. * It defaults to 0.1 (10% blending).
  59451. */
  59452. get cascadeBlendPercentage(): number;
  59453. set cascadeBlendPercentage(value: number);
  59454. private _lambda;
  59455. /**
  59456. * Gets or set the lambda parameter.
  59457. * This parameter is used to split the camera frustum and create the cascades.
  59458. * 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.
  59459. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  59460. */
  59461. get lambda(): number;
  59462. set lambda(value: number);
  59463. /**
  59464. * Gets the view matrix corresponding to a given cascade
  59465. * @param cascadeNum cascade to retrieve the view matrix from
  59466. * @returns the cascade view matrix
  59467. */
  59468. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  59469. /**
  59470. * Gets the projection matrix corresponding to a given cascade
  59471. * @param cascadeNum cascade to retrieve the projection matrix from
  59472. * @returns the cascade projection matrix
  59473. */
  59474. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  59475. /**
  59476. * Gets the transformation matrix corresponding to a given cascade
  59477. * @param cascadeNum cascade to retrieve the transformation matrix from
  59478. * @returns the cascade transformation matrix
  59479. */
  59480. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  59481. private _depthRenderer;
  59482. /**
  59483. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  59484. *
  59485. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  59486. *
  59487. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  59488. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  59489. * @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
  59490. */
  59491. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  59492. private _depthReducer;
  59493. private _autoCalcDepthBounds;
  59494. /**
  59495. * Gets or sets the autoCalcDepthBounds property.
  59496. *
  59497. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  59498. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  59499. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  59500. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  59501. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  59502. */
  59503. get autoCalcDepthBounds(): boolean;
  59504. set autoCalcDepthBounds(value: boolean);
  59505. /**
  59506. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  59507. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  59508. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  59509. * for setting the refresh rate on the renderer yourself!
  59510. */
  59511. get autoCalcDepthBoundsRefreshRate(): number;
  59512. set autoCalcDepthBoundsRefreshRate(value: number);
  59513. /**
  59514. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  59515. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  59516. * you change the camera near/far planes!
  59517. */
  59518. splitFrustum(): void;
  59519. private _splitFrustum;
  59520. private _computeMatrices;
  59521. private _computeFrustumInWorldSpace;
  59522. private _computeCascadeFrustum;
  59523. /**
  59524. * Support test.
  59525. */
  59526. static get IsSupported(): boolean;
  59527. /** @hidden */
  59528. static _SceneComponentInitialization: (scene: Scene) => void;
  59529. /**
  59530. * Creates a Cascaded Shadow Generator object.
  59531. * A ShadowGenerator is the required tool to use the shadows.
  59532. * Each directional light casting shadows needs to use its own ShadowGenerator.
  59533. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  59534. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  59535. * @param light The directional light object generating the shadows.
  59536. * @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.
  59537. */
  59538. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  59539. protected _initializeGenerator(): void;
  59540. protected _createTargetRenderTexture(): void;
  59541. protected _initializeShadowMap(): void;
  59542. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  59543. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  59544. /**
  59545. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  59546. * @param defines Defines of the material we want to update
  59547. * @param lightIndex Index of the light in the enabled light list of the material
  59548. */
  59549. prepareDefines(defines: any, lightIndex: number): void;
  59550. /**
  59551. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  59552. * defined in the generator but impacting the effect).
  59553. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  59554. * @param effect The effect we are binfing the information for
  59555. */
  59556. bindShadowLight(lightIndex: string, effect: Effect): void;
  59557. /**
  59558. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  59559. * (eq to view projection * shadow projection matrices)
  59560. * @returns The transform matrix used to create the shadow map
  59561. */
  59562. getTransformMatrix(): Matrix;
  59563. /**
  59564. * Disposes the ShadowGenerator.
  59565. * Returns nothing.
  59566. */
  59567. dispose(): void;
  59568. /**
  59569. * Serializes the shadow generator setup to a json object.
  59570. * @returns The serialized JSON object
  59571. */
  59572. serialize(): any;
  59573. /**
  59574. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  59575. * @param parsedShadowGenerator The JSON object to parse
  59576. * @param scene The scene to create the shadow map for
  59577. * @returns The parsed shadow generator
  59578. */
  59579. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  59580. }
  59581. }
  59582. declare module BABYLON {
  59583. /**
  59584. * Defines the shadow generator component responsible to manage any shadow generators
  59585. * in a given scene.
  59586. */
  59587. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  59588. /**
  59589. * The component name helpfull to identify the component in the list of scene components.
  59590. */
  59591. readonly name: string;
  59592. /**
  59593. * The scene the component belongs to.
  59594. */
  59595. scene: Scene;
  59596. /**
  59597. * Creates a new instance of the component for the given scene
  59598. * @param scene Defines the scene to register the component in
  59599. */
  59600. constructor(scene: Scene);
  59601. /**
  59602. * Registers the component in a given scene
  59603. */
  59604. register(): void;
  59605. /**
  59606. * Rebuilds the elements related to this component in case of
  59607. * context lost for instance.
  59608. */
  59609. rebuild(): void;
  59610. /**
  59611. * Serializes the component data to the specified json object
  59612. * @param serializationObject The object to serialize to
  59613. */
  59614. serialize(serializationObject: any): void;
  59615. /**
  59616. * Adds all the elements from the container to the scene
  59617. * @param container the container holding the elements
  59618. */
  59619. addFromContainer(container: AbstractScene): void;
  59620. /**
  59621. * Removes all the elements in the container from the scene
  59622. * @param container contains the elements to remove
  59623. * @param dispose if the removed element should be disposed (default: false)
  59624. */
  59625. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59626. /**
  59627. * Rebuilds the elements related to this component in case of
  59628. * context lost for instance.
  59629. */
  59630. dispose(): void;
  59631. private _gatherRenderTargets;
  59632. }
  59633. }
  59634. declare module BABYLON {
  59635. /**
  59636. * A point light is a light defined by an unique point in world space.
  59637. * The light is emitted in every direction from this point.
  59638. * A good example of a point light is a standard light bulb.
  59639. * Documentation: https://doc.babylonjs.com/babylon101/lights
  59640. */
  59641. export class PointLight extends ShadowLight {
  59642. private _shadowAngle;
  59643. /**
  59644. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59645. * This specifies what angle the shadow will use to be created.
  59646. *
  59647. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  59648. */
  59649. get shadowAngle(): number;
  59650. /**
  59651. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59652. * This specifies what angle the shadow will use to be created.
  59653. *
  59654. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  59655. */
  59656. set shadowAngle(value: number);
  59657. /**
  59658. * Gets the direction if it has been set.
  59659. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59660. */
  59661. get direction(): Vector3;
  59662. /**
  59663. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59664. */
  59665. set direction(value: Vector3);
  59666. /**
  59667. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  59668. * A PointLight emits the light in every direction.
  59669. * It can cast shadows.
  59670. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  59671. * ```javascript
  59672. * var pointLight = new PointLight("pl", camera.position, scene);
  59673. * ```
  59674. * Documentation : https://doc.babylonjs.com/babylon101/lights
  59675. * @param name The light friendly name
  59676. * @param position The position of the point light in the scene
  59677. * @param scene The scene the lights belongs to
  59678. */
  59679. constructor(name: string, position: Vector3, scene: Scene);
  59680. /**
  59681. * Returns the string "PointLight"
  59682. * @returns the class name
  59683. */
  59684. getClassName(): string;
  59685. /**
  59686. * Returns the integer 0.
  59687. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  59688. */
  59689. getTypeID(): number;
  59690. /**
  59691. * Specifies wether or not the shadowmap should be a cube texture.
  59692. * @returns true if the shadowmap needs to be a cube texture.
  59693. */
  59694. needCube(): boolean;
  59695. /**
  59696. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  59697. * @param faceIndex The index of the face we are computed the direction to generate shadow
  59698. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  59699. */
  59700. getShadowDirection(faceIndex?: number): Vector3;
  59701. /**
  59702. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  59703. * - fov = PI / 2
  59704. * - aspect ratio : 1.0
  59705. * - z-near and far equal to the active camera minZ and maxZ.
  59706. * Returns the PointLight.
  59707. */
  59708. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59709. protected _buildUniformLayout(): void;
  59710. /**
  59711. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  59712. * @param effect The effect to update
  59713. * @param lightIndex The index of the light in the effect to update
  59714. * @returns The point light
  59715. */
  59716. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  59717. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  59718. /**
  59719. * Prepares the list of defines specific to the light type.
  59720. * @param defines the list of defines
  59721. * @param lightIndex defines the index of the light for the effect
  59722. */
  59723. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  59724. }
  59725. }
  59726. declare module BABYLON {
  59727. /**
  59728. * Header information of HDR texture files.
  59729. */
  59730. export interface HDRInfo {
  59731. /**
  59732. * The height of the texture in pixels.
  59733. */
  59734. height: number;
  59735. /**
  59736. * The width of the texture in pixels.
  59737. */
  59738. width: number;
  59739. /**
  59740. * The index of the beginning of the data in the binary file.
  59741. */
  59742. dataPosition: number;
  59743. }
  59744. /**
  59745. * This groups tools to convert HDR texture to native colors array.
  59746. */
  59747. export class HDRTools {
  59748. private static Ldexp;
  59749. private static Rgbe2float;
  59750. private static readStringLine;
  59751. /**
  59752. * Reads header information from an RGBE texture stored in a native array.
  59753. * More information on this format are available here:
  59754. * https://en.wikipedia.org/wiki/RGBE_image_format
  59755. *
  59756. * @param uint8array The binary file stored in native array.
  59757. * @return The header information.
  59758. */
  59759. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  59760. /**
  59761. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  59762. * This RGBE texture needs to store the information as a panorama.
  59763. *
  59764. * More information on this format are available here:
  59765. * https://en.wikipedia.org/wiki/RGBE_image_format
  59766. *
  59767. * @param buffer The binary file stored in an array buffer.
  59768. * @param size The expected size of the extracted cubemap.
  59769. * @return The Cube Map information.
  59770. */
  59771. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  59772. /**
  59773. * Returns the pixels data extracted from an RGBE texture.
  59774. * This pixels will be stored left to right up to down in the R G B order in one array.
  59775. *
  59776. * More information on this format are available here:
  59777. * https://en.wikipedia.org/wiki/RGBE_image_format
  59778. *
  59779. * @param uint8array The binary file stored in an array buffer.
  59780. * @param hdrInfo The header information of the file.
  59781. * @return The pixels data in RGB right to left up to down order.
  59782. */
  59783. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  59784. private static RGBE_ReadPixels_RLE;
  59785. private static RGBE_ReadPixels_NOT_RLE;
  59786. }
  59787. }
  59788. declare module BABYLON {
  59789. /**
  59790. * Effect Render Options
  59791. */
  59792. export interface IEffectRendererOptions {
  59793. /**
  59794. * Defines the vertices positions.
  59795. */
  59796. positions?: number[];
  59797. /**
  59798. * Defines the indices.
  59799. */
  59800. indices?: number[];
  59801. }
  59802. /**
  59803. * Helper class to render one or more effects.
  59804. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  59805. */
  59806. export class EffectRenderer {
  59807. private engine;
  59808. private static _DefaultOptions;
  59809. private _vertexBuffers;
  59810. private _indexBuffer;
  59811. private _fullscreenViewport;
  59812. /**
  59813. * Creates an effect renderer
  59814. * @param engine the engine to use for rendering
  59815. * @param options defines the options of the effect renderer
  59816. */
  59817. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  59818. /**
  59819. * Sets the current viewport in normalized coordinates 0-1
  59820. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  59821. */
  59822. setViewport(viewport?: Viewport): void;
  59823. /**
  59824. * Binds the embedded attributes buffer to the effect.
  59825. * @param effect Defines the effect to bind the attributes for
  59826. */
  59827. bindBuffers(effect: Effect): void;
  59828. /**
  59829. * Sets the current effect wrapper to use during draw.
  59830. * The effect needs to be ready before calling this api.
  59831. * This also sets the default full screen position attribute.
  59832. * @param effectWrapper Defines the effect to draw with
  59833. */
  59834. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  59835. /**
  59836. * Restores engine states
  59837. */
  59838. restoreStates(): void;
  59839. /**
  59840. * Draws a full screen quad.
  59841. */
  59842. draw(): void;
  59843. private isRenderTargetTexture;
  59844. /**
  59845. * renders one or more effects to a specified texture
  59846. * @param effectWrapper the effect to renderer
  59847. * @param outputTexture texture to draw to, if null it will render to the screen.
  59848. */
  59849. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  59850. /**
  59851. * Disposes of the effect renderer
  59852. */
  59853. dispose(): void;
  59854. }
  59855. /**
  59856. * Options to create an EffectWrapper
  59857. */
  59858. interface EffectWrapperCreationOptions {
  59859. /**
  59860. * Engine to use to create the effect
  59861. */
  59862. engine: ThinEngine;
  59863. /**
  59864. * Fragment shader for the effect
  59865. */
  59866. fragmentShader: string;
  59867. /**
  59868. * Use the shader store instead of direct source code
  59869. */
  59870. useShaderStore?: boolean;
  59871. /**
  59872. * Vertex shader for the effect
  59873. */
  59874. vertexShader?: string;
  59875. /**
  59876. * Attributes to use in the shader
  59877. */
  59878. attributeNames?: Array<string>;
  59879. /**
  59880. * Uniforms to use in the shader
  59881. */
  59882. uniformNames?: Array<string>;
  59883. /**
  59884. * Texture sampler names to use in the shader
  59885. */
  59886. samplerNames?: Array<string>;
  59887. /**
  59888. * Defines to use in the shader
  59889. */
  59890. defines?: Array<string>;
  59891. /**
  59892. * Callback when effect is compiled
  59893. */
  59894. onCompiled?: Nullable<(effect: Effect) => void>;
  59895. /**
  59896. * The friendly name of the effect displayed in Spector.
  59897. */
  59898. name?: string;
  59899. }
  59900. /**
  59901. * Wraps an effect to be used for rendering
  59902. */
  59903. export class EffectWrapper {
  59904. /**
  59905. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  59906. */
  59907. onApplyObservable: Observable<{}>;
  59908. /**
  59909. * The underlying effect
  59910. */
  59911. effect: Effect;
  59912. /**
  59913. * Creates an effect to be renderer
  59914. * @param creationOptions options to create the effect
  59915. */
  59916. constructor(creationOptions: EffectWrapperCreationOptions);
  59917. /**
  59918. * Disposes of the effect wrapper
  59919. */
  59920. dispose(): void;
  59921. }
  59922. }
  59923. declare module BABYLON {
  59924. /** @hidden */
  59925. export var hdrFilteringVertexShader: {
  59926. name: string;
  59927. shader: string;
  59928. };
  59929. }
  59930. declare module BABYLON {
  59931. /** @hidden */
  59932. export var hdrFilteringPixelShader: {
  59933. name: string;
  59934. shader: string;
  59935. };
  59936. }
  59937. declare module BABYLON {
  59938. /**
  59939. * Options for texture filtering
  59940. */
  59941. interface IHDRFilteringOptions {
  59942. /**
  59943. * Scales pixel intensity for the input HDR map.
  59944. */
  59945. hdrScale?: number;
  59946. /**
  59947. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  59948. */
  59949. quality?: number;
  59950. }
  59951. /**
  59952. * Filters HDR maps to get correct renderings of PBR reflections
  59953. */
  59954. export class HDRFiltering {
  59955. private _engine;
  59956. private _effectRenderer;
  59957. private _effectWrapper;
  59958. private _lodGenerationOffset;
  59959. private _lodGenerationScale;
  59960. /**
  59961. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  59962. * you care about baking speed.
  59963. */
  59964. quality: number;
  59965. /**
  59966. * Scales pixel intensity for the input HDR map.
  59967. */
  59968. hdrScale: number;
  59969. /**
  59970. * Instantiates HDR filter for reflection maps
  59971. *
  59972. * @param engine Thin engine
  59973. * @param options Options
  59974. */
  59975. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  59976. private _createRenderTarget;
  59977. private _prefilterInternal;
  59978. private _createEffect;
  59979. /**
  59980. * Get a value indicating if the filter is ready to be used
  59981. * @param texture Texture to filter
  59982. * @returns true if the filter is ready
  59983. */
  59984. isReady(texture: BaseTexture): boolean;
  59985. /**
  59986. * Prefilters a cube texture to have mipmap levels representing roughness values.
  59987. * Prefiltering will be invoked at the end of next rendering pass.
  59988. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  59989. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  59990. * @param texture Texture to filter
  59991. * @param onFinished Callback when filtering is done
  59992. * @return Promise called when prefiltering is done
  59993. */
  59994. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  59995. }
  59996. }
  59997. declare module BABYLON {
  59998. /**
  59999. * This represents a texture coming from an HDR input.
  60000. *
  60001. * The only supported format is currently panorama picture stored in RGBE format.
  60002. * Example of such files can be found on HDRLib: http://hdrlib.com/
  60003. */
  60004. export class HDRCubeTexture extends BaseTexture {
  60005. private static _facesMapping;
  60006. private _generateHarmonics;
  60007. private _noMipmap;
  60008. private _prefilterOnLoad;
  60009. private _textureMatrix;
  60010. private _size;
  60011. private _onLoad;
  60012. private _onError;
  60013. /**
  60014. * The texture URL.
  60015. */
  60016. url: string;
  60017. /**
  60018. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  60019. */
  60020. coordinatesMode: number;
  60021. protected _isBlocking: boolean;
  60022. /**
  60023. * Sets wether or not the texture is blocking during loading.
  60024. */
  60025. set isBlocking(value: boolean);
  60026. /**
  60027. * Gets wether or not the texture is blocking during loading.
  60028. */
  60029. get isBlocking(): boolean;
  60030. protected _rotationY: number;
  60031. /**
  60032. * Sets texture matrix rotation angle around Y axis in radians.
  60033. */
  60034. set rotationY(value: number);
  60035. /**
  60036. * Gets texture matrix rotation angle around Y axis radians.
  60037. */
  60038. get rotationY(): number;
  60039. /**
  60040. * Gets or sets the center of the bounding box associated with the cube texture
  60041. * It must define where the camera used to render the texture was set
  60042. */
  60043. boundingBoxPosition: Vector3;
  60044. private _boundingBoxSize;
  60045. /**
  60046. * Gets or sets the size of the bounding box associated with the cube texture
  60047. * When defined, the cubemap will switch to local mode
  60048. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  60049. * @example https://www.babylonjs-playground.com/#RNASML
  60050. */
  60051. set boundingBoxSize(value: Vector3);
  60052. get boundingBoxSize(): Vector3;
  60053. /**
  60054. * Instantiates an HDRTexture from the following parameters.
  60055. *
  60056. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  60057. * @param sceneOrEngine The scene or engine the texture will be used in
  60058. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  60059. * @param noMipmap Forces to not generate the mipmap if true
  60060. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  60061. * @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)
  60062. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  60063. */
  60064. 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>);
  60065. /**
  60066. * Get the current class name of the texture useful for serialization or dynamic coding.
  60067. * @returns "HDRCubeTexture"
  60068. */
  60069. getClassName(): string;
  60070. /**
  60071. * Occurs when the file is raw .hdr file.
  60072. */
  60073. private loadTexture;
  60074. clone(): HDRCubeTexture;
  60075. delayLoad(): void;
  60076. /**
  60077. * Get the texture reflection matrix used to rotate/transform the reflection.
  60078. * @returns the reflection matrix
  60079. */
  60080. getReflectionTextureMatrix(): Matrix;
  60081. /**
  60082. * Set the texture reflection matrix used to rotate/transform the reflection.
  60083. * @param value Define the reflection matrix to set
  60084. */
  60085. setReflectionTextureMatrix(value: Matrix): void;
  60086. /**
  60087. * Parses a JSON representation of an HDR Texture in order to create the texture
  60088. * @param parsedTexture Define the JSON representation
  60089. * @param scene Define the scene the texture should be created in
  60090. * @param rootUrl Define the root url in case we need to load relative dependencies
  60091. * @returns the newly created texture after parsing
  60092. */
  60093. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  60094. serialize(): any;
  60095. }
  60096. }
  60097. declare module BABYLON {
  60098. /**
  60099. * Class used to control physics engine
  60100. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  60101. */
  60102. export class PhysicsEngine implements IPhysicsEngine {
  60103. private _physicsPlugin;
  60104. /**
  60105. * Global value used to control the smallest number supported by the simulation
  60106. */
  60107. static Epsilon: number;
  60108. private _impostors;
  60109. private _joints;
  60110. private _subTimeStep;
  60111. /**
  60112. * Gets the gravity vector used by the simulation
  60113. */
  60114. gravity: Vector3;
  60115. /**
  60116. * Factory used to create the default physics plugin.
  60117. * @returns The default physics plugin
  60118. */
  60119. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  60120. /**
  60121. * Creates a new Physics Engine
  60122. * @param gravity defines the gravity vector used by the simulation
  60123. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  60124. */
  60125. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  60126. /**
  60127. * Sets the gravity vector used by the simulation
  60128. * @param gravity defines the gravity vector to use
  60129. */
  60130. setGravity(gravity: Vector3): void;
  60131. /**
  60132. * Set the time step of the physics engine.
  60133. * Default is 1/60.
  60134. * To slow it down, enter 1/600 for example.
  60135. * To speed it up, 1/30
  60136. * @param newTimeStep defines the new timestep to apply to this world.
  60137. */
  60138. setTimeStep(newTimeStep?: number): void;
  60139. /**
  60140. * Get the time step of the physics engine.
  60141. * @returns the current time step
  60142. */
  60143. getTimeStep(): number;
  60144. /**
  60145. * Set the sub time step of the physics engine.
  60146. * Default is 0 meaning there is no sub steps
  60147. * To increase physics resolution precision, set a small value (like 1 ms)
  60148. * @param subTimeStep defines the new sub timestep used for physics resolution.
  60149. */
  60150. setSubTimeStep(subTimeStep?: number): void;
  60151. /**
  60152. * Get the sub time step of the physics engine.
  60153. * @returns the current sub time step
  60154. */
  60155. getSubTimeStep(): number;
  60156. /**
  60157. * Release all resources
  60158. */
  60159. dispose(): void;
  60160. /**
  60161. * Gets the name of the current physics plugin
  60162. * @returns the name of the plugin
  60163. */
  60164. getPhysicsPluginName(): string;
  60165. /**
  60166. * Adding a new impostor for the impostor tracking.
  60167. * This will be done by the impostor itself.
  60168. * @param impostor the impostor to add
  60169. */
  60170. addImpostor(impostor: PhysicsImpostor): void;
  60171. /**
  60172. * Remove an impostor from the engine.
  60173. * This impostor and its mesh will not longer be updated by the physics engine.
  60174. * @param impostor the impostor to remove
  60175. */
  60176. removeImpostor(impostor: PhysicsImpostor): void;
  60177. /**
  60178. * Add a joint to the physics engine
  60179. * @param mainImpostor defines the main impostor to which the joint is added.
  60180. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  60181. * @param joint defines the joint that will connect both impostors.
  60182. */
  60183. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  60184. /**
  60185. * Removes a joint from the simulation
  60186. * @param mainImpostor defines the impostor used with the joint
  60187. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  60188. * @param joint defines the joint to remove
  60189. */
  60190. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  60191. /**
  60192. * Called by the scene. No need to call it.
  60193. * @param delta defines the timespam between frames
  60194. */
  60195. _step(delta: number): void;
  60196. /**
  60197. * Gets the current plugin used to run the simulation
  60198. * @returns current plugin
  60199. */
  60200. getPhysicsPlugin(): IPhysicsEnginePlugin;
  60201. /**
  60202. * Gets the list of physic impostors
  60203. * @returns an array of PhysicsImpostor
  60204. */
  60205. getImpostors(): Array<PhysicsImpostor>;
  60206. /**
  60207. * Gets the impostor for a physics enabled object
  60208. * @param object defines the object impersonated by the impostor
  60209. * @returns the PhysicsImpostor or null if not found
  60210. */
  60211. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  60212. /**
  60213. * Gets the impostor for a physics body object
  60214. * @param body defines physics body used by the impostor
  60215. * @returns the PhysicsImpostor or null if not found
  60216. */
  60217. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  60218. /**
  60219. * Does a raycast in the physics world
  60220. * @param from when should the ray start?
  60221. * @param to when should the ray end?
  60222. * @returns PhysicsRaycastResult
  60223. */
  60224. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60225. }
  60226. }
  60227. declare module BABYLON {
  60228. /** @hidden */
  60229. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  60230. private _useDeltaForWorldStep;
  60231. world: any;
  60232. name: string;
  60233. private _physicsMaterials;
  60234. private _fixedTimeStep;
  60235. private _cannonRaycastResult;
  60236. private _raycastResult;
  60237. private _physicsBodysToRemoveAfterStep;
  60238. private _firstFrame;
  60239. BJSCANNON: any;
  60240. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  60241. setGravity(gravity: Vector3): void;
  60242. setTimeStep(timeStep: number): void;
  60243. getTimeStep(): number;
  60244. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60245. private _removeMarkedPhysicsBodiesFromWorld;
  60246. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60247. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60248. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60249. private _processChildMeshes;
  60250. removePhysicsBody(impostor: PhysicsImpostor): void;
  60251. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60252. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60253. private _addMaterial;
  60254. private _checkWithEpsilon;
  60255. private _createShape;
  60256. private _createHeightmap;
  60257. private _minus90X;
  60258. private _plus90X;
  60259. private _tmpPosition;
  60260. private _tmpDeltaPosition;
  60261. private _tmpUnityRotation;
  60262. private _updatePhysicsBodyTransformation;
  60263. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60264. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60265. isSupported(): boolean;
  60266. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60267. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60268. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60269. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60270. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60271. getBodyMass(impostor: PhysicsImpostor): number;
  60272. getBodyFriction(impostor: PhysicsImpostor): number;
  60273. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60274. getBodyRestitution(impostor: PhysicsImpostor): number;
  60275. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60276. sleepBody(impostor: PhysicsImpostor): void;
  60277. wakeUpBody(impostor: PhysicsImpostor): void;
  60278. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  60279. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  60280. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  60281. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60282. getRadius(impostor: PhysicsImpostor): number;
  60283. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60284. dispose(): void;
  60285. private _extendNamespace;
  60286. /**
  60287. * Does a raycast in the physics world
  60288. * @param from when should the ray start?
  60289. * @param to when should the ray end?
  60290. * @returns PhysicsRaycastResult
  60291. */
  60292. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60293. }
  60294. }
  60295. declare module BABYLON {
  60296. /** @hidden */
  60297. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  60298. private _useDeltaForWorldStep;
  60299. world: any;
  60300. name: string;
  60301. BJSOIMO: any;
  60302. private _raycastResult;
  60303. private _fixedTimeStep;
  60304. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  60305. setGravity(gravity: Vector3): void;
  60306. setTimeStep(timeStep: number): void;
  60307. getTimeStep(): number;
  60308. private _tmpImpostorsArray;
  60309. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60310. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60311. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60312. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60313. private _tmpPositionVector;
  60314. removePhysicsBody(impostor: PhysicsImpostor): void;
  60315. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60316. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60317. isSupported(): boolean;
  60318. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60319. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60320. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60321. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60322. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60323. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60324. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60325. getBodyMass(impostor: PhysicsImpostor): number;
  60326. getBodyFriction(impostor: PhysicsImpostor): number;
  60327. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60328. getBodyRestitution(impostor: PhysicsImpostor): number;
  60329. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60330. sleepBody(impostor: PhysicsImpostor): void;
  60331. wakeUpBody(impostor: PhysicsImpostor): void;
  60332. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  60333. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  60334. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  60335. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60336. getRadius(impostor: PhysicsImpostor): number;
  60337. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60338. dispose(): void;
  60339. /**
  60340. * Does a raycast in the physics world
  60341. * @param from when should the ray start?
  60342. * @param to when should the ray end?
  60343. * @returns PhysicsRaycastResult
  60344. */
  60345. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60346. }
  60347. }
  60348. declare module BABYLON {
  60349. /**
  60350. * AmmoJS Physics plugin
  60351. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  60352. * @see https://github.com/kripken/ammo.js/
  60353. */
  60354. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  60355. private _useDeltaForWorldStep;
  60356. /**
  60357. * Reference to the Ammo library
  60358. */
  60359. bjsAMMO: any;
  60360. /**
  60361. * Created ammoJS world which physics bodies are added to
  60362. */
  60363. world: any;
  60364. /**
  60365. * Name of the plugin
  60366. */
  60367. name: string;
  60368. private _timeStep;
  60369. private _fixedTimeStep;
  60370. private _maxSteps;
  60371. private _tmpQuaternion;
  60372. private _tmpAmmoTransform;
  60373. private _tmpAmmoQuaternion;
  60374. private _tmpAmmoConcreteContactResultCallback;
  60375. private _collisionConfiguration;
  60376. private _dispatcher;
  60377. private _overlappingPairCache;
  60378. private _solver;
  60379. private _softBodySolver;
  60380. private _tmpAmmoVectorA;
  60381. private _tmpAmmoVectorB;
  60382. private _tmpAmmoVectorC;
  60383. private _tmpAmmoVectorD;
  60384. private _tmpContactCallbackResult;
  60385. private _tmpAmmoVectorRCA;
  60386. private _tmpAmmoVectorRCB;
  60387. private _raycastResult;
  60388. private static readonly DISABLE_COLLISION_FLAG;
  60389. private static readonly KINEMATIC_FLAG;
  60390. private static readonly DISABLE_DEACTIVATION_FLAG;
  60391. /**
  60392. * Initializes the ammoJS plugin
  60393. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  60394. * @param ammoInjection can be used to inject your own ammo reference
  60395. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  60396. */
  60397. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  60398. /**
  60399. * Sets the gravity of the physics world (m/(s^2))
  60400. * @param gravity Gravity to set
  60401. */
  60402. setGravity(gravity: Vector3): void;
  60403. /**
  60404. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  60405. * @param timeStep timestep to use in seconds
  60406. */
  60407. setTimeStep(timeStep: number): void;
  60408. /**
  60409. * 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)
  60410. * @param fixedTimeStep fixedTimeStep to use in seconds
  60411. */
  60412. setFixedTimeStep(fixedTimeStep: number): void;
  60413. /**
  60414. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  60415. * @param maxSteps the maximum number of steps by the physics engine per frame
  60416. */
  60417. setMaxSteps(maxSteps: number): void;
  60418. /**
  60419. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  60420. * @returns the current timestep in seconds
  60421. */
  60422. getTimeStep(): number;
  60423. /**
  60424. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  60425. */
  60426. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  60427. private _isImpostorInContact;
  60428. private _isImpostorPairInContact;
  60429. private _stepSimulation;
  60430. /**
  60431. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  60432. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  60433. * After the step the babylon meshes are set to the position of the physics imposters
  60434. * @param delta amount of time to step forward
  60435. * @param impostors array of imposters to update before/after the step
  60436. */
  60437. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60438. /**
  60439. * Update babylon mesh to match physics world object
  60440. * @param impostor imposter to match
  60441. */
  60442. private _afterSoftStep;
  60443. /**
  60444. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  60445. * @param impostor imposter to match
  60446. */
  60447. private _ropeStep;
  60448. /**
  60449. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  60450. * @param impostor imposter to match
  60451. */
  60452. private _softbodyOrClothStep;
  60453. private _tmpMatrix;
  60454. /**
  60455. * Applies an impulse on the imposter
  60456. * @param impostor imposter to apply impulse to
  60457. * @param force amount of force to be applied to the imposter
  60458. * @param contactPoint the location to apply the impulse on the imposter
  60459. */
  60460. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60461. /**
  60462. * Applies a force on the imposter
  60463. * @param impostor imposter to apply force
  60464. * @param force amount of force to be applied to the imposter
  60465. * @param contactPoint the location to apply the force on the imposter
  60466. */
  60467. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60468. /**
  60469. * Creates a physics body using the plugin
  60470. * @param impostor the imposter to create the physics body on
  60471. */
  60472. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60473. /**
  60474. * Removes the physics body from the imposter and disposes of the body's memory
  60475. * @param impostor imposter to remove the physics body from
  60476. */
  60477. removePhysicsBody(impostor: PhysicsImpostor): void;
  60478. /**
  60479. * Generates a joint
  60480. * @param impostorJoint the imposter joint to create the joint with
  60481. */
  60482. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60483. /**
  60484. * Removes a joint
  60485. * @param impostorJoint the imposter joint to remove the joint from
  60486. */
  60487. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60488. private _addMeshVerts;
  60489. /**
  60490. * Initialise the soft body vertices to match its object's (mesh) vertices
  60491. * Softbody vertices (nodes) are in world space and to match this
  60492. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  60493. * @param impostor to create the softbody for
  60494. */
  60495. private _softVertexData;
  60496. /**
  60497. * Create an impostor's soft body
  60498. * @param impostor to create the softbody for
  60499. */
  60500. private _createSoftbody;
  60501. /**
  60502. * Create cloth for an impostor
  60503. * @param impostor to create the softbody for
  60504. */
  60505. private _createCloth;
  60506. /**
  60507. * Create rope for an impostor
  60508. * @param impostor to create the softbody for
  60509. */
  60510. private _createRope;
  60511. /**
  60512. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  60513. * @param impostor to create the custom physics shape for
  60514. */
  60515. private _createCustom;
  60516. private _addHullVerts;
  60517. private _createShape;
  60518. /**
  60519. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  60520. * @param impostor imposter containing the physics body and babylon object
  60521. */
  60522. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60523. /**
  60524. * Sets the babylon object's position/rotation from the physics body's position/rotation
  60525. * @param impostor imposter containing the physics body and babylon object
  60526. * @param newPosition new position
  60527. * @param newRotation new rotation
  60528. */
  60529. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60530. /**
  60531. * If this plugin is supported
  60532. * @returns true if its supported
  60533. */
  60534. isSupported(): boolean;
  60535. /**
  60536. * Sets the linear velocity of the physics body
  60537. * @param impostor imposter to set the velocity on
  60538. * @param velocity velocity to set
  60539. */
  60540. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60541. /**
  60542. * Sets the angular velocity of the physics body
  60543. * @param impostor imposter to set the velocity on
  60544. * @param velocity velocity to set
  60545. */
  60546. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60547. /**
  60548. * gets the linear velocity
  60549. * @param impostor imposter to get linear velocity from
  60550. * @returns linear velocity
  60551. */
  60552. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60553. /**
  60554. * gets the angular velocity
  60555. * @param impostor imposter to get angular velocity from
  60556. * @returns angular velocity
  60557. */
  60558. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60559. /**
  60560. * Sets the mass of physics body
  60561. * @param impostor imposter to set the mass on
  60562. * @param mass mass to set
  60563. */
  60564. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60565. /**
  60566. * Gets the mass of the physics body
  60567. * @param impostor imposter to get the mass from
  60568. * @returns mass
  60569. */
  60570. getBodyMass(impostor: PhysicsImpostor): number;
  60571. /**
  60572. * Gets friction of the impostor
  60573. * @param impostor impostor to get friction from
  60574. * @returns friction value
  60575. */
  60576. getBodyFriction(impostor: PhysicsImpostor): number;
  60577. /**
  60578. * Sets friction of the impostor
  60579. * @param impostor impostor to set friction on
  60580. * @param friction friction value
  60581. */
  60582. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60583. /**
  60584. * Gets restitution of the impostor
  60585. * @param impostor impostor to get restitution from
  60586. * @returns restitution value
  60587. */
  60588. getBodyRestitution(impostor: PhysicsImpostor): number;
  60589. /**
  60590. * Sets resitution of the impostor
  60591. * @param impostor impostor to set resitution on
  60592. * @param restitution resitution value
  60593. */
  60594. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60595. /**
  60596. * Gets pressure inside the impostor
  60597. * @param impostor impostor to get pressure from
  60598. * @returns pressure value
  60599. */
  60600. getBodyPressure(impostor: PhysicsImpostor): number;
  60601. /**
  60602. * Sets pressure inside a soft body impostor
  60603. * Cloth and rope must remain 0 pressure
  60604. * @param impostor impostor to set pressure on
  60605. * @param pressure pressure value
  60606. */
  60607. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  60608. /**
  60609. * Gets stiffness of the impostor
  60610. * @param impostor impostor to get stiffness from
  60611. * @returns pressure value
  60612. */
  60613. getBodyStiffness(impostor: PhysicsImpostor): number;
  60614. /**
  60615. * Sets stiffness of the impostor
  60616. * @param impostor impostor to set stiffness on
  60617. * @param stiffness stiffness value from 0 to 1
  60618. */
  60619. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  60620. /**
  60621. * Gets velocityIterations of the impostor
  60622. * @param impostor impostor to get velocity iterations from
  60623. * @returns velocityIterations value
  60624. */
  60625. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  60626. /**
  60627. * Sets velocityIterations of the impostor
  60628. * @param impostor impostor to set velocity iterations on
  60629. * @param velocityIterations velocityIterations value
  60630. */
  60631. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  60632. /**
  60633. * Gets positionIterations of the impostor
  60634. * @param impostor impostor to get position iterations from
  60635. * @returns positionIterations value
  60636. */
  60637. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  60638. /**
  60639. * Sets positionIterations of the impostor
  60640. * @param impostor impostor to set position on
  60641. * @param positionIterations positionIterations value
  60642. */
  60643. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  60644. /**
  60645. * Append an anchor to a cloth object
  60646. * @param impostor is the cloth impostor to add anchor to
  60647. * @param otherImpostor is the rigid impostor to anchor to
  60648. * @param width ratio across width from 0 to 1
  60649. * @param height ratio up height from 0 to 1
  60650. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  60651. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  60652. */
  60653. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  60654. /**
  60655. * Append an hook to a rope object
  60656. * @param impostor is the rope impostor to add hook to
  60657. * @param otherImpostor is the rigid impostor to hook to
  60658. * @param length ratio along the rope from 0 to 1
  60659. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  60660. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  60661. */
  60662. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  60663. /**
  60664. * Sleeps the physics body and stops it from being active
  60665. * @param impostor impostor to sleep
  60666. */
  60667. sleepBody(impostor: PhysicsImpostor): void;
  60668. /**
  60669. * Activates the physics body
  60670. * @param impostor impostor to activate
  60671. */
  60672. wakeUpBody(impostor: PhysicsImpostor): void;
  60673. /**
  60674. * Updates the distance parameters of the joint
  60675. * @param joint joint to update
  60676. * @param maxDistance maximum distance of the joint
  60677. * @param minDistance minimum distance of the joint
  60678. */
  60679. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  60680. /**
  60681. * Sets a motor on the joint
  60682. * @param joint joint to set motor on
  60683. * @param speed speed of the motor
  60684. * @param maxForce maximum force of the motor
  60685. * @param motorIndex index of the motor
  60686. */
  60687. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  60688. /**
  60689. * Sets the motors limit
  60690. * @param joint joint to set limit on
  60691. * @param upperLimit upper limit
  60692. * @param lowerLimit lower limit
  60693. */
  60694. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  60695. /**
  60696. * Syncs the position and rotation of a mesh with the impostor
  60697. * @param mesh mesh to sync
  60698. * @param impostor impostor to update the mesh with
  60699. */
  60700. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60701. /**
  60702. * Gets the radius of the impostor
  60703. * @param impostor impostor to get radius from
  60704. * @returns the radius
  60705. */
  60706. getRadius(impostor: PhysicsImpostor): number;
  60707. /**
  60708. * Gets the box size of the impostor
  60709. * @param impostor impostor to get box size from
  60710. * @param result the resulting box size
  60711. */
  60712. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60713. /**
  60714. * Disposes of the impostor
  60715. */
  60716. dispose(): void;
  60717. /**
  60718. * Does a raycast in the physics world
  60719. * @param from when should the ray start?
  60720. * @param to when should the ray end?
  60721. * @returns PhysicsRaycastResult
  60722. */
  60723. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60724. }
  60725. }
  60726. declare module BABYLON {
  60727. interface AbstractScene {
  60728. /**
  60729. * The list of reflection probes added to the scene
  60730. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  60731. */
  60732. reflectionProbes: Array<ReflectionProbe>;
  60733. /**
  60734. * Removes the given reflection probe from this scene.
  60735. * @param toRemove The reflection probe to remove
  60736. * @returns The index of the removed reflection probe
  60737. */
  60738. removeReflectionProbe(toRemove: ReflectionProbe): number;
  60739. /**
  60740. * Adds the given reflection probe to this scene.
  60741. * @param newReflectionProbe The reflection probe to add
  60742. */
  60743. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  60744. }
  60745. /**
  60746. * Class used to generate realtime reflection / refraction cube textures
  60747. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  60748. */
  60749. export class ReflectionProbe {
  60750. /** defines the name of the probe */
  60751. name: string;
  60752. private _scene;
  60753. private _renderTargetTexture;
  60754. private _projectionMatrix;
  60755. private _viewMatrix;
  60756. private _target;
  60757. private _add;
  60758. private _attachedMesh;
  60759. private _invertYAxis;
  60760. /** Gets or sets probe position (center of the cube map) */
  60761. position: Vector3;
  60762. /**
  60763. * Creates a new reflection probe
  60764. * @param name defines the name of the probe
  60765. * @param size defines the texture resolution (for each face)
  60766. * @param scene defines the hosting scene
  60767. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  60768. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  60769. */
  60770. constructor(
  60771. /** defines the name of the probe */
  60772. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  60773. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  60774. get samples(): number;
  60775. set samples(value: number);
  60776. /** Gets or sets the refresh rate to use (on every frame by default) */
  60777. get refreshRate(): number;
  60778. set refreshRate(value: number);
  60779. /**
  60780. * Gets the hosting scene
  60781. * @returns a Scene
  60782. */
  60783. getScene(): Scene;
  60784. /** Gets the internal CubeTexture used to render to */
  60785. get cubeTexture(): RenderTargetTexture;
  60786. /** Gets the list of meshes to render */
  60787. get renderList(): Nullable<AbstractMesh[]>;
  60788. /**
  60789. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  60790. * @param mesh defines the mesh to attach to
  60791. */
  60792. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  60793. /**
  60794. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  60795. * @param renderingGroupId The rendering group id corresponding to its index
  60796. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  60797. */
  60798. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  60799. /**
  60800. * Clean all associated resources
  60801. */
  60802. dispose(): void;
  60803. /**
  60804. * Converts the reflection probe information to a readable string for debug purpose.
  60805. * @param fullDetails Supports for multiple levels of logging within scene loading
  60806. * @returns the human readable reflection probe info
  60807. */
  60808. toString(fullDetails?: boolean): string;
  60809. /**
  60810. * Get the class name of the relfection probe.
  60811. * @returns "ReflectionProbe"
  60812. */
  60813. getClassName(): string;
  60814. /**
  60815. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  60816. * @returns The JSON representation of the texture
  60817. */
  60818. serialize(): any;
  60819. /**
  60820. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  60821. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  60822. * @param scene Define the scene the parsed reflection probe should be instantiated in
  60823. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  60824. * @returns The parsed reflection probe if successful
  60825. */
  60826. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  60827. }
  60828. }
  60829. declare module BABYLON {
  60830. /** @hidden */
  60831. export var _BabylonLoaderRegistered: boolean;
  60832. /**
  60833. * Helps setting up some configuration for the babylon file loader.
  60834. */
  60835. export class BabylonFileLoaderConfiguration {
  60836. /**
  60837. * The loader does not allow injecting custom physix engine into the plugins.
  60838. * Unfortunately in ES6, we need to manually inject them into the plugin.
  60839. * So you could set this variable to your engine import to make it work.
  60840. */
  60841. static LoaderInjectedPhysicsEngine: any;
  60842. }
  60843. }
  60844. declare module BABYLON {
  60845. /**
  60846. * The Physically based simple base material of BJS.
  60847. *
  60848. * This enables better naming and convention enforcements on top of the pbrMaterial.
  60849. * It is used as the base class for both the specGloss and metalRough conventions.
  60850. */
  60851. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  60852. /**
  60853. * Number of Simultaneous lights allowed on the material.
  60854. */
  60855. maxSimultaneousLights: number;
  60856. /**
  60857. * If sets to true, disables all the lights affecting the material.
  60858. */
  60859. disableLighting: boolean;
  60860. /**
  60861. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  60862. */
  60863. environmentTexture: BaseTexture;
  60864. /**
  60865. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  60866. */
  60867. invertNormalMapX: boolean;
  60868. /**
  60869. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  60870. */
  60871. invertNormalMapY: boolean;
  60872. /**
  60873. * Normal map used in the model.
  60874. */
  60875. normalTexture: BaseTexture;
  60876. /**
  60877. * Emissivie color used to self-illuminate the model.
  60878. */
  60879. emissiveColor: Color3;
  60880. /**
  60881. * Emissivie texture used to self-illuminate the model.
  60882. */
  60883. emissiveTexture: BaseTexture;
  60884. /**
  60885. * Occlusion Channel Strenght.
  60886. */
  60887. occlusionStrength: number;
  60888. /**
  60889. * Occlusion Texture of the material (adding extra occlusion effects).
  60890. */
  60891. occlusionTexture: BaseTexture;
  60892. /**
  60893. * Defines the alpha limits in alpha test mode.
  60894. */
  60895. alphaCutOff: number;
  60896. /**
  60897. * Gets the current double sided mode.
  60898. */
  60899. get doubleSided(): boolean;
  60900. /**
  60901. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  60902. */
  60903. set doubleSided(value: boolean);
  60904. /**
  60905. * Stores the pre-calculated light information of a mesh in a texture.
  60906. */
  60907. lightmapTexture: BaseTexture;
  60908. /**
  60909. * If true, the light map contains occlusion information instead of lighting info.
  60910. */
  60911. useLightmapAsShadowmap: boolean;
  60912. /**
  60913. * Instantiates a new PBRMaterial instance.
  60914. *
  60915. * @param name The material name
  60916. * @param scene The scene the material will be use in.
  60917. */
  60918. constructor(name: string, scene: Scene);
  60919. getClassName(): string;
  60920. }
  60921. }
  60922. declare module BABYLON {
  60923. /**
  60924. * The PBR material of BJS following the metal roughness convention.
  60925. *
  60926. * This fits to the PBR convention in the GLTF definition:
  60927. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  60928. */
  60929. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  60930. /**
  60931. * The base color has two different interpretations depending on the value of metalness.
  60932. * When the material is a metal, the base color is the specific measured reflectance value
  60933. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  60934. * of the material.
  60935. */
  60936. baseColor: Color3;
  60937. /**
  60938. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  60939. * well as opacity information in the alpha channel.
  60940. */
  60941. baseTexture: BaseTexture;
  60942. /**
  60943. * Specifies the metallic scalar value of the material.
  60944. * Can also be used to scale the metalness values of the metallic texture.
  60945. */
  60946. metallic: number;
  60947. /**
  60948. * Specifies the roughness scalar value of the material.
  60949. * Can also be used to scale the roughness values of the metallic texture.
  60950. */
  60951. roughness: number;
  60952. /**
  60953. * Texture containing both the metallic value in the B channel and the
  60954. * roughness value in the G channel to keep better precision.
  60955. */
  60956. metallicRoughnessTexture: BaseTexture;
  60957. /**
  60958. * Instantiates a new PBRMetalRoughnessMaterial instance.
  60959. *
  60960. * @param name The material name
  60961. * @param scene The scene the material will be use in.
  60962. */
  60963. constructor(name: string, scene: Scene);
  60964. /**
  60965. * Return the currrent class name of the material.
  60966. */
  60967. getClassName(): string;
  60968. /**
  60969. * Makes a duplicate of the current material.
  60970. * @param name - name to use for the new material.
  60971. */
  60972. clone(name: string): PBRMetallicRoughnessMaterial;
  60973. /**
  60974. * Serialize the material to a parsable JSON object.
  60975. */
  60976. serialize(): any;
  60977. /**
  60978. * Parses a JSON object correponding to the serialize function.
  60979. */
  60980. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  60981. }
  60982. }
  60983. declare module BABYLON {
  60984. /**
  60985. * The PBR material of BJS following the specular glossiness convention.
  60986. *
  60987. * This fits to the PBR convention in the GLTF definition:
  60988. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  60989. */
  60990. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  60991. /**
  60992. * Specifies the diffuse color of the material.
  60993. */
  60994. diffuseColor: Color3;
  60995. /**
  60996. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  60997. * channel.
  60998. */
  60999. diffuseTexture: BaseTexture;
  61000. /**
  61001. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  61002. */
  61003. specularColor: Color3;
  61004. /**
  61005. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  61006. */
  61007. glossiness: number;
  61008. /**
  61009. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  61010. */
  61011. specularGlossinessTexture: BaseTexture;
  61012. /**
  61013. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  61014. *
  61015. * @param name The material name
  61016. * @param scene The scene the material will be use in.
  61017. */
  61018. constructor(name: string, scene: Scene);
  61019. /**
  61020. * Return the currrent class name of the material.
  61021. */
  61022. getClassName(): string;
  61023. /**
  61024. * Makes a duplicate of the current material.
  61025. * @param name - name to use for the new material.
  61026. */
  61027. clone(name: string): PBRSpecularGlossinessMaterial;
  61028. /**
  61029. * Serialize the material to a parsable JSON object.
  61030. */
  61031. serialize(): any;
  61032. /**
  61033. * Parses a JSON object correponding to the serialize function.
  61034. */
  61035. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  61036. }
  61037. }
  61038. declare module BABYLON {
  61039. /**
  61040. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  61041. * It can help converting any input color in a desired output one. This can then be used to create effects
  61042. * from sepia, black and white to sixties or futuristic rendering...
  61043. *
  61044. * The only supported format is currently 3dl.
  61045. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  61046. */
  61047. export class ColorGradingTexture extends BaseTexture {
  61048. /**
  61049. * The texture URL.
  61050. */
  61051. url: string;
  61052. /**
  61053. * Empty line regex stored for GC.
  61054. */
  61055. private static _noneEmptyLineRegex;
  61056. private _textureMatrix;
  61057. private _onLoad;
  61058. /**
  61059. * Instantiates a ColorGradingTexture from the following parameters.
  61060. *
  61061. * @param url The location of the color gradind data (currently only supporting 3dl)
  61062. * @param sceneOrEngine The scene or engine the texture will be used in
  61063. * @param onLoad defines a callback triggered when the texture has been loaded
  61064. */
  61065. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  61066. /**
  61067. * Fires the onload event from the constructor if requested.
  61068. */
  61069. private _triggerOnLoad;
  61070. /**
  61071. * Returns the texture matrix used in most of the material.
  61072. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  61073. */
  61074. getTextureMatrix(): Matrix;
  61075. /**
  61076. * Occurs when the file being loaded is a .3dl LUT file.
  61077. */
  61078. private load3dlTexture;
  61079. /**
  61080. * Starts the loading process of the texture.
  61081. */
  61082. private loadTexture;
  61083. /**
  61084. * Clones the color gradind texture.
  61085. */
  61086. clone(): ColorGradingTexture;
  61087. /**
  61088. * Called during delayed load for textures.
  61089. */
  61090. delayLoad(): void;
  61091. /**
  61092. * Parses a color grading texture serialized by Babylon.
  61093. * @param parsedTexture The texture information being parsedTexture
  61094. * @param scene The scene to load the texture in
  61095. * @param rootUrl The root url of the data assets to load
  61096. * @return A color gradind texture
  61097. */
  61098. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  61099. /**
  61100. * Serializes the LUT texture to json format.
  61101. */
  61102. serialize(): any;
  61103. }
  61104. }
  61105. declare module BABYLON {
  61106. /**
  61107. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  61108. */
  61109. export class EquiRectangularCubeTexture extends BaseTexture {
  61110. /** The six faces of the cube. */
  61111. private static _FacesMapping;
  61112. private _noMipmap;
  61113. private _onLoad;
  61114. private _onError;
  61115. /** The size of the cubemap. */
  61116. private _size;
  61117. /** The buffer of the image. */
  61118. private _buffer;
  61119. /** The width of the input image. */
  61120. private _width;
  61121. /** The height of the input image. */
  61122. private _height;
  61123. /** The URL to the image. */
  61124. url: string;
  61125. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  61126. coordinatesMode: number;
  61127. /**
  61128. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  61129. * @param url The location of the image
  61130. * @param scene The scene the texture will be used in
  61131. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61132. * @param noMipmap Forces to not generate the mipmap if true
  61133. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61134. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61135. * @param onLoad — defines a callback called when texture is loaded
  61136. * @param onError — defines a callback called if there is an error
  61137. */
  61138. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  61139. /**
  61140. * Load the image data, by putting the image on a canvas and extracting its buffer.
  61141. */
  61142. private loadImage;
  61143. /**
  61144. * Convert the image buffer into a cubemap and create a CubeTexture.
  61145. */
  61146. private loadTexture;
  61147. /**
  61148. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  61149. * @param buffer The ArrayBuffer that should be converted.
  61150. * @returns The buffer as Float32Array.
  61151. */
  61152. private getFloat32ArrayFromArrayBuffer;
  61153. /**
  61154. * Get the current class name of the texture useful for serialization or dynamic coding.
  61155. * @returns "EquiRectangularCubeTexture"
  61156. */
  61157. getClassName(): string;
  61158. /**
  61159. * Create a clone of the current EquiRectangularCubeTexture and return it.
  61160. * @returns A clone of the current EquiRectangularCubeTexture.
  61161. */
  61162. clone(): EquiRectangularCubeTexture;
  61163. }
  61164. }
  61165. declare module BABYLON {
  61166. /**
  61167. * Defines the options related to the creation of an HtmlElementTexture
  61168. */
  61169. export interface IHtmlElementTextureOptions {
  61170. /**
  61171. * Defines wether mip maps should be created or not.
  61172. */
  61173. generateMipMaps?: boolean;
  61174. /**
  61175. * Defines the sampling mode of the texture.
  61176. */
  61177. samplingMode?: number;
  61178. /**
  61179. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  61180. */
  61181. engine: Nullable<ThinEngine>;
  61182. /**
  61183. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  61184. */
  61185. scene: Nullable<Scene>;
  61186. }
  61187. /**
  61188. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  61189. * To be as efficient as possible depending on your constraints nothing aside the first upload
  61190. * is automatically managed.
  61191. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  61192. * in your application.
  61193. *
  61194. * As the update is not automatic, you need to call them manually.
  61195. */
  61196. export class HtmlElementTexture extends BaseTexture {
  61197. /**
  61198. * The texture URL.
  61199. */
  61200. element: HTMLVideoElement | HTMLCanvasElement;
  61201. private static readonly DefaultOptions;
  61202. private _textureMatrix;
  61203. private _isVideo;
  61204. private _generateMipMaps;
  61205. private _samplingMode;
  61206. /**
  61207. * Instantiates a HtmlElementTexture from the following parameters.
  61208. *
  61209. * @param name Defines the name of the texture
  61210. * @param element Defines the video or canvas the texture is filled with
  61211. * @param options Defines the other none mandatory texture creation options
  61212. */
  61213. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  61214. private _createInternalTexture;
  61215. /**
  61216. * Returns the texture matrix used in most of the material.
  61217. */
  61218. getTextureMatrix(): Matrix;
  61219. /**
  61220. * Updates the content of the texture.
  61221. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  61222. */
  61223. update(invertY?: Nullable<boolean>): void;
  61224. }
  61225. }
  61226. declare module BABYLON {
  61227. /**
  61228. * Based on jsTGALoader - Javascript loader for TGA file
  61229. * By Vincent Thibault
  61230. * @see http://blog.robrowser.com/javascript-tga-loader.html
  61231. */
  61232. export class TGATools {
  61233. private static _TYPE_INDEXED;
  61234. private static _TYPE_RGB;
  61235. private static _TYPE_GREY;
  61236. private static _TYPE_RLE_INDEXED;
  61237. private static _TYPE_RLE_RGB;
  61238. private static _TYPE_RLE_GREY;
  61239. private static _ORIGIN_MASK;
  61240. private static _ORIGIN_SHIFT;
  61241. private static _ORIGIN_BL;
  61242. private static _ORIGIN_BR;
  61243. private static _ORIGIN_UL;
  61244. private static _ORIGIN_UR;
  61245. /**
  61246. * Gets the header of a TGA file
  61247. * @param data defines the TGA data
  61248. * @returns the header
  61249. */
  61250. static GetTGAHeader(data: Uint8Array): any;
  61251. /**
  61252. * Uploads TGA content to a Babylon Texture
  61253. * @hidden
  61254. */
  61255. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  61256. /** @hidden */
  61257. 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;
  61258. /** @hidden */
  61259. 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;
  61260. /** @hidden */
  61261. 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;
  61262. /** @hidden */
  61263. 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;
  61264. /** @hidden */
  61265. 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;
  61266. /** @hidden */
  61267. 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;
  61268. }
  61269. }
  61270. declare module BABYLON {
  61271. /**
  61272. * Implementation of the TGA Texture Loader.
  61273. * @hidden
  61274. */
  61275. export class _TGATextureLoader implements IInternalTextureLoader {
  61276. /**
  61277. * Defines wether the loader supports cascade loading the different faces.
  61278. */
  61279. readonly supportCascades: boolean;
  61280. /**
  61281. * This returns if the loader support the current file information.
  61282. * @param extension defines the file extension of the file being loaded
  61283. * @returns true if the loader can load the specified file
  61284. */
  61285. canLoad(extension: string): boolean;
  61286. /**
  61287. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61288. * @param data contains the texture data
  61289. * @param texture defines the BabylonJS internal texture
  61290. * @param createPolynomials will be true if polynomials have been requested
  61291. * @param onLoad defines the callback to trigger once the texture is ready
  61292. * @param onError defines the callback to trigger in case of error
  61293. */
  61294. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61295. /**
  61296. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61297. * @param data contains the texture data
  61298. * @param texture defines the BabylonJS internal texture
  61299. * @param callback defines the method to call once ready to upload
  61300. */
  61301. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61302. }
  61303. }
  61304. declare module BABYLON {
  61305. /**
  61306. * Info about the .basis files
  61307. */
  61308. class BasisFileInfo {
  61309. /**
  61310. * If the file has alpha
  61311. */
  61312. hasAlpha: boolean;
  61313. /**
  61314. * Info about each image of the basis file
  61315. */
  61316. images: Array<{
  61317. levels: Array<{
  61318. width: number;
  61319. height: number;
  61320. transcodedPixels: ArrayBufferView;
  61321. }>;
  61322. }>;
  61323. }
  61324. /**
  61325. * Result of transcoding a basis file
  61326. */
  61327. class TranscodeResult {
  61328. /**
  61329. * Info about the .basis file
  61330. */
  61331. fileInfo: BasisFileInfo;
  61332. /**
  61333. * Format to use when loading the file
  61334. */
  61335. format: number;
  61336. }
  61337. /**
  61338. * Configuration options for the Basis transcoder
  61339. */
  61340. export class BasisTranscodeConfiguration {
  61341. /**
  61342. * Supported compression formats used to determine the supported output format of the transcoder
  61343. */
  61344. supportedCompressionFormats?: {
  61345. /**
  61346. * etc1 compression format
  61347. */
  61348. etc1?: boolean;
  61349. /**
  61350. * s3tc compression format
  61351. */
  61352. s3tc?: boolean;
  61353. /**
  61354. * pvrtc compression format
  61355. */
  61356. pvrtc?: boolean;
  61357. /**
  61358. * etc2 compression format
  61359. */
  61360. etc2?: boolean;
  61361. };
  61362. /**
  61363. * If mipmap levels should be loaded for transcoded images (Default: true)
  61364. */
  61365. loadMipmapLevels?: boolean;
  61366. /**
  61367. * Index of a single image to load (Default: all images)
  61368. */
  61369. loadSingleImage?: number;
  61370. }
  61371. /**
  61372. * Used to load .Basis files
  61373. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  61374. */
  61375. export class BasisTools {
  61376. private static _IgnoreSupportedFormats;
  61377. /**
  61378. * URL to use when loading the basis transcoder
  61379. */
  61380. static JSModuleURL: string;
  61381. /**
  61382. * URL to use when loading the wasm module for the transcoder
  61383. */
  61384. static WasmModuleURL: string;
  61385. /**
  61386. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  61387. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  61388. * @returns internal format corresponding to the Basis format
  61389. */
  61390. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  61391. private static _WorkerPromise;
  61392. private static _Worker;
  61393. private static _actionId;
  61394. private static _CreateWorkerAsync;
  61395. /**
  61396. * Transcodes a loaded image file to compressed pixel data
  61397. * @param data image data to transcode
  61398. * @param config configuration options for the transcoding
  61399. * @returns a promise resulting in the transcoded image
  61400. */
  61401. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  61402. /**
  61403. * Loads a texture from the transcode result
  61404. * @param texture texture load to
  61405. * @param transcodeResult the result of transcoding the basis file to load from
  61406. */
  61407. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  61408. }
  61409. }
  61410. declare module BABYLON {
  61411. /**
  61412. * Loader for .basis file format
  61413. */
  61414. export class _BasisTextureLoader implements IInternalTextureLoader {
  61415. /**
  61416. * Defines whether the loader supports cascade loading the different faces.
  61417. */
  61418. readonly supportCascades: boolean;
  61419. /**
  61420. * This returns if the loader support the current file information.
  61421. * @param extension defines the file extension of the file being loaded
  61422. * @returns true if the loader can load the specified file
  61423. */
  61424. canLoad(extension: string): boolean;
  61425. /**
  61426. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61427. * @param data contains the texture data
  61428. * @param texture defines the BabylonJS internal texture
  61429. * @param createPolynomials will be true if polynomials have been requested
  61430. * @param onLoad defines the callback to trigger once the texture is ready
  61431. * @param onError defines the callback to trigger in case of error
  61432. */
  61433. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61434. /**
  61435. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61436. * @param data contains the texture data
  61437. * @param texture defines the BabylonJS internal texture
  61438. * @param callback defines the method to call once ready to upload
  61439. */
  61440. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61441. }
  61442. }
  61443. declare module BABYLON {
  61444. /**
  61445. * Defines the basic options interface of a TexturePacker Frame
  61446. */
  61447. export interface ITexturePackerFrame {
  61448. /**
  61449. * The frame ID
  61450. */
  61451. id: number;
  61452. /**
  61453. * The frames Scale
  61454. */
  61455. scale: Vector2;
  61456. /**
  61457. * The Frames offset
  61458. */
  61459. offset: Vector2;
  61460. }
  61461. /**
  61462. * This is a support class for frame Data on texture packer sets.
  61463. */
  61464. export class TexturePackerFrame implements ITexturePackerFrame {
  61465. /**
  61466. * The frame ID
  61467. */
  61468. id: number;
  61469. /**
  61470. * The frames Scale
  61471. */
  61472. scale: Vector2;
  61473. /**
  61474. * The Frames offset
  61475. */
  61476. offset: Vector2;
  61477. /**
  61478. * Initializes a texture package frame.
  61479. * @param id The numerical frame identifier
  61480. * @param scale Scalar Vector2 for UV frame
  61481. * @param offset Vector2 for the frame position in UV units.
  61482. * @returns TexturePackerFrame
  61483. */
  61484. constructor(id: number, scale: Vector2, offset: Vector2);
  61485. }
  61486. }
  61487. declare module BABYLON {
  61488. /**
  61489. * Defines the basic options interface of a TexturePacker
  61490. */
  61491. export interface ITexturePackerOptions {
  61492. /**
  61493. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  61494. */
  61495. map?: string[];
  61496. /**
  61497. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  61498. */
  61499. uvsIn?: string;
  61500. /**
  61501. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  61502. */
  61503. uvsOut?: string;
  61504. /**
  61505. * number representing the layout style. Defaults to LAYOUT_STRIP
  61506. */
  61507. layout?: number;
  61508. /**
  61509. * number of columns if using custom column count layout(2). This defaults to 4.
  61510. */
  61511. colnum?: number;
  61512. /**
  61513. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  61514. */
  61515. updateInputMeshes?: boolean;
  61516. /**
  61517. * boolean flag to dispose all the source textures. Defaults to true.
  61518. */
  61519. disposeSources?: boolean;
  61520. /**
  61521. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  61522. */
  61523. fillBlanks?: boolean;
  61524. /**
  61525. * string value representing the context fill style color. Defaults to 'black'.
  61526. */
  61527. customFillColor?: string;
  61528. /**
  61529. * Width and Height Value of each Frame in the TexturePacker Sets
  61530. */
  61531. frameSize?: number;
  61532. /**
  61533. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  61534. */
  61535. paddingRatio?: number;
  61536. /**
  61537. * Number that declares the fill method for the padding gutter.
  61538. */
  61539. paddingMode?: number;
  61540. /**
  61541. * If in SUBUV_COLOR padding mode what color to use.
  61542. */
  61543. paddingColor?: Color3 | Color4;
  61544. }
  61545. /**
  61546. * Defines the basic interface of a TexturePacker JSON File
  61547. */
  61548. export interface ITexturePackerJSON {
  61549. /**
  61550. * The frame ID
  61551. */
  61552. name: string;
  61553. /**
  61554. * The base64 channel data
  61555. */
  61556. sets: any;
  61557. /**
  61558. * The options of the Packer
  61559. */
  61560. options: ITexturePackerOptions;
  61561. /**
  61562. * The frame data of the Packer
  61563. */
  61564. frames: Array<number>;
  61565. }
  61566. /**
  61567. * This is a support class that generates a series of packed texture sets.
  61568. * @see https://doc.babylonjs.com/babylon101/materials
  61569. */
  61570. export class TexturePacker {
  61571. /** Packer Layout Constant 0 */
  61572. static readonly LAYOUT_STRIP: number;
  61573. /** Packer Layout Constant 1 */
  61574. static readonly LAYOUT_POWER2: number;
  61575. /** Packer Layout Constant 2 */
  61576. static readonly LAYOUT_COLNUM: number;
  61577. /** Packer Layout Constant 0 */
  61578. static readonly SUBUV_WRAP: number;
  61579. /** Packer Layout Constant 1 */
  61580. static readonly SUBUV_EXTEND: number;
  61581. /** Packer Layout Constant 2 */
  61582. static readonly SUBUV_COLOR: number;
  61583. /** The Name of the Texture Package */
  61584. name: string;
  61585. /** The scene scope of the TexturePacker */
  61586. scene: Scene;
  61587. /** The Meshes to target */
  61588. meshes: AbstractMesh[];
  61589. /** Arguments passed with the Constructor */
  61590. options: ITexturePackerOptions;
  61591. /** The promise that is started upon initialization */
  61592. promise: Nullable<Promise<TexturePacker | string>>;
  61593. /** The Container object for the channel sets that are generated */
  61594. sets: object;
  61595. /** The Container array for the frames that are generated */
  61596. frames: TexturePackerFrame[];
  61597. /** The expected number of textures the system is parsing. */
  61598. private _expecting;
  61599. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  61600. private _paddingValue;
  61601. /**
  61602. * Initializes a texture package series from an array of meshes or a single mesh.
  61603. * @param name The name of the package
  61604. * @param meshes The target meshes to compose the package from
  61605. * @param options The arguments that texture packer should follow while building.
  61606. * @param scene The scene which the textures are scoped to.
  61607. * @returns TexturePacker
  61608. */
  61609. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  61610. /**
  61611. * Starts the package process
  61612. * @param resolve The promises resolution function
  61613. * @returns TexturePacker
  61614. */
  61615. private _createFrames;
  61616. /**
  61617. * Calculates the Size of the Channel Sets
  61618. * @returns Vector2
  61619. */
  61620. private _calculateSize;
  61621. /**
  61622. * Calculates the UV data for the frames.
  61623. * @param baseSize the base frameSize
  61624. * @param padding the base frame padding
  61625. * @param dtSize size of the Dynamic Texture for that channel
  61626. * @param dtUnits is 1/dtSize
  61627. * @param update flag to update the input meshes
  61628. */
  61629. private _calculateMeshUVFrames;
  61630. /**
  61631. * Calculates the frames Offset.
  61632. * @param index of the frame
  61633. * @returns Vector2
  61634. */
  61635. private _getFrameOffset;
  61636. /**
  61637. * Updates a Mesh to the frame data
  61638. * @param mesh that is the target
  61639. * @param frameID or the frame index
  61640. */
  61641. private _updateMeshUV;
  61642. /**
  61643. * Updates a Meshes materials to use the texture packer channels
  61644. * @param m is the mesh to target
  61645. * @param force all channels on the packer to be set.
  61646. */
  61647. private _updateTextureReferences;
  61648. /**
  61649. * Public method to set a Mesh to a frame
  61650. * @param m that is the target
  61651. * @param frameID or the frame index
  61652. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  61653. */
  61654. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  61655. /**
  61656. * Starts the async promise to compile the texture packer.
  61657. * @returns Promise<void>
  61658. */
  61659. processAsync(): Promise<void>;
  61660. /**
  61661. * Disposes all textures associated with this packer
  61662. */
  61663. dispose(): void;
  61664. /**
  61665. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  61666. * @param imageType is the image type to use.
  61667. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  61668. */
  61669. download(imageType?: string, quality?: number): void;
  61670. /**
  61671. * Public method to load a texturePacker JSON file.
  61672. * @param data of the JSON file in string format.
  61673. */
  61674. updateFromJSON(data: string): void;
  61675. }
  61676. }
  61677. declare module BABYLON {
  61678. /**
  61679. * 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.
  61680. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  61681. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  61682. */
  61683. export class CustomProceduralTexture extends ProceduralTexture {
  61684. private _animate;
  61685. private _time;
  61686. private _config;
  61687. private _texturePath;
  61688. /**
  61689. * Instantiates a new Custom Procedural Texture.
  61690. * 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.
  61691. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  61692. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  61693. * @param name Define the name of the texture
  61694. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  61695. * @param size Define the size of the texture to create
  61696. * @param scene Define the scene the texture belongs to
  61697. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  61698. * @param generateMipMaps Define if the texture should creates mip maps or not
  61699. */
  61700. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  61701. private _loadJson;
  61702. /**
  61703. * Is the texture ready to be used ? (rendered at least once)
  61704. * @returns true if ready, otherwise, false.
  61705. */
  61706. isReady(): boolean;
  61707. /**
  61708. * Render the texture to its associated render target.
  61709. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  61710. */
  61711. render(useCameraPostProcess?: boolean): void;
  61712. /**
  61713. * Update the list of dependant textures samplers in the shader.
  61714. */
  61715. updateTextures(): void;
  61716. /**
  61717. * Update the uniform values of the procedural texture in the shader.
  61718. */
  61719. updateShaderUniforms(): void;
  61720. /**
  61721. * Define if the texture animates or not.
  61722. */
  61723. get animate(): boolean;
  61724. set animate(value: boolean);
  61725. }
  61726. }
  61727. declare module BABYLON {
  61728. /** @hidden */
  61729. export var noisePixelShader: {
  61730. name: string;
  61731. shader: string;
  61732. };
  61733. }
  61734. declare module BABYLON {
  61735. /**
  61736. * Class used to generate noise procedural textures
  61737. */
  61738. export class NoiseProceduralTexture extends ProceduralTexture {
  61739. private _time;
  61740. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  61741. brightness: number;
  61742. /** Defines the number of octaves to process */
  61743. octaves: number;
  61744. /** Defines the level of persistence (0.8 by default) */
  61745. persistence: number;
  61746. /** Gets or sets animation speed factor (default is 1) */
  61747. animationSpeedFactor: number;
  61748. /**
  61749. * Creates a new NoiseProceduralTexture
  61750. * @param name defines the name fo the texture
  61751. * @param size defines the size of the texture (default is 256)
  61752. * @param scene defines the hosting scene
  61753. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  61754. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  61755. */
  61756. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  61757. private _updateShaderUniforms;
  61758. protected _getDefines(): string;
  61759. /** Generate the current state of the procedural texture */
  61760. render(useCameraPostProcess?: boolean): void;
  61761. /**
  61762. * Serializes this noise procedural texture
  61763. * @returns a serialized noise procedural texture object
  61764. */
  61765. serialize(): any;
  61766. /**
  61767. * Clone the texture.
  61768. * @returns the cloned texture
  61769. */
  61770. clone(): NoiseProceduralTexture;
  61771. /**
  61772. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  61773. * @param parsedTexture defines parsed texture data
  61774. * @param scene defines the current scene
  61775. * @param rootUrl defines the root URL containing noise procedural texture information
  61776. * @returns a parsed NoiseProceduralTexture
  61777. */
  61778. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  61779. }
  61780. }
  61781. declare module BABYLON {
  61782. /**
  61783. * Raw cube texture where the raw buffers are passed in
  61784. */
  61785. export class RawCubeTexture extends CubeTexture {
  61786. /**
  61787. * Creates a cube texture where the raw buffers are passed in.
  61788. * @param scene defines the scene the texture is attached to
  61789. * @param data defines the array of data to use to create each face
  61790. * @param size defines the size of the textures
  61791. * @param format defines the format of the data
  61792. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  61793. * @param generateMipMaps defines if the engine should generate the mip levels
  61794. * @param invertY defines if data must be stored with Y axis inverted
  61795. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  61796. * @param compression defines the compression used (null by default)
  61797. */
  61798. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  61799. /**
  61800. * Updates the raw cube texture.
  61801. * @param data defines the data to store
  61802. * @param format defines the data format
  61803. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  61804. * @param invertY defines if data must be stored with Y axis inverted
  61805. * @param compression defines the compression used (null by default)
  61806. * @param level defines which level of the texture to update
  61807. */
  61808. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  61809. /**
  61810. * Updates a raw cube texture with RGBD encoded data.
  61811. * @param data defines the array of data [mipmap][face] to use to create each face
  61812. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  61813. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  61814. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  61815. * @returns a promsie that resolves when the operation is complete
  61816. */
  61817. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  61818. /**
  61819. * Clones the raw cube texture.
  61820. * @return a new cube texture
  61821. */
  61822. clone(): CubeTexture;
  61823. /** @hidden */
  61824. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  61825. }
  61826. }
  61827. declare module BABYLON {
  61828. /**
  61829. * Class used to store 2D array textures containing user data
  61830. */
  61831. export class RawTexture2DArray extends Texture {
  61832. /** Gets or sets the texture format to use */
  61833. format: number;
  61834. /**
  61835. * Create a new RawTexture2DArray
  61836. * @param data defines the data of the texture
  61837. * @param width defines the width of the texture
  61838. * @param height defines the height of the texture
  61839. * @param depth defines the number of layers of the texture
  61840. * @param format defines the texture format to use
  61841. * @param scene defines the hosting scene
  61842. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  61843. * @param invertY defines if texture must be stored with Y axis inverted
  61844. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61845. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  61846. */
  61847. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  61848. /** Gets or sets the texture format to use */
  61849. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  61850. /**
  61851. * Update the texture with new data
  61852. * @param data defines the data to store in the texture
  61853. */
  61854. update(data: ArrayBufferView): void;
  61855. }
  61856. }
  61857. declare module BABYLON {
  61858. /**
  61859. * Class used to store 3D textures containing user data
  61860. */
  61861. export class RawTexture3D extends Texture {
  61862. /** Gets or sets the texture format to use */
  61863. format: number;
  61864. /**
  61865. * Create a new RawTexture3D
  61866. * @param data defines the data of the texture
  61867. * @param width defines the width of the texture
  61868. * @param height defines the height of the texture
  61869. * @param depth defines the depth of the texture
  61870. * @param format defines the texture format to use
  61871. * @param scene defines the hosting scene
  61872. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  61873. * @param invertY defines if texture must be stored with Y axis inverted
  61874. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61875. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  61876. */
  61877. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  61878. /** Gets or sets the texture format to use */
  61879. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  61880. /**
  61881. * Update the texture with new data
  61882. * @param data defines the data to store in the texture
  61883. */
  61884. update(data: ArrayBufferView): void;
  61885. }
  61886. }
  61887. declare module BABYLON {
  61888. /**
  61889. * Creates a refraction texture used by refraction channel of the standard material.
  61890. * It is like a mirror but to see through a material.
  61891. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61892. */
  61893. export class RefractionTexture extends RenderTargetTexture {
  61894. /**
  61895. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  61896. * 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.
  61897. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61898. */
  61899. refractionPlane: Plane;
  61900. /**
  61901. * Define how deep under the surface we should see.
  61902. */
  61903. depth: number;
  61904. /**
  61905. * Creates a refraction texture used by refraction channel of the standard material.
  61906. * It is like a mirror but to see through a material.
  61907. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61908. * @param name Define the texture name
  61909. * @param size Define the size of the underlying texture
  61910. * @param scene Define the scene the refraction belongs to
  61911. * @param generateMipMaps Define if we need to generate mips level for the refraction
  61912. */
  61913. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  61914. /**
  61915. * Clone the refraction texture.
  61916. * @returns the cloned texture
  61917. */
  61918. clone(): RefractionTexture;
  61919. /**
  61920. * Serialize the texture to a JSON representation you could use in Parse later on
  61921. * @returns the serialized JSON representation
  61922. */
  61923. serialize(): any;
  61924. }
  61925. }
  61926. declare module BABYLON {
  61927. /**
  61928. * Block used to add support for vertex skinning (bones)
  61929. */
  61930. export class BonesBlock extends NodeMaterialBlock {
  61931. /**
  61932. * Creates a new BonesBlock
  61933. * @param name defines the block name
  61934. */
  61935. constructor(name: string);
  61936. /**
  61937. * Initialize the block and prepare the context for build
  61938. * @param state defines the state that will be used for the build
  61939. */
  61940. initialize(state: NodeMaterialBuildState): void;
  61941. /**
  61942. * Gets the current class name
  61943. * @returns the class name
  61944. */
  61945. getClassName(): string;
  61946. /**
  61947. * Gets the matrix indices input component
  61948. */
  61949. get matricesIndices(): NodeMaterialConnectionPoint;
  61950. /**
  61951. * Gets the matrix weights input component
  61952. */
  61953. get matricesWeights(): NodeMaterialConnectionPoint;
  61954. /**
  61955. * Gets the extra matrix indices input component
  61956. */
  61957. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  61958. /**
  61959. * Gets the extra matrix weights input component
  61960. */
  61961. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  61962. /**
  61963. * Gets the world input component
  61964. */
  61965. get world(): NodeMaterialConnectionPoint;
  61966. /**
  61967. * Gets the output component
  61968. */
  61969. get output(): NodeMaterialConnectionPoint;
  61970. autoConfigure(material: NodeMaterial): void;
  61971. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  61972. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61973. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61974. protected _buildBlock(state: NodeMaterialBuildState): this;
  61975. }
  61976. }
  61977. declare module BABYLON {
  61978. /**
  61979. * Block used to add support for instances
  61980. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  61981. */
  61982. export class InstancesBlock extends NodeMaterialBlock {
  61983. /**
  61984. * Creates a new InstancesBlock
  61985. * @param name defines the block name
  61986. */
  61987. constructor(name: string);
  61988. /**
  61989. * Gets the current class name
  61990. * @returns the class name
  61991. */
  61992. getClassName(): string;
  61993. /**
  61994. * Gets the first world row input component
  61995. */
  61996. get world0(): NodeMaterialConnectionPoint;
  61997. /**
  61998. * Gets the second world row input component
  61999. */
  62000. get world1(): NodeMaterialConnectionPoint;
  62001. /**
  62002. * Gets the third world row input component
  62003. */
  62004. get world2(): NodeMaterialConnectionPoint;
  62005. /**
  62006. * Gets the forth world row input component
  62007. */
  62008. get world3(): NodeMaterialConnectionPoint;
  62009. /**
  62010. * Gets the world input component
  62011. */
  62012. get world(): NodeMaterialConnectionPoint;
  62013. /**
  62014. * Gets the output component
  62015. */
  62016. get output(): NodeMaterialConnectionPoint;
  62017. /**
  62018. * Gets the isntanceID component
  62019. */
  62020. get instanceID(): NodeMaterialConnectionPoint;
  62021. autoConfigure(material: NodeMaterial): void;
  62022. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  62023. protected _buildBlock(state: NodeMaterialBuildState): this;
  62024. }
  62025. }
  62026. declare module BABYLON {
  62027. /**
  62028. * Block used to add morph targets support to vertex shader
  62029. */
  62030. export class MorphTargetsBlock extends NodeMaterialBlock {
  62031. private _repeatableContentAnchor;
  62032. /**
  62033. * Create a new MorphTargetsBlock
  62034. * @param name defines the block name
  62035. */
  62036. constructor(name: string);
  62037. /**
  62038. * Gets the current class name
  62039. * @returns the class name
  62040. */
  62041. getClassName(): string;
  62042. /**
  62043. * Gets the position input component
  62044. */
  62045. get position(): NodeMaterialConnectionPoint;
  62046. /**
  62047. * Gets the normal input component
  62048. */
  62049. get normal(): NodeMaterialConnectionPoint;
  62050. /**
  62051. * Gets the tangent input component
  62052. */
  62053. get tangent(): NodeMaterialConnectionPoint;
  62054. /**
  62055. * Gets the tangent input component
  62056. */
  62057. get uv(): NodeMaterialConnectionPoint;
  62058. /**
  62059. * Gets the position output component
  62060. */
  62061. get positionOutput(): NodeMaterialConnectionPoint;
  62062. /**
  62063. * Gets the normal output component
  62064. */
  62065. get normalOutput(): NodeMaterialConnectionPoint;
  62066. /**
  62067. * Gets the tangent output component
  62068. */
  62069. get tangentOutput(): NodeMaterialConnectionPoint;
  62070. /**
  62071. * Gets the tangent output component
  62072. */
  62073. get uvOutput(): NodeMaterialConnectionPoint;
  62074. initialize(state: NodeMaterialBuildState): void;
  62075. autoConfigure(material: NodeMaterial): void;
  62076. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62077. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62078. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  62079. protected _buildBlock(state: NodeMaterialBuildState): this;
  62080. }
  62081. }
  62082. declare module BABYLON {
  62083. /**
  62084. * Block used to get data information from a light
  62085. */
  62086. export class LightInformationBlock extends NodeMaterialBlock {
  62087. private _lightDataUniformName;
  62088. private _lightColorUniformName;
  62089. private _lightTypeDefineName;
  62090. /**
  62091. * Gets or sets the light associated with this block
  62092. */
  62093. light: Nullable<Light>;
  62094. /**
  62095. * Creates a new LightInformationBlock
  62096. * @param name defines the block name
  62097. */
  62098. constructor(name: string);
  62099. /**
  62100. * Gets the current class name
  62101. * @returns the class name
  62102. */
  62103. getClassName(): string;
  62104. /**
  62105. * Gets the world position input component
  62106. */
  62107. get worldPosition(): NodeMaterialConnectionPoint;
  62108. /**
  62109. * Gets the direction output component
  62110. */
  62111. get direction(): NodeMaterialConnectionPoint;
  62112. /**
  62113. * Gets the direction output component
  62114. */
  62115. get color(): NodeMaterialConnectionPoint;
  62116. /**
  62117. * Gets the direction output component
  62118. */
  62119. get intensity(): NodeMaterialConnectionPoint;
  62120. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62121. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62122. protected _buildBlock(state: NodeMaterialBuildState): this;
  62123. serialize(): any;
  62124. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62125. }
  62126. }
  62127. declare module BABYLON {
  62128. /**
  62129. * Block used to add image processing support to fragment shader
  62130. */
  62131. export class ImageProcessingBlock extends NodeMaterialBlock {
  62132. /**
  62133. * Create a new ImageProcessingBlock
  62134. * @param name defines the block name
  62135. */
  62136. constructor(name: string);
  62137. /**
  62138. * Gets the current class name
  62139. * @returns the class name
  62140. */
  62141. getClassName(): string;
  62142. /**
  62143. * Gets the color input component
  62144. */
  62145. get color(): NodeMaterialConnectionPoint;
  62146. /**
  62147. * Gets the output component
  62148. */
  62149. get output(): NodeMaterialConnectionPoint;
  62150. /**
  62151. * Initialize the block and prepare the context for build
  62152. * @param state defines the state that will be used for the build
  62153. */
  62154. initialize(state: NodeMaterialBuildState): void;
  62155. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  62156. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62157. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62158. protected _buildBlock(state: NodeMaterialBuildState): this;
  62159. }
  62160. }
  62161. declare module BABYLON {
  62162. /**
  62163. * Block used to pertub normals based on a normal map
  62164. */
  62165. export class PerturbNormalBlock extends NodeMaterialBlock {
  62166. private _tangentSpaceParameterName;
  62167. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62168. invertX: boolean;
  62169. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  62170. invertY: boolean;
  62171. /**
  62172. * Create a new PerturbNormalBlock
  62173. * @param name defines the block name
  62174. */
  62175. constructor(name: string);
  62176. /**
  62177. * Gets the current class name
  62178. * @returns the class name
  62179. */
  62180. getClassName(): string;
  62181. /**
  62182. * Gets the world position input component
  62183. */
  62184. get worldPosition(): NodeMaterialConnectionPoint;
  62185. /**
  62186. * Gets the world normal input component
  62187. */
  62188. get worldNormal(): NodeMaterialConnectionPoint;
  62189. /**
  62190. * Gets the world tangent input component
  62191. */
  62192. get worldTangent(): NodeMaterialConnectionPoint;
  62193. /**
  62194. * Gets the uv input component
  62195. */
  62196. get uv(): NodeMaterialConnectionPoint;
  62197. /**
  62198. * Gets the normal map color input component
  62199. */
  62200. get normalMapColor(): NodeMaterialConnectionPoint;
  62201. /**
  62202. * Gets the strength input component
  62203. */
  62204. get strength(): NodeMaterialConnectionPoint;
  62205. /**
  62206. * Gets the output component
  62207. */
  62208. get output(): NodeMaterialConnectionPoint;
  62209. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62210. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62211. autoConfigure(material: NodeMaterial): void;
  62212. protected _buildBlock(state: NodeMaterialBuildState): this;
  62213. protected _dumpPropertiesCode(): string;
  62214. serialize(): any;
  62215. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62216. }
  62217. }
  62218. declare module BABYLON {
  62219. /**
  62220. * Block used to discard a pixel if a value is smaller than a cutoff
  62221. */
  62222. export class DiscardBlock extends NodeMaterialBlock {
  62223. /**
  62224. * Create a new DiscardBlock
  62225. * @param name defines the block name
  62226. */
  62227. constructor(name: string);
  62228. /**
  62229. * Gets the current class name
  62230. * @returns the class name
  62231. */
  62232. getClassName(): string;
  62233. /**
  62234. * Gets the color input component
  62235. */
  62236. get value(): NodeMaterialConnectionPoint;
  62237. /**
  62238. * Gets the cutoff input component
  62239. */
  62240. get cutoff(): NodeMaterialConnectionPoint;
  62241. protected _buildBlock(state: NodeMaterialBuildState): this;
  62242. }
  62243. }
  62244. declare module BABYLON {
  62245. /**
  62246. * Block used to test if the fragment shader is front facing
  62247. */
  62248. export class FrontFacingBlock extends NodeMaterialBlock {
  62249. /**
  62250. * Creates a new FrontFacingBlock
  62251. * @param name defines the block name
  62252. */
  62253. constructor(name: string);
  62254. /**
  62255. * Gets the current class name
  62256. * @returns the class name
  62257. */
  62258. getClassName(): string;
  62259. /**
  62260. * Gets the output component
  62261. */
  62262. get output(): NodeMaterialConnectionPoint;
  62263. protected _buildBlock(state: NodeMaterialBuildState): this;
  62264. }
  62265. }
  62266. declare module BABYLON {
  62267. /**
  62268. * Block used to get the derivative value on x and y of a given input
  62269. */
  62270. export class DerivativeBlock extends NodeMaterialBlock {
  62271. /**
  62272. * Create a new DerivativeBlock
  62273. * @param name defines the block name
  62274. */
  62275. constructor(name: string);
  62276. /**
  62277. * Gets the current class name
  62278. * @returns the class name
  62279. */
  62280. getClassName(): string;
  62281. /**
  62282. * Gets the input component
  62283. */
  62284. get input(): NodeMaterialConnectionPoint;
  62285. /**
  62286. * Gets the derivative output on x
  62287. */
  62288. get dx(): NodeMaterialConnectionPoint;
  62289. /**
  62290. * Gets the derivative output on y
  62291. */
  62292. get dy(): NodeMaterialConnectionPoint;
  62293. protected _buildBlock(state: NodeMaterialBuildState): this;
  62294. }
  62295. }
  62296. declare module BABYLON {
  62297. /**
  62298. * Block used to make gl_FragCoord available
  62299. */
  62300. export class FragCoordBlock extends NodeMaterialBlock {
  62301. /**
  62302. * Creates a new FragCoordBlock
  62303. * @param name defines the block name
  62304. */
  62305. constructor(name: string);
  62306. /**
  62307. * Gets the current class name
  62308. * @returns the class name
  62309. */
  62310. getClassName(): string;
  62311. /**
  62312. * Gets the xy component
  62313. */
  62314. get xy(): NodeMaterialConnectionPoint;
  62315. /**
  62316. * Gets the xyz component
  62317. */
  62318. get xyz(): NodeMaterialConnectionPoint;
  62319. /**
  62320. * Gets the xyzw component
  62321. */
  62322. get xyzw(): NodeMaterialConnectionPoint;
  62323. /**
  62324. * Gets the x component
  62325. */
  62326. get x(): NodeMaterialConnectionPoint;
  62327. /**
  62328. * Gets the y component
  62329. */
  62330. get y(): NodeMaterialConnectionPoint;
  62331. /**
  62332. * Gets the z component
  62333. */
  62334. get z(): NodeMaterialConnectionPoint;
  62335. /**
  62336. * Gets the w component
  62337. */
  62338. get output(): NodeMaterialConnectionPoint;
  62339. protected writeOutputs(state: NodeMaterialBuildState): string;
  62340. protected _buildBlock(state: NodeMaterialBuildState): this;
  62341. }
  62342. }
  62343. declare module BABYLON {
  62344. /**
  62345. * Block used to get the screen sizes
  62346. */
  62347. export class ScreenSizeBlock extends NodeMaterialBlock {
  62348. private _varName;
  62349. private _scene;
  62350. /**
  62351. * Creates a new ScreenSizeBlock
  62352. * @param name defines the block name
  62353. */
  62354. constructor(name: string);
  62355. /**
  62356. * Gets the current class name
  62357. * @returns the class name
  62358. */
  62359. getClassName(): string;
  62360. /**
  62361. * Gets the xy component
  62362. */
  62363. get xy(): NodeMaterialConnectionPoint;
  62364. /**
  62365. * Gets the x component
  62366. */
  62367. get x(): NodeMaterialConnectionPoint;
  62368. /**
  62369. * Gets the y component
  62370. */
  62371. get y(): NodeMaterialConnectionPoint;
  62372. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62373. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  62374. protected _buildBlock(state: NodeMaterialBuildState): this;
  62375. }
  62376. }
  62377. declare module BABYLON {
  62378. /**
  62379. * Block used to add support for scene fog
  62380. */
  62381. export class FogBlock extends NodeMaterialBlock {
  62382. private _fogDistanceName;
  62383. private _fogParameters;
  62384. /**
  62385. * Create a new FogBlock
  62386. * @param name defines the block name
  62387. */
  62388. constructor(name: string);
  62389. /**
  62390. * Gets the current class name
  62391. * @returns the class name
  62392. */
  62393. getClassName(): string;
  62394. /**
  62395. * Gets the world position input component
  62396. */
  62397. get worldPosition(): NodeMaterialConnectionPoint;
  62398. /**
  62399. * Gets the view input component
  62400. */
  62401. get view(): NodeMaterialConnectionPoint;
  62402. /**
  62403. * Gets the color input component
  62404. */
  62405. get input(): NodeMaterialConnectionPoint;
  62406. /**
  62407. * Gets the fog color input component
  62408. */
  62409. get fogColor(): NodeMaterialConnectionPoint;
  62410. /**
  62411. * Gets the output component
  62412. */
  62413. get output(): NodeMaterialConnectionPoint;
  62414. autoConfigure(material: NodeMaterial): void;
  62415. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62416. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62417. protected _buildBlock(state: NodeMaterialBuildState): this;
  62418. }
  62419. }
  62420. declare module BABYLON {
  62421. /**
  62422. * Block used to add light in the fragment shader
  62423. */
  62424. export class LightBlock extends NodeMaterialBlock {
  62425. private _lightId;
  62426. /**
  62427. * Gets or sets the light associated with this block
  62428. */
  62429. light: Nullable<Light>;
  62430. /**
  62431. * Create a new LightBlock
  62432. * @param name defines the block name
  62433. */
  62434. constructor(name: string);
  62435. /**
  62436. * Gets the current class name
  62437. * @returns the class name
  62438. */
  62439. getClassName(): string;
  62440. /**
  62441. * Gets the world position input component
  62442. */
  62443. get worldPosition(): NodeMaterialConnectionPoint;
  62444. /**
  62445. * Gets the world normal input component
  62446. */
  62447. get worldNormal(): NodeMaterialConnectionPoint;
  62448. /**
  62449. * Gets the camera (or eye) position component
  62450. */
  62451. get cameraPosition(): NodeMaterialConnectionPoint;
  62452. /**
  62453. * Gets the glossiness component
  62454. */
  62455. get glossiness(): NodeMaterialConnectionPoint;
  62456. /**
  62457. * Gets the glossinness power component
  62458. */
  62459. get glossPower(): NodeMaterialConnectionPoint;
  62460. /**
  62461. * Gets the diffuse color component
  62462. */
  62463. get diffuseColor(): NodeMaterialConnectionPoint;
  62464. /**
  62465. * Gets the specular color component
  62466. */
  62467. get specularColor(): NodeMaterialConnectionPoint;
  62468. /**
  62469. * Gets the diffuse output component
  62470. */
  62471. get diffuseOutput(): NodeMaterialConnectionPoint;
  62472. /**
  62473. * Gets the specular output component
  62474. */
  62475. get specularOutput(): NodeMaterialConnectionPoint;
  62476. /**
  62477. * Gets the shadow output component
  62478. */
  62479. get shadow(): NodeMaterialConnectionPoint;
  62480. autoConfigure(material: NodeMaterial): void;
  62481. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62482. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  62483. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62484. private _injectVertexCode;
  62485. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62486. serialize(): any;
  62487. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62488. }
  62489. }
  62490. declare module BABYLON {
  62491. /**
  62492. * Block used to read a reflection texture from a sampler
  62493. */
  62494. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  62495. /**
  62496. * Create a new ReflectionTextureBlock
  62497. * @param name defines the block name
  62498. */
  62499. constructor(name: string);
  62500. /**
  62501. * Gets the current class name
  62502. * @returns the class name
  62503. */
  62504. getClassName(): string;
  62505. /**
  62506. * Gets the world position input component
  62507. */
  62508. get position(): NodeMaterialConnectionPoint;
  62509. /**
  62510. * Gets the world position input component
  62511. */
  62512. get worldPosition(): NodeMaterialConnectionPoint;
  62513. /**
  62514. * Gets the world normal input component
  62515. */
  62516. get worldNormal(): NodeMaterialConnectionPoint;
  62517. /**
  62518. * Gets the world input component
  62519. */
  62520. get world(): NodeMaterialConnectionPoint;
  62521. /**
  62522. * Gets the camera (or eye) position component
  62523. */
  62524. get cameraPosition(): NodeMaterialConnectionPoint;
  62525. /**
  62526. * Gets the view input component
  62527. */
  62528. get view(): NodeMaterialConnectionPoint;
  62529. /**
  62530. * Gets the rgb output component
  62531. */
  62532. get rgb(): NodeMaterialConnectionPoint;
  62533. /**
  62534. * Gets the rgba output component
  62535. */
  62536. get rgba(): NodeMaterialConnectionPoint;
  62537. /**
  62538. * Gets the r output component
  62539. */
  62540. get r(): NodeMaterialConnectionPoint;
  62541. /**
  62542. * Gets the g output component
  62543. */
  62544. get g(): NodeMaterialConnectionPoint;
  62545. /**
  62546. * Gets the b output component
  62547. */
  62548. get b(): NodeMaterialConnectionPoint;
  62549. /**
  62550. * Gets the a output component
  62551. */
  62552. get a(): NodeMaterialConnectionPoint;
  62553. autoConfigure(material: NodeMaterial): void;
  62554. protected _buildBlock(state: NodeMaterialBuildState): this;
  62555. }
  62556. }
  62557. declare module BABYLON {
  62558. /**
  62559. * Block used to add 2 vectors
  62560. */
  62561. export class AddBlock extends NodeMaterialBlock {
  62562. /**
  62563. * Creates a new AddBlock
  62564. * @param name defines the block name
  62565. */
  62566. constructor(name: string);
  62567. /**
  62568. * Gets the current class name
  62569. * @returns the class name
  62570. */
  62571. getClassName(): string;
  62572. /**
  62573. * Gets the left operand input component
  62574. */
  62575. get left(): NodeMaterialConnectionPoint;
  62576. /**
  62577. * Gets the right operand input component
  62578. */
  62579. get right(): NodeMaterialConnectionPoint;
  62580. /**
  62581. * Gets the output component
  62582. */
  62583. get output(): NodeMaterialConnectionPoint;
  62584. protected _buildBlock(state: NodeMaterialBuildState): this;
  62585. }
  62586. }
  62587. declare module BABYLON {
  62588. /**
  62589. * Block used to scale a vector by a float
  62590. */
  62591. export class ScaleBlock extends NodeMaterialBlock {
  62592. /**
  62593. * Creates a new ScaleBlock
  62594. * @param name defines the block name
  62595. */
  62596. constructor(name: string);
  62597. /**
  62598. * Gets the current class name
  62599. * @returns the class name
  62600. */
  62601. getClassName(): string;
  62602. /**
  62603. * Gets the input component
  62604. */
  62605. get input(): NodeMaterialConnectionPoint;
  62606. /**
  62607. * Gets the factor input component
  62608. */
  62609. get factor(): NodeMaterialConnectionPoint;
  62610. /**
  62611. * Gets the output component
  62612. */
  62613. get output(): NodeMaterialConnectionPoint;
  62614. protected _buildBlock(state: NodeMaterialBuildState): this;
  62615. }
  62616. }
  62617. declare module BABYLON {
  62618. /**
  62619. * Block used to clamp a float
  62620. */
  62621. export class ClampBlock extends NodeMaterialBlock {
  62622. /** Gets or sets the minimum range */
  62623. minimum: number;
  62624. /** Gets or sets the maximum range */
  62625. maximum: number;
  62626. /**
  62627. * Creates a new ClampBlock
  62628. * @param name defines the block name
  62629. */
  62630. constructor(name: string);
  62631. /**
  62632. * Gets the current class name
  62633. * @returns the class name
  62634. */
  62635. getClassName(): string;
  62636. /**
  62637. * Gets the value input component
  62638. */
  62639. get value(): NodeMaterialConnectionPoint;
  62640. /**
  62641. * Gets the output component
  62642. */
  62643. get output(): NodeMaterialConnectionPoint;
  62644. protected _buildBlock(state: NodeMaterialBuildState): this;
  62645. protected _dumpPropertiesCode(): string;
  62646. serialize(): any;
  62647. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62648. }
  62649. }
  62650. declare module BABYLON {
  62651. /**
  62652. * Block used to apply a cross product between 2 vectors
  62653. */
  62654. export class CrossBlock extends NodeMaterialBlock {
  62655. /**
  62656. * Creates a new CrossBlock
  62657. * @param name defines the block name
  62658. */
  62659. constructor(name: string);
  62660. /**
  62661. * Gets the current class name
  62662. * @returns the class name
  62663. */
  62664. getClassName(): string;
  62665. /**
  62666. * Gets the left operand input component
  62667. */
  62668. get left(): NodeMaterialConnectionPoint;
  62669. /**
  62670. * Gets the right operand input component
  62671. */
  62672. get right(): NodeMaterialConnectionPoint;
  62673. /**
  62674. * Gets the output component
  62675. */
  62676. get output(): NodeMaterialConnectionPoint;
  62677. protected _buildBlock(state: NodeMaterialBuildState): this;
  62678. }
  62679. }
  62680. declare module BABYLON {
  62681. /**
  62682. * Block used to apply a dot product between 2 vectors
  62683. */
  62684. export class DotBlock extends NodeMaterialBlock {
  62685. /**
  62686. * Creates a new DotBlock
  62687. * @param name defines the block name
  62688. */
  62689. constructor(name: string);
  62690. /**
  62691. * Gets the current class name
  62692. * @returns the class name
  62693. */
  62694. getClassName(): string;
  62695. /**
  62696. * Gets the left operand input component
  62697. */
  62698. get left(): NodeMaterialConnectionPoint;
  62699. /**
  62700. * Gets the right operand input component
  62701. */
  62702. get right(): NodeMaterialConnectionPoint;
  62703. /**
  62704. * Gets the output component
  62705. */
  62706. get output(): NodeMaterialConnectionPoint;
  62707. protected _buildBlock(state: NodeMaterialBuildState): this;
  62708. }
  62709. }
  62710. declare module BABYLON {
  62711. /**
  62712. * Block used to normalize a vector
  62713. */
  62714. export class NormalizeBlock extends NodeMaterialBlock {
  62715. /**
  62716. * Creates a new NormalizeBlock
  62717. * @param name defines the block name
  62718. */
  62719. constructor(name: string);
  62720. /**
  62721. * Gets the current class name
  62722. * @returns the class name
  62723. */
  62724. getClassName(): string;
  62725. /**
  62726. * Gets the input component
  62727. */
  62728. get input(): NodeMaterialConnectionPoint;
  62729. /**
  62730. * Gets the output component
  62731. */
  62732. get output(): NodeMaterialConnectionPoint;
  62733. protected _buildBlock(state: NodeMaterialBuildState): this;
  62734. }
  62735. }
  62736. declare module BABYLON {
  62737. /**
  62738. * Operations supported by the Trigonometry block
  62739. */
  62740. export enum TrigonometryBlockOperations {
  62741. /** Cos */
  62742. Cos = 0,
  62743. /** Sin */
  62744. Sin = 1,
  62745. /** Abs */
  62746. Abs = 2,
  62747. /** Exp */
  62748. Exp = 3,
  62749. /** Exp2 */
  62750. Exp2 = 4,
  62751. /** Round */
  62752. Round = 5,
  62753. /** Floor */
  62754. Floor = 6,
  62755. /** Ceiling */
  62756. Ceiling = 7,
  62757. /** Square root */
  62758. Sqrt = 8,
  62759. /** Log */
  62760. Log = 9,
  62761. /** Tangent */
  62762. Tan = 10,
  62763. /** Arc tangent */
  62764. ArcTan = 11,
  62765. /** Arc cosinus */
  62766. ArcCos = 12,
  62767. /** Arc sinus */
  62768. ArcSin = 13,
  62769. /** Fraction */
  62770. Fract = 14,
  62771. /** Sign */
  62772. Sign = 15,
  62773. /** To radians (from degrees) */
  62774. Radians = 16,
  62775. /** To degrees (from radians) */
  62776. Degrees = 17
  62777. }
  62778. /**
  62779. * Block used to apply trigonometry operation to floats
  62780. */
  62781. export class TrigonometryBlock extends NodeMaterialBlock {
  62782. /**
  62783. * Gets or sets the operation applied by the block
  62784. */
  62785. operation: TrigonometryBlockOperations;
  62786. /**
  62787. * Creates a new TrigonometryBlock
  62788. * @param name defines the block name
  62789. */
  62790. constructor(name: string);
  62791. /**
  62792. * Gets the current class name
  62793. * @returns the class name
  62794. */
  62795. getClassName(): string;
  62796. /**
  62797. * Gets the input component
  62798. */
  62799. get input(): NodeMaterialConnectionPoint;
  62800. /**
  62801. * Gets the output component
  62802. */
  62803. get output(): NodeMaterialConnectionPoint;
  62804. protected _buildBlock(state: NodeMaterialBuildState): this;
  62805. serialize(): any;
  62806. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62807. protected _dumpPropertiesCode(): string;
  62808. }
  62809. }
  62810. declare module BABYLON {
  62811. /**
  62812. * Block used to create a Color3/4 out of individual inputs (one for each component)
  62813. */
  62814. export class ColorMergerBlock extends NodeMaterialBlock {
  62815. /**
  62816. * Create a new ColorMergerBlock
  62817. * @param name defines the block name
  62818. */
  62819. constructor(name: string);
  62820. /**
  62821. * Gets the current class name
  62822. * @returns the class name
  62823. */
  62824. getClassName(): string;
  62825. /**
  62826. * Gets the rgb component (input)
  62827. */
  62828. get rgbIn(): NodeMaterialConnectionPoint;
  62829. /**
  62830. * Gets the r component (input)
  62831. */
  62832. get r(): NodeMaterialConnectionPoint;
  62833. /**
  62834. * Gets the g component (input)
  62835. */
  62836. get g(): NodeMaterialConnectionPoint;
  62837. /**
  62838. * Gets the b component (input)
  62839. */
  62840. get b(): NodeMaterialConnectionPoint;
  62841. /**
  62842. * Gets the a component (input)
  62843. */
  62844. get a(): NodeMaterialConnectionPoint;
  62845. /**
  62846. * Gets the rgba component (output)
  62847. */
  62848. get rgba(): NodeMaterialConnectionPoint;
  62849. /**
  62850. * Gets the rgb component (output)
  62851. */
  62852. get rgbOut(): NodeMaterialConnectionPoint;
  62853. /**
  62854. * Gets the rgb component (output)
  62855. * @deprecated Please use rgbOut instead.
  62856. */
  62857. get rgb(): NodeMaterialConnectionPoint;
  62858. protected _buildBlock(state: NodeMaterialBuildState): this;
  62859. }
  62860. }
  62861. declare module BABYLON {
  62862. /**
  62863. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  62864. */
  62865. export class VectorSplitterBlock extends NodeMaterialBlock {
  62866. /**
  62867. * Create a new VectorSplitterBlock
  62868. * @param name defines the block name
  62869. */
  62870. constructor(name: string);
  62871. /**
  62872. * Gets the current class name
  62873. * @returns the class name
  62874. */
  62875. getClassName(): string;
  62876. /**
  62877. * Gets the xyzw component (input)
  62878. */
  62879. get xyzw(): NodeMaterialConnectionPoint;
  62880. /**
  62881. * Gets the xyz component (input)
  62882. */
  62883. get xyzIn(): NodeMaterialConnectionPoint;
  62884. /**
  62885. * Gets the xy component (input)
  62886. */
  62887. get xyIn(): NodeMaterialConnectionPoint;
  62888. /**
  62889. * Gets the xyz component (output)
  62890. */
  62891. get xyzOut(): NodeMaterialConnectionPoint;
  62892. /**
  62893. * Gets the xy component (output)
  62894. */
  62895. get xyOut(): NodeMaterialConnectionPoint;
  62896. /**
  62897. * Gets the x component (output)
  62898. */
  62899. get x(): NodeMaterialConnectionPoint;
  62900. /**
  62901. * Gets the y component (output)
  62902. */
  62903. get y(): NodeMaterialConnectionPoint;
  62904. /**
  62905. * Gets the z component (output)
  62906. */
  62907. get z(): NodeMaterialConnectionPoint;
  62908. /**
  62909. * Gets the w component (output)
  62910. */
  62911. get w(): NodeMaterialConnectionPoint;
  62912. protected _inputRename(name: string): string;
  62913. protected _outputRename(name: string): string;
  62914. protected _buildBlock(state: NodeMaterialBuildState): this;
  62915. }
  62916. }
  62917. declare module BABYLON {
  62918. /**
  62919. * Block used to lerp between 2 values
  62920. */
  62921. export class LerpBlock extends NodeMaterialBlock {
  62922. /**
  62923. * Creates a new LerpBlock
  62924. * @param name defines the block name
  62925. */
  62926. constructor(name: string);
  62927. /**
  62928. * Gets the current class name
  62929. * @returns the class name
  62930. */
  62931. getClassName(): string;
  62932. /**
  62933. * Gets the left operand input component
  62934. */
  62935. get left(): NodeMaterialConnectionPoint;
  62936. /**
  62937. * Gets the right operand input component
  62938. */
  62939. get right(): NodeMaterialConnectionPoint;
  62940. /**
  62941. * Gets the gradient operand input component
  62942. */
  62943. get gradient(): NodeMaterialConnectionPoint;
  62944. /**
  62945. * Gets the output component
  62946. */
  62947. get output(): NodeMaterialConnectionPoint;
  62948. protected _buildBlock(state: NodeMaterialBuildState): this;
  62949. }
  62950. }
  62951. declare module BABYLON {
  62952. /**
  62953. * Block used to divide 2 vectors
  62954. */
  62955. export class DivideBlock extends NodeMaterialBlock {
  62956. /**
  62957. * Creates a new DivideBlock
  62958. * @param name defines the block name
  62959. */
  62960. constructor(name: string);
  62961. /**
  62962. * Gets the current class name
  62963. * @returns the class name
  62964. */
  62965. getClassName(): string;
  62966. /**
  62967. * Gets the left operand input component
  62968. */
  62969. get left(): NodeMaterialConnectionPoint;
  62970. /**
  62971. * Gets the right operand input component
  62972. */
  62973. get right(): NodeMaterialConnectionPoint;
  62974. /**
  62975. * Gets the output component
  62976. */
  62977. get output(): NodeMaterialConnectionPoint;
  62978. protected _buildBlock(state: NodeMaterialBuildState): this;
  62979. }
  62980. }
  62981. declare module BABYLON {
  62982. /**
  62983. * Block used to subtract 2 vectors
  62984. */
  62985. export class SubtractBlock extends NodeMaterialBlock {
  62986. /**
  62987. * Creates a new SubtractBlock
  62988. * @param name defines the block name
  62989. */
  62990. constructor(name: string);
  62991. /**
  62992. * Gets the current class name
  62993. * @returns the class name
  62994. */
  62995. getClassName(): string;
  62996. /**
  62997. * Gets the left operand input component
  62998. */
  62999. get left(): NodeMaterialConnectionPoint;
  63000. /**
  63001. * Gets the right operand input component
  63002. */
  63003. get right(): NodeMaterialConnectionPoint;
  63004. /**
  63005. * Gets the output component
  63006. */
  63007. get output(): NodeMaterialConnectionPoint;
  63008. protected _buildBlock(state: NodeMaterialBuildState): this;
  63009. }
  63010. }
  63011. declare module BABYLON {
  63012. /**
  63013. * Block used to step a value
  63014. */
  63015. export class StepBlock extends NodeMaterialBlock {
  63016. /**
  63017. * Creates a new StepBlock
  63018. * @param name defines the block name
  63019. */
  63020. constructor(name: string);
  63021. /**
  63022. * Gets the current class name
  63023. * @returns the class name
  63024. */
  63025. getClassName(): string;
  63026. /**
  63027. * Gets the value operand input component
  63028. */
  63029. get value(): NodeMaterialConnectionPoint;
  63030. /**
  63031. * Gets the edge operand input component
  63032. */
  63033. get edge(): NodeMaterialConnectionPoint;
  63034. /**
  63035. * Gets the output component
  63036. */
  63037. get output(): NodeMaterialConnectionPoint;
  63038. protected _buildBlock(state: NodeMaterialBuildState): this;
  63039. }
  63040. }
  63041. declare module BABYLON {
  63042. /**
  63043. * Block used to get the opposite (1 - x) of a value
  63044. */
  63045. export class OneMinusBlock extends NodeMaterialBlock {
  63046. /**
  63047. * Creates a new OneMinusBlock
  63048. * @param name defines the block name
  63049. */
  63050. constructor(name: string);
  63051. /**
  63052. * Gets the current class name
  63053. * @returns the class name
  63054. */
  63055. getClassName(): string;
  63056. /**
  63057. * Gets the input component
  63058. */
  63059. get input(): NodeMaterialConnectionPoint;
  63060. /**
  63061. * Gets the output component
  63062. */
  63063. get output(): NodeMaterialConnectionPoint;
  63064. protected _buildBlock(state: NodeMaterialBuildState): this;
  63065. }
  63066. }
  63067. declare module BABYLON {
  63068. /**
  63069. * Block used to get the view direction
  63070. */
  63071. export class ViewDirectionBlock extends NodeMaterialBlock {
  63072. /**
  63073. * Creates a new ViewDirectionBlock
  63074. * @param name defines the block name
  63075. */
  63076. constructor(name: string);
  63077. /**
  63078. * Gets the current class name
  63079. * @returns the class name
  63080. */
  63081. getClassName(): string;
  63082. /**
  63083. * Gets the world position component
  63084. */
  63085. get worldPosition(): NodeMaterialConnectionPoint;
  63086. /**
  63087. * Gets the camera position component
  63088. */
  63089. get cameraPosition(): NodeMaterialConnectionPoint;
  63090. /**
  63091. * Gets the output component
  63092. */
  63093. get output(): NodeMaterialConnectionPoint;
  63094. autoConfigure(material: NodeMaterial): void;
  63095. protected _buildBlock(state: NodeMaterialBuildState): this;
  63096. }
  63097. }
  63098. declare module BABYLON {
  63099. /**
  63100. * Block used to compute fresnel value
  63101. */
  63102. export class FresnelBlock extends NodeMaterialBlock {
  63103. /**
  63104. * Create a new FresnelBlock
  63105. * @param name defines the block name
  63106. */
  63107. constructor(name: string);
  63108. /**
  63109. * Gets the current class name
  63110. * @returns the class name
  63111. */
  63112. getClassName(): string;
  63113. /**
  63114. * Gets the world normal input component
  63115. */
  63116. get worldNormal(): NodeMaterialConnectionPoint;
  63117. /**
  63118. * Gets the view direction input component
  63119. */
  63120. get viewDirection(): NodeMaterialConnectionPoint;
  63121. /**
  63122. * Gets the bias input component
  63123. */
  63124. get bias(): NodeMaterialConnectionPoint;
  63125. /**
  63126. * Gets the camera (or eye) position component
  63127. */
  63128. get power(): NodeMaterialConnectionPoint;
  63129. /**
  63130. * Gets the fresnel output component
  63131. */
  63132. get fresnel(): NodeMaterialConnectionPoint;
  63133. autoConfigure(material: NodeMaterial): void;
  63134. protected _buildBlock(state: NodeMaterialBuildState): this;
  63135. }
  63136. }
  63137. declare module BABYLON {
  63138. /**
  63139. * Block used to get the max of 2 values
  63140. */
  63141. export class MaxBlock extends NodeMaterialBlock {
  63142. /**
  63143. * Creates a new MaxBlock
  63144. * @param name defines the block name
  63145. */
  63146. constructor(name: string);
  63147. /**
  63148. * Gets the current class name
  63149. * @returns the class name
  63150. */
  63151. getClassName(): string;
  63152. /**
  63153. * Gets the left operand input component
  63154. */
  63155. get left(): NodeMaterialConnectionPoint;
  63156. /**
  63157. * Gets the right operand input component
  63158. */
  63159. get right(): 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 get the min of 2 values
  63170. */
  63171. export class MinBlock extends NodeMaterialBlock {
  63172. /**
  63173. * Creates a new MinBlock
  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 left operand input component
  63184. */
  63185. get left(): NodeMaterialConnectionPoint;
  63186. /**
  63187. * Gets the right operand input component
  63188. */
  63189. get right(): NodeMaterialConnectionPoint;
  63190. /**
  63191. * Gets the output component
  63192. */
  63193. get output(): NodeMaterialConnectionPoint;
  63194. protected _buildBlock(state: NodeMaterialBuildState): this;
  63195. }
  63196. }
  63197. declare module BABYLON {
  63198. /**
  63199. * Block used to get the distance between 2 values
  63200. */
  63201. export class DistanceBlock extends NodeMaterialBlock {
  63202. /**
  63203. * Creates a new DistanceBlock
  63204. * @param name defines the block name
  63205. */
  63206. constructor(name: string);
  63207. /**
  63208. * Gets the current class name
  63209. * @returns the class name
  63210. */
  63211. getClassName(): string;
  63212. /**
  63213. * Gets the left operand input component
  63214. */
  63215. get left(): NodeMaterialConnectionPoint;
  63216. /**
  63217. * Gets the right operand input component
  63218. */
  63219. get right(): NodeMaterialConnectionPoint;
  63220. /**
  63221. * Gets the output component
  63222. */
  63223. get output(): NodeMaterialConnectionPoint;
  63224. protected _buildBlock(state: NodeMaterialBuildState): this;
  63225. }
  63226. }
  63227. declare module BABYLON {
  63228. /**
  63229. * Block used to get the length of a vector
  63230. */
  63231. export class LengthBlock extends NodeMaterialBlock {
  63232. /**
  63233. * Creates a new LengthBlock
  63234. * @param name defines the block name
  63235. */
  63236. constructor(name: string);
  63237. /**
  63238. * Gets the current class name
  63239. * @returns the class name
  63240. */
  63241. getClassName(): string;
  63242. /**
  63243. * Gets the value input component
  63244. */
  63245. get value(): NodeMaterialConnectionPoint;
  63246. /**
  63247. * Gets the output component
  63248. */
  63249. get output(): NodeMaterialConnectionPoint;
  63250. protected _buildBlock(state: NodeMaterialBuildState): this;
  63251. }
  63252. }
  63253. declare module BABYLON {
  63254. /**
  63255. * Block used to get negative version of a value (i.e. x * -1)
  63256. */
  63257. export class NegateBlock extends NodeMaterialBlock {
  63258. /**
  63259. * Creates a new NegateBlock
  63260. * @param name defines the block name
  63261. */
  63262. constructor(name: string);
  63263. /**
  63264. * Gets the current class name
  63265. * @returns the class name
  63266. */
  63267. getClassName(): string;
  63268. /**
  63269. * Gets the value input component
  63270. */
  63271. get value(): NodeMaterialConnectionPoint;
  63272. /**
  63273. * Gets the output component
  63274. */
  63275. get output(): NodeMaterialConnectionPoint;
  63276. protected _buildBlock(state: NodeMaterialBuildState): this;
  63277. }
  63278. }
  63279. declare module BABYLON {
  63280. /**
  63281. * Block used to get the value of the first parameter raised to the power of the second
  63282. */
  63283. export class PowBlock extends NodeMaterialBlock {
  63284. /**
  63285. * Creates a new PowBlock
  63286. * @param name defines the block name
  63287. */
  63288. constructor(name: string);
  63289. /**
  63290. * Gets the current class name
  63291. * @returns the class name
  63292. */
  63293. getClassName(): string;
  63294. /**
  63295. * Gets the value operand input component
  63296. */
  63297. get value(): NodeMaterialConnectionPoint;
  63298. /**
  63299. * Gets the power operand input component
  63300. */
  63301. get power(): NodeMaterialConnectionPoint;
  63302. /**
  63303. * Gets the output component
  63304. */
  63305. get output(): NodeMaterialConnectionPoint;
  63306. protected _buildBlock(state: NodeMaterialBuildState): this;
  63307. }
  63308. }
  63309. declare module BABYLON {
  63310. /**
  63311. * Block used to get a random number
  63312. */
  63313. export class RandomNumberBlock extends NodeMaterialBlock {
  63314. /**
  63315. * Creates a new RandomNumberBlock
  63316. * @param name defines the block name
  63317. */
  63318. constructor(name: string);
  63319. /**
  63320. * Gets the current class name
  63321. * @returns the class name
  63322. */
  63323. getClassName(): string;
  63324. /**
  63325. * Gets the seed input component
  63326. */
  63327. get seed(): NodeMaterialConnectionPoint;
  63328. /**
  63329. * Gets the output component
  63330. */
  63331. get output(): NodeMaterialConnectionPoint;
  63332. protected _buildBlock(state: NodeMaterialBuildState): this;
  63333. }
  63334. }
  63335. declare module BABYLON {
  63336. /**
  63337. * Block used to compute arc tangent of 2 values
  63338. */
  63339. export class ArcTan2Block extends NodeMaterialBlock {
  63340. /**
  63341. * Creates a new ArcTan2Block
  63342. * @param name defines the block name
  63343. */
  63344. constructor(name: string);
  63345. /**
  63346. * Gets the current class name
  63347. * @returns the class name
  63348. */
  63349. getClassName(): string;
  63350. /**
  63351. * Gets the x operand input component
  63352. */
  63353. get x(): NodeMaterialConnectionPoint;
  63354. /**
  63355. * Gets the y operand input component
  63356. */
  63357. get y(): NodeMaterialConnectionPoint;
  63358. /**
  63359. * Gets the output component
  63360. */
  63361. get output(): NodeMaterialConnectionPoint;
  63362. protected _buildBlock(state: NodeMaterialBuildState): this;
  63363. }
  63364. }
  63365. declare module BABYLON {
  63366. /**
  63367. * Block used to smooth step a value
  63368. */
  63369. export class SmoothStepBlock extends NodeMaterialBlock {
  63370. /**
  63371. * Creates a new SmoothStepBlock
  63372. * @param name defines the block name
  63373. */
  63374. constructor(name: string);
  63375. /**
  63376. * Gets the current class name
  63377. * @returns the class name
  63378. */
  63379. getClassName(): string;
  63380. /**
  63381. * Gets the value operand input component
  63382. */
  63383. get value(): NodeMaterialConnectionPoint;
  63384. /**
  63385. * Gets the first edge operand input component
  63386. */
  63387. get edge0(): NodeMaterialConnectionPoint;
  63388. /**
  63389. * Gets the second edge operand input component
  63390. */
  63391. get edge1(): NodeMaterialConnectionPoint;
  63392. /**
  63393. * Gets the output component
  63394. */
  63395. get output(): NodeMaterialConnectionPoint;
  63396. protected _buildBlock(state: NodeMaterialBuildState): this;
  63397. }
  63398. }
  63399. declare module BABYLON {
  63400. /**
  63401. * Block used to get the reciprocal (1 / x) of a value
  63402. */
  63403. export class ReciprocalBlock extends NodeMaterialBlock {
  63404. /**
  63405. * Creates a new ReciprocalBlock
  63406. * @param name defines the block name
  63407. */
  63408. constructor(name: string);
  63409. /**
  63410. * Gets the current class name
  63411. * @returns the class name
  63412. */
  63413. getClassName(): string;
  63414. /**
  63415. * Gets the input component
  63416. */
  63417. get input(): NodeMaterialConnectionPoint;
  63418. /**
  63419. * Gets the output component
  63420. */
  63421. get output(): NodeMaterialConnectionPoint;
  63422. protected _buildBlock(state: NodeMaterialBuildState): this;
  63423. }
  63424. }
  63425. declare module BABYLON {
  63426. /**
  63427. * Block used to replace a color by another one
  63428. */
  63429. export class ReplaceColorBlock extends NodeMaterialBlock {
  63430. /**
  63431. * Creates a new ReplaceColorBlock
  63432. * @param name defines the block name
  63433. */
  63434. constructor(name: string);
  63435. /**
  63436. * Gets the current class name
  63437. * @returns the class name
  63438. */
  63439. getClassName(): string;
  63440. /**
  63441. * Gets the value input component
  63442. */
  63443. get value(): NodeMaterialConnectionPoint;
  63444. /**
  63445. * Gets the reference input component
  63446. */
  63447. get reference(): NodeMaterialConnectionPoint;
  63448. /**
  63449. * Gets the distance input component
  63450. */
  63451. get distance(): NodeMaterialConnectionPoint;
  63452. /**
  63453. * Gets the replacement input component
  63454. */
  63455. get replacement(): NodeMaterialConnectionPoint;
  63456. /**
  63457. * Gets the output component
  63458. */
  63459. get output(): NodeMaterialConnectionPoint;
  63460. protected _buildBlock(state: NodeMaterialBuildState): this;
  63461. }
  63462. }
  63463. declare module BABYLON {
  63464. /**
  63465. * Block used to posterize a value
  63466. * @see https://en.wikipedia.org/wiki/Posterization
  63467. */
  63468. export class PosterizeBlock extends NodeMaterialBlock {
  63469. /**
  63470. * Creates a new PosterizeBlock
  63471. * @param name defines the block name
  63472. */
  63473. constructor(name: string);
  63474. /**
  63475. * Gets the current class name
  63476. * @returns the class name
  63477. */
  63478. getClassName(): string;
  63479. /**
  63480. * Gets the value input component
  63481. */
  63482. get value(): NodeMaterialConnectionPoint;
  63483. /**
  63484. * Gets the steps input component
  63485. */
  63486. get steps(): NodeMaterialConnectionPoint;
  63487. /**
  63488. * Gets the output component
  63489. */
  63490. get output(): NodeMaterialConnectionPoint;
  63491. protected _buildBlock(state: NodeMaterialBuildState): this;
  63492. }
  63493. }
  63494. declare module BABYLON {
  63495. /**
  63496. * Operations supported by the Wave block
  63497. */
  63498. export enum WaveBlockKind {
  63499. /** SawTooth */
  63500. SawTooth = 0,
  63501. /** Square */
  63502. Square = 1,
  63503. /** Triangle */
  63504. Triangle = 2
  63505. }
  63506. /**
  63507. * Block used to apply wave operation to floats
  63508. */
  63509. export class WaveBlock extends NodeMaterialBlock {
  63510. /**
  63511. * Gets or sets the kibnd of wave to be applied by the block
  63512. */
  63513. kind: WaveBlockKind;
  63514. /**
  63515. * Creates a new WaveBlock
  63516. * @param name defines the block name
  63517. */
  63518. constructor(name: string);
  63519. /**
  63520. * Gets the current class name
  63521. * @returns the class name
  63522. */
  63523. getClassName(): string;
  63524. /**
  63525. * Gets the input component
  63526. */
  63527. get input(): NodeMaterialConnectionPoint;
  63528. /**
  63529. * Gets the output component
  63530. */
  63531. get output(): NodeMaterialConnectionPoint;
  63532. protected _buildBlock(state: NodeMaterialBuildState): this;
  63533. serialize(): any;
  63534. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63535. }
  63536. }
  63537. declare module BABYLON {
  63538. /**
  63539. * Class used to store a color step for the GradientBlock
  63540. */
  63541. export class GradientBlockColorStep {
  63542. /**
  63543. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63544. */
  63545. step: number;
  63546. /**
  63547. * Gets or sets the color associated with this step
  63548. */
  63549. color: Color3;
  63550. /**
  63551. * Creates a new GradientBlockColorStep
  63552. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  63553. * @param color defines the color associated with this step
  63554. */
  63555. constructor(
  63556. /**
  63557. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63558. */
  63559. step: number,
  63560. /**
  63561. * Gets or sets the color associated with this step
  63562. */
  63563. color: Color3);
  63564. }
  63565. /**
  63566. * Block used to return a color from a gradient based on an input value between 0 and 1
  63567. */
  63568. export class GradientBlock extends NodeMaterialBlock {
  63569. /**
  63570. * Gets or sets the list of color steps
  63571. */
  63572. colorSteps: GradientBlockColorStep[];
  63573. /**
  63574. * Creates a new GradientBlock
  63575. * @param name defines the block name
  63576. */
  63577. constructor(name: string);
  63578. /**
  63579. * Gets the current class name
  63580. * @returns the class name
  63581. */
  63582. getClassName(): string;
  63583. /**
  63584. * Gets the gradient input component
  63585. */
  63586. get gradient(): NodeMaterialConnectionPoint;
  63587. /**
  63588. * Gets the output component
  63589. */
  63590. get output(): NodeMaterialConnectionPoint;
  63591. private _writeColorConstant;
  63592. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63593. serialize(): any;
  63594. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63595. protected _dumpPropertiesCode(): string;
  63596. }
  63597. }
  63598. declare module BABYLON {
  63599. /**
  63600. * Block used to normalize lerp between 2 values
  63601. */
  63602. export class NLerpBlock extends NodeMaterialBlock {
  63603. /**
  63604. * Creates a new NLerpBlock
  63605. * @param name defines the block name
  63606. */
  63607. constructor(name: string);
  63608. /**
  63609. * Gets the current class name
  63610. * @returns the class name
  63611. */
  63612. getClassName(): string;
  63613. /**
  63614. * Gets the left operand input component
  63615. */
  63616. get left(): NodeMaterialConnectionPoint;
  63617. /**
  63618. * Gets the right operand input component
  63619. */
  63620. get right(): NodeMaterialConnectionPoint;
  63621. /**
  63622. * Gets the gradient operand input component
  63623. */
  63624. get gradient(): NodeMaterialConnectionPoint;
  63625. /**
  63626. * Gets the output component
  63627. */
  63628. get output(): NodeMaterialConnectionPoint;
  63629. protected _buildBlock(state: NodeMaterialBuildState): this;
  63630. }
  63631. }
  63632. declare module BABYLON {
  63633. /**
  63634. * block used to Generate a Worley Noise 3D Noise Pattern
  63635. */
  63636. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  63637. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  63638. manhattanDistance: boolean;
  63639. /**
  63640. * Creates a new WorleyNoise3DBlock
  63641. * @param name defines the block name
  63642. */
  63643. constructor(name: string);
  63644. /**
  63645. * Gets the current class name
  63646. * @returns the class name
  63647. */
  63648. getClassName(): string;
  63649. /**
  63650. * Gets the seed input component
  63651. */
  63652. get seed(): NodeMaterialConnectionPoint;
  63653. /**
  63654. * Gets the jitter input component
  63655. */
  63656. get jitter(): NodeMaterialConnectionPoint;
  63657. /**
  63658. * Gets the output component
  63659. */
  63660. get output(): NodeMaterialConnectionPoint;
  63661. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63662. /**
  63663. * Exposes the properties to the UI?
  63664. */
  63665. protected _dumpPropertiesCode(): string;
  63666. /**
  63667. * Exposes the properties to the Seralize?
  63668. */
  63669. serialize(): any;
  63670. /**
  63671. * Exposes the properties to the deseralize?
  63672. */
  63673. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63674. }
  63675. }
  63676. declare module BABYLON {
  63677. /**
  63678. * block used to Generate a Simplex Perlin 3d Noise Pattern
  63679. */
  63680. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  63681. /**
  63682. * Creates a new SimplexPerlin3DBlock
  63683. * @param name defines the block name
  63684. */
  63685. constructor(name: string);
  63686. /**
  63687. * Gets the current class name
  63688. * @returns the class name
  63689. */
  63690. getClassName(): string;
  63691. /**
  63692. * Gets the seed operand input component
  63693. */
  63694. get seed(): NodeMaterialConnectionPoint;
  63695. /**
  63696. * Gets the output component
  63697. */
  63698. get output(): NodeMaterialConnectionPoint;
  63699. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63700. }
  63701. }
  63702. declare module BABYLON {
  63703. /**
  63704. * Block used to blend normals
  63705. */
  63706. export class NormalBlendBlock extends NodeMaterialBlock {
  63707. /**
  63708. * Creates a new NormalBlendBlock
  63709. * @param name defines the block name
  63710. */
  63711. constructor(name: string);
  63712. /**
  63713. * Gets the current class name
  63714. * @returns the class name
  63715. */
  63716. getClassName(): string;
  63717. /**
  63718. * Gets the first input component
  63719. */
  63720. get normalMap0(): NodeMaterialConnectionPoint;
  63721. /**
  63722. * Gets the second input component
  63723. */
  63724. get normalMap1(): NodeMaterialConnectionPoint;
  63725. /**
  63726. * Gets the output component
  63727. */
  63728. get output(): NodeMaterialConnectionPoint;
  63729. protected _buildBlock(state: NodeMaterialBuildState): this;
  63730. }
  63731. }
  63732. declare module BABYLON {
  63733. /**
  63734. * Block used to rotate a 2d vector by a given angle
  63735. */
  63736. export class Rotate2dBlock extends NodeMaterialBlock {
  63737. /**
  63738. * Creates a new Rotate2dBlock
  63739. * @param name defines the block name
  63740. */
  63741. constructor(name: string);
  63742. /**
  63743. * Gets the current class name
  63744. * @returns the class name
  63745. */
  63746. getClassName(): string;
  63747. /**
  63748. * Gets the input vector
  63749. */
  63750. get input(): NodeMaterialConnectionPoint;
  63751. /**
  63752. * Gets the input angle
  63753. */
  63754. get angle(): NodeMaterialConnectionPoint;
  63755. /**
  63756. * Gets the output component
  63757. */
  63758. get output(): NodeMaterialConnectionPoint;
  63759. autoConfigure(material: NodeMaterial): void;
  63760. protected _buildBlock(state: NodeMaterialBuildState): this;
  63761. }
  63762. }
  63763. declare module BABYLON {
  63764. /**
  63765. * Block used to get the reflected vector from a direction and a normal
  63766. */
  63767. export class ReflectBlock extends NodeMaterialBlock {
  63768. /**
  63769. * Creates a new ReflectBlock
  63770. * @param name defines the block name
  63771. */
  63772. constructor(name: string);
  63773. /**
  63774. * Gets the current class name
  63775. * @returns the class name
  63776. */
  63777. getClassName(): string;
  63778. /**
  63779. * Gets the incident component
  63780. */
  63781. get incident(): NodeMaterialConnectionPoint;
  63782. /**
  63783. * Gets the normal component
  63784. */
  63785. get normal(): NodeMaterialConnectionPoint;
  63786. /**
  63787. * Gets the output component
  63788. */
  63789. get output(): NodeMaterialConnectionPoint;
  63790. protected _buildBlock(state: NodeMaterialBuildState): this;
  63791. }
  63792. }
  63793. declare module BABYLON {
  63794. /**
  63795. * Block used to get the refracted vector from a direction and a normal
  63796. */
  63797. export class RefractBlock extends NodeMaterialBlock {
  63798. /**
  63799. * Creates a new RefractBlock
  63800. * @param name defines the block name
  63801. */
  63802. constructor(name: string);
  63803. /**
  63804. * Gets the current class name
  63805. * @returns the class name
  63806. */
  63807. getClassName(): string;
  63808. /**
  63809. * Gets the incident component
  63810. */
  63811. get incident(): NodeMaterialConnectionPoint;
  63812. /**
  63813. * Gets the normal component
  63814. */
  63815. get normal(): NodeMaterialConnectionPoint;
  63816. /**
  63817. * Gets the index of refraction component
  63818. */
  63819. get ior(): NodeMaterialConnectionPoint;
  63820. /**
  63821. * Gets the output component
  63822. */
  63823. get output(): NodeMaterialConnectionPoint;
  63824. protected _buildBlock(state: NodeMaterialBuildState): this;
  63825. }
  63826. }
  63827. declare module BABYLON {
  63828. /**
  63829. * Block used to desaturate a color
  63830. */
  63831. export class DesaturateBlock extends NodeMaterialBlock {
  63832. /**
  63833. * Creates a new DesaturateBlock
  63834. * @param name defines the block name
  63835. */
  63836. constructor(name: string);
  63837. /**
  63838. * Gets the current class name
  63839. * @returns the class name
  63840. */
  63841. getClassName(): string;
  63842. /**
  63843. * Gets the color operand input component
  63844. */
  63845. get color(): NodeMaterialConnectionPoint;
  63846. /**
  63847. * Gets the level operand input component
  63848. */
  63849. get level(): NodeMaterialConnectionPoint;
  63850. /**
  63851. * Gets the output component
  63852. */
  63853. get output(): NodeMaterialConnectionPoint;
  63854. protected _buildBlock(state: NodeMaterialBuildState): this;
  63855. }
  63856. }
  63857. declare module BABYLON {
  63858. /**
  63859. * Block used to implement the ambient occlusion module of the PBR material
  63860. */
  63861. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  63862. /**
  63863. * Create a new AmbientOcclusionBlock
  63864. * @param name defines the block name
  63865. */
  63866. constructor(name: string);
  63867. /**
  63868. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  63869. */
  63870. useAmbientInGrayScale: boolean;
  63871. /**
  63872. * Initialize the block and prepare the context for build
  63873. * @param state defines the state that will be used for the build
  63874. */
  63875. initialize(state: NodeMaterialBuildState): void;
  63876. /**
  63877. * Gets the current class name
  63878. * @returns the class name
  63879. */
  63880. getClassName(): string;
  63881. /**
  63882. * Gets the texture input component
  63883. */
  63884. get texture(): NodeMaterialConnectionPoint;
  63885. /**
  63886. * Gets the texture intensity component
  63887. */
  63888. get intensity(): NodeMaterialConnectionPoint;
  63889. /**
  63890. * Gets the direct light intensity input component
  63891. */
  63892. get directLightIntensity(): NodeMaterialConnectionPoint;
  63893. /**
  63894. * Gets the ambient occlusion object output component
  63895. */
  63896. get ambientOcclusion(): NodeMaterialConnectionPoint;
  63897. /**
  63898. * Gets the main code of the block (fragment side)
  63899. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  63900. * @returns the shader code
  63901. */
  63902. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  63903. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63904. protected _buildBlock(state: NodeMaterialBuildState): this;
  63905. protected _dumpPropertiesCode(): string;
  63906. serialize(): any;
  63907. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63908. }
  63909. }
  63910. declare module BABYLON {
  63911. /**
  63912. * Block used to implement the reflection module of the PBR material
  63913. */
  63914. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  63915. /** @hidden */
  63916. _defineLODReflectionAlpha: string;
  63917. /** @hidden */
  63918. _defineLinearSpecularReflection: string;
  63919. private _vEnvironmentIrradianceName;
  63920. /** @hidden */
  63921. _vReflectionMicrosurfaceInfosName: string;
  63922. /** @hidden */
  63923. _vReflectionInfosName: string;
  63924. /** @hidden */
  63925. _vReflectionFilteringInfoName: string;
  63926. private _scene;
  63927. /**
  63928. * The three properties below are set by the main PBR block prior to calling methods of this class.
  63929. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  63930. * It's less burden on the user side in the editor part.
  63931. */
  63932. /** @hidden */
  63933. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  63934. /** @hidden */
  63935. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  63936. /** @hidden */
  63937. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  63938. /**
  63939. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  63940. * diffuse part of the IBL.
  63941. */
  63942. useSphericalHarmonics: boolean;
  63943. /**
  63944. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  63945. */
  63946. forceIrradianceInFragment: boolean;
  63947. /**
  63948. * Create a new ReflectionBlock
  63949. * @param name defines the block name
  63950. */
  63951. constructor(name: string);
  63952. /**
  63953. * Gets the current class name
  63954. * @returns the class name
  63955. */
  63956. getClassName(): string;
  63957. /**
  63958. * Gets the position input component
  63959. */
  63960. get position(): NodeMaterialConnectionPoint;
  63961. /**
  63962. * Gets the world position input component
  63963. */
  63964. get worldPosition(): NodeMaterialConnectionPoint;
  63965. /**
  63966. * Gets the world normal input component
  63967. */
  63968. get worldNormal(): NodeMaterialConnectionPoint;
  63969. /**
  63970. * Gets the world input component
  63971. */
  63972. get world(): NodeMaterialConnectionPoint;
  63973. /**
  63974. * Gets the camera (or eye) position component
  63975. */
  63976. get cameraPosition(): NodeMaterialConnectionPoint;
  63977. /**
  63978. * Gets the view input component
  63979. */
  63980. get view(): NodeMaterialConnectionPoint;
  63981. /**
  63982. * Gets the color input component
  63983. */
  63984. get color(): NodeMaterialConnectionPoint;
  63985. /**
  63986. * Gets the reflection object output component
  63987. */
  63988. get reflection(): NodeMaterialConnectionPoint;
  63989. /**
  63990. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  63991. */
  63992. get hasTexture(): boolean;
  63993. /**
  63994. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  63995. */
  63996. get reflectionColor(): string;
  63997. protected _getTexture(): Nullable<BaseTexture>;
  63998. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63999. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64000. /**
  64001. * Gets the code to inject in the vertex shader
  64002. * @param state current state of the node material building
  64003. * @returns the shader code
  64004. */
  64005. handleVertexSide(state: NodeMaterialBuildState): string;
  64006. /**
  64007. * Gets the main code of the block (fragment side)
  64008. * @param state current state of the node material building
  64009. * @param normalVarName name of the existing variable corresponding to the normal
  64010. * @returns the shader code
  64011. */
  64012. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  64013. protected _buildBlock(state: NodeMaterialBuildState): this;
  64014. protected _dumpPropertiesCode(): string;
  64015. serialize(): any;
  64016. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64017. }
  64018. }
  64019. declare module BABYLON {
  64020. /**
  64021. * Block used to implement the sheen module of the PBR material
  64022. */
  64023. export class SheenBlock extends NodeMaterialBlock {
  64024. /**
  64025. * Create a new SheenBlock
  64026. * @param name defines the block name
  64027. */
  64028. constructor(name: string);
  64029. /**
  64030. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  64031. * It allows the strength of the sheen effect to not depend on the base color of the material,
  64032. * making it easier to setup and tweak the effect
  64033. */
  64034. albedoScaling: boolean;
  64035. /**
  64036. * Defines if the sheen is linked to the sheen color.
  64037. */
  64038. linkSheenWithAlbedo: boolean;
  64039. /**
  64040. * Initialize the block and prepare the context for build
  64041. * @param state defines the state that will be used for the build
  64042. */
  64043. initialize(state: NodeMaterialBuildState): void;
  64044. /**
  64045. * Gets the current class name
  64046. * @returns the class name
  64047. */
  64048. getClassName(): string;
  64049. /**
  64050. * Gets the intensity input component
  64051. */
  64052. get intensity(): NodeMaterialConnectionPoint;
  64053. /**
  64054. * Gets the color input component
  64055. */
  64056. get color(): NodeMaterialConnectionPoint;
  64057. /**
  64058. * Gets the roughness input component
  64059. */
  64060. get roughness(): NodeMaterialConnectionPoint;
  64061. /**
  64062. * Gets the sheen object output component
  64063. */
  64064. get sheen(): NodeMaterialConnectionPoint;
  64065. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64066. /**
  64067. * Gets the main code of the block (fragment side)
  64068. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64069. * @returns the shader code
  64070. */
  64071. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  64072. protected _buildBlock(state: NodeMaterialBuildState): this;
  64073. protected _dumpPropertiesCode(): string;
  64074. serialize(): any;
  64075. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64076. }
  64077. }
  64078. declare module BABYLON {
  64079. /**
  64080. * Block used to implement the reflectivity module of the PBR material
  64081. */
  64082. export class ReflectivityBlock extends NodeMaterialBlock {
  64083. private _metallicReflectanceColor;
  64084. private _metallicF0Factor;
  64085. /** @hidden */
  64086. _vMetallicReflectanceFactorsName: string;
  64087. /**
  64088. * The property below is set by the main PBR block prior to calling methods of this class.
  64089. */
  64090. /** @hidden */
  64091. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  64092. /**
  64093. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  64094. */
  64095. useAmbientOcclusionFromMetallicTextureRed: boolean;
  64096. /**
  64097. * Specifies if the metallic texture contains the metallness information in its blue channel.
  64098. */
  64099. useMetallnessFromMetallicTextureBlue: boolean;
  64100. /**
  64101. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  64102. */
  64103. useRoughnessFromMetallicTextureAlpha: boolean;
  64104. /**
  64105. * Specifies if the metallic texture contains the roughness information in its green channel.
  64106. */
  64107. useRoughnessFromMetallicTextureGreen: boolean;
  64108. /**
  64109. * Create a new ReflectivityBlock
  64110. * @param name defines the block name
  64111. */
  64112. constructor(name: string);
  64113. /**
  64114. * Initialize the block and prepare the context for build
  64115. * @param state defines the state that will be used for the build
  64116. */
  64117. initialize(state: NodeMaterialBuildState): void;
  64118. /**
  64119. * Gets the current class name
  64120. * @returns the class name
  64121. */
  64122. getClassName(): string;
  64123. /**
  64124. * Gets the metallic input component
  64125. */
  64126. get metallic(): NodeMaterialConnectionPoint;
  64127. /**
  64128. * Gets the roughness input component
  64129. */
  64130. get roughness(): NodeMaterialConnectionPoint;
  64131. /**
  64132. * Gets the texture input component
  64133. */
  64134. get texture(): NodeMaterialConnectionPoint;
  64135. /**
  64136. * Gets the reflectivity object output component
  64137. */
  64138. get reflectivity(): NodeMaterialConnectionPoint;
  64139. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64140. /**
  64141. * Gets the main code of the block (fragment side)
  64142. * @param state current state of the node material building
  64143. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  64144. * @returns the shader code
  64145. */
  64146. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  64147. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64148. protected _buildBlock(state: NodeMaterialBuildState): this;
  64149. protected _dumpPropertiesCode(): string;
  64150. serialize(): any;
  64151. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64152. }
  64153. }
  64154. declare module BABYLON {
  64155. /**
  64156. * Block used to implement the anisotropy module of the PBR material
  64157. */
  64158. export class AnisotropyBlock extends NodeMaterialBlock {
  64159. /**
  64160. * The two properties below are set by the main PBR block prior to calling methods of this class.
  64161. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64162. * It's less burden on the user side in the editor part.
  64163. */
  64164. /** @hidden */
  64165. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64166. /** @hidden */
  64167. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64168. /**
  64169. * Create a new AnisotropyBlock
  64170. * @param name defines the block name
  64171. */
  64172. constructor(name: string);
  64173. /**
  64174. * Initialize the block and prepare the context for build
  64175. * @param state defines the state that will be used for the build
  64176. */
  64177. initialize(state: NodeMaterialBuildState): void;
  64178. /**
  64179. * Gets the current class name
  64180. * @returns the class name
  64181. */
  64182. getClassName(): string;
  64183. /**
  64184. * Gets the intensity input component
  64185. */
  64186. get intensity(): NodeMaterialConnectionPoint;
  64187. /**
  64188. * Gets the direction input component
  64189. */
  64190. get direction(): NodeMaterialConnectionPoint;
  64191. /**
  64192. * Gets the texture input component
  64193. */
  64194. get texture(): NodeMaterialConnectionPoint;
  64195. /**
  64196. * Gets the uv input component
  64197. */
  64198. get uv(): NodeMaterialConnectionPoint;
  64199. /**
  64200. * Gets the worldTangent input component
  64201. */
  64202. get worldTangent(): NodeMaterialConnectionPoint;
  64203. /**
  64204. * Gets the anisotropy object output component
  64205. */
  64206. get anisotropy(): NodeMaterialConnectionPoint;
  64207. private _generateTBNSpace;
  64208. /**
  64209. * Gets the main code of the block (fragment side)
  64210. * @param state current state of the node material building
  64211. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64212. * @returns the shader code
  64213. */
  64214. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  64215. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64216. protected _buildBlock(state: NodeMaterialBuildState): this;
  64217. }
  64218. }
  64219. declare module BABYLON {
  64220. /**
  64221. * Block used to implement the clear coat module of the PBR material
  64222. */
  64223. export class ClearCoatBlock extends NodeMaterialBlock {
  64224. private _scene;
  64225. /**
  64226. * Create a new ClearCoatBlock
  64227. * @param name defines the block name
  64228. */
  64229. constructor(name: string);
  64230. /**
  64231. * Initialize the block and prepare the context for build
  64232. * @param state defines the state that will be used for the build
  64233. */
  64234. initialize(state: NodeMaterialBuildState): void;
  64235. /**
  64236. * Gets the current class name
  64237. * @returns the class name
  64238. */
  64239. getClassName(): string;
  64240. /**
  64241. * Gets the intensity input component
  64242. */
  64243. get intensity(): NodeMaterialConnectionPoint;
  64244. /**
  64245. * Gets the roughness input component
  64246. */
  64247. get roughness(): NodeMaterialConnectionPoint;
  64248. /**
  64249. * Gets the ior input component
  64250. */
  64251. get ior(): NodeMaterialConnectionPoint;
  64252. /**
  64253. * Gets the texture input component
  64254. */
  64255. get texture(): NodeMaterialConnectionPoint;
  64256. /**
  64257. * Gets the bump texture input component
  64258. */
  64259. get bumpTexture(): NodeMaterialConnectionPoint;
  64260. /**
  64261. * Gets the uv input component
  64262. */
  64263. get uv(): NodeMaterialConnectionPoint;
  64264. /**
  64265. * Gets the tint color input component
  64266. */
  64267. get tintColor(): NodeMaterialConnectionPoint;
  64268. /**
  64269. * Gets the tint "at distance" input component
  64270. */
  64271. get tintAtDistance(): NodeMaterialConnectionPoint;
  64272. /**
  64273. * Gets the tint thickness input component
  64274. */
  64275. get tintThickness(): NodeMaterialConnectionPoint;
  64276. /**
  64277. * Gets the world tangent input component
  64278. */
  64279. get worldTangent(): NodeMaterialConnectionPoint;
  64280. /**
  64281. * Gets the clear coat object output component
  64282. */
  64283. get clearcoat(): NodeMaterialConnectionPoint;
  64284. autoConfigure(material: NodeMaterial): void;
  64285. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64286. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64287. private _generateTBNSpace;
  64288. /**
  64289. * Gets the main code of the block (fragment side)
  64290. * @param state current state of the node material building
  64291. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  64292. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64293. * @param worldPosVarName name of the variable holding the world position
  64294. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64295. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  64296. * @param worldNormalVarName name of the variable holding the world normal
  64297. * @returns the shader code
  64298. */
  64299. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  64300. protected _buildBlock(state: NodeMaterialBuildState): this;
  64301. }
  64302. }
  64303. declare module BABYLON {
  64304. /**
  64305. * Block used to implement the sub surface module of the PBR material
  64306. */
  64307. export class SubSurfaceBlock extends NodeMaterialBlock {
  64308. /**
  64309. * Create a new SubSurfaceBlock
  64310. * @param name defines the block name
  64311. */
  64312. constructor(name: string);
  64313. /**
  64314. * Stores the intensity of the different subsurface effects in the thickness texture.
  64315. * * the green channel is the translucency intensity.
  64316. * * the blue channel is the scattering intensity.
  64317. * * the alpha channel is the refraction intensity.
  64318. */
  64319. useMaskFromThicknessTexture: boolean;
  64320. /**
  64321. * Initialize the block and prepare the context for build
  64322. * @param state defines the state that will be used for the build
  64323. */
  64324. initialize(state: NodeMaterialBuildState): void;
  64325. /**
  64326. * Gets the current class name
  64327. * @returns the class name
  64328. */
  64329. getClassName(): string;
  64330. /**
  64331. * Gets the min thickness input component
  64332. */
  64333. get minThickness(): NodeMaterialConnectionPoint;
  64334. /**
  64335. * Gets the max thickness input component
  64336. */
  64337. get maxThickness(): NodeMaterialConnectionPoint;
  64338. /**
  64339. * Gets the thickness texture component
  64340. */
  64341. get thicknessTexture(): NodeMaterialConnectionPoint;
  64342. /**
  64343. * Gets the tint color input component
  64344. */
  64345. get tintColor(): NodeMaterialConnectionPoint;
  64346. /**
  64347. * Gets the translucency intensity input component
  64348. */
  64349. get translucencyIntensity(): NodeMaterialConnectionPoint;
  64350. /**
  64351. * Gets the translucency diffusion distance input component
  64352. */
  64353. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  64354. /**
  64355. * Gets the refraction object parameters
  64356. */
  64357. get refraction(): NodeMaterialConnectionPoint;
  64358. /**
  64359. * Gets the sub surface object output component
  64360. */
  64361. get subsurface(): NodeMaterialConnectionPoint;
  64362. autoConfigure(material: NodeMaterial): void;
  64363. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64364. /**
  64365. * Gets the main code of the block (fragment side)
  64366. * @param state current state of the node material building
  64367. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  64368. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64369. * @param worldPosVarName name of the variable holding the world position
  64370. * @returns the shader code
  64371. */
  64372. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  64373. protected _buildBlock(state: NodeMaterialBuildState): this;
  64374. }
  64375. }
  64376. declare module BABYLON {
  64377. /**
  64378. * Block used to implement the PBR metallic/roughness model
  64379. */
  64380. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  64381. /**
  64382. * Gets or sets the light associated with this block
  64383. */
  64384. light: Nullable<Light>;
  64385. private _lightId;
  64386. private _scene;
  64387. private _environmentBRDFTexture;
  64388. private _environmentBrdfSamplerName;
  64389. private _vNormalWName;
  64390. private _invertNormalName;
  64391. /**
  64392. * Create a new ReflectionBlock
  64393. * @param name defines the block name
  64394. */
  64395. constructor(name: string);
  64396. /**
  64397. * Intensity of the direct lights e.g. the four lights available in your scene.
  64398. * This impacts both the direct diffuse and specular highlights.
  64399. */
  64400. directIntensity: number;
  64401. /**
  64402. * Intensity of the environment e.g. how much the environment will light the object
  64403. * either through harmonics for rough material or through the refelction for shiny ones.
  64404. */
  64405. environmentIntensity: number;
  64406. /**
  64407. * This is a special control allowing the reduction of the specular highlights coming from the
  64408. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  64409. */
  64410. specularIntensity: number;
  64411. /**
  64412. * Defines the falloff type used in this material.
  64413. * It by default is Physical.
  64414. */
  64415. lightFalloff: number;
  64416. /**
  64417. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  64418. */
  64419. useAlphaFromAlbedoTexture: boolean;
  64420. /**
  64421. * Specifies that alpha test should be used
  64422. */
  64423. useAlphaTest: boolean;
  64424. /**
  64425. * Defines the alpha limits in alpha test mode.
  64426. */
  64427. alphaTestCutoff: number;
  64428. /**
  64429. * Specifies that alpha blending should be used
  64430. */
  64431. useAlphaBlending: boolean;
  64432. /**
  64433. * Defines if the alpha value should be determined via the rgb values.
  64434. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  64435. */
  64436. opacityRGB: boolean;
  64437. /**
  64438. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  64439. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  64440. */
  64441. useRadianceOverAlpha: boolean;
  64442. /**
  64443. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  64444. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  64445. */
  64446. useSpecularOverAlpha: boolean;
  64447. /**
  64448. * Enables specular anti aliasing in the PBR shader.
  64449. * It will both interacts on the Geometry for analytical and IBL lighting.
  64450. * It also prefilter the roughness map based on the bump values.
  64451. */
  64452. enableSpecularAntiAliasing: boolean;
  64453. /**
  64454. * Enables realtime filtering on the texture.
  64455. */
  64456. realTimeFiltering: boolean;
  64457. /**
  64458. * Quality switch for realtime filtering
  64459. */
  64460. realTimeFilteringQuality: number;
  64461. /**
  64462. * Defines if the material uses energy conservation.
  64463. */
  64464. useEnergyConservation: boolean;
  64465. /**
  64466. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  64467. * too much the area relying on ambient texture to define their ambient occlusion.
  64468. */
  64469. useRadianceOcclusion: boolean;
  64470. /**
  64471. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  64472. * makes the reflect vector face the model (under horizon).
  64473. */
  64474. useHorizonOcclusion: boolean;
  64475. /**
  64476. * If set to true, no lighting calculations will be applied.
  64477. */
  64478. unlit: boolean;
  64479. /**
  64480. * Force normal to face away from face.
  64481. */
  64482. forceNormalForward: boolean;
  64483. /**
  64484. * Defines the material debug mode.
  64485. * It helps seeing only some components of the material while troubleshooting.
  64486. */
  64487. debugMode: number;
  64488. /**
  64489. * Specify from where on screen the debug mode should start.
  64490. * The value goes from -1 (full screen) to 1 (not visible)
  64491. * It helps with side by side comparison against the final render
  64492. * This defaults to 0
  64493. */
  64494. debugLimit: number;
  64495. /**
  64496. * As the default viewing range might not be enough (if the ambient is really small for instance)
  64497. * You can use the factor to better multiply the final value.
  64498. */
  64499. debugFactor: number;
  64500. /**
  64501. * Initialize the block and prepare the context for build
  64502. * @param state defines the state that will be used for the build
  64503. */
  64504. initialize(state: NodeMaterialBuildState): void;
  64505. /**
  64506. * Gets the current class name
  64507. * @returns the class name
  64508. */
  64509. getClassName(): string;
  64510. /**
  64511. * Gets the world position input component
  64512. */
  64513. get worldPosition(): NodeMaterialConnectionPoint;
  64514. /**
  64515. * Gets the world normal input component
  64516. */
  64517. get worldNormal(): NodeMaterialConnectionPoint;
  64518. /**
  64519. * Gets the perturbed normal input component
  64520. */
  64521. get perturbedNormal(): NodeMaterialConnectionPoint;
  64522. /**
  64523. * Gets the camera position input component
  64524. */
  64525. get cameraPosition(): NodeMaterialConnectionPoint;
  64526. /**
  64527. * Gets the base color input component
  64528. */
  64529. get baseColor(): NodeMaterialConnectionPoint;
  64530. /**
  64531. * Gets the opacity texture input component
  64532. */
  64533. get opacityTexture(): NodeMaterialConnectionPoint;
  64534. /**
  64535. * Gets the ambient color input component
  64536. */
  64537. get ambientColor(): NodeMaterialConnectionPoint;
  64538. /**
  64539. * Gets the reflectivity object parameters
  64540. */
  64541. get reflectivity(): NodeMaterialConnectionPoint;
  64542. /**
  64543. * Gets the ambient occlusion object parameters
  64544. */
  64545. get ambientOcclusion(): NodeMaterialConnectionPoint;
  64546. /**
  64547. * Gets the reflection object parameters
  64548. */
  64549. get reflection(): NodeMaterialConnectionPoint;
  64550. /**
  64551. * Gets the sheen object parameters
  64552. */
  64553. get sheen(): NodeMaterialConnectionPoint;
  64554. /**
  64555. * Gets the clear coat object parameters
  64556. */
  64557. get clearcoat(): NodeMaterialConnectionPoint;
  64558. /**
  64559. * Gets the sub surface object parameters
  64560. */
  64561. get subsurface(): NodeMaterialConnectionPoint;
  64562. /**
  64563. * Gets the anisotropy object parameters
  64564. */
  64565. get anisotropy(): NodeMaterialConnectionPoint;
  64566. /**
  64567. * Gets the ambient output component
  64568. */
  64569. get ambient(): NodeMaterialConnectionPoint;
  64570. /**
  64571. * Gets the diffuse output component
  64572. */
  64573. get diffuse(): NodeMaterialConnectionPoint;
  64574. /**
  64575. * Gets the specular output component
  64576. */
  64577. get specular(): NodeMaterialConnectionPoint;
  64578. /**
  64579. * Gets the sheen output component
  64580. */
  64581. get sheenDir(): NodeMaterialConnectionPoint;
  64582. /**
  64583. * Gets the clear coat output component
  64584. */
  64585. get clearcoatDir(): NodeMaterialConnectionPoint;
  64586. /**
  64587. * Gets the indirect diffuse output component
  64588. */
  64589. get diffuseIndirect(): NodeMaterialConnectionPoint;
  64590. /**
  64591. * Gets the indirect specular output component
  64592. */
  64593. get specularIndirect(): NodeMaterialConnectionPoint;
  64594. /**
  64595. * Gets the indirect sheen output component
  64596. */
  64597. get sheenIndirect(): NodeMaterialConnectionPoint;
  64598. /**
  64599. * Gets the indirect clear coat output component
  64600. */
  64601. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  64602. /**
  64603. * Gets the refraction output component
  64604. */
  64605. get refraction(): NodeMaterialConnectionPoint;
  64606. /**
  64607. * Gets the global lighting output component
  64608. */
  64609. get lighting(): NodeMaterialConnectionPoint;
  64610. /**
  64611. * Gets the shadow output component
  64612. */
  64613. get shadow(): NodeMaterialConnectionPoint;
  64614. /**
  64615. * Gets the alpha output component
  64616. */
  64617. get alpha(): NodeMaterialConnectionPoint;
  64618. autoConfigure(material: NodeMaterial): void;
  64619. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64620. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  64621. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64622. private _injectVertexCode;
  64623. /**
  64624. * Gets the code corresponding to the albedo/opacity module
  64625. * @returns the shader code
  64626. */
  64627. getAlbedoOpacityCode(): string;
  64628. protected _buildBlock(state: NodeMaterialBuildState): this;
  64629. protected _dumpPropertiesCode(): string;
  64630. serialize(): any;
  64631. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64632. }
  64633. }
  64634. declare module BABYLON {
  64635. /**
  64636. * Block used to compute value of one parameter modulo another
  64637. */
  64638. export class ModBlock extends NodeMaterialBlock {
  64639. /**
  64640. * Creates a new ModBlock
  64641. * @param name defines the block name
  64642. */
  64643. constructor(name: string);
  64644. /**
  64645. * Gets the current class name
  64646. * @returns the class name
  64647. */
  64648. getClassName(): string;
  64649. /**
  64650. * Gets the left operand input component
  64651. */
  64652. get left(): NodeMaterialConnectionPoint;
  64653. /**
  64654. * Gets the right operand input component
  64655. */
  64656. get right(): NodeMaterialConnectionPoint;
  64657. /**
  64658. * Gets the output component
  64659. */
  64660. get output(): NodeMaterialConnectionPoint;
  64661. protected _buildBlock(state: NodeMaterialBuildState): this;
  64662. }
  64663. }
  64664. declare module BABYLON {
  64665. /**
  64666. * Helper class to push actions to a pool of workers.
  64667. */
  64668. export class WorkerPool implements IDisposable {
  64669. private _workerInfos;
  64670. private _pendingActions;
  64671. /**
  64672. * Constructor
  64673. * @param workers Array of workers to use for actions
  64674. */
  64675. constructor(workers: Array<Worker>);
  64676. /**
  64677. * Terminates all workers and clears any pending actions.
  64678. */
  64679. dispose(): void;
  64680. /**
  64681. * Pushes an action to the worker pool. If all the workers are active, the action will be
  64682. * pended until a worker has completed its action.
  64683. * @param action The action to perform. Call onComplete when the action is complete.
  64684. */
  64685. push(action: (worker: Worker, onComplete: () => void) => void): void;
  64686. private _execute;
  64687. }
  64688. }
  64689. declare module BABYLON {
  64690. /**
  64691. * Configuration for Draco compression
  64692. */
  64693. export interface IDracoCompressionConfiguration {
  64694. /**
  64695. * Configuration for the decoder.
  64696. */
  64697. decoder: {
  64698. /**
  64699. * The url to the WebAssembly module.
  64700. */
  64701. wasmUrl?: string;
  64702. /**
  64703. * The url to the WebAssembly binary.
  64704. */
  64705. wasmBinaryUrl?: string;
  64706. /**
  64707. * The url to the fallback JavaScript module.
  64708. */
  64709. fallbackUrl?: string;
  64710. };
  64711. }
  64712. /**
  64713. * Draco compression (https://google.github.io/draco/)
  64714. *
  64715. * This class wraps the Draco module.
  64716. *
  64717. * **Encoder**
  64718. *
  64719. * The encoder is not currently implemented.
  64720. *
  64721. * **Decoder**
  64722. *
  64723. * 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.
  64724. *
  64725. * To update the configuration, use the following code:
  64726. * ```javascript
  64727. * DracoCompression.Configuration = {
  64728. * decoder: {
  64729. * wasmUrl: "<url to the WebAssembly library>",
  64730. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  64731. * fallbackUrl: "<url to the fallback JavaScript library>",
  64732. * }
  64733. * };
  64734. * ```
  64735. *
  64736. * 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.
  64737. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  64738. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  64739. *
  64740. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  64741. * ```javascript
  64742. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  64743. * ```
  64744. *
  64745. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  64746. */
  64747. export class DracoCompression implements IDisposable {
  64748. private _workerPoolPromise?;
  64749. private _decoderModulePromise?;
  64750. /**
  64751. * The configuration. Defaults to the following urls:
  64752. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  64753. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  64754. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  64755. */
  64756. static Configuration: IDracoCompressionConfiguration;
  64757. /**
  64758. * Returns true if the decoder configuration is available.
  64759. */
  64760. static get DecoderAvailable(): boolean;
  64761. /**
  64762. * Default number of workers to create when creating the draco compression object.
  64763. */
  64764. static DefaultNumWorkers: number;
  64765. private static GetDefaultNumWorkers;
  64766. private static _Default;
  64767. /**
  64768. * Default instance for the draco compression object.
  64769. */
  64770. static get Default(): DracoCompression;
  64771. /**
  64772. * Constructor
  64773. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  64774. */
  64775. constructor(numWorkers?: number);
  64776. /**
  64777. * Stop all async operations and release resources.
  64778. */
  64779. dispose(): void;
  64780. /**
  64781. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  64782. * @returns a promise that resolves when ready
  64783. */
  64784. whenReadyAsync(): Promise<void>;
  64785. /**
  64786. * Decode Draco compressed mesh data to vertex data.
  64787. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  64788. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  64789. * @returns A promise that resolves with the decoded vertex data
  64790. */
  64791. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  64792. [kind: string]: number;
  64793. }): Promise<VertexData>;
  64794. }
  64795. }
  64796. declare module BABYLON {
  64797. /**
  64798. * Class for building Constructive Solid Geometry
  64799. */
  64800. export class CSG {
  64801. private polygons;
  64802. /**
  64803. * The world matrix
  64804. */
  64805. matrix: Matrix;
  64806. /**
  64807. * Stores the position
  64808. */
  64809. position: Vector3;
  64810. /**
  64811. * Stores the rotation
  64812. */
  64813. rotation: Vector3;
  64814. /**
  64815. * Stores the rotation quaternion
  64816. */
  64817. rotationQuaternion: Nullable<Quaternion>;
  64818. /**
  64819. * Stores the scaling vector
  64820. */
  64821. scaling: Vector3;
  64822. /**
  64823. * Convert the Mesh to CSG
  64824. * @param mesh The Mesh to convert to CSG
  64825. * @returns A new CSG from the Mesh
  64826. */
  64827. static FromMesh(mesh: Mesh): CSG;
  64828. /**
  64829. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  64830. * @param polygons Polygons used to construct a CSG solid
  64831. */
  64832. private static FromPolygons;
  64833. /**
  64834. * Clones, or makes a deep copy, of the CSG
  64835. * @returns A new CSG
  64836. */
  64837. clone(): CSG;
  64838. /**
  64839. * Unions this CSG with another CSG
  64840. * @param csg The CSG to union against this CSG
  64841. * @returns The unioned CSG
  64842. */
  64843. union(csg: CSG): CSG;
  64844. /**
  64845. * Unions this CSG with another CSG in place
  64846. * @param csg The CSG to union against this CSG
  64847. */
  64848. unionInPlace(csg: CSG): void;
  64849. /**
  64850. * Subtracts this CSG with another CSG
  64851. * @param csg The CSG to subtract against this CSG
  64852. * @returns A new CSG
  64853. */
  64854. subtract(csg: CSG): CSG;
  64855. /**
  64856. * Subtracts this CSG with another CSG in place
  64857. * @param csg The CSG to subtact against this CSG
  64858. */
  64859. subtractInPlace(csg: CSG): void;
  64860. /**
  64861. * Intersect this CSG with another CSG
  64862. * @param csg The CSG to intersect against this CSG
  64863. * @returns A new CSG
  64864. */
  64865. intersect(csg: CSG): CSG;
  64866. /**
  64867. * Intersects this CSG with another CSG in place
  64868. * @param csg The CSG to intersect against this CSG
  64869. */
  64870. intersectInPlace(csg: CSG): void;
  64871. /**
  64872. * Return a new CSG solid with solid and empty space switched. This solid is
  64873. * not modified.
  64874. * @returns A new CSG solid with solid and empty space switched
  64875. */
  64876. inverse(): CSG;
  64877. /**
  64878. * Inverses the CSG in place
  64879. */
  64880. inverseInPlace(): void;
  64881. /**
  64882. * This is used to keep meshes transformations so they can be restored
  64883. * when we build back a Babylon Mesh
  64884. * NB : All CSG operations are performed in world coordinates
  64885. * @param csg The CSG to copy the transform attributes from
  64886. * @returns This CSG
  64887. */
  64888. copyTransformAttributes(csg: CSG): CSG;
  64889. /**
  64890. * Build Raw mesh from CSG
  64891. * Coordinates here are in world space
  64892. * @param name The name of the mesh geometry
  64893. * @param scene The Scene
  64894. * @param keepSubMeshes Specifies if the submeshes should be kept
  64895. * @returns A new Mesh
  64896. */
  64897. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64898. /**
  64899. * Build Mesh from CSG taking material and transforms into account
  64900. * @param name The name of the Mesh
  64901. * @param material The material of the Mesh
  64902. * @param scene The Scene
  64903. * @param keepSubMeshes Specifies if submeshes should be kept
  64904. * @returns The new Mesh
  64905. */
  64906. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64907. }
  64908. }
  64909. declare module BABYLON {
  64910. /**
  64911. * Class used to create a trail following a mesh
  64912. */
  64913. export class TrailMesh extends Mesh {
  64914. private _generator;
  64915. private _autoStart;
  64916. private _running;
  64917. private _diameter;
  64918. private _length;
  64919. private _sectionPolygonPointsCount;
  64920. private _sectionVectors;
  64921. private _sectionNormalVectors;
  64922. private _beforeRenderObserver;
  64923. /**
  64924. * @constructor
  64925. * @param name The value used by scene.getMeshByName() to do a lookup.
  64926. * @param generator The mesh or transform node to generate a trail.
  64927. * @param scene The scene to add this mesh to.
  64928. * @param diameter Diameter of trailing mesh. Default is 1.
  64929. * @param length Length of trailing mesh. Default is 60.
  64930. * @param autoStart Automatically start trailing mesh. Default true.
  64931. */
  64932. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  64933. /**
  64934. * "TrailMesh"
  64935. * @returns "TrailMesh"
  64936. */
  64937. getClassName(): string;
  64938. private _createMesh;
  64939. /**
  64940. * Start trailing mesh.
  64941. */
  64942. start(): void;
  64943. /**
  64944. * Stop trailing mesh.
  64945. */
  64946. stop(): void;
  64947. /**
  64948. * Update trailing mesh geometry.
  64949. */
  64950. update(): void;
  64951. /**
  64952. * Returns a new TrailMesh object.
  64953. * @param name is a string, the name given to the new mesh
  64954. * @param newGenerator use new generator object for cloned trail mesh
  64955. * @returns a new mesh
  64956. */
  64957. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  64958. /**
  64959. * Serializes this trail mesh
  64960. * @param serializationObject object to write serialization to
  64961. */
  64962. serialize(serializationObject: any): void;
  64963. /**
  64964. * Parses a serialized trail mesh
  64965. * @param parsedMesh the serialized mesh
  64966. * @param scene the scene to create the trail mesh in
  64967. * @returns the created trail mesh
  64968. */
  64969. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  64970. }
  64971. }
  64972. declare module BABYLON {
  64973. /**
  64974. * Class containing static functions to help procedurally build meshes
  64975. */
  64976. export class TiledBoxBuilder {
  64977. /**
  64978. * Creates a box mesh
  64979. * 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)
  64980. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64981. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64982. * * 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
  64983. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64984. * @param name defines the name of the mesh
  64985. * @param options defines the options used to create the mesh
  64986. * @param scene defines the hosting scene
  64987. * @returns the box mesh
  64988. */
  64989. static CreateTiledBox(name: string, options: {
  64990. pattern?: number;
  64991. width?: number;
  64992. height?: number;
  64993. depth?: number;
  64994. tileSize?: number;
  64995. tileWidth?: number;
  64996. tileHeight?: number;
  64997. alignHorizontal?: number;
  64998. alignVertical?: number;
  64999. faceUV?: Vector4[];
  65000. faceColors?: Color4[];
  65001. sideOrientation?: number;
  65002. updatable?: boolean;
  65003. }, scene?: Nullable<Scene>): Mesh;
  65004. }
  65005. }
  65006. declare module BABYLON {
  65007. /**
  65008. * Class containing static functions to help procedurally build meshes
  65009. */
  65010. export class TorusKnotBuilder {
  65011. /**
  65012. * Creates a torus knot mesh
  65013. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  65014. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  65015. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  65016. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  65017. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65018. * * 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
  65019. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65020. * @param name defines the name of the mesh
  65021. * @param options defines the options used to create the mesh
  65022. * @param scene defines the hosting scene
  65023. * @returns the torus knot mesh
  65024. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  65025. */
  65026. static CreateTorusKnot(name: string, options: {
  65027. radius?: number;
  65028. tube?: number;
  65029. radialSegments?: number;
  65030. tubularSegments?: number;
  65031. p?: number;
  65032. q?: number;
  65033. updatable?: boolean;
  65034. sideOrientation?: number;
  65035. frontUVs?: Vector4;
  65036. backUVs?: Vector4;
  65037. }, scene: any): Mesh;
  65038. }
  65039. }
  65040. declare module BABYLON {
  65041. /**
  65042. * Polygon
  65043. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  65044. */
  65045. export class Polygon {
  65046. /**
  65047. * Creates a rectangle
  65048. * @param xmin bottom X coord
  65049. * @param ymin bottom Y coord
  65050. * @param xmax top X coord
  65051. * @param ymax top Y coord
  65052. * @returns points that make the resulting rectation
  65053. */
  65054. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  65055. /**
  65056. * Creates a circle
  65057. * @param radius radius of circle
  65058. * @param cx scale in x
  65059. * @param cy scale in y
  65060. * @param numberOfSides number of sides that make up the circle
  65061. * @returns points that make the resulting circle
  65062. */
  65063. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  65064. /**
  65065. * Creates a polygon from input string
  65066. * @param input Input polygon data
  65067. * @returns the parsed points
  65068. */
  65069. static Parse(input: string): Vector2[];
  65070. /**
  65071. * Starts building a polygon from x and y coordinates
  65072. * @param x x coordinate
  65073. * @param y y coordinate
  65074. * @returns the started path2
  65075. */
  65076. static StartingAt(x: number, y: number): Path2;
  65077. }
  65078. /**
  65079. * Builds a polygon
  65080. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  65081. */
  65082. export class PolygonMeshBuilder {
  65083. private _points;
  65084. private _outlinepoints;
  65085. private _holes;
  65086. private _name;
  65087. private _scene;
  65088. private _epoints;
  65089. private _eholes;
  65090. private _addToepoint;
  65091. /**
  65092. * Babylon reference to the earcut plugin.
  65093. */
  65094. bjsEarcut: any;
  65095. /**
  65096. * Creates a PolygonMeshBuilder
  65097. * @param name name of the builder
  65098. * @param contours Path of the polygon
  65099. * @param scene scene to add to when creating the mesh
  65100. * @param earcutInjection can be used to inject your own earcut reference
  65101. */
  65102. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  65103. /**
  65104. * Adds a whole within the polygon
  65105. * @param hole Array of points defining the hole
  65106. * @returns this
  65107. */
  65108. addHole(hole: Vector2[]): PolygonMeshBuilder;
  65109. /**
  65110. * Creates the polygon
  65111. * @param updatable If the mesh should be updatable
  65112. * @param depth The depth of the mesh created
  65113. * @returns the created mesh
  65114. */
  65115. build(updatable?: boolean, depth?: number): Mesh;
  65116. /**
  65117. * Creates the polygon
  65118. * @param depth The depth of the mesh created
  65119. * @returns the created VertexData
  65120. */
  65121. buildVertexData(depth?: number): VertexData;
  65122. /**
  65123. * Adds a side to the polygon
  65124. * @param positions points that make the polygon
  65125. * @param normals normals of the polygon
  65126. * @param uvs uvs of the polygon
  65127. * @param indices indices of the polygon
  65128. * @param bounds bounds of the polygon
  65129. * @param points points of the polygon
  65130. * @param depth depth of the polygon
  65131. * @param flip flip of the polygon
  65132. */
  65133. private addSide;
  65134. }
  65135. }
  65136. declare module BABYLON {
  65137. /**
  65138. * Class containing static functions to help procedurally build meshes
  65139. */
  65140. export class PolygonBuilder {
  65141. /**
  65142. * Creates a polygon mesh
  65143. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65144. * * 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
  65145. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65146. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65147. * * 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)
  65148. * * Remember you can only change the shape positions, not their number when updating a polygon
  65149. * @param name defines the name of the mesh
  65150. * @param options defines the options used to create the mesh
  65151. * @param scene defines the hosting scene
  65152. * @param earcutInjection can be used to inject your own earcut reference
  65153. * @returns the polygon mesh
  65154. */
  65155. static CreatePolygon(name: string, options: {
  65156. shape: Vector3[];
  65157. holes?: Vector3[][];
  65158. depth?: number;
  65159. faceUV?: Vector4[];
  65160. faceColors?: Color4[];
  65161. updatable?: boolean;
  65162. sideOrientation?: number;
  65163. frontUVs?: Vector4;
  65164. backUVs?: Vector4;
  65165. wrap?: boolean;
  65166. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65167. /**
  65168. * Creates an extruded polygon mesh, with depth in the Y direction.
  65169. * * 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)
  65170. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65171. * @param name defines the name of the mesh
  65172. * @param options defines the options used to create the mesh
  65173. * @param scene defines the hosting scene
  65174. * @param earcutInjection can be used to inject your own earcut reference
  65175. * @returns the polygon mesh
  65176. */
  65177. static ExtrudePolygon(name: string, options: {
  65178. shape: Vector3[];
  65179. holes?: Vector3[][];
  65180. depth?: number;
  65181. faceUV?: Vector4[];
  65182. faceColors?: Color4[];
  65183. updatable?: boolean;
  65184. sideOrientation?: number;
  65185. frontUVs?: Vector4;
  65186. backUVs?: Vector4;
  65187. wrap?: boolean;
  65188. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65189. }
  65190. }
  65191. declare module BABYLON {
  65192. /**
  65193. * Class containing static functions to help procedurally build meshes
  65194. */
  65195. export class LatheBuilder {
  65196. /**
  65197. * Creates lathe mesh.
  65198. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  65199. * * 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
  65200. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  65201. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  65202. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  65203. * * 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
  65204. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  65205. * * 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
  65206. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65207. * * 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
  65208. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65209. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65210. * @param name defines the name of the mesh
  65211. * @param options defines the options used to create the mesh
  65212. * @param scene defines the hosting scene
  65213. * @returns the lathe mesh
  65214. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  65215. */
  65216. static CreateLathe(name: string, options: {
  65217. shape: Vector3[];
  65218. radius?: number;
  65219. tessellation?: number;
  65220. clip?: number;
  65221. arc?: number;
  65222. closed?: boolean;
  65223. updatable?: boolean;
  65224. sideOrientation?: number;
  65225. frontUVs?: Vector4;
  65226. backUVs?: Vector4;
  65227. cap?: number;
  65228. invertUV?: boolean;
  65229. }, scene?: Nullable<Scene>): Mesh;
  65230. }
  65231. }
  65232. declare module BABYLON {
  65233. /**
  65234. * Class containing static functions to help procedurally build meshes
  65235. */
  65236. export class TiledPlaneBuilder {
  65237. /**
  65238. * Creates a tiled plane mesh
  65239. * * The parameter `pattern` will, depending on value, do nothing or
  65240. * * * flip (reflect about central vertical) alternate tiles across and up
  65241. * * * flip every tile on alternate rows
  65242. * * * rotate (180 degs) alternate tiles across and up
  65243. * * * rotate every tile on alternate rows
  65244. * * * flip and rotate alternate tiles across and up
  65245. * * * flip and rotate every tile on alternate rows
  65246. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  65247. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  65248. * * 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
  65249. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65250. * * 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)
  65251. * * 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)
  65252. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65253. * @param name defines the name of the mesh
  65254. * @param options defines the options used to create the mesh
  65255. * @param scene defines the hosting scene
  65256. * @returns the box mesh
  65257. */
  65258. static CreateTiledPlane(name: string, options: {
  65259. pattern?: number;
  65260. tileSize?: number;
  65261. tileWidth?: number;
  65262. tileHeight?: number;
  65263. size?: number;
  65264. width?: number;
  65265. height?: number;
  65266. alignHorizontal?: number;
  65267. alignVertical?: number;
  65268. sideOrientation?: number;
  65269. frontUVs?: Vector4;
  65270. backUVs?: Vector4;
  65271. updatable?: boolean;
  65272. }, scene?: Nullable<Scene>): Mesh;
  65273. }
  65274. }
  65275. declare module BABYLON {
  65276. /**
  65277. * Class containing static functions to help procedurally build meshes
  65278. */
  65279. export class TubeBuilder {
  65280. /**
  65281. * Creates a tube mesh.
  65282. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65283. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65284. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65285. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65286. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65287. * * 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)
  65288. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65289. * * 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
  65290. * * 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
  65291. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65292. * * 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
  65293. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65295. * @param name defines the name of the mesh
  65296. * @param options defines the options used to create the mesh
  65297. * @param scene defines the hosting scene
  65298. * @returns the tube mesh
  65299. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65300. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65301. */
  65302. static CreateTube(name: string, options: {
  65303. path: Vector3[];
  65304. radius?: number;
  65305. tessellation?: number;
  65306. radiusFunction?: {
  65307. (i: number, distance: number): number;
  65308. };
  65309. cap?: number;
  65310. arc?: number;
  65311. updatable?: boolean;
  65312. sideOrientation?: number;
  65313. frontUVs?: Vector4;
  65314. backUVs?: Vector4;
  65315. instance?: Mesh;
  65316. invertUV?: boolean;
  65317. }, scene?: Nullable<Scene>): Mesh;
  65318. }
  65319. }
  65320. declare module BABYLON {
  65321. /**
  65322. * Class containing static functions to help procedurally build meshes
  65323. */
  65324. export class IcoSphereBuilder {
  65325. /**
  65326. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65327. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65328. * * 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`)
  65329. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65330. * * 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
  65331. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65332. * * 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
  65333. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65334. * @param name defines the name of the mesh
  65335. * @param options defines the options used to create the mesh
  65336. * @param scene defines the hosting scene
  65337. * @returns the icosahedron mesh
  65338. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65339. */
  65340. static CreateIcoSphere(name: string, options: {
  65341. radius?: number;
  65342. radiusX?: number;
  65343. radiusY?: number;
  65344. radiusZ?: number;
  65345. flat?: boolean;
  65346. subdivisions?: number;
  65347. sideOrientation?: number;
  65348. frontUVs?: Vector4;
  65349. backUVs?: Vector4;
  65350. updatable?: boolean;
  65351. }, scene?: Nullable<Scene>): Mesh;
  65352. }
  65353. }
  65354. declare module BABYLON {
  65355. /**
  65356. * Class containing static functions to help procedurally build meshes
  65357. */
  65358. export class DecalBuilder {
  65359. /**
  65360. * Creates a decal mesh.
  65361. * 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
  65362. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65363. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65364. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65365. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65366. * @param name defines the name of the mesh
  65367. * @param sourceMesh defines the mesh where the decal must be applied
  65368. * @param options defines the options used to create the mesh
  65369. * @param scene defines the hosting scene
  65370. * @returns the decal mesh
  65371. * @see https://doc.babylonjs.com/how_to/decals
  65372. */
  65373. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65374. position?: Vector3;
  65375. normal?: Vector3;
  65376. size?: Vector3;
  65377. angle?: number;
  65378. }): Mesh;
  65379. }
  65380. }
  65381. declare module BABYLON {
  65382. /**
  65383. * Class containing static functions to help procedurally build meshes
  65384. */
  65385. export class MeshBuilder {
  65386. /**
  65387. * Creates a box mesh
  65388. * * The parameter `size` sets the size (float) of each box side (default 1)
  65389. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  65390. * * 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)
  65391. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65392. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65393. * * 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
  65394. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65395. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65396. * @param name defines the name of the mesh
  65397. * @param options defines the options used to create the mesh
  65398. * @param scene defines the hosting scene
  65399. * @returns the box mesh
  65400. */
  65401. static CreateBox(name: string, options: {
  65402. size?: number;
  65403. width?: number;
  65404. height?: number;
  65405. depth?: number;
  65406. faceUV?: Vector4[];
  65407. faceColors?: Color4[];
  65408. sideOrientation?: number;
  65409. frontUVs?: Vector4;
  65410. backUVs?: Vector4;
  65411. wrap?: boolean;
  65412. topBaseAt?: number;
  65413. bottomBaseAt?: number;
  65414. updatable?: boolean;
  65415. }, scene?: Nullable<Scene>): Mesh;
  65416. /**
  65417. * Creates a tiled box mesh
  65418. * * faceTiles sets the pattern, tile size and number of tiles for a face
  65419. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65420. * @param name defines the name of the mesh
  65421. * @param options defines the options used to create the mesh
  65422. * @param scene defines the hosting scene
  65423. * @returns the tiled box mesh
  65424. */
  65425. static CreateTiledBox(name: string, options: {
  65426. pattern?: number;
  65427. size?: number;
  65428. width?: number;
  65429. height?: number;
  65430. depth: number;
  65431. tileSize?: number;
  65432. tileWidth?: number;
  65433. tileHeight?: number;
  65434. faceUV?: Vector4[];
  65435. faceColors?: Color4[];
  65436. alignHorizontal?: number;
  65437. alignVertical?: number;
  65438. sideOrientation?: number;
  65439. updatable?: boolean;
  65440. }, scene?: Nullable<Scene>): Mesh;
  65441. /**
  65442. * Creates a sphere mesh
  65443. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  65444. * * 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`)
  65445. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  65446. * * 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
  65447. * * 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)
  65448. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65449. * * 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
  65450. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65451. * @param name defines the name of the mesh
  65452. * @param options defines the options used to create the mesh
  65453. * @param scene defines the hosting scene
  65454. * @returns the sphere mesh
  65455. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  65456. */
  65457. static CreateSphere(name: string, options: {
  65458. segments?: number;
  65459. diameter?: number;
  65460. diameterX?: number;
  65461. diameterY?: number;
  65462. diameterZ?: number;
  65463. arc?: number;
  65464. slice?: number;
  65465. sideOrientation?: number;
  65466. frontUVs?: Vector4;
  65467. backUVs?: Vector4;
  65468. updatable?: boolean;
  65469. }, scene?: Nullable<Scene>): Mesh;
  65470. /**
  65471. * Creates a plane polygonal mesh. By default, this is a disc
  65472. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  65473. * * 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
  65474. * * 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
  65475. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65476. * * 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
  65477. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65478. * @param name defines the name of the mesh
  65479. * @param options defines the options used to create the mesh
  65480. * @param scene defines the hosting scene
  65481. * @returns the plane polygonal mesh
  65482. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  65483. */
  65484. static CreateDisc(name: string, options: {
  65485. radius?: number;
  65486. tessellation?: number;
  65487. arc?: number;
  65488. updatable?: boolean;
  65489. sideOrientation?: number;
  65490. frontUVs?: Vector4;
  65491. backUVs?: Vector4;
  65492. }, scene?: Nullable<Scene>): Mesh;
  65493. /**
  65494. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65495. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65496. * * 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`)
  65497. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65498. * * 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
  65499. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65500. * * 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
  65501. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65502. * @param name defines the name of the mesh
  65503. * @param options defines the options used to create the mesh
  65504. * @param scene defines the hosting scene
  65505. * @returns the icosahedron mesh
  65506. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65507. */
  65508. static CreateIcoSphere(name: string, options: {
  65509. radius?: number;
  65510. radiusX?: number;
  65511. radiusY?: number;
  65512. radiusZ?: number;
  65513. flat?: boolean;
  65514. subdivisions?: number;
  65515. sideOrientation?: number;
  65516. frontUVs?: Vector4;
  65517. backUVs?: Vector4;
  65518. updatable?: boolean;
  65519. }, scene?: Nullable<Scene>): Mesh;
  65520. /**
  65521. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65522. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  65523. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  65524. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  65525. * * 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
  65526. * * 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
  65527. * * 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
  65528. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65529. * * 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
  65530. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65531. * * 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
  65532. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  65533. * * 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
  65534. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  65535. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65536. * @param name defines the name of the mesh
  65537. * @param options defines the options used to create the mesh
  65538. * @param scene defines the hosting scene
  65539. * @returns the ribbon mesh
  65540. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  65541. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65542. */
  65543. static CreateRibbon(name: string, options: {
  65544. pathArray: Vector3[][];
  65545. closeArray?: boolean;
  65546. closePath?: boolean;
  65547. offset?: number;
  65548. updatable?: boolean;
  65549. sideOrientation?: number;
  65550. frontUVs?: Vector4;
  65551. backUVs?: Vector4;
  65552. instance?: Mesh;
  65553. invertUV?: boolean;
  65554. uvs?: Vector2[];
  65555. colors?: Color4[];
  65556. }, scene?: Nullable<Scene>): Mesh;
  65557. /**
  65558. * Creates a cylinder or a cone mesh
  65559. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  65560. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  65561. * * 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.
  65562. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  65563. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  65564. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  65565. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  65566. * * 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).
  65567. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  65568. * * 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).
  65569. * * 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
  65570. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  65571. * * 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
  65572. * * 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.
  65573. * * If `enclose` is false, a ring surface is one element.
  65574. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  65575. * * 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
  65576. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65577. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65578. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65579. * @param name defines the name of the mesh
  65580. * @param options defines the options used to create the mesh
  65581. * @param scene defines the hosting scene
  65582. * @returns the cylinder mesh
  65583. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  65584. */
  65585. static CreateCylinder(name: string, options: {
  65586. height?: number;
  65587. diameterTop?: number;
  65588. diameterBottom?: number;
  65589. diameter?: number;
  65590. tessellation?: number;
  65591. subdivisions?: number;
  65592. arc?: number;
  65593. faceColors?: Color4[];
  65594. faceUV?: Vector4[];
  65595. updatable?: boolean;
  65596. hasRings?: boolean;
  65597. enclose?: boolean;
  65598. cap?: number;
  65599. sideOrientation?: number;
  65600. frontUVs?: Vector4;
  65601. backUVs?: Vector4;
  65602. }, scene?: Nullable<Scene>): Mesh;
  65603. /**
  65604. * Creates a torus mesh
  65605. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  65606. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  65607. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  65608. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65609. * * 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
  65610. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65611. * @param name defines the name of the mesh
  65612. * @param options defines the options used to create the mesh
  65613. * @param scene defines the hosting scene
  65614. * @returns the torus mesh
  65615. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  65616. */
  65617. static CreateTorus(name: string, options: {
  65618. diameter?: number;
  65619. thickness?: number;
  65620. tessellation?: number;
  65621. updatable?: boolean;
  65622. sideOrientation?: number;
  65623. frontUVs?: Vector4;
  65624. backUVs?: Vector4;
  65625. }, scene?: Nullable<Scene>): Mesh;
  65626. /**
  65627. * Creates a torus knot mesh
  65628. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  65629. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  65630. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  65631. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  65632. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65633. * * 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
  65634. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65635. * @param name defines the name of the mesh
  65636. * @param options defines the options used to create the mesh
  65637. * @param scene defines the hosting scene
  65638. * @returns the torus knot mesh
  65639. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  65640. */
  65641. static CreateTorusKnot(name: string, options: {
  65642. radius?: number;
  65643. tube?: number;
  65644. radialSegments?: number;
  65645. tubularSegments?: number;
  65646. p?: number;
  65647. q?: number;
  65648. updatable?: boolean;
  65649. sideOrientation?: number;
  65650. frontUVs?: Vector4;
  65651. backUVs?: Vector4;
  65652. }, scene?: Nullable<Scene>): Mesh;
  65653. /**
  65654. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  65655. * * 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
  65656. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  65657. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  65658. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  65659. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  65660. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  65661. * * 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
  65662. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  65663. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65664. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  65665. * @param name defines the name of the new line system
  65666. * @param options defines the options used to create the line system
  65667. * @param scene defines the hosting scene
  65668. * @returns a new line system mesh
  65669. */
  65670. static CreateLineSystem(name: string, options: {
  65671. lines: Vector3[][];
  65672. updatable?: boolean;
  65673. instance?: Nullable<LinesMesh>;
  65674. colors?: Nullable<Color4[][]>;
  65675. useVertexAlpha?: boolean;
  65676. }, scene: Nullable<Scene>): LinesMesh;
  65677. /**
  65678. * Creates a line mesh
  65679. * 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
  65680. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  65681. * * The parameter `points` is an array successive Vector3
  65682. * * 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
  65683. * * The optional parameter `colors` is an array of successive Color4, one per line point
  65684. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  65685. * * When updating an instance, remember that only point positions can change, not the number of points
  65686. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65687. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  65688. * @param name defines the name of the new line system
  65689. * @param options defines the options used to create the line system
  65690. * @param scene defines the hosting scene
  65691. * @returns a new line mesh
  65692. */
  65693. static CreateLines(name: string, options: {
  65694. points: Vector3[];
  65695. updatable?: boolean;
  65696. instance?: Nullable<LinesMesh>;
  65697. colors?: Color4[];
  65698. useVertexAlpha?: boolean;
  65699. }, scene?: Nullable<Scene>): LinesMesh;
  65700. /**
  65701. * Creates a dashed line mesh
  65702. * * 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
  65703. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  65704. * * The parameter `points` is an array successive Vector3
  65705. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  65706. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  65707. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  65708. * * 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
  65709. * * When updating an instance, remember that only point positions can change, not the number of points
  65710. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  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. * @returns the dashed line mesh
  65715. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  65716. */
  65717. static CreateDashedLines(name: string, options: {
  65718. points: Vector3[];
  65719. dashSize?: number;
  65720. gapSize?: number;
  65721. dashNb?: number;
  65722. updatable?: boolean;
  65723. instance?: LinesMesh;
  65724. }, scene?: Nullable<Scene>): LinesMesh;
  65725. /**
  65726. * 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.
  65727. * * 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.
  65728. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65729. * * 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.
  65730. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  65731. * * 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
  65732. * * 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
  65733. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  65734. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65735. * * 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
  65736. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  65737. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65738. * @param name defines the name of the mesh
  65739. * @param options defines the options used to create the mesh
  65740. * @param scene defines the hosting scene
  65741. * @returns the extruded shape mesh
  65742. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65743. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65744. */
  65745. static ExtrudeShape(name: string, options: {
  65746. shape: Vector3[];
  65747. path: Vector3[];
  65748. scale?: number;
  65749. rotation?: number;
  65750. cap?: number;
  65751. updatable?: boolean;
  65752. sideOrientation?: number;
  65753. frontUVs?: Vector4;
  65754. backUVs?: Vector4;
  65755. instance?: Mesh;
  65756. invertUV?: boolean;
  65757. }, scene?: Nullable<Scene>): Mesh;
  65758. /**
  65759. * Creates an custom extruded shape mesh.
  65760. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  65761. * * 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.
  65762. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65763. * * 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
  65764. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  65765. * * 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
  65766. * * It must returns a float value that will be the scale value applied to the shape on each path point
  65767. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  65768. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  65769. * * 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
  65770. * * 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
  65771. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  65772. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65773. * * 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
  65774. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65775. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65776. * @param name defines the name of the mesh
  65777. * @param options defines the options used to create the mesh
  65778. * @param scene defines the hosting scene
  65779. * @returns the custom extruded shape mesh
  65780. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  65781. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65782. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65783. */
  65784. static ExtrudeShapeCustom(name: string, options: {
  65785. shape: Vector3[];
  65786. path: Vector3[];
  65787. scaleFunction?: any;
  65788. rotationFunction?: any;
  65789. ribbonCloseArray?: boolean;
  65790. ribbonClosePath?: boolean;
  65791. cap?: number;
  65792. updatable?: boolean;
  65793. sideOrientation?: number;
  65794. frontUVs?: Vector4;
  65795. backUVs?: Vector4;
  65796. instance?: Mesh;
  65797. invertUV?: boolean;
  65798. }, scene?: Nullable<Scene>): Mesh;
  65799. /**
  65800. * Creates lathe mesh.
  65801. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  65802. * * 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
  65803. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  65804. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  65805. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  65806. * * 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
  65807. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  65808. * * 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
  65809. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65810. * * 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
  65811. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65812. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65813. * @param name defines the name of the mesh
  65814. * @param options defines the options used to create the mesh
  65815. * @param scene defines the hosting scene
  65816. * @returns the lathe mesh
  65817. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  65818. */
  65819. static CreateLathe(name: string, options: {
  65820. shape: Vector3[];
  65821. radius?: number;
  65822. tessellation?: number;
  65823. clip?: number;
  65824. arc?: number;
  65825. closed?: boolean;
  65826. updatable?: boolean;
  65827. sideOrientation?: number;
  65828. frontUVs?: Vector4;
  65829. backUVs?: Vector4;
  65830. cap?: number;
  65831. invertUV?: boolean;
  65832. }, scene?: Nullable<Scene>): Mesh;
  65833. /**
  65834. * Creates a tiled plane mesh
  65835. * * You can set a limited pattern arrangement with the tiles
  65836. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65837. * * 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
  65838. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65839. * @param name defines the name of the mesh
  65840. * @param options defines the options used to create the mesh
  65841. * @param scene defines the hosting scene
  65842. * @returns the plane mesh
  65843. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  65844. */
  65845. static CreateTiledPlane(name: string, options: {
  65846. pattern?: number;
  65847. tileSize?: number;
  65848. tileWidth?: number;
  65849. tileHeight?: number;
  65850. size?: number;
  65851. width?: number;
  65852. height?: number;
  65853. alignHorizontal?: number;
  65854. alignVertical?: number;
  65855. sideOrientation?: number;
  65856. frontUVs?: Vector4;
  65857. backUVs?: Vector4;
  65858. updatable?: boolean;
  65859. }, scene?: Nullable<Scene>): Mesh;
  65860. /**
  65861. * Creates a plane mesh
  65862. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  65863. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  65864. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  65865. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65866. * * 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
  65867. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65868. * @param name defines the name of the mesh
  65869. * @param options defines the options used to create the mesh
  65870. * @param scene defines the hosting scene
  65871. * @returns the plane mesh
  65872. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  65873. */
  65874. static CreatePlane(name: string, options: {
  65875. size?: number;
  65876. width?: number;
  65877. height?: number;
  65878. sideOrientation?: number;
  65879. frontUVs?: Vector4;
  65880. backUVs?: Vector4;
  65881. updatable?: boolean;
  65882. sourcePlane?: Plane;
  65883. }, scene?: Nullable<Scene>): Mesh;
  65884. /**
  65885. * Creates a ground mesh
  65886. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  65887. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  65888. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65889. * @param name defines the name of the mesh
  65890. * @param options defines the options used to create the mesh
  65891. * @param scene defines the hosting scene
  65892. * @returns the ground mesh
  65893. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  65894. */
  65895. static CreateGround(name: string, options: {
  65896. width?: number;
  65897. height?: number;
  65898. subdivisions?: number;
  65899. subdivisionsX?: number;
  65900. subdivisionsY?: number;
  65901. updatable?: boolean;
  65902. }, scene?: Nullable<Scene>): Mesh;
  65903. /**
  65904. * Creates a tiled ground mesh
  65905. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  65906. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  65907. * * 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
  65908. * * 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
  65909. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65910. * @param name defines the name of the mesh
  65911. * @param options defines the options used to create the mesh
  65912. * @param scene defines the hosting scene
  65913. * @returns the tiled ground mesh
  65914. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  65915. */
  65916. static CreateTiledGround(name: string, options: {
  65917. xmin: number;
  65918. zmin: number;
  65919. xmax: number;
  65920. zmax: number;
  65921. subdivisions?: {
  65922. w: number;
  65923. h: number;
  65924. };
  65925. precision?: {
  65926. w: number;
  65927. h: number;
  65928. };
  65929. updatable?: boolean;
  65930. }, scene?: Nullable<Scene>): Mesh;
  65931. /**
  65932. * Creates a ground mesh from a height map
  65933. * * The parameter `url` sets the URL of the height map image resource.
  65934. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  65935. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  65936. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  65937. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  65938. * * 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.
  65939. * * 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).
  65940. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  65941. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65942. * @param name defines the name of the mesh
  65943. * @param url defines the url to the height map
  65944. * @param options defines the options used to create the mesh
  65945. * @param scene defines the hosting scene
  65946. * @returns the ground mesh
  65947. * @see https://doc.babylonjs.com/babylon101/height_map
  65948. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  65949. */
  65950. static CreateGroundFromHeightMap(name: string, url: string, options: {
  65951. width?: number;
  65952. height?: number;
  65953. subdivisions?: number;
  65954. minHeight?: number;
  65955. maxHeight?: number;
  65956. colorFilter?: Color3;
  65957. alphaFilter?: number;
  65958. updatable?: boolean;
  65959. onReady?: (mesh: GroundMesh) => void;
  65960. }, scene?: Nullable<Scene>): GroundMesh;
  65961. /**
  65962. * Creates a polygon mesh
  65963. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65964. * * 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
  65965. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65966. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65967. * * 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)
  65968. * * Remember you can only change the shape positions, not their number when updating a polygon
  65969. * @param name defines the name of the mesh
  65970. * @param options defines the options used to create the mesh
  65971. * @param scene defines the hosting scene
  65972. * @param earcutInjection can be used to inject your own earcut reference
  65973. * @returns the polygon mesh
  65974. */
  65975. static CreatePolygon(name: string, options: {
  65976. shape: Vector3[];
  65977. holes?: Vector3[][];
  65978. depth?: number;
  65979. faceUV?: Vector4[];
  65980. faceColors?: Color4[];
  65981. updatable?: boolean;
  65982. sideOrientation?: number;
  65983. frontUVs?: Vector4;
  65984. backUVs?: Vector4;
  65985. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65986. /**
  65987. * Creates an extruded polygon mesh, with depth in the Y direction.
  65988. * * 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)
  65989. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65990. * @param name defines the name of the mesh
  65991. * @param options defines the options used to create the mesh
  65992. * @param scene defines the hosting scene
  65993. * @param earcutInjection can be used to inject your own earcut reference
  65994. * @returns the polygon mesh
  65995. */
  65996. static ExtrudePolygon(name: string, options: {
  65997. shape: Vector3[];
  65998. holes?: Vector3[][];
  65999. depth?: number;
  66000. faceUV?: Vector4[];
  66001. faceColors?: Color4[];
  66002. updatable?: boolean;
  66003. sideOrientation?: number;
  66004. frontUVs?: Vector4;
  66005. backUVs?: Vector4;
  66006. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66007. /**
  66008. * Creates a tube mesh.
  66009. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66010. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66011. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66012. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66013. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66014. * * 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)
  66015. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66016. * * 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
  66017. * * 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
  66018. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66019. * * 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
  66020. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66021. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66022. * @param name defines the name of the mesh
  66023. * @param options defines the options used to create the mesh
  66024. * @param scene defines the hosting scene
  66025. * @returns the tube mesh
  66026. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66027. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66028. */
  66029. static CreateTube(name: string, options: {
  66030. path: Vector3[];
  66031. radius?: number;
  66032. tessellation?: number;
  66033. radiusFunction?: {
  66034. (i: number, distance: number): number;
  66035. };
  66036. cap?: number;
  66037. arc?: number;
  66038. updatable?: boolean;
  66039. sideOrientation?: number;
  66040. frontUVs?: Vector4;
  66041. backUVs?: Vector4;
  66042. instance?: Mesh;
  66043. invertUV?: boolean;
  66044. }, scene?: Nullable<Scene>): Mesh;
  66045. /**
  66046. * Creates a polyhedron mesh
  66047. * * 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
  66048. * * The parameter `size` (positive float, default 1) sets the polygon size
  66049. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  66050. * * 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`
  66051. * * 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
  66052. * * 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)`)
  66053. * * 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
  66054. * * 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
  66055. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66056. * * 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
  66057. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66058. * @param name defines the name of the mesh
  66059. * @param options defines the options used to create the mesh
  66060. * @param scene defines the hosting scene
  66061. * @returns the polyhedron mesh
  66062. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  66063. */
  66064. static CreatePolyhedron(name: string, options: {
  66065. type?: number;
  66066. size?: number;
  66067. sizeX?: number;
  66068. sizeY?: number;
  66069. sizeZ?: number;
  66070. custom?: any;
  66071. faceUV?: Vector4[];
  66072. faceColors?: Color4[];
  66073. flat?: boolean;
  66074. updatable?: boolean;
  66075. sideOrientation?: number;
  66076. frontUVs?: Vector4;
  66077. backUVs?: Vector4;
  66078. }, scene?: Nullable<Scene>): Mesh;
  66079. /**
  66080. * Creates a decal mesh.
  66081. * 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
  66082. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  66083. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  66084. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  66085. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  66086. * @param name defines the name of the mesh
  66087. * @param sourceMesh defines the mesh where the decal must be applied
  66088. * @param options defines the options used to create the mesh
  66089. * @param scene defines the hosting scene
  66090. * @returns the decal mesh
  66091. * @see https://doc.babylonjs.com/how_to/decals
  66092. */
  66093. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  66094. position?: Vector3;
  66095. normal?: Vector3;
  66096. size?: Vector3;
  66097. angle?: number;
  66098. }): Mesh;
  66099. }
  66100. }
  66101. declare module BABYLON {
  66102. /**
  66103. * A simplifier interface for future simplification implementations
  66104. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66105. */
  66106. export interface ISimplifier {
  66107. /**
  66108. * Simplification of a given mesh according to the given settings.
  66109. * Since this requires computation, it is assumed that the function runs async.
  66110. * @param settings The settings of the simplification, including quality and distance
  66111. * @param successCallback A callback that will be called after the mesh was simplified.
  66112. * @param errorCallback in case of an error, this callback will be called. optional.
  66113. */
  66114. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  66115. }
  66116. /**
  66117. * Expected simplification settings.
  66118. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  66119. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66120. */
  66121. export interface ISimplificationSettings {
  66122. /**
  66123. * Gets or sets the expected quality
  66124. */
  66125. quality: number;
  66126. /**
  66127. * Gets or sets the distance when this optimized version should be used
  66128. */
  66129. distance: number;
  66130. /**
  66131. * Gets an already optimized mesh
  66132. */
  66133. optimizeMesh?: boolean;
  66134. }
  66135. /**
  66136. * Class used to specify simplification options
  66137. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66138. */
  66139. export class SimplificationSettings implements ISimplificationSettings {
  66140. /** expected quality */
  66141. quality: number;
  66142. /** distance when this optimized version should be used */
  66143. distance: number;
  66144. /** already optimized mesh */
  66145. optimizeMesh?: boolean | undefined;
  66146. /**
  66147. * Creates a SimplificationSettings
  66148. * @param quality expected quality
  66149. * @param distance distance when this optimized version should be used
  66150. * @param optimizeMesh already optimized mesh
  66151. */
  66152. constructor(
  66153. /** expected quality */
  66154. quality: number,
  66155. /** distance when this optimized version should be used */
  66156. distance: number,
  66157. /** already optimized mesh */
  66158. optimizeMesh?: boolean | undefined);
  66159. }
  66160. /**
  66161. * Interface used to define a simplification task
  66162. */
  66163. export interface ISimplificationTask {
  66164. /**
  66165. * Array of settings
  66166. */
  66167. settings: Array<ISimplificationSettings>;
  66168. /**
  66169. * Simplification type
  66170. */
  66171. simplificationType: SimplificationType;
  66172. /**
  66173. * Mesh to simplify
  66174. */
  66175. mesh: Mesh;
  66176. /**
  66177. * Callback called on success
  66178. */
  66179. successCallback?: () => void;
  66180. /**
  66181. * Defines if parallel processing can be used
  66182. */
  66183. parallelProcessing: boolean;
  66184. }
  66185. /**
  66186. * Queue used to order the simplification tasks
  66187. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66188. */
  66189. export class SimplificationQueue {
  66190. private _simplificationArray;
  66191. /**
  66192. * Gets a boolean indicating that the process is still running
  66193. */
  66194. running: boolean;
  66195. /**
  66196. * Creates a new queue
  66197. */
  66198. constructor();
  66199. /**
  66200. * Adds a new simplification task
  66201. * @param task defines a task to add
  66202. */
  66203. addTask(task: ISimplificationTask): void;
  66204. /**
  66205. * Execute next task
  66206. */
  66207. executeNext(): void;
  66208. /**
  66209. * Execute a simplification task
  66210. * @param task defines the task to run
  66211. */
  66212. runSimplification(task: ISimplificationTask): void;
  66213. private getSimplifier;
  66214. }
  66215. /**
  66216. * The implemented types of simplification
  66217. * At the moment only Quadratic Error Decimation is implemented
  66218. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66219. */
  66220. export enum SimplificationType {
  66221. /** Quadratic error decimation */
  66222. QUADRATIC = 0
  66223. }
  66224. /**
  66225. * An implementation of the Quadratic Error simplification algorithm.
  66226. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  66227. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  66228. * @author RaananW
  66229. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66230. */
  66231. export class QuadraticErrorSimplification implements ISimplifier {
  66232. private _mesh;
  66233. private triangles;
  66234. private vertices;
  66235. private references;
  66236. private _reconstructedMesh;
  66237. /** Gets or sets the number pf sync interations */
  66238. syncIterations: number;
  66239. /** Gets or sets the aggressiveness of the simplifier */
  66240. aggressiveness: number;
  66241. /** Gets or sets the number of allowed iterations for decimation */
  66242. decimationIterations: number;
  66243. /** Gets or sets the espilon to use for bounding box computation */
  66244. boundingBoxEpsilon: number;
  66245. /**
  66246. * Creates a new QuadraticErrorSimplification
  66247. * @param _mesh defines the target mesh
  66248. */
  66249. constructor(_mesh: Mesh);
  66250. /**
  66251. * Simplification of a given mesh according to the given settings.
  66252. * Since this requires computation, it is assumed that the function runs async.
  66253. * @param settings The settings of the simplification, including quality and distance
  66254. * @param successCallback A callback that will be called after the mesh was simplified.
  66255. */
  66256. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  66257. private runDecimation;
  66258. private initWithMesh;
  66259. private init;
  66260. private reconstructMesh;
  66261. private initDecimatedMesh;
  66262. private isFlipped;
  66263. private updateTriangles;
  66264. private identifyBorder;
  66265. private updateMesh;
  66266. private vertexError;
  66267. private calculateError;
  66268. }
  66269. }
  66270. declare module BABYLON {
  66271. interface Scene {
  66272. /** @hidden (Backing field) */
  66273. _simplificationQueue: SimplificationQueue;
  66274. /**
  66275. * Gets or sets the simplification queue attached to the scene
  66276. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66277. */
  66278. simplificationQueue: SimplificationQueue;
  66279. }
  66280. interface Mesh {
  66281. /**
  66282. * Simplify the mesh according to the given array of settings.
  66283. * Function will return immediately and will simplify async
  66284. * @param settings a collection of simplification settings
  66285. * @param parallelProcessing should all levels calculate parallel or one after the other
  66286. * @param simplificationType the type of simplification to run
  66287. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  66288. * @returns the current mesh
  66289. */
  66290. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  66291. }
  66292. /**
  66293. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  66294. * created in a scene
  66295. */
  66296. export class SimplicationQueueSceneComponent implements ISceneComponent {
  66297. /**
  66298. * The component name helpfull to identify the component in the list of scene components.
  66299. */
  66300. readonly name: string;
  66301. /**
  66302. * The scene the component belongs to.
  66303. */
  66304. scene: Scene;
  66305. /**
  66306. * Creates a new instance of the component for the given scene
  66307. * @param scene Defines the scene to register the component in
  66308. */
  66309. constructor(scene: Scene);
  66310. /**
  66311. * Registers the component in a given scene
  66312. */
  66313. register(): void;
  66314. /**
  66315. * Rebuilds the elements related to this component in case of
  66316. * context lost for instance.
  66317. */
  66318. rebuild(): void;
  66319. /**
  66320. * Disposes the component and the associated ressources
  66321. */
  66322. dispose(): void;
  66323. private _beforeCameraUpdate;
  66324. }
  66325. }
  66326. declare module BABYLON {
  66327. interface Mesh {
  66328. /**
  66329. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  66330. */
  66331. thinInstanceEnablePicking: boolean;
  66332. /**
  66333. * Creates a new thin instance
  66334. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  66335. * @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
  66336. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  66337. */
  66338. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  66339. /**
  66340. * Adds the transformation (matrix) of the current mesh as a thin instance
  66341. * @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
  66342. * @returns the thin instance index number
  66343. */
  66344. thinInstanceAddSelf(refresh: boolean): number;
  66345. /**
  66346. * Registers a custom attribute to be used with thin instances
  66347. * @param kind name of the attribute
  66348. * @param stride size in floats of the attribute
  66349. */
  66350. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  66351. /**
  66352. * Sets the matrix of a thin instance
  66353. * @param index index of the thin instance
  66354. * @param matrix matrix to set
  66355. * @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
  66356. */
  66357. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  66358. /**
  66359. * Sets the value of a custom attribute for a thin instance
  66360. * @param kind name of the attribute
  66361. * @param index index of the thin instance
  66362. * @param value value to set
  66363. * @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
  66364. */
  66365. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  66366. /**
  66367. * 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.
  66368. */
  66369. thinInstanceCount: number;
  66370. /**
  66371. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  66372. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  66373. * @param buffer buffer to set
  66374. * @param stride size in floats of each value of the buffer
  66375. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  66376. */
  66377. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  66378. /**
  66379. * Gets the list of world matrices
  66380. * @return an array containing all the world matrices from the thin instances
  66381. */
  66382. thinInstanceGetWorldMatrices(): Matrix[];
  66383. /**
  66384. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  66385. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  66386. */
  66387. thinInstanceBufferUpdated(kind: string): void;
  66388. /**
  66389. * Refreshes the bounding info, taking into account all the thin instances defined
  66390. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  66391. */
  66392. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  66393. /** @hidden */
  66394. _thinInstanceInitializeUserStorage(): void;
  66395. /** @hidden */
  66396. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  66397. /** @hidden */
  66398. _userThinInstanceBuffersStorage: {
  66399. data: {
  66400. [key: string]: Float32Array;
  66401. };
  66402. sizes: {
  66403. [key: string]: number;
  66404. };
  66405. vertexBuffers: {
  66406. [key: string]: Nullable<VertexBuffer>;
  66407. };
  66408. strides: {
  66409. [key: string]: number;
  66410. };
  66411. };
  66412. }
  66413. }
  66414. declare module BABYLON {
  66415. /**
  66416. * Navigation plugin interface to add navigation constrained by a navigation mesh
  66417. */
  66418. export interface INavigationEnginePlugin {
  66419. /**
  66420. * plugin name
  66421. */
  66422. name: string;
  66423. /**
  66424. * Creates a navigation mesh
  66425. * @param meshes array of all the geometry used to compute the navigatio mesh
  66426. * @param parameters bunch of parameters used to filter geometry
  66427. */
  66428. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  66429. /**
  66430. * Create a navigation mesh debug mesh
  66431. * @param scene is where the mesh will be added
  66432. * @returns debug display mesh
  66433. */
  66434. createDebugNavMesh(scene: Scene): Mesh;
  66435. /**
  66436. * Get a navigation mesh constrained position, closest to the parameter position
  66437. * @param position world position
  66438. * @returns the closest point to position constrained by the navigation mesh
  66439. */
  66440. getClosestPoint(position: Vector3): Vector3;
  66441. /**
  66442. * Get a navigation mesh constrained position, closest to the parameter position
  66443. * @param position world position
  66444. * @param result output the closest point to position constrained by the navigation mesh
  66445. */
  66446. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66447. /**
  66448. * Get a navigation mesh constrained position, within a particular radius
  66449. * @param position world position
  66450. * @param maxRadius the maximum distance to the constrained world position
  66451. * @returns the closest point to position constrained by the navigation mesh
  66452. */
  66453. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66454. /**
  66455. * Get a navigation mesh constrained position, within a particular radius
  66456. * @param position world position
  66457. * @param maxRadius the maximum distance to the constrained world position
  66458. * @param result output the closest point to position constrained by the navigation mesh
  66459. */
  66460. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  66461. /**
  66462. * Compute the final position from a segment made of destination-position
  66463. * @param position world position
  66464. * @param destination world position
  66465. * @returns the resulting point along the navmesh
  66466. */
  66467. moveAlong(position: Vector3, destination: Vector3): Vector3;
  66468. /**
  66469. * Compute the final position from a segment made of destination-position
  66470. * @param position world position
  66471. * @param destination world position
  66472. * @param result output the resulting point along the navmesh
  66473. */
  66474. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  66475. /**
  66476. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  66477. * @param start world position
  66478. * @param end world position
  66479. * @returns array containing world position composing the path
  66480. */
  66481. computePath(start: Vector3, end: Vector3): Vector3[];
  66482. /**
  66483. * If this plugin is supported
  66484. * @returns true if plugin is supported
  66485. */
  66486. isSupported(): boolean;
  66487. /**
  66488. * Create a new Crowd so you can add agents
  66489. * @param maxAgents the maximum agent count in the crowd
  66490. * @param maxAgentRadius the maximum radius an agent can have
  66491. * @param scene to attach the crowd to
  66492. * @returns the crowd you can add agents to
  66493. */
  66494. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  66495. /**
  66496. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66497. * The queries will try to find a solution within those bounds
  66498. * default is (1,1,1)
  66499. * @param extent x,y,z value that define the extent around the queries point of reference
  66500. */
  66501. setDefaultQueryExtent(extent: Vector3): void;
  66502. /**
  66503. * Get the Bounding box extent specified by setDefaultQueryExtent
  66504. * @returns the box extent values
  66505. */
  66506. getDefaultQueryExtent(): Vector3;
  66507. /**
  66508. * build the navmesh from a previously saved state using getNavmeshData
  66509. * @param data the Uint8Array returned by getNavmeshData
  66510. */
  66511. buildFromNavmeshData(data: Uint8Array): void;
  66512. /**
  66513. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  66514. * @returns data the Uint8Array that can be saved and reused
  66515. */
  66516. getNavmeshData(): Uint8Array;
  66517. /**
  66518. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66519. * @param result output the box extent values
  66520. */
  66521. getDefaultQueryExtentToRef(result: Vector3): void;
  66522. /**
  66523. * Release all resources
  66524. */
  66525. dispose(): void;
  66526. }
  66527. /**
  66528. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  66529. */
  66530. export interface ICrowd {
  66531. /**
  66532. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  66533. * You can attach anything to that node. The node position is updated in the scene update tick.
  66534. * @param pos world position that will be constrained by the navigation mesh
  66535. * @param parameters agent parameters
  66536. * @param transform hooked to the agent that will be update by the scene
  66537. * @returns agent index
  66538. */
  66539. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  66540. /**
  66541. * Returns the agent position in world space
  66542. * @param index agent index returned by addAgent
  66543. * @returns world space position
  66544. */
  66545. getAgentPosition(index: number): Vector3;
  66546. /**
  66547. * Gets the agent position result in world space
  66548. * @param index agent index returned by addAgent
  66549. * @param result output world space position
  66550. */
  66551. getAgentPositionToRef(index: number, result: Vector3): void;
  66552. /**
  66553. * Gets the agent velocity in world space
  66554. * @param index agent index returned by addAgent
  66555. * @returns world space velocity
  66556. */
  66557. getAgentVelocity(index: number): Vector3;
  66558. /**
  66559. * Gets the agent velocity result in world space
  66560. * @param index agent index returned by addAgent
  66561. * @param result output world space velocity
  66562. */
  66563. getAgentVelocityToRef(index: number, result: Vector3): void;
  66564. /**
  66565. * remove a particular agent previously created
  66566. * @param index agent index returned by addAgent
  66567. */
  66568. removeAgent(index: number): void;
  66569. /**
  66570. * get the list of all agents attached to this crowd
  66571. * @returns list of agent indices
  66572. */
  66573. getAgents(): number[];
  66574. /**
  66575. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  66576. * @param deltaTime in seconds
  66577. */
  66578. update(deltaTime: number): void;
  66579. /**
  66580. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  66581. * @param index agent index returned by addAgent
  66582. * @param destination targeted world position
  66583. */
  66584. agentGoto(index: number, destination: Vector3): void;
  66585. /**
  66586. * Teleport the agent to a new position
  66587. * @param index agent index returned by addAgent
  66588. * @param destination targeted world position
  66589. */
  66590. agentTeleport(index: number, destination: Vector3): void;
  66591. /**
  66592. * Update agent parameters
  66593. * @param index agent index returned by addAgent
  66594. * @param parameters agent parameters
  66595. */
  66596. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  66597. /**
  66598. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66599. * The queries will try to find a solution within those bounds
  66600. * default is (1,1,1)
  66601. * @param extent x,y,z value that define the extent around the queries point of reference
  66602. */
  66603. setDefaultQueryExtent(extent: Vector3): void;
  66604. /**
  66605. * Get the Bounding box extent specified by setDefaultQueryExtent
  66606. * @returns the box extent values
  66607. */
  66608. getDefaultQueryExtent(): Vector3;
  66609. /**
  66610. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66611. * @param result output the box extent values
  66612. */
  66613. getDefaultQueryExtentToRef(result: Vector3): void;
  66614. /**
  66615. * Release all resources
  66616. */
  66617. dispose(): void;
  66618. }
  66619. /**
  66620. * Configures an agent
  66621. */
  66622. export interface IAgentParameters {
  66623. /**
  66624. * Agent radius. [Limit: >= 0]
  66625. */
  66626. radius: number;
  66627. /**
  66628. * Agent height. [Limit: > 0]
  66629. */
  66630. height: number;
  66631. /**
  66632. * Maximum allowed acceleration. [Limit: >= 0]
  66633. */
  66634. maxAcceleration: number;
  66635. /**
  66636. * Maximum allowed speed. [Limit: >= 0]
  66637. */
  66638. maxSpeed: number;
  66639. /**
  66640. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  66641. */
  66642. collisionQueryRange: number;
  66643. /**
  66644. * The path visibility optimization range. [Limit: > 0]
  66645. */
  66646. pathOptimizationRange: number;
  66647. /**
  66648. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  66649. */
  66650. separationWeight: number;
  66651. }
  66652. /**
  66653. * Configures the navigation mesh creation
  66654. */
  66655. export interface INavMeshParameters {
  66656. /**
  66657. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  66658. */
  66659. cs: number;
  66660. /**
  66661. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  66662. */
  66663. ch: number;
  66664. /**
  66665. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  66666. */
  66667. walkableSlopeAngle: number;
  66668. /**
  66669. * Minimum floor to 'ceiling' height that will still allow the floor area to
  66670. * be considered walkable. [Limit: >= 3] [Units: vx]
  66671. */
  66672. walkableHeight: number;
  66673. /**
  66674. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  66675. */
  66676. walkableClimb: number;
  66677. /**
  66678. * The distance to erode/shrink the walkable area of the heightfield away from
  66679. * obstructions. [Limit: >=0] [Units: vx]
  66680. */
  66681. walkableRadius: number;
  66682. /**
  66683. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  66684. */
  66685. maxEdgeLen: number;
  66686. /**
  66687. * The maximum distance a simplfied contour's border edges should deviate
  66688. * the original raw contour. [Limit: >=0] [Units: vx]
  66689. */
  66690. maxSimplificationError: number;
  66691. /**
  66692. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  66693. */
  66694. minRegionArea: number;
  66695. /**
  66696. * Any regions with a span count smaller than this value will, if possible,
  66697. * be merged with larger regions. [Limit: >=0] [Units: vx]
  66698. */
  66699. mergeRegionArea: number;
  66700. /**
  66701. * The maximum number of vertices allowed for polygons generated during the
  66702. * contour to polygon conversion process. [Limit: >= 3]
  66703. */
  66704. maxVertsPerPoly: number;
  66705. /**
  66706. * Sets the sampling distance to use when generating the detail mesh.
  66707. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  66708. */
  66709. detailSampleDist: number;
  66710. /**
  66711. * The maximum distance the detail mesh surface should deviate from heightfield
  66712. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  66713. */
  66714. detailSampleMaxError: number;
  66715. }
  66716. }
  66717. declare module BABYLON {
  66718. /**
  66719. * RecastJS navigation plugin
  66720. */
  66721. export class RecastJSPlugin implements INavigationEnginePlugin {
  66722. /**
  66723. * Reference to the Recast library
  66724. */
  66725. bjsRECAST: any;
  66726. /**
  66727. * plugin name
  66728. */
  66729. name: string;
  66730. /**
  66731. * the first navmesh created. We might extend this to support multiple navmeshes
  66732. */
  66733. navMesh: any;
  66734. /**
  66735. * Initializes the recastJS plugin
  66736. * @param recastInjection can be used to inject your own recast reference
  66737. */
  66738. constructor(recastInjection?: any);
  66739. /**
  66740. * Creates a navigation mesh
  66741. * @param meshes array of all the geometry used to compute the navigatio mesh
  66742. * @param parameters bunch of parameters used to filter geometry
  66743. */
  66744. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  66745. /**
  66746. * Create a navigation mesh debug mesh
  66747. * @param scene is where the mesh will be added
  66748. * @returns debug display mesh
  66749. */
  66750. createDebugNavMesh(scene: Scene): Mesh;
  66751. /**
  66752. * Get a navigation mesh constrained position, closest to the parameter position
  66753. * @param position world position
  66754. * @returns the closest point to position constrained by the navigation mesh
  66755. */
  66756. getClosestPoint(position: Vector3): Vector3;
  66757. /**
  66758. * Get a navigation mesh constrained position, closest to the parameter position
  66759. * @param position world position
  66760. * @param result output the closest point to position constrained by the navigation mesh
  66761. */
  66762. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66763. /**
  66764. * Get a navigation mesh constrained position, within a particular radius
  66765. * @param position world position
  66766. * @param maxRadius the maximum distance to the constrained world position
  66767. * @returns the closest point to position constrained by the navigation mesh
  66768. */
  66769. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66770. /**
  66771. * Get a navigation mesh constrained position, within a particular radius
  66772. * @param position world position
  66773. * @param maxRadius the maximum distance to the constrained world position
  66774. * @param result output the closest point to position constrained by the navigation mesh
  66775. */
  66776. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  66777. /**
  66778. * Compute the final position from a segment made of destination-position
  66779. * @param position world position
  66780. * @param destination world position
  66781. * @returns the resulting point along the navmesh
  66782. */
  66783. moveAlong(position: Vector3, destination: Vector3): Vector3;
  66784. /**
  66785. * Compute the final position from a segment made of destination-position
  66786. * @param position world position
  66787. * @param destination world position
  66788. * @param result output the resulting point along the navmesh
  66789. */
  66790. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  66791. /**
  66792. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  66793. * @param start world position
  66794. * @param end world position
  66795. * @returns array containing world position composing the path
  66796. */
  66797. computePath(start: Vector3, end: Vector3): Vector3[];
  66798. /**
  66799. * Create a new Crowd so you can add agents
  66800. * @param maxAgents the maximum agent count in the crowd
  66801. * @param maxAgentRadius the maximum radius an agent can have
  66802. * @param scene to attach the crowd to
  66803. * @returns the crowd you can add agents to
  66804. */
  66805. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  66806. /**
  66807. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66808. * The queries will try to find a solution within those bounds
  66809. * default is (1,1,1)
  66810. * @param extent x,y,z value that define the extent around the queries point of reference
  66811. */
  66812. setDefaultQueryExtent(extent: Vector3): void;
  66813. /**
  66814. * Get the Bounding box extent specified by setDefaultQueryExtent
  66815. * @returns the box extent values
  66816. */
  66817. getDefaultQueryExtent(): Vector3;
  66818. /**
  66819. * build the navmesh from a previously saved state using getNavmeshData
  66820. * @param data the Uint8Array returned by getNavmeshData
  66821. */
  66822. buildFromNavmeshData(data: Uint8Array): void;
  66823. /**
  66824. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  66825. * @returns data the Uint8Array that can be saved and reused
  66826. */
  66827. getNavmeshData(): Uint8Array;
  66828. /**
  66829. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66830. * @param result output the box extent values
  66831. */
  66832. getDefaultQueryExtentToRef(result: Vector3): void;
  66833. /**
  66834. * Disposes
  66835. */
  66836. dispose(): void;
  66837. /**
  66838. * If this plugin is supported
  66839. * @returns true if plugin is supported
  66840. */
  66841. isSupported(): boolean;
  66842. }
  66843. /**
  66844. * Recast detour crowd implementation
  66845. */
  66846. export class RecastJSCrowd implements ICrowd {
  66847. /**
  66848. * Recast/detour plugin
  66849. */
  66850. bjsRECASTPlugin: RecastJSPlugin;
  66851. /**
  66852. * Link to the detour crowd
  66853. */
  66854. recastCrowd: any;
  66855. /**
  66856. * One transform per agent
  66857. */
  66858. transforms: TransformNode[];
  66859. /**
  66860. * All agents created
  66861. */
  66862. agents: number[];
  66863. /**
  66864. * Link to the scene is kept to unregister the crowd from the scene
  66865. */
  66866. private _scene;
  66867. /**
  66868. * Observer for crowd updates
  66869. */
  66870. private _onBeforeAnimationsObserver;
  66871. /**
  66872. * Constructor
  66873. * @param plugin recastJS plugin
  66874. * @param maxAgents the maximum agent count in the crowd
  66875. * @param maxAgentRadius the maximum radius an agent can have
  66876. * @param scene to attach the crowd to
  66877. * @returns the crowd you can add agents to
  66878. */
  66879. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  66880. /**
  66881. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  66882. * You can attach anything to that node. The node position is updated in the scene update tick.
  66883. * @param pos world position that will be constrained by the navigation mesh
  66884. * @param parameters agent parameters
  66885. * @param transform hooked to the agent that will be update by the scene
  66886. * @returns agent index
  66887. */
  66888. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  66889. /**
  66890. * Returns the agent position in world space
  66891. * @param index agent index returned by addAgent
  66892. * @returns world space position
  66893. */
  66894. getAgentPosition(index: number): Vector3;
  66895. /**
  66896. * Returns the agent position result in world space
  66897. * @param index agent index returned by addAgent
  66898. * @param result output world space position
  66899. */
  66900. getAgentPositionToRef(index: number, result: Vector3): void;
  66901. /**
  66902. * Returns the agent velocity in world space
  66903. * @param index agent index returned by addAgent
  66904. * @returns world space velocity
  66905. */
  66906. getAgentVelocity(index: number): Vector3;
  66907. /**
  66908. * Returns the agent velocity result in world space
  66909. * @param index agent index returned by addAgent
  66910. * @param result output world space velocity
  66911. */
  66912. getAgentVelocityToRef(index: number, result: Vector3): void;
  66913. /**
  66914. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  66915. * @param index agent index returned by addAgent
  66916. * @param destination targeted world position
  66917. */
  66918. agentGoto(index: number, destination: Vector3): void;
  66919. /**
  66920. * Teleport the agent to a new position
  66921. * @param index agent index returned by addAgent
  66922. * @param destination targeted world position
  66923. */
  66924. agentTeleport(index: number, destination: Vector3): void;
  66925. /**
  66926. * Update agent parameters
  66927. * @param index agent index returned by addAgent
  66928. * @param parameters agent parameters
  66929. */
  66930. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  66931. /**
  66932. * remove a particular agent previously created
  66933. * @param index agent index returned by addAgent
  66934. */
  66935. removeAgent(index: number): void;
  66936. /**
  66937. * get the list of all agents attached to this crowd
  66938. * @returns list of agent indices
  66939. */
  66940. getAgents(): number[];
  66941. /**
  66942. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  66943. * @param deltaTime in seconds
  66944. */
  66945. update(deltaTime: number): void;
  66946. /**
  66947. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66948. * The queries will try to find a solution within those bounds
  66949. * default is (1,1,1)
  66950. * @param extent x,y,z value that define the extent around the queries point of reference
  66951. */
  66952. setDefaultQueryExtent(extent: Vector3): void;
  66953. /**
  66954. * Get the Bounding box extent specified by setDefaultQueryExtent
  66955. * @returns the box extent values
  66956. */
  66957. getDefaultQueryExtent(): Vector3;
  66958. /**
  66959. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66960. * @param result output the box extent values
  66961. */
  66962. getDefaultQueryExtentToRef(result: Vector3): void;
  66963. /**
  66964. * Release all resources
  66965. */
  66966. dispose(): void;
  66967. }
  66968. }
  66969. declare module BABYLON {
  66970. /**
  66971. * Class used to enable access to IndexedDB
  66972. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  66973. */
  66974. export class Database implements IOfflineProvider {
  66975. private _callbackManifestChecked;
  66976. private _currentSceneUrl;
  66977. private _db;
  66978. private _enableSceneOffline;
  66979. private _enableTexturesOffline;
  66980. private _manifestVersionFound;
  66981. private _mustUpdateRessources;
  66982. private _hasReachedQuota;
  66983. private _isSupported;
  66984. private _idbFactory;
  66985. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  66986. private static IsUASupportingBlobStorage;
  66987. /**
  66988. * Gets a boolean indicating if Database storate is enabled (off by default)
  66989. */
  66990. static IDBStorageEnabled: boolean;
  66991. /**
  66992. * Gets a boolean indicating if scene must be saved in the database
  66993. */
  66994. get enableSceneOffline(): boolean;
  66995. /**
  66996. * Gets a boolean indicating if textures must be saved in the database
  66997. */
  66998. get enableTexturesOffline(): boolean;
  66999. /**
  67000. * Creates a new Database
  67001. * @param urlToScene defines the url to load the scene
  67002. * @param callbackManifestChecked defines the callback to use when manifest is checked
  67003. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  67004. */
  67005. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  67006. private static _ParseURL;
  67007. private static _ReturnFullUrlLocation;
  67008. private _checkManifestFile;
  67009. /**
  67010. * Open the database and make it available
  67011. * @param successCallback defines the callback to call on success
  67012. * @param errorCallback defines the callback to call on error
  67013. */
  67014. open(successCallback: () => void, errorCallback: () => void): void;
  67015. /**
  67016. * Loads an image from the database
  67017. * @param url defines the url to load from
  67018. * @param image defines the target DOM image
  67019. */
  67020. loadImage(url: string, image: HTMLImageElement): void;
  67021. private _loadImageFromDBAsync;
  67022. private _saveImageIntoDBAsync;
  67023. private _checkVersionFromDB;
  67024. private _loadVersionFromDBAsync;
  67025. private _saveVersionIntoDBAsync;
  67026. /**
  67027. * Loads a file from database
  67028. * @param url defines the URL to load from
  67029. * @param sceneLoaded defines a callback to call on success
  67030. * @param progressCallBack defines a callback to call when progress changed
  67031. * @param errorCallback defines a callback to call on error
  67032. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  67033. */
  67034. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  67035. private _loadFileAsync;
  67036. private _saveFileAsync;
  67037. /**
  67038. * Validates if xhr data is correct
  67039. * @param xhr defines the request to validate
  67040. * @param dataType defines the expected data type
  67041. * @returns true if data is correct
  67042. */
  67043. private static _ValidateXHRData;
  67044. }
  67045. }
  67046. declare module BABYLON {
  67047. /** @hidden */
  67048. export var gpuUpdateParticlesPixelShader: {
  67049. name: string;
  67050. shader: string;
  67051. };
  67052. }
  67053. declare module BABYLON {
  67054. /** @hidden */
  67055. export var gpuUpdateParticlesVertexShader: {
  67056. name: string;
  67057. shader: string;
  67058. };
  67059. }
  67060. declare module BABYLON {
  67061. /** @hidden */
  67062. export var clipPlaneFragmentDeclaration2: {
  67063. name: string;
  67064. shader: string;
  67065. };
  67066. }
  67067. declare module BABYLON {
  67068. /** @hidden */
  67069. export var gpuRenderParticlesPixelShader: {
  67070. name: string;
  67071. shader: string;
  67072. };
  67073. }
  67074. declare module BABYLON {
  67075. /** @hidden */
  67076. export var clipPlaneVertexDeclaration2: {
  67077. name: string;
  67078. shader: string;
  67079. };
  67080. }
  67081. declare module BABYLON {
  67082. /** @hidden */
  67083. export var gpuRenderParticlesVertexShader: {
  67084. name: string;
  67085. shader: string;
  67086. };
  67087. }
  67088. declare module BABYLON {
  67089. /**
  67090. * This represents a GPU particle system in Babylon
  67091. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  67092. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  67093. */
  67094. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  67095. /**
  67096. * The layer mask we are rendering the particles through.
  67097. */
  67098. layerMask: number;
  67099. private _capacity;
  67100. private _activeCount;
  67101. private _currentActiveCount;
  67102. private _accumulatedCount;
  67103. private _renderEffect;
  67104. private _updateEffect;
  67105. private _buffer0;
  67106. private _buffer1;
  67107. private _spriteBuffer;
  67108. private _updateVAO;
  67109. private _renderVAO;
  67110. private _targetIndex;
  67111. private _sourceBuffer;
  67112. private _targetBuffer;
  67113. private _currentRenderId;
  67114. private _started;
  67115. private _stopped;
  67116. private _timeDelta;
  67117. private _randomTexture;
  67118. private _randomTexture2;
  67119. private _attributesStrideSize;
  67120. private _updateEffectOptions;
  67121. private _randomTextureSize;
  67122. private _actualFrame;
  67123. private _customEffect;
  67124. private readonly _rawTextureWidth;
  67125. /**
  67126. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  67127. */
  67128. static get IsSupported(): boolean;
  67129. /**
  67130. * An event triggered when the system is disposed.
  67131. */
  67132. onDisposeObservable: Observable<IParticleSystem>;
  67133. /**
  67134. * Gets the maximum number of particles active at the same time.
  67135. * @returns The max number of active particles.
  67136. */
  67137. getCapacity(): number;
  67138. /**
  67139. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  67140. * to override the particles.
  67141. */
  67142. forceDepthWrite: boolean;
  67143. /**
  67144. * Gets or set the number of active particles
  67145. */
  67146. get activeParticleCount(): number;
  67147. set activeParticleCount(value: number);
  67148. private _preWarmDone;
  67149. /**
  67150. * Specifies if the particles are updated in emitter local space or world space.
  67151. */
  67152. isLocal: boolean;
  67153. /** Gets or sets a matrix to use to compute projection */
  67154. defaultProjectionMatrix: Matrix;
  67155. /**
  67156. * Is this system ready to be used/rendered
  67157. * @return true if the system is ready
  67158. */
  67159. isReady(): boolean;
  67160. /**
  67161. * Gets if the system has been started. (Note: this will still be true after stop is called)
  67162. * @returns True if it has been started, otherwise false.
  67163. */
  67164. isStarted(): boolean;
  67165. /**
  67166. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  67167. * @returns True if it has been stopped, otherwise false.
  67168. */
  67169. isStopped(): boolean;
  67170. /**
  67171. * Gets a boolean indicating that the system is stopping
  67172. * @returns true if the system is currently stopping
  67173. */
  67174. isStopping(): boolean;
  67175. /**
  67176. * Gets the number of particles active at the same time.
  67177. * @returns The number of active particles.
  67178. */
  67179. getActiveCount(): number;
  67180. /**
  67181. * Starts the particle system and begins to emit
  67182. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  67183. */
  67184. start(delay?: number): void;
  67185. /**
  67186. * Stops the particle system.
  67187. */
  67188. stop(): void;
  67189. /**
  67190. * Remove all active particles
  67191. */
  67192. reset(): void;
  67193. /**
  67194. * Returns the string "GPUParticleSystem"
  67195. * @returns a string containing the class name
  67196. */
  67197. getClassName(): string;
  67198. /**
  67199. * Gets the custom effect used to render the particles
  67200. * @param blendMode Blend mode for which the effect should be retrieved
  67201. * @returns The effect
  67202. */
  67203. getCustomEffect(blendMode?: number): Nullable<Effect>;
  67204. /**
  67205. * Sets the custom effect used to render the particles
  67206. * @param effect The effect to set
  67207. * @param blendMode Blend mode for which the effect should be set
  67208. */
  67209. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  67210. /** @hidden */
  67211. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  67212. /**
  67213. * Observable that will be called just before the particles are drawn
  67214. */
  67215. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  67216. /**
  67217. * Gets the name of the particle vertex shader
  67218. */
  67219. get vertexShaderName(): string;
  67220. private _colorGradientsTexture;
  67221. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  67222. /**
  67223. * Adds a new color gradient
  67224. * @param gradient defines the gradient to use (between 0 and 1)
  67225. * @param color1 defines the color to affect to the specified gradient
  67226. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  67227. * @returns the current particle system
  67228. */
  67229. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  67230. private _refreshColorGradient;
  67231. /** Force the system to rebuild all gradients that need to be resync */
  67232. forceRefreshGradients(): void;
  67233. /**
  67234. * Remove a specific color gradient
  67235. * @param gradient defines the gradient to remove
  67236. * @returns the current particle system
  67237. */
  67238. removeColorGradient(gradient: number): GPUParticleSystem;
  67239. private _angularSpeedGradientsTexture;
  67240. private _sizeGradientsTexture;
  67241. private _velocityGradientsTexture;
  67242. private _limitVelocityGradientsTexture;
  67243. private _dragGradientsTexture;
  67244. private _addFactorGradient;
  67245. /**
  67246. * Adds a new size gradient
  67247. * @param gradient defines the gradient to use (between 0 and 1)
  67248. * @param factor defines the size factor to affect to the specified gradient
  67249. * @returns the current particle system
  67250. */
  67251. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  67252. /**
  67253. * Remove a specific size gradient
  67254. * @param gradient defines the gradient to remove
  67255. * @returns the current particle system
  67256. */
  67257. removeSizeGradient(gradient: number): GPUParticleSystem;
  67258. private _refreshFactorGradient;
  67259. /**
  67260. * Adds a new angular speed gradient
  67261. * @param gradient defines the gradient to use (between 0 and 1)
  67262. * @param factor defines the angular speed to affect to the specified gradient
  67263. * @returns the current particle system
  67264. */
  67265. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  67266. /**
  67267. * Remove a specific angular speed gradient
  67268. * @param gradient defines the gradient to remove
  67269. * @returns the current particle system
  67270. */
  67271. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  67272. /**
  67273. * Adds a new velocity gradient
  67274. * @param gradient defines the gradient to use (between 0 and 1)
  67275. * @param factor defines the velocity to affect to the specified gradient
  67276. * @returns the current particle system
  67277. */
  67278. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67279. /**
  67280. * Remove a specific velocity gradient
  67281. * @param gradient defines the gradient to remove
  67282. * @returns the current particle system
  67283. */
  67284. removeVelocityGradient(gradient: number): GPUParticleSystem;
  67285. /**
  67286. * Adds a new limit velocity gradient
  67287. * @param gradient defines the gradient to use (between 0 and 1)
  67288. * @param factor defines the limit velocity value to affect to the specified gradient
  67289. * @returns the current particle system
  67290. */
  67291. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67292. /**
  67293. * Remove a specific limit velocity gradient
  67294. * @param gradient defines the gradient to remove
  67295. * @returns the current particle system
  67296. */
  67297. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  67298. /**
  67299. * Adds a new drag gradient
  67300. * @param gradient defines the gradient to use (between 0 and 1)
  67301. * @param factor defines the drag value to affect to the specified gradient
  67302. * @returns the current particle system
  67303. */
  67304. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  67305. /**
  67306. * Remove a specific drag gradient
  67307. * @param gradient defines the gradient to remove
  67308. * @returns the current particle system
  67309. */
  67310. removeDragGradient(gradient: number): GPUParticleSystem;
  67311. /**
  67312. * Not supported by GPUParticleSystem
  67313. * @param gradient defines the gradient to use (between 0 and 1)
  67314. * @param factor defines the emit rate value to affect to the specified gradient
  67315. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67316. * @returns the current particle system
  67317. */
  67318. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67319. /**
  67320. * Not supported by GPUParticleSystem
  67321. * @param gradient defines the gradient to remove
  67322. * @returns the current particle system
  67323. */
  67324. removeEmitRateGradient(gradient: number): IParticleSystem;
  67325. /**
  67326. * Not supported by GPUParticleSystem
  67327. * @param gradient defines the gradient to use (between 0 and 1)
  67328. * @param factor defines the start size value to affect to the specified gradient
  67329. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67330. * @returns the current particle system
  67331. */
  67332. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67333. /**
  67334. * Not supported by GPUParticleSystem
  67335. * @param gradient defines the gradient to remove
  67336. * @returns the current particle system
  67337. */
  67338. removeStartSizeGradient(gradient: number): IParticleSystem;
  67339. /**
  67340. * Not supported by GPUParticleSystem
  67341. * @param gradient defines the gradient to use (between 0 and 1)
  67342. * @param min defines the color remap minimal range
  67343. * @param max defines the color remap maximal range
  67344. * @returns the current particle system
  67345. */
  67346. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67347. /**
  67348. * Not supported by GPUParticleSystem
  67349. * @param gradient defines the gradient to remove
  67350. * @returns the current particle system
  67351. */
  67352. removeColorRemapGradient(): IParticleSystem;
  67353. /**
  67354. * Not supported by GPUParticleSystem
  67355. * @param gradient defines the gradient to use (between 0 and 1)
  67356. * @param min defines the alpha remap minimal range
  67357. * @param max defines the alpha remap maximal range
  67358. * @returns the current particle system
  67359. */
  67360. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67361. /**
  67362. * Not supported by GPUParticleSystem
  67363. * @param gradient defines the gradient to remove
  67364. * @returns the current particle system
  67365. */
  67366. removeAlphaRemapGradient(): IParticleSystem;
  67367. /**
  67368. * Not supported by GPUParticleSystem
  67369. * @param gradient defines the gradient to use (between 0 and 1)
  67370. * @param color defines the color to affect to the specified gradient
  67371. * @returns the current particle system
  67372. */
  67373. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  67374. /**
  67375. * Not supported by GPUParticleSystem
  67376. * @param gradient defines the gradient to remove
  67377. * @returns the current particle system
  67378. */
  67379. removeRampGradient(): IParticleSystem;
  67380. /**
  67381. * Not supported by GPUParticleSystem
  67382. * @returns the list of ramp gradients
  67383. */
  67384. getRampGradients(): Nullable<Array<Color3Gradient>>;
  67385. /**
  67386. * Not supported by GPUParticleSystem
  67387. * Gets or sets a boolean indicating that ramp gradients must be used
  67388. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  67389. */
  67390. get useRampGradients(): boolean;
  67391. set useRampGradients(value: boolean);
  67392. /**
  67393. * Not supported by GPUParticleSystem
  67394. * @param gradient defines the gradient to use (between 0 and 1)
  67395. * @param factor defines the life time factor to affect to the specified gradient
  67396. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67397. * @returns the current particle system
  67398. */
  67399. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67400. /**
  67401. * Not supported by GPUParticleSystem
  67402. * @param gradient defines the gradient to remove
  67403. * @returns the current particle system
  67404. */
  67405. removeLifeTimeGradient(gradient: number): IParticleSystem;
  67406. /**
  67407. * Instantiates a GPU particle system.
  67408. * 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.
  67409. * @param name The name of the particle system
  67410. * @param options The options used to create the system
  67411. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  67412. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  67413. * @param customEffect a custom effect used to change the way particles are rendered by default
  67414. */
  67415. constructor(name: string, options: Partial<{
  67416. capacity: number;
  67417. randomTextureSize: number;
  67418. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  67419. protected _reset(): void;
  67420. private _createUpdateVAO;
  67421. private _createRenderVAO;
  67422. private _initialize;
  67423. /** @hidden */
  67424. _recreateUpdateEffect(): void;
  67425. private _getEffect;
  67426. /**
  67427. * Fill the defines array according to the current settings of the particle system
  67428. * @param defines Array to be updated
  67429. * @param blendMode blend mode to take into account when updating the array
  67430. */
  67431. fillDefines(defines: Array<string>, blendMode?: number): void;
  67432. /**
  67433. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  67434. * @param uniforms Uniforms array to fill
  67435. * @param attributes Attributes array to fill
  67436. * @param samplers Samplers array to fill
  67437. */
  67438. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  67439. /** @hidden */
  67440. _recreateRenderEffect(): Effect;
  67441. /**
  67442. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  67443. * @param preWarm defines if we are in the pre-warmimg phase
  67444. */
  67445. animate(preWarm?: boolean): void;
  67446. private _createFactorGradientTexture;
  67447. private _createSizeGradientTexture;
  67448. private _createAngularSpeedGradientTexture;
  67449. private _createVelocityGradientTexture;
  67450. private _createLimitVelocityGradientTexture;
  67451. private _createDragGradientTexture;
  67452. private _createColorGradientTexture;
  67453. /**
  67454. * Renders the particle system in its current state
  67455. * @param preWarm defines if the system should only update the particles but not render them
  67456. * @returns the current number of particles
  67457. */
  67458. render(preWarm?: boolean): number;
  67459. /**
  67460. * Rebuilds the particle system
  67461. */
  67462. rebuild(): void;
  67463. private _releaseBuffers;
  67464. private _releaseVAOs;
  67465. /**
  67466. * Disposes the particle system and free the associated resources
  67467. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  67468. */
  67469. dispose(disposeTexture?: boolean): void;
  67470. /**
  67471. * Clones the particle system.
  67472. * @param name The name of the cloned object
  67473. * @param newEmitter The new emitter to use
  67474. * @returns the cloned particle system
  67475. */
  67476. clone(name: string, newEmitter: any): GPUParticleSystem;
  67477. /**
  67478. * Serializes the particle system to a JSON object
  67479. * @param serializeTexture defines if the texture must be serialized as well
  67480. * @returns the JSON object
  67481. */
  67482. serialize(serializeTexture?: boolean): any;
  67483. /**
  67484. * Parses a JSON object to create a GPU particle system.
  67485. * @param parsedParticleSystem The JSON object to parse
  67486. * @param sceneOrEngine The scene or the engine to create the particle system in
  67487. * @param rootUrl The root url to use to load external dependencies like texture
  67488. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  67489. * @returns the parsed GPU particle system
  67490. */
  67491. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  67492. }
  67493. }
  67494. declare module BABYLON {
  67495. /**
  67496. * Represents a set of particle systems working together to create a specific effect
  67497. */
  67498. export class ParticleSystemSet implements IDisposable {
  67499. /**
  67500. * Gets or sets base Assets URL
  67501. */
  67502. static BaseAssetsUrl: string;
  67503. private _emitterCreationOptions;
  67504. private _emitterNode;
  67505. /**
  67506. * Gets the particle system list
  67507. */
  67508. systems: IParticleSystem[];
  67509. /**
  67510. * Gets the emitter node used with this set
  67511. */
  67512. get emitterNode(): Nullable<TransformNode>;
  67513. /**
  67514. * Creates a new emitter mesh as a sphere
  67515. * @param options defines the options used to create the sphere
  67516. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  67517. * @param scene defines the hosting scene
  67518. */
  67519. setEmitterAsSphere(options: {
  67520. diameter: number;
  67521. segments: number;
  67522. color: Color3;
  67523. }, renderingGroupId: number, scene: Scene): void;
  67524. /**
  67525. * Starts all particle systems of the set
  67526. * @param emitter defines an optional mesh to use as emitter for the particle systems
  67527. */
  67528. start(emitter?: AbstractMesh): void;
  67529. /**
  67530. * Release all associated resources
  67531. */
  67532. dispose(): void;
  67533. /**
  67534. * Serialize the set into a JSON compatible object
  67535. * @param serializeTexture defines if the texture must be serialized as well
  67536. * @returns a JSON compatible representation of the set
  67537. */
  67538. serialize(serializeTexture?: boolean): any;
  67539. /**
  67540. * Parse a new ParticleSystemSet from a serialized source
  67541. * @param data defines a JSON compatible representation of the set
  67542. * @param scene defines the hosting scene
  67543. * @param gpu defines if we want GPU particles or CPU particles
  67544. * @returns a new ParticleSystemSet
  67545. */
  67546. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  67547. }
  67548. }
  67549. declare module BABYLON {
  67550. /**
  67551. * This class is made for on one-liner static method to help creating particle system set.
  67552. */
  67553. export class ParticleHelper {
  67554. /**
  67555. * Gets or sets base Assets URL
  67556. */
  67557. static BaseAssetsUrl: string;
  67558. /** Define the Url to load snippets */
  67559. static SnippetUrl: string;
  67560. /**
  67561. * Create a default particle system that you can tweak
  67562. * @param emitter defines the emitter to use
  67563. * @param capacity defines the system capacity (default is 500 particles)
  67564. * @param scene defines the hosting scene
  67565. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  67566. * @returns the new Particle system
  67567. */
  67568. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  67569. /**
  67570. * This is the main static method (one-liner) of this helper to create different particle systems
  67571. * @param type This string represents the type to the particle system to create
  67572. * @param scene The scene where the particle system should live
  67573. * @param gpu If the system will use gpu
  67574. * @returns the ParticleSystemSet created
  67575. */
  67576. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  67577. /**
  67578. * Static function used to export a particle system to a ParticleSystemSet variable.
  67579. * Please note that the emitter shape is not exported
  67580. * @param systems defines the particle systems to export
  67581. * @returns the created particle system set
  67582. */
  67583. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  67584. /**
  67585. * Creates a particle system from a snippet saved in a remote file
  67586. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  67587. * @param url defines the url to load from
  67588. * @param scene defines the hosting scene
  67589. * @param gpu If the system will use gpu
  67590. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67591. * @returns a promise that will resolve to the new particle system
  67592. */
  67593. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  67594. /**
  67595. * Creates a particle system from a snippet saved by the particle system editor
  67596. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  67597. * @param scene defines the hosting scene
  67598. * @param gpu If the system will use gpu
  67599. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67600. * @returns a promise that will resolve to the new particle system
  67601. */
  67602. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  67603. }
  67604. }
  67605. declare module BABYLON {
  67606. interface Engine {
  67607. /**
  67608. * Create an effect to use with particle systems.
  67609. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  67610. * the particle system for which you want to create a custom effect in the last parameter
  67611. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  67612. * @param uniformsNames defines a list of attribute names
  67613. * @param samplers defines an array of string used to represent textures
  67614. * @param defines defines the string containing the defines to use to compile the shaders
  67615. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  67616. * @param onCompiled defines a function to call when the effect creation is successful
  67617. * @param onError defines a function to call when the effect creation has failed
  67618. * @param particleSystem the particle system you want to create the effect for
  67619. * @returns the new Effect
  67620. */
  67621. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  67622. }
  67623. interface Mesh {
  67624. /**
  67625. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  67626. * @returns an array of IParticleSystem
  67627. */
  67628. getEmittedParticleSystems(): IParticleSystem[];
  67629. /**
  67630. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  67631. * @returns an array of IParticleSystem
  67632. */
  67633. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  67634. }
  67635. }
  67636. declare module BABYLON {
  67637. /** Defines the 4 color options */
  67638. export enum PointColor {
  67639. /** color value */
  67640. Color = 2,
  67641. /** uv value */
  67642. UV = 1,
  67643. /** random value */
  67644. Random = 0,
  67645. /** stated value */
  67646. Stated = 3
  67647. }
  67648. /**
  67649. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  67650. * 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.
  67651. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  67652. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  67653. *
  67654. * Full documentation here : TO BE ENTERED
  67655. */
  67656. export class PointsCloudSystem implements IDisposable {
  67657. /**
  67658. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  67659. * Example : var p = SPS.particles[i];
  67660. */
  67661. particles: CloudPoint[];
  67662. /**
  67663. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  67664. */
  67665. nbParticles: number;
  67666. /**
  67667. * This a counter for your own usage. It's not set by any SPS functions.
  67668. */
  67669. counter: number;
  67670. /**
  67671. * The PCS name. This name is also given to the underlying mesh.
  67672. */
  67673. name: string;
  67674. /**
  67675. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  67676. */
  67677. mesh: Mesh;
  67678. /**
  67679. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  67680. * Please read :
  67681. */
  67682. vars: any;
  67683. /**
  67684. * @hidden
  67685. */
  67686. _size: number;
  67687. private _scene;
  67688. private _promises;
  67689. private _positions;
  67690. private _indices;
  67691. private _normals;
  67692. private _colors;
  67693. private _uvs;
  67694. private _indices32;
  67695. private _positions32;
  67696. private _colors32;
  67697. private _uvs32;
  67698. private _updatable;
  67699. private _isVisibilityBoxLocked;
  67700. private _alwaysVisible;
  67701. private _groups;
  67702. private _groupCounter;
  67703. private _computeParticleColor;
  67704. private _computeParticleTexture;
  67705. private _computeParticleRotation;
  67706. private _computeBoundingBox;
  67707. private _isReady;
  67708. /**
  67709. * Creates a PCS (Points Cloud System) object
  67710. * @param name (String) is the PCS name, this will be the underlying mesh name
  67711. * @param pointSize (number) is the size for each point
  67712. * @param scene (Scene) is the scene in which the PCS is added
  67713. * @param options defines the options of the PCS e.g.
  67714. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  67715. */
  67716. constructor(name: string, pointSize: number, scene: Scene, options?: {
  67717. updatable?: boolean;
  67718. });
  67719. /**
  67720. * Builds the PCS underlying mesh. Returns a standard Mesh.
  67721. * If no points were added to the PCS, the returned mesh is just a single point.
  67722. * @returns a promise for the created mesh
  67723. */
  67724. buildMeshAsync(): Promise<Mesh>;
  67725. /**
  67726. * @hidden
  67727. */
  67728. private _buildMesh;
  67729. private _addParticle;
  67730. private _randomUnitVector;
  67731. private _getColorIndicesForCoord;
  67732. private _setPointsColorOrUV;
  67733. private _colorFromTexture;
  67734. private _calculateDensity;
  67735. /**
  67736. * Adds points to the PCS in random positions within a unit sphere
  67737. * @param nb (positive integer) the number of particles to be created from this model
  67738. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  67739. * @returns the number of groups in the system
  67740. */
  67741. addPoints(nb: number, pointFunction?: any): number;
  67742. /**
  67743. * Adds points to the PCS from the surface of the model shape
  67744. * @param mesh is any Mesh object that will be used as a surface model for the points
  67745. * @param nb (positive integer) the number of particles to be created from this model
  67746. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67747. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67748. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67749. * @returns the number of groups in the system
  67750. */
  67751. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67752. /**
  67753. * Adds points to the PCS inside the model shape
  67754. * @param mesh is any Mesh object that will be used as a surface model for the points
  67755. * @param nb (positive integer) the number of particles to be created from this model
  67756. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67757. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67758. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67759. * @returns the number of groups in the system
  67760. */
  67761. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67762. /**
  67763. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  67764. * This method calls `updateParticle()` for each particle of the SPS.
  67765. * For an animated SPS, it is usually called within the render loop.
  67766. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  67767. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  67768. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  67769. * @returns the PCS.
  67770. */
  67771. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  67772. /**
  67773. * Disposes the PCS.
  67774. */
  67775. dispose(): void;
  67776. /**
  67777. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  67778. * doc :
  67779. * @returns the PCS.
  67780. */
  67781. refreshVisibleSize(): PointsCloudSystem;
  67782. /**
  67783. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  67784. * @param size the size (float) of the visibility box
  67785. * note : this doesn't lock the PCS mesh bounding box.
  67786. * doc :
  67787. */
  67788. setVisibilityBox(size: number): void;
  67789. /**
  67790. * Gets whether the PCS is always visible or not
  67791. * doc :
  67792. */
  67793. get isAlwaysVisible(): boolean;
  67794. /**
  67795. * Sets the PCS as always visible or not
  67796. * doc :
  67797. */
  67798. set isAlwaysVisible(val: boolean);
  67799. /**
  67800. * Tells to `setParticles()` to compute the particle rotations or not
  67801. * Default value : false. The PCS is faster when it's set to false
  67802. * Note : particle rotations are only applied to parent particles
  67803. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  67804. */
  67805. set computeParticleRotation(val: boolean);
  67806. /**
  67807. * Tells to `setParticles()` to compute the particle colors or not.
  67808. * Default value : true. The PCS is faster when it's set to false.
  67809. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  67810. */
  67811. set computeParticleColor(val: boolean);
  67812. set computeParticleTexture(val: boolean);
  67813. /**
  67814. * Gets if `setParticles()` computes the particle colors or not.
  67815. * Default value : false. The PCS is faster when it's set to false.
  67816. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  67817. */
  67818. get computeParticleColor(): boolean;
  67819. /**
  67820. * Gets if `setParticles()` computes the particle textures or not.
  67821. * Default value : false. The PCS is faster when it's set to false.
  67822. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  67823. */
  67824. get computeParticleTexture(): boolean;
  67825. /**
  67826. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  67827. */
  67828. set computeBoundingBox(val: boolean);
  67829. /**
  67830. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  67831. */
  67832. get computeBoundingBox(): boolean;
  67833. /**
  67834. * This function does nothing. It may be overwritten to set all the particle first values.
  67835. * The PCS doesn't call this function, you may have to call it by your own.
  67836. * doc :
  67837. */
  67838. initParticles(): void;
  67839. /**
  67840. * This function does nothing. It may be overwritten to recycle a particle
  67841. * The PCS doesn't call this function, you can to call it
  67842. * doc :
  67843. * @param particle The particle to recycle
  67844. * @returns the recycled particle
  67845. */
  67846. recycleParticle(particle: CloudPoint): CloudPoint;
  67847. /**
  67848. * Updates a particle : this function should be overwritten by the user.
  67849. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  67850. * doc :
  67851. * @example : just set a particle position or velocity and recycle conditions
  67852. * @param particle The particle to update
  67853. * @returns the updated particle
  67854. */
  67855. updateParticle(particle: CloudPoint): CloudPoint;
  67856. /**
  67857. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  67858. * This does nothing and may be overwritten by the user.
  67859. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  67860. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  67861. * @param update the boolean update value actually passed to setParticles()
  67862. */
  67863. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  67864. /**
  67865. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  67866. * This will be passed three parameters.
  67867. * This does nothing and may be overwritten by the user.
  67868. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  67869. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  67870. * @param update the boolean update value actually passed to setParticles()
  67871. */
  67872. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  67873. }
  67874. }
  67875. declare module BABYLON {
  67876. /**
  67877. * Represents one particle of a points cloud system.
  67878. */
  67879. export class CloudPoint {
  67880. /**
  67881. * particle global index
  67882. */
  67883. idx: number;
  67884. /**
  67885. * The color of the particle
  67886. */
  67887. color: Nullable<Color4>;
  67888. /**
  67889. * The world space position of the particle.
  67890. */
  67891. position: Vector3;
  67892. /**
  67893. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  67894. */
  67895. rotation: Vector3;
  67896. /**
  67897. * The world space rotation quaternion of the particle.
  67898. */
  67899. rotationQuaternion: Nullable<Quaternion>;
  67900. /**
  67901. * The uv of the particle.
  67902. */
  67903. uv: Nullable<Vector2>;
  67904. /**
  67905. * The current speed of the particle.
  67906. */
  67907. velocity: Vector3;
  67908. /**
  67909. * The pivot point in the particle local space.
  67910. */
  67911. pivot: Vector3;
  67912. /**
  67913. * Must the particle be translated from its pivot point in its local space ?
  67914. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  67915. * Default : false
  67916. */
  67917. translateFromPivot: boolean;
  67918. /**
  67919. * Index of this particle in the global "positions" array (Internal use)
  67920. * @hidden
  67921. */
  67922. _pos: number;
  67923. /**
  67924. * @hidden Index of this particle in the global "indices" array (Internal use)
  67925. */
  67926. _ind: number;
  67927. /**
  67928. * Group this particle belongs to
  67929. */
  67930. _group: PointsGroup;
  67931. /**
  67932. * Group id of this particle
  67933. */
  67934. groupId: number;
  67935. /**
  67936. * Index of the particle in its group id (Internal use)
  67937. */
  67938. idxInGroup: number;
  67939. /**
  67940. * @hidden Particle BoundingInfo object (Internal use)
  67941. */
  67942. _boundingInfo: BoundingInfo;
  67943. /**
  67944. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  67945. */
  67946. _pcs: PointsCloudSystem;
  67947. /**
  67948. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  67949. */
  67950. _stillInvisible: boolean;
  67951. /**
  67952. * @hidden Last computed particle rotation matrix
  67953. */
  67954. _rotationMatrix: number[];
  67955. /**
  67956. * Parent particle Id, if any.
  67957. * Default null.
  67958. */
  67959. parentId: Nullable<number>;
  67960. /**
  67961. * @hidden Internal global position in the PCS.
  67962. */
  67963. _globalPosition: Vector3;
  67964. /**
  67965. * Creates a Point Cloud object.
  67966. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  67967. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  67968. * @param group (PointsGroup) is the group the particle belongs to
  67969. * @param groupId (integer) is the group identifier in the PCS.
  67970. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  67971. * @param pcs defines the PCS it is associated to
  67972. */
  67973. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  67974. /**
  67975. * get point size
  67976. */
  67977. get size(): Vector3;
  67978. /**
  67979. * Set point size
  67980. */
  67981. set size(scale: Vector3);
  67982. /**
  67983. * Legacy support, changed quaternion to rotationQuaternion
  67984. */
  67985. get quaternion(): Nullable<Quaternion>;
  67986. /**
  67987. * Legacy support, changed quaternion to rotationQuaternion
  67988. */
  67989. set quaternion(q: Nullable<Quaternion>);
  67990. /**
  67991. * Returns a boolean. True if the particle intersects a mesh, else false
  67992. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  67993. * @param target is the object (point or mesh) what the intersection is computed against
  67994. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  67995. * @returns true if it intersects
  67996. */
  67997. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  67998. /**
  67999. * get the rotation matrix of the particle
  68000. * @hidden
  68001. */
  68002. getRotationMatrix(m: Matrix): void;
  68003. }
  68004. /**
  68005. * Represents a group of points in a points cloud system
  68006. * * PCS internal tool, don't use it manually.
  68007. */
  68008. export class PointsGroup {
  68009. /**
  68010. * The group id
  68011. * @hidden
  68012. */
  68013. groupID: number;
  68014. /**
  68015. * image data for group (internal use)
  68016. * @hidden
  68017. */
  68018. _groupImageData: Nullable<ArrayBufferView>;
  68019. /**
  68020. * Image Width (internal use)
  68021. * @hidden
  68022. */
  68023. _groupImgWidth: number;
  68024. /**
  68025. * Image Height (internal use)
  68026. * @hidden
  68027. */
  68028. _groupImgHeight: number;
  68029. /**
  68030. * Custom position function (internal use)
  68031. * @hidden
  68032. */
  68033. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  68034. /**
  68035. * density per facet for surface points
  68036. * @hidden
  68037. */
  68038. _groupDensity: number[];
  68039. /**
  68040. * Only when points are colored by texture carries pointer to texture list array
  68041. * @hidden
  68042. */
  68043. _textureNb: number;
  68044. /**
  68045. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  68046. * PCS internal tool, don't use it manually.
  68047. * @hidden
  68048. */
  68049. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  68050. }
  68051. }
  68052. declare module BABYLON {
  68053. interface Scene {
  68054. /** @hidden (Backing field) */
  68055. _physicsEngine: Nullable<IPhysicsEngine>;
  68056. /** @hidden */
  68057. _physicsTimeAccumulator: number;
  68058. /**
  68059. * Gets the current physics engine
  68060. * @returns a IPhysicsEngine or null if none attached
  68061. */
  68062. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  68063. /**
  68064. * Enables physics to the current scene
  68065. * @param gravity defines the scene's gravity for the physics engine
  68066. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  68067. * @return a boolean indicating if the physics engine was initialized
  68068. */
  68069. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  68070. /**
  68071. * Disables and disposes the physics engine associated with the scene
  68072. */
  68073. disablePhysicsEngine(): void;
  68074. /**
  68075. * Gets a boolean indicating if there is an active physics engine
  68076. * @returns a boolean indicating if there is an active physics engine
  68077. */
  68078. isPhysicsEnabled(): boolean;
  68079. /**
  68080. * Deletes a physics compound impostor
  68081. * @param compound defines the compound to delete
  68082. */
  68083. deleteCompoundImpostor(compound: any): void;
  68084. /**
  68085. * An event triggered when physic simulation is about to be run
  68086. */
  68087. onBeforePhysicsObservable: Observable<Scene>;
  68088. /**
  68089. * An event triggered when physic simulation has been done
  68090. */
  68091. onAfterPhysicsObservable: Observable<Scene>;
  68092. }
  68093. interface AbstractMesh {
  68094. /** @hidden */
  68095. _physicsImpostor: Nullable<PhysicsImpostor>;
  68096. /**
  68097. * Gets or sets impostor used for physic simulation
  68098. * @see https://doc.babylonjs.com/features/physics_engine
  68099. */
  68100. physicsImpostor: Nullable<PhysicsImpostor>;
  68101. /**
  68102. * Gets the current physics impostor
  68103. * @see https://doc.babylonjs.com/features/physics_engine
  68104. * @returns a physics impostor or null
  68105. */
  68106. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  68107. /** Apply a physic impulse to the mesh
  68108. * @param force defines the force to apply
  68109. * @param contactPoint defines where to apply the force
  68110. * @returns the current mesh
  68111. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  68112. */
  68113. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  68114. /**
  68115. * Creates a physic joint between two meshes
  68116. * @param otherMesh defines the other mesh to use
  68117. * @param pivot1 defines the pivot to use on this mesh
  68118. * @param pivot2 defines the pivot to use on the other mesh
  68119. * @param options defines additional options (can be plugin dependent)
  68120. * @returns the current mesh
  68121. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  68122. */
  68123. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  68124. /** @hidden */
  68125. _disposePhysicsObserver: Nullable<Observer<Node>>;
  68126. }
  68127. /**
  68128. * Defines the physics engine scene component responsible to manage a physics engine
  68129. */
  68130. export class PhysicsEngineSceneComponent implements ISceneComponent {
  68131. /**
  68132. * The component name helpful to identify the component in the list of scene components.
  68133. */
  68134. readonly name: string;
  68135. /**
  68136. * The scene the component belongs to.
  68137. */
  68138. scene: Scene;
  68139. /**
  68140. * Creates a new instance of the component for the given scene
  68141. * @param scene Defines the scene to register the component in
  68142. */
  68143. constructor(scene: Scene);
  68144. /**
  68145. * Registers the component in a given scene
  68146. */
  68147. register(): void;
  68148. /**
  68149. * Rebuilds the elements related to this component in case of
  68150. * context lost for instance.
  68151. */
  68152. rebuild(): void;
  68153. /**
  68154. * Disposes the component and the associated ressources
  68155. */
  68156. dispose(): void;
  68157. }
  68158. }
  68159. declare module BABYLON {
  68160. /**
  68161. * A helper for physics simulations
  68162. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68163. */
  68164. export class PhysicsHelper {
  68165. private _scene;
  68166. private _physicsEngine;
  68167. /**
  68168. * Initializes the Physics helper
  68169. * @param scene Babylon.js scene
  68170. */
  68171. constructor(scene: Scene);
  68172. /**
  68173. * Applies a radial explosion impulse
  68174. * @param origin the origin of the explosion
  68175. * @param radiusOrEventOptions the radius or the options of radial explosion
  68176. * @param strength the explosion strength
  68177. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68178. * @returns A physics radial explosion event, or null
  68179. */
  68180. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68181. /**
  68182. * Applies a radial explosion force
  68183. * @param origin the origin of the explosion
  68184. * @param radiusOrEventOptions the radius or the options of radial explosion
  68185. * @param strength the explosion strength
  68186. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68187. * @returns A physics radial explosion event, or null
  68188. */
  68189. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68190. /**
  68191. * Creates a gravitational field
  68192. * @param origin the origin of the explosion
  68193. * @param radiusOrEventOptions the radius or the options of radial explosion
  68194. * @param strength the explosion strength
  68195. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68196. * @returns A physics gravitational field event, or null
  68197. */
  68198. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  68199. /**
  68200. * Creates a physics updraft event
  68201. * @param origin the origin of the updraft
  68202. * @param radiusOrEventOptions the radius or the options of the updraft
  68203. * @param strength the strength of the updraft
  68204. * @param height the height of the updraft
  68205. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  68206. * @returns A physics updraft event, or null
  68207. */
  68208. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  68209. /**
  68210. * Creates a physics vortex event
  68211. * @param origin the of the vortex
  68212. * @param radiusOrEventOptions the radius or the options of the vortex
  68213. * @param strength the strength of the vortex
  68214. * @param height the height of the vortex
  68215. * @returns a Physics vortex event, or null
  68216. * A physics vortex event or null
  68217. */
  68218. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  68219. }
  68220. /**
  68221. * Represents a physics radial explosion event
  68222. */
  68223. class PhysicsRadialExplosionEvent {
  68224. private _scene;
  68225. private _options;
  68226. private _sphere;
  68227. private _dataFetched;
  68228. /**
  68229. * Initializes a radial explosioin event
  68230. * @param _scene BabylonJS scene
  68231. * @param _options The options for the vortex event
  68232. */
  68233. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  68234. /**
  68235. * Returns the data related to the radial explosion event (sphere).
  68236. * @returns The radial explosion event data
  68237. */
  68238. getData(): PhysicsRadialExplosionEventData;
  68239. /**
  68240. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  68241. * @param impostor A physics imposter
  68242. * @param origin the origin of the explosion
  68243. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  68244. */
  68245. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  68246. /**
  68247. * Triggers affecterd impostors callbacks
  68248. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  68249. */
  68250. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  68251. /**
  68252. * Disposes the sphere.
  68253. * @param force Specifies if the sphere should be disposed by force
  68254. */
  68255. dispose(force?: boolean): void;
  68256. /*** Helpers ***/
  68257. private _prepareSphere;
  68258. private _intersectsWithSphere;
  68259. }
  68260. /**
  68261. * Represents a gravitational field event
  68262. */
  68263. class PhysicsGravitationalFieldEvent {
  68264. private _physicsHelper;
  68265. private _scene;
  68266. private _origin;
  68267. private _options;
  68268. private _tickCallback;
  68269. private _sphere;
  68270. private _dataFetched;
  68271. /**
  68272. * Initializes the physics gravitational field event
  68273. * @param _physicsHelper A physics helper
  68274. * @param _scene BabylonJS scene
  68275. * @param _origin The origin position of the gravitational field event
  68276. * @param _options The options for the vortex event
  68277. */
  68278. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  68279. /**
  68280. * Returns the data related to the gravitational field event (sphere).
  68281. * @returns A gravitational field event
  68282. */
  68283. getData(): PhysicsGravitationalFieldEventData;
  68284. /**
  68285. * Enables the gravitational field.
  68286. */
  68287. enable(): void;
  68288. /**
  68289. * Disables the gravitational field.
  68290. */
  68291. disable(): void;
  68292. /**
  68293. * Disposes the sphere.
  68294. * @param force The force to dispose from the gravitational field event
  68295. */
  68296. dispose(force?: boolean): void;
  68297. private _tick;
  68298. }
  68299. /**
  68300. * Represents a physics updraft event
  68301. */
  68302. class PhysicsUpdraftEvent {
  68303. private _scene;
  68304. private _origin;
  68305. private _options;
  68306. private _physicsEngine;
  68307. private _originTop;
  68308. private _originDirection;
  68309. private _tickCallback;
  68310. private _cylinder;
  68311. private _cylinderPosition;
  68312. private _dataFetched;
  68313. /**
  68314. * Initializes the physics updraft event
  68315. * @param _scene BabylonJS scene
  68316. * @param _origin The origin position of the updraft
  68317. * @param _options The options for the updraft event
  68318. */
  68319. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  68320. /**
  68321. * Returns the data related to the updraft event (cylinder).
  68322. * @returns A physics updraft event
  68323. */
  68324. getData(): PhysicsUpdraftEventData;
  68325. /**
  68326. * Enables the updraft.
  68327. */
  68328. enable(): void;
  68329. /**
  68330. * Disables the updraft.
  68331. */
  68332. disable(): void;
  68333. /**
  68334. * Disposes the cylinder.
  68335. * @param force Specifies if the updraft should be disposed by force
  68336. */
  68337. dispose(force?: boolean): void;
  68338. private getImpostorHitData;
  68339. private _tick;
  68340. /*** Helpers ***/
  68341. private _prepareCylinder;
  68342. private _intersectsWithCylinder;
  68343. }
  68344. /**
  68345. * Represents a physics vortex event
  68346. */
  68347. class PhysicsVortexEvent {
  68348. private _scene;
  68349. private _origin;
  68350. private _options;
  68351. private _physicsEngine;
  68352. private _originTop;
  68353. private _tickCallback;
  68354. private _cylinder;
  68355. private _cylinderPosition;
  68356. private _dataFetched;
  68357. /**
  68358. * Initializes the physics vortex event
  68359. * @param _scene The BabylonJS scene
  68360. * @param _origin The origin position of the vortex
  68361. * @param _options The options for the vortex event
  68362. */
  68363. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  68364. /**
  68365. * Returns the data related to the vortex event (cylinder).
  68366. * @returns The physics vortex event data
  68367. */
  68368. getData(): PhysicsVortexEventData;
  68369. /**
  68370. * Enables the vortex.
  68371. */
  68372. enable(): void;
  68373. /**
  68374. * Disables the cortex.
  68375. */
  68376. disable(): void;
  68377. /**
  68378. * Disposes the sphere.
  68379. * @param force
  68380. */
  68381. dispose(force?: boolean): void;
  68382. private getImpostorHitData;
  68383. private _tick;
  68384. /*** Helpers ***/
  68385. private _prepareCylinder;
  68386. private _intersectsWithCylinder;
  68387. }
  68388. /**
  68389. * Options fot the radial explosion event
  68390. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68391. */
  68392. export class PhysicsRadialExplosionEventOptions {
  68393. /**
  68394. * The radius of the sphere for the radial explosion.
  68395. */
  68396. radius: number;
  68397. /**
  68398. * The strenth of the explosion.
  68399. */
  68400. strength: number;
  68401. /**
  68402. * The strenght of the force in correspondence to the distance of the affected object
  68403. */
  68404. falloff: PhysicsRadialImpulseFalloff;
  68405. /**
  68406. * Sphere options for the radial explosion.
  68407. */
  68408. sphere: {
  68409. segments: number;
  68410. diameter: number;
  68411. };
  68412. /**
  68413. * Sphere options for the radial explosion.
  68414. */
  68415. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  68416. }
  68417. /**
  68418. * Options fot the updraft event
  68419. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68420. */
  68421. export class PhysicsUpdraftEventOptions {
  68422. /**
  68423. * The radius of the cylinder for the vortex
  68424. */
  68425. radius: number;
  68426. /**
  68427. * The strenth of the updraft.
  68428. */
  68429. strength: number;
  68430. /**
  68431. * The height of the cylinder for the updraft.
  68432. */
  68433. height: number;
  68434. /**
  68435. * The mode for the the updraft.
  68436. */
  68437. updraftMode: PhysicsUpdraftMode;
  68438. }
  68439. /**
  68440. * Options fot the vortex event
  68441. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68442. */
  68443. export class PhysicsVortexEventOptions {
  68444. /**
  68445. * The radius of the cylinder for the vortex
  68446. */
  68447. radius: number;
  68448. /**
  68449. * The strenth of the vortex.
  68450. */
  68451. strength: number;
  68452. /**
  68453. * The height of the cylinder for the vortex.
  68454. */
  68455. height: number;
  68456. /**
  68457. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  68458. */
  68459. centripetalForceThreshold: number;
  68460. /**
  68461. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  68462. */
  68463. centripetalForceMultiplier: number;
  68464. /**
  68465. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  68466. */
  68467. centrifugalForceMultiplier: number;
  68468. /**
  68469. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  68470. */
  68471. updraftForceMultiplier: number;
  68472. }
  68473. /**
  68474. * The strenght of the force in correspondence to the distance of the affected object
  68475. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68476. */
  68477. export enum PhysicsRadialImpulseFalloff {
  68478. /** Defines that impulse is constant in strength across it's whole radius */
  68479. Constant = 0,
  68480. /** Defines that impulse gets weaker if it's further from the origin */
  68481. Linear = 1
  68482. }
  68483. /**
  68484. * The strength of the force in correspondence to the distance of the affected object
  68485. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68486. */
  68487. export enum PhysicsUpdraftMode {
  68488. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  68489. Center = 0,
  68490. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  68491. Perpendicular = 1
  68492. }
  68493. /**
  68494. * Interface for a physics hit data
  68495. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68496. */
  68497. export interface PhysicsHitData {
  68498. /**
  68499. * The force applied at the contact point
  68500. */
  68501. force: Vector3;
  68502. /**
  68503. * The contact point
  68504. */
  68505. contactPoint: Vector3;
  68506. /**
  68507. * The distance from the origin to the contact point
  68508. */
  68509. distanceFromOrigin: number;
  68510. }
  68511. /**
  68512. * Interface for radial explosion event data
  68513. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68514. */
  68515. export interface PhysicsRadialExplosionEventData {
  68516. /**
  68517. * A sphere used for the radial explosion event
  68518. */
  68519. sphere: Mesh;
  68520. }
  68521. /**
  68522. * Interface for gravitational field event data
  68523. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68524. */
  68525. export interface PhysicsGravitationalFieldEventData {
  68526. /**
  68527. * A sphere mesh used for the gravitational field event
  68528. */
  68529. sphere: Mesh;
  68530. }
  68531. /**
  68532. * Interface for updraft event data
  68533. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68534. */
  68535. export interface PhysicsUpdraftEventData {
  68536. /**
  68537. * A cylinder used for the updraft event
  68538. */
  68539. cylinder: Mesh;
  68540. }
  68541. /**
  68542. * Interface for vortex event data
  68543. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68544. */
  68545. export interface PhysicsVortexEventData {
  68546. /**
  68547. * A cylinder used for the vortex event
  68548. */
  68549. cylinder: Mesh;
  68550. }
  68551. /**
  68552. * Interface for an affected physics impostor
  68553. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68554. */
  68555. export interface PhysicsAffectedImpostorWithData {
  68556. /**
  68557. * The impostor affected by the effect
  68558. */
  68559. impostor: PhysicsImpostor;
  68560. /**
  68561. * The data about the hit/horce from the explosion
  68562. */
  68563. hitData: PhysicsHitData;
  68564. }
  68565. }
  68566. declare module BABYLON {
  68567. /** @hidden */
  68568. export var blackAndWhitePixelShader: {
  68569. name: string;
  68570. shader: string;
  68571. };
  68572. }
  68573. declare module BABYLON {
  68574. /**
  68575. * Post process used to render in black and white
  68576. */
  68577. export class BlackAndWhitePostProcess extends PostProcess {
  68578. /**
  68579. * Linear about to convert he result to black and white (default: 1)
  68580. */
  68581. degree: number;
  68582. /**
  68583. * Creates a black and white post process
  68584. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  68585. * @param name The name of the effect.
  68586. * @param options The required width/height ratio to downsize to before computing the render pass.
  68587. * @param camera The camera to apply the render pass to.
  68588. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68589. * @param engine The engine which the post process will be applied. (default: current engine)
  68590. * @param reusable If the post process can be reused on the same frame. (default: false)
  68591. */
  68592. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68593. }
  68594. }
  68595. declare module BABYLON {
  68596. /**
  68597. * This represents a set of one or more post processes in Babylon.
  68598. * A post process can be used to apply a shader to a texture after it is rendered.
  68599. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68600. */
  68601. export class PostProcessRenderEffect {
  68602. private _postProcesses;
  68603. private _getPostProcesses;
  68604. private _singleInstance;
  68605. private _cameras;
  68606. private _indicesForCamera;
  68607. /**
  68608. * Name of the effect
  68609. * @hidden
  68610. */
  68611. _name: string;
  68612. /**
  68613. * Instantiates a post process render effect.
  68614. * A post process can be used to apply a shader to a texture after it is rendered.
  68615. * @param engine The engine the effect is tied to
  68616. * @param name The name of the effect
  68617. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  68618. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  68619. */
  68620. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  68621. /**
  68622. * Checks if all the post processes in the effect are supported.
  68623. */
  68624. get isSupported(): boolean;
  68625. /**
  68626. * Updates the current state of the effect
  68627. * @hidden
  68628. */
  68629. _update(): void;
  68630. /**
  68631. * Attaches the effect on cameras
  68632. * @param cameras The camera to attach to.
  68633. * @hidden
  68634. */
  68635. _attachCameras(cameras: Camera): void;
  68636. /**
  68637. * Attaches the effect on cameras
  68638. * @param cameras The camera to attach to.
  68639. * @hidden
  68640. */
  68641. _attachCameras(cameras: Camera[]): void;
  68642. /**
  68643. * Detaches the effect on cameras
  68644. * @param cameras The camera to detatch from.
  68645. * @hidden
  68646. */
  68647. _detachCameras(cameras: Camera): void;
  68648. /**
  68649. * Detatches the effect on cameras
  68650. * @param cameras The camera to detatch from.
  68651. * @hidden
  68652. */
  68653. _detachCameras(cameras: Camera[]): void;
  68654. /**
  68655. * Enables the effect on given cameras
  68656. * @param cameras The camera to enable.
  68657. * @hidden
  68658. */
  68659. _enable(cameras: Camera): void;
  68660. /**
  68661. * Enables the effect on given cameras
  68662. * @param cameras The camera to enable.
  68663. * @hidden
  68664. */
  68665. _enable(cameras: Nullable<Camera[]>): void;
  68666. /**
  68667. * Disables the effect on the given cameras
  68668. * @param cameras The camera to disable.
  68669. * @hidden
  68670. */
  68671. _disable(cameras: Camera): void;
  68672. /**
  68673. * Disables the effect on the given cameras
  68674. * @param cameras The camera to disable.
  68675. * @hidden
  68676. */
  68677. _disable(cameras: Nullable<Camera[]>): void;
  68678. /**
  68679. * Gets a list of the post processes contained in the effect.
  68680. * @param camera The camera to get the post processes on.
  68681. * @returns The list of the post processes in the effect.
  68682. */
  68683. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  68684. }
  68685. }
  68686. declare module BABYLON {
  68687. /** @hidden */
  68688. export var extractHighlightsPixelShader: {
  68689. name: string;
  68690. shader: string;
  68691. };
  68692. }
  68693. declare module BABYLON {
  68694. /**
  68695. * 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.
  68696. */
  68697. export class ExtractHighlightsPostProcess extends PostProcess {
  68698. /**
  68699. * The luminance threshold, pixels below this value will be set to black.
  68700. */
  68701. threshold: number;
  68702. /** @hidden */
  68703. _exposure: number;
  68704. /**
  68705. * Post process which has the input texture to be used when performing highlight extraction
  68706. * @hidden
  68707. */
  68708. _inputPostProcess: Nullable<PostProcess>;
  68709. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68710. }
  68711. }
  68712. declare module BABYLON {
  68713. /** @hidden */
  68714. export var bloomMergePixelShader: {
  68715. name: string;
  68716. shader: string;
  68717. };
  68718. }
  68719. declare module BABYLON {
  68720. /**
  68721. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68722. */
  68723. export class BloomMergePostProcess extends PostProcess {
  68724. /** Weight of the bloom to be added to the original input. */
  68725. weight: number;
  68726. /**
  68727. * Creates a new instance of @see BloomMergePostProcess
  68728. * @param name The name of the effect.
  68729. * @param originalFromInput Post process which's input will be used for the merge.
  68730. * @param blurred Blurred highlights post process which's output will be used.
  68731. * @param weight Weight of the bloom to be added to the original input.
  68732. * @param options The required width/height ratio to downsize to before computing the render pass.
  68733. * @param camera The camera to apply the render pass to.
  68734. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68735. * @param engine The engine which the post process will be applied. (default: current engine)
  68736. * @param reusable If the post process can be reused on the same frame. (default: false)
  68737. * @param textureType Type of textures used when performing the post process. (default: 0)
  68738. * @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)
  68739. */
  68740. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  68741. /** Weight of the bloom to be added to the original input. */
  68742. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68743. }
  68744. }
  68745. declare module BABYLON {
  68746. /**
  68747. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  68748. */
  68749. export class BloomEffect extends PostProcessRenderEffect {
  68750. private bloomScale;
  68751. /**
  68752. * @hidden Internal
  68753. */
  68754. _effects: Array<PostProcess>;
  68755. /**
  68756. * @hidden Internal
  68757. */
  68758. _downscale: ExtractHighlightsPostProcess;
  68759. private _blurX;
  68760. private _blurY;
  68761. private _merge;
  68762. /**
  68763. * The luminance threshold to find bright areas of the image to bloom.
  68764. */
  68765. get threshold(): number;
  68766. set threshold(value: number);
  68767. /**
  68768. * The strength of the bloom.
  68769. */
  68770. get weight(): number;
  68771. set weight(value: number);
  68772. /**
  68773. * Specifies the size of the bloom blur kernel, relative to the final output size
  68774. */
  68775. get kernel(): number;
  68776. set kernel(value: number);
  68777. /**
  68778. * Creates a new instance of @see BloomEffect
  68779. * @param scene The scene the effect belongs to.
  68780. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  68781. * @param bloomKernel The size of the kernel to be used when applying the blur.
  68782. * @param bloomWeight The the strength of bloom.
  68783. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68784. * @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)
  68785. */
  68786. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  68787. /**
  68788. * Disposes each of the internal effects for a given camera.
  68789. * @param camera The camera to dispose the effect on.
  68790. */
  68791. disposeEffects(camera: Camera): void;
  68792. /**
  68793. * @hidden Internal
  68794. */
  68795. _updateEffects(): void;
  68796. /**
  68797. * Internal
  68798. * @returns if all the contained post processes are ready.
  68799. * @hidden
  68800. */
  68801. _isReady(): boolean;
  68802. }
  68803. }
  68804. declare module BABYLON {
  68805. /** @hidden */
  68806. export var chromaticAberrationPixelShader: {
  68807. name: string;
  68808. shader: string;
  68809. };
  68810. }
  68811. declare module BABYLON {
  68812. /**
  68813. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  68814. */
  68815. export class ChromaticAberrationPostProcess extends PostProcess {
  68816. /**
  68817. * The amount of seperation of rgb channels (default: 30)
  68818. */
  68819. aberrationAmount: number;
  68820. /**
  68821. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  68822. */
  68823. radialIntensity: number;
  68824. /**
  68825. * 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))
  68826. */
  68827. direction: Vector2;
  68828. /**
  68829. * 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))
  68830. */
  68831. centerPosition: Vector2;
  68832. /**
  68833. * Creates a new instance ChromaticAberrationPostProcess
  68834. * @param name The name of the effect.
  68835. * @param screenWidth The width of the screen to apply the effect on.
  68836. * @param screenHeight The height of the screen to apply the effect on.
  68837. * @param options The required width/height ratio to downsize to before computing the render pass.
  68838. * @param camera The camera to apply the render pass to.
  68839. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68840. * @param engine The engine which the post process will be applied. (default: current engine)
  68841. * @param reusable If the post process can be reused on the same frame. (default: false)
  68842. * @param textureType Type of textures used when performing the post process. (default: 0)
  68843. * @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)
  68844. */
  68845. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68846. }
  68847. }
  68848. declare module BABYLON {
  68849. /** @hidden */
  68850. export var circleOfConfusionPixelShader: {
  68851. name: string;
  68852. shader: string;
  68853. };
  68854. }
  68855. declare module BABYLON {
  68856. /**
  68857. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  68858. */
  68859. export class CircleOfConfusionPostProcess extends PostProcess {
  68860. /**
  68861. * 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.
  68862. */
  68863. lensSize: number;
  68864. /**
  68865. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68866. */
  68867. fStop: number;
  68868. /**
  68869. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68870. */
  68871. focusDistance: number;
  68872. /**
  68873. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  68874. */
  68875. focalLength: number;
  68876. private _depthTexture;
  68877. /**
  68878. * Creates a new instance CircleOfConfusionPostProcess
  68879. * @param name The name of the effect.
  68880. * @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.
  68881. * @param options The required width/height ratio to downsize to before computing the render pass.
  68882. * @param camera The camera to apply the render pass to.
  68883. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68884. * @param engine The engine which the post process will be applied. (default: current engine)
  68885. * @param reusable If the post process can be reused on the same frame. (default: false)
  68886. * @param textureType Type of textures used when performing the post process. (default: 0)
  68887. * @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)
  68888. */
  68889. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68890. /**
  68891. * 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.
  68892. */
  68893. set depthTexture(value: RenderTargetTexture);
  68894. }
  68895. }
  68896. declare module BABYLON {
  68897. /** @hidden */
  68898. export var colorCorrectionPixelShader: {
  68899. name: string;
  68900. shader: string;
  68901. };
  68902. }
  68903. declare module BABYLON {
  68904. /**
  68905. *
  68906. * This post-process allows the modification of rendered colors by using
  68907. * a 'look-up table' (LUT). This effect is also called Color Grading.
  68908. *
  68909. * The object needs to be provided an url to a texture containing the color
  68910. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  68911. * Use an image editing software to tweak the LUT to match your needs.
  68912. *
  68913. * For an example of a color LUT, see here:
  68914. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  68915. * For explanations on color grading, see here:
  68916. * @see http://udn.epicgames.com/Three/ColorGrading.html
  68917. *
  68918. */
  68919. export class ColorCorrectionPostProcess extends PostProcess {
  68920. private _colorTableTexture;
  68921. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68922. }
  68923. }
  68924. declare module BABYLON {
  68925. /** @hidden */
  68926. export var convolutionPixelShader: {
  68927. name: string;
  68928. shader: string;
  68929. };
  68930. }
  68931. declare module BABYLON {
  68932. /**
  68933. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  68934. * input texture to perform effects such as edge detection or sharpening
  68935. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68936. */
  68937. export class ConvolutionPostProcess extends PostProcess {
  68938. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68939. kernel: number[];
  68940. /**
  68941. * Creates a new instance ConvolutionPostProcess
  68942. * @param name The name of the effect.
  68943. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  68944. * @param options The required width/height ratio to downsize to before computing the render pass.
  68945. * @param camera The camera to apply the render pass to.
  68946. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68947. * @param engine The engine which the post process will be applied. (default: current engine)
  68948. * @param reusable If the post process can be reused on the same frame. (default: false)
  68949. * @param textureType Type of textures used when performing the post process. (default: 0)
  68950. */
  68951. constructor(name: string,
  68952. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68953. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68954. /**
  68955. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68956. */
  68957. static EdgeDetect0Kernel: number[];
  68958. /**
  68959. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68960. */
  68961. static EdgeDetect1Kernel: number[];
  68962. /**
  68963. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68964. */
  68965. static EdgeDetect2Kernel: number[];
  68966. /**
  68967. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68968. */
  68969. static SharpenKernel: number[];
  68970. /**
  68971. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68972. */
  68973. static EmbossKernel: number[];
  68974. /**
  68975. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68976. */
  68977. static GaussianKernel: number[];
  68978. }
  68979. }
  68980. declare module BABYLON {
  68981. /**
  68982. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  68983. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  68984. * based on samples that have a large difference in distance than the center pixel.
  68985. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  68986. */
  68987. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  68988. direction: Vector2;
  68989. /**
  68990. * Creates a new instance CircleOfConfusionPostProcess
  68991. * @param name The name of the effect.
  68992. * @param scene The scene the effect belongs to.
  68993. * @param direction The direction the blur should be applied.
  68994. * @param kernel The size of the kernel used to blur.
  68995. * @param options The required width/height ratio to downsize to before computing the render pass.
  68996. * @param camera The camera to apply the render pass to.
  68997. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  68998. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  68999. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69000. * @param engine The engine which the post process will be applied. (default: current engine)
  69001. * @param reusable If the post process can be reused on the same frame. (default: false)
  69002. * @param textureType Type of textures used when performing the post process. (default: 0)
  69003. * @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)
  69004. */
  69005. 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);
  69006. }
  69007. }
  69008. declare module BABYLON {
  69009. /** @hidden */
  69010. export var depthOfFieldMergePixelShader: {
  69011. name: string;
  69012. shader: string;
  69013. };
  69014. }
  69015. declare module BABYLON {
  69016. /**
  69017. * Options to be set when merging outputs from the default pipeline.
  69018. */
  69019. export class DepthOfFieldMergePostProcessOptions {
  69020. /**
  69021. * The original image to merge on top of
  69022. */
  69023. originalFromInput: PostProcess;
  69024. /**
  69025. * Parameters to perform the merge of the depth of field effect
  69026. */
  69027. depthOfField?: {
  69028. circleOfConfusion: PostProcess;
  69029. blurSteps: Array<PostProcess>;
  69030. };
  69031. /**
  69032. * Parameters to perform the merge of bloom effect
  69033. */
  69034. bloom?: {
  69035. blurred: PostProcess;
  69036. weight: number;
  69037. };
  69038. }
  69039. /**
  69040. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  69041. */
  69042. export class DepthOfFieldMergePostProcess extends PostProcess {
  69043. private blurSteps;
  69044. /**
  69045. * Creates a new instance of DepthOfFieldMergePostProcess
  69046. * @param name The name of the effect.
  69047. * @param originalFromInput Post process which's input will be used for the merge.
  69048. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  69049. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  69050. * @param options The required width/height ratio to downsize to before computing the render pass.
  69051. * @param camera The camera to apply the render pass to.
  69052. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69053. * @param engine The engine which the post process will be applied. (default: current engine)
  69054. * @param reusable If the post process can be reused on the same frame. (default: false)
  69055. * @param textureType Type of textures used when performing the post process. (default: 0)
  69056. * @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)
  69057. */
  69058. 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);
  69059. /**
  69060. * Updates the effect with the current post process compile time values and recompiles the shader.
  69061. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  69062. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  69063. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  69064. * @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
  69065. * @param onCompiled Called when the shader has been compiled.
  69066. * @param onError Called if there is an error when compiling a shader.
  69067. */
  69068. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69069. }
  69070. }
  69071. declare module BABYLON {
  69072. /**
  69073. * Specifies the level of max blur that should be applied when using the depth of field effect
  69074. */
  69075. export enum DepthOfFieldEffectBlurLevel {
  69076. /**
  69077. * Subtle blur
  69078. */
  69079. Low = 0,
  69080. /**
  69081. * Medium blur
  69082. */
  69083. Medium = 1,
  69084. /**
  69085. * Large blur
  69086. */
  69087. High = 2
  69088. }
  69089. /**
  69090. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  69091. */
  69092. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  69093. private _circleOfConfusion;
  69094. /**
  69095. * @hidden Internal, blurs from high to low
  69096. */
  69097. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  69098. private _depthOfFieldBlurY;
  69099. private _dofMerge;
  69100. /**
  69101. * @hidden Internal post processes in depth of field effect
  69102. */
  69103. _effects: Array<PostProcess>;
  69104. /**
  69105. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  69106. */
  69107. set focalLength(value: number);
  69108. get focalLength(): number;
  69109. /**
  69110. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69111. */
  69112. set fStop(value: number);
  69113. get fStop(): number;
  69114. /**
  69115. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69116. */
  69117. set focusDistance(value: number);
  69118. get focusDistance(): number;
  69119. /**
  69120. * 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.
  69121. */
  69122. set lensSize(value: number);
  69123. get lensSize(): number;
  69124. /**
  69125. * Creates a new instance DepthOfFieldEffect
  69126. * @param scene The scene the effect belongs to.
  69127. * @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.
  69128. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69129. * @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)
  69130. */
  69131. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  69132. /**
  69133. * Get the current class name of the current effet
  69134. * @returns "DepthOfFieldEffect"
  69135. */
  69136. getClassName(): string;
  69137. /**
  69138. * 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.
  69139. */
  69140. set depthTexture(value: RenderTargetTexture);
  69141. /**
  69142. * Disposes each of the internal effects for a given camera.
  69143. * @param camera The camera to dispose the effect on.
  69144. */
  69145. disposeEffects(camera: Camera): void;
  69146. /**
  69147. * @hidden Internal
  69148. */
  69149. _updateEffects(): void;
  69150. /**
  69151. * Internal
  69152. * @returns if all the contained post processes are ready.
  69153. * @hidden
  69154. */
  69155. _isReady(): boolean;
  69156. }
  69157. }
  69158. declare module BABYLON {
  69159. /** @hidden */
  69160. export var displayPassPixelShader: {
  69161. name: string;
  69162. shader: string;
  69163. };
  69164. }
  69165. declare module BABYLON {
  69166. /**
  69167. * DisplayPassPostProcess which produces an output the same as it's input
  69168. */
  69169. export class DisplayPassPostProcess extends PostProcess {
  69170. /**
  69171. * Creates the DisplayPassPostProcess
  69172. * @param name The name of the effect.
  69173. * @param options The required width/height ratio to downsize to before computing the render pass.
  69174. * @param camera The camera to apply the render pass to.
  69175. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69176. * @param engine The engine which the post process will be applied. (default: current engine)
  69177. * @param reusable If the post process can be reused on the same frame. (default: false)
  69178. */
  69179. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69180. }
  69181. }
  69182. declare module BABYLON {
  69183. /** @hidden */
  69184. export var filterPixelShader: {
  69185. name: string;
  69186. shader: string;
  69187. };
  69188. }
  69189. declare module BABYLON {
  69190. /**
  69191. * Applies a kernel filter to the image
  69192. */
  69193. export class FilterPostProcess extends PostProcess {
  69194. /** The matrix to be applied to the image */
  69195. kernelMatrix: Matrix;
  69196. /**
  69197. *
  69198. * @param name The name of the effect.
  69199. * @param kernelMatrix The matrix to be applied to the image
  69200. * @param options The required width/height ratio to downsize to before computing the render pass.
  69201. * @param camera The camera to apply the render pass to.
  69202. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69203. * @param engine The engine which the post process will be applied. (default: current engine)
  69204. * @param reusable If the post process can be reused on the same frame. (default: false)
  69205. */
  69206. constructor(name: string,
  69207. /** The matrix to be applied to the image */
  69208. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69209. }
  69210. }
  69211. declare module BABYLON {
  69212. /** @hidden */
  69213. export var fxaaPixelShader: {
  69214. name: string;
  69215. shader: string;
  69216. };
  69217. }
  69218. declare module BABYLON {
  69219. /** @hidden */
  69220. export var fxaaVertexShader: {
  69221. name: string;
  69222. shader: string;
  69223. };
  69224. }
  69225. declare module BABYLON {
  69226. /**
  69227. * Fxaa post process
  69228. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  69229. */
  69230. export class FxaaPostProcess extends PostProcess {
  69231. /** @hidden */
  69232. texelWidth: number;
  69233. /** @hidden */
  69234. texelHeight: number;
  69235. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69236. private _getDefines;
  69237. }
  69238. }
  69239. declare module BABYLON {
  69240. /** @hidden */
  69241. export var grainPixelShader: {
  69242. name: string;
  69243. shader: string;
  69244. };
  69245. }
  69246. declare module BABYLON {
  69247. /**
  69248. * The GrainPostProcess adds noise to the image at mid luminance levels
  69249. */
  69250. export class GrainPostProcess extends PostProcess {
  69251. /**
  69252. * The intensity of the grain added (default: 30)
  69253. */
  69254. intensity: number;
  69255. /**
  69256. * If the grain should be randomized on every frame
  69257. */
  69258. animated: boolean;
  69259. /**
  69260. * Creates a new instance of @see GrainPostProcess
  69261. * @param name The name of the effect.
  69262. * @param options The required width/height ratio to downsize to before computing the render pass.
  69263. * @param camera The camera to apply the render pass to.
  69264. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69265. * @param engine The engine which the post process will be applied. (default: current engine)
  69266. * @param reusable If the post process can be reused on the same frame. (default: false)
  69267. * @param textureType Type of textures used when performing the post process. (default: 0)
  69268. * @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)
  69269. */
  69270. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69271. }
  69272. }
  69273. declare module BABYLON {
  69274. /** @hidden */
  69275. export var highlightsPixelShader: {
  69276. name: string;
  69277. shader: string;
  69278. };
  69279. }
  69280. declare module BABYLON {
  69281. /**
  69282. * Extracts highlights from the image
  69283. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69284. */
  69285. export class HighlightsPostProcess extends PostProcess {
  69286. /**
  69287. * Extracts highlights from the image
  69288. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69289. * @param name The name of the effect.
  69290. * @param options The required width/height ratio to downsize to before computing the render pass.
  69291. * @param camera The camera to apply the render pass to.
  69292. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69293. * @param engine The engine which the post process will be applied. (default: current engine)
  69294. * @param reusable If the post process can be reused on the same frame. (default: false)
  69295. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  69296. */
  69297. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69298. }
  69299. }
  69300. declare module BABYLON {
  69301. /** @hidden */
  69302. export var mrtFragmentDeclaration: {
  69303. name: string;
  69304. shader: string;
  69305. };
  69306. }
  69307. declare module BABYLON {
  69308. /** @hidden */
  69309. export var geometryPixelShader: {
  69310. name: string;
  69311. shader: string;
  69312. };
  69313. }
  69314. declare module BABYLON {
  69315. /** @hidden */
  69316. export var geometryVertexShader: {
  69317. name: string;
  69318. shader: string;
  69319. };
  69320. }
  69321. declare module BABYLON {
  69322. /** @hidden */
  69323. interface ISavedTransformationMatrix {
  69324. world: Matrix;
  69325. viewProjection: Matrix;
  69326. }
  69327. /**
  69328. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  69329. */
  69330. export class GeometryBufferRenderer {
  69331. /**
  69332. * Constant used to retrieve the position texture index in the G-Buffer textures array
  69333. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  69334. */
  69335. static readonly POSITION_TEXTURE_TYPE: number;
  69336. /**
  69337. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  69338. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  69339. */
  69340. static readonly VELOCITY_TEXTURE_TYPE: number;
  69341. /**
  69342. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  69343. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  69344. */
  69345. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  69346. /**
  69347. * Dictionary used to store the previous transformation matrices of each rendered mesh
  69348. * in order to compute objects velocities when enableVelocity is set to "true"
  69349. * @hidden
  69350. */
  69351. _previousTransformationMatrices: {
  69352. [index: number]: ISavedTransformationMatrix;
  69353. };
  69354. /**
  69355. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  69356. * in order to compute objects velocities when enableVelocity is set to "true"
  69357. * @hidden
  69358. */
  69359. _previousBonesTransformationMatrices: {
  69360. [index: number]: Float32Array;
  69361. };
  69362. /**
  69363. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  69364. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  69365. */
  69366. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  69367. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  69368. renderTransparentMeshes: boolean;
  69369. private _scene;
  69370. private _resizeObserver;
  69371. private _multiRenderTarget;
  69372. private _ratio;
  69373. private _enablePosition;
  69374. private _enableVelocity;
  69375. private _enableReflectivity;
  69376. private _positionIndex;
  69377. private _velocityIndex;
  69378. private _reflectivityIndex;
  69379. protected _effect: Effect;
  69380. protected _cachedDefines: string;
  69381. /**
  69382. * Set the render list (meshes to be rendered) used in the G buffer.
  69383. */
  69384. set renderList(meshes: Mesh[]);
  69385. /**
  69386. * Gets wether or not G buffer are supported by the running hardware.
  69387. * This requires draw buffer supports
  69388. */
  69389. get isSupported(): boolean;
  69390. /**
  69391. * Returns the index of the given texture type in the G-Buffer textures array
  69392. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  69393. * @returns the index of the given texture type in the G-Buffer textures array
  69394. */
  69395. getTextureIndex(textureType: number): number;
  69396. /**
  69397. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  69398. */
  69399. get enablePosition(): boolean;
  69400. /**
  69401. * Sets whether or not objects positions are enabled for the G buffer.
  69402. */
  69403. set enablePosition(enable: boolean);
  69404. /**
  69405. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  69406. */
  69407. get enableVelocity(): boolean;
  69408. /**
  69409. * Sets wether or not objects velocities are enabled for the G buffer.
  69410. */
  69411. set enableVelocity(enable: boolean);
  69412. /**
  69413. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  69414. */
  69415. get enableReflectivity(): boolean;
  69416. /**
  69417. * Sets wether or not objects roughness are enabled for the G buffer.
  69418. */
  69419. set enableReflectivity(enable: boolean);
  69420. /**
  69421. * Gets the scene associated with the buffer.
  69422. */
  69423. get scene(): Scene;
  69424. /**
  69425. * Gets the ratio used by the buffer during its creation.
  69426. * How big is the buffer related to the main canvas.
  69427. */
  69428. get ratio(): number;
  69429. /** @hidden */
  69430. static _SceneComponentInitialization: (scene: Scene) => void;
  69431. /**
  69432. * Creates a new G Buffer for the scene
  69433. * @param scene The scene the buffer belongs to
  69434. * @param ratio How big is the buffer related to the main canvas.
  69435. */
  69436. constructor(scene: Scene, ratio?: number);
  69437. /**
  69438. * Checks wether everything is ready to render a submesh to the G buffer.
  69439. * @param subMesh the submesh to check readiness for
  69440. * @param useInstances is the mesh drawn using instance or not
  69441. * @returns true if ready otherwise false
  69442. */
  69443. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69444. /**
  69445. * Gets the current underlying G Buffer.
  69446. * @returns the buffer
  69447. */
  69448. getGBuffer(): MultiRenderTarget;
  69449. /**
  69450. * Gets the number of samples used to render the buffer (anti aliasing).
  69451. */
  69452. get samples(): number;
  69453. /**
  69454. * Sets the number of samples used to render the buffer (anti aliasing).
  69455. */
  69456. set samples(value: number);
  69457. /**
  69458. * Disposes the renderer and frees up associated resources.
  69459. */
  69460. dispose(): void;
  69461. protected _createRenderTargets(): void;
  69462. private _copyBonesTransformationMatrices;
  69463. }
  69464. }
  69465. declare module BABYLON {
  69466. interface Scene {
  69467. /** @hidden (Backing field) */
  69468. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  69469. /**
  69470. * Gets or Sets the current geometry buffer associated to the scene.
  69471. */
  69472. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  69473. /**
  69474. * Enables a GeometryBufferRender and associates it with the scene
  69475. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  69476. * @returns the GeometryBufferRenderer
  69477. */
  69478. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  69479. /**
  69480. * Disables the GeometryBufferRender associated with the scene
  69481. */
  69482. disableGeometryBufferRenderer(): void;
  69483. }
  69484. /**
  69485. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  69486. * in several rendering techniques.
  69487. */
  69488. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  69489. /**
  69490. * The component name helpful to identify the component in the list of scene components.
  69491. */
  69492. readonly name: string;
  69493. /**
  69494. * The scene the component belongs to.
  69495. */
  69496. scene: Scene;
  69497. /**
  69498. * Creates a new instance of the component for the given scene
  69499. * @param scene Defines the scene to register the component in
  69500. */
  69501. constructor(scene: Scene);
  69502. /**
  69503. * Registers the component in a given scene
  69504. */
  69505. register(): void;
  69506. /**
  69507. * Rebuilds the elements related to this component in case of
  69508. * context lost for instance.
  69509. */
  69510. rebuild(): void;
  69511. /**
  69512. * Disposes the component and the associated ressources
  69513. */
  69514. dispose(): void;
  69515. private _gatherRenderTargets;
  69516. }
  69517. }
  69518. declare module BABYLON {
  69519. /** @hidden */
  69520. export var motionBlurPixelShader: {
  69521. name: string;
  69522. shader: string;
  69523. };
  69524. }
  69525. declare module BABYLON {
  69526. /**
  69527. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  69528. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  69529. * As an example, all you have to do is to create the post-process:
  69530. * var mb = new BABYLON.MotionBlurPostProcess(
  69531. * 'mb', // The name of the effect.
  69532. * scene, // The scene containing the objects to blur according to their velocity.
  69533. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  69534. * camera // The camera to apply the render pass to.
  69535. * );
  69536. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  69537. */
  69538. export class MotionBlurPostProcess extends PostProcess {
  69539. /**
  69540. * Defines how much the image is blurred by the movement. Default value is equal to 1
  69541. */
  69542. motionStrength: number;
  69543. /**
  69544. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  69545. */
  69546. get motionBlurSamples(): number;
  69547. /**
  69548. * Sets the number of iterations to be used for motion blur quality
  69549. */
  69550. set motionBlurSamples(samples: number);
  69551. private _motionBlurSamples;
  69552. private _geometryBufferRenderer;
  69553. /**
  69554. * Creates a new instance MotionBlurPostProcess
  69555. * @param name The name of the effect.
  69556. * @param scene The scene containing the objects to blur according to their velocity.
  69557. * @param options The required width/height ratio to downsize to before computing the render pass.
  69558. * @param camera The camera to apply the render pass to.
  69559. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69560. * @param engine The engine which the post process will be applied. (default: current engine)
  69561. * @param reusable If the post process can be reused on the same frame. (default: false)
  69562. * @param textureType Type of textures used when performing the post process. (default: 0)
  69563. * @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)
  69564. */
  69565. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69566. /**
  69567. * Excludes the given skinned mesh from computing bones velocities.
  69568. * 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.
  69569. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  69570. */
  69571. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  69572. /**
  69573. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  69574. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  69575. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  69576. */
  69577. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  69578. /**
  69579. * Disposes the post process.
  69580. * @param camera The camera to dispose the post process on.
  69581. */
  69582. dispose(camera?: Camera): void;
  69583. }
  69584. }
  69585. declare module BABYLON {
  69586. /** @hidden */
  69587. export var refractionPixelShader: {
  69588. name: string;
  69589. shader: string;
  69590. };
  69591. }
  69592. declare module BABYLON {
  69593. /**
  69594. * Post process which applies a refractin texture
  69595. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  69596. */
  69597. export class RefractionPostProcess extends PostProcess {
  69598. /** the base color of the refraction (used to taint the rendering) */
  69599. color: Color3;
  69600. /** simulated refraction depth */
  69601. depth: number;
  69602. /** the coefficient of the base color (0 to remove base color tainting) */
  69603. colorLevel: number;
  69604. private _refTexture;
  69605. private _ownRefractionTexture;
  69606. /**
  69607. * Gets or sets the refraction texture
  69608. * Please note that you are responsible for disposing the texture if you set it manually
  69609. */
  69610. get refractionTexture(): Texture;
  69611. set refractionTexture(value: Texture);
  69612. /**
  69613. * Initializes the RefractionPostProcess
  69614. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  69615. * @param name The name of the effect.
  69616. * @param refractionTextureUrl Url of the refraction texture to use
  69617. * @param color the base color of the refraction (used to taint the rendering)
  69618. * @param depth simulated refraction depth
  69619. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  69620. * @param camera The camera to apply the render pass to.
  69621. * @param options The required width/height ratio to downsize to before computing the render pass.
  69622. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69623. * @param engine The engine which the post process will be applied. (default: current engine)
  69624. * @param reusable If the post process can be reused on the same frame. (default: false)
  69625. */
  69626. constructor(name: string, refractionTextureUrl: string,
  69627. /** the base color of the refraction (used to taint the rendering) */
  69628. color: Color3,
  69629. /** simulated refraction depth */
  69630. depth: number,
  69631. /** the coefficient of the base color (0 to remove base color tainting) */
  69632. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69633. /**
  69634. * Disposes of the post process
  69635. * @param camera Camera to dispose post process on
  69636. */
  69637. dispose(camera: Camera): void;
  69638. }
  69639. }
  69640. declare module BABYLON {
  69641. /** @hidden */
  69642. export var sharpenPixelShader: {
  69643. name: string;
  69644. shader: string;
  69645. };
  69646. }
  69647. declare module BABYLON {
  69648. /**
  69649. * The SharpenPostProcess applies a sharpen kernel to every pixel
  69650. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  69651. */
  69652. export class SharpenPostProcess extends PostProcess {
  69653. /**
  69654. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  69655. */
  69656. colorAmount: number;
  69657. /**
  69658. * How much sharpness should be applied (default: 0.3)
  69659. */
  69660. edgeAmount: number;
  69661. /**
  69662. * Creates a new instance ConvolutionPostProcess
  69663. * @param name The name of the effect.
  69664. * @param options The required width/height ratio to downsize to before computing the render pass.
  69665. * @param camera The camera to apply the render pass to.
  69666. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69667. * @param engine The engine which the post process will be applied. (default: current engine)
  69668. * @param reusable If the post process can be reused on the same frame. (default: false)
  69669. * @param textureType Type of textures used when performing the post process. (default: 0)
  69670. * @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)
  69671. */
  69672. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69673. }
  69674. }
  69675. declare module BABYLON {
  69676. /**
  69677. * PostProcessRenderPipeline
  69678. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69679. */
  69680. export class PostProcessRenderPipeline {
  69681. private engine;
  69682. private _renderEffects;
  69683. private _renderEffectsForIsolatedPass;
  69684. /**
  69685. * List of inspectable custom properties (used by the Inspector)
  69686. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  69687. */
  69688. inspectableCustomProperties: IInspectable[];
  69689. /**
  69690. * @hidden
  69691. */
  69692. protected _cameras: Camera[];
  69693. /** @hidden */
  69694. _name: string;
  69695. /**
  69696. * Gets pipeline name
  69697. */
  69698. get name(): string;
  69699. /** Gets the list of attached cameras */
  69700. get cameras(): Camera[];
  69701. /**
  69702. * Initializes a PostProcessRenderPipeline
  69703. * @param engine engine to add the pipeline to
  69704. * @param name name of the pipeline
  69705. */
  69706. constructor(engine: Engine, name: string);
  69707. /**
  69708. * Gets the class name
  69709. * @returns "PostProcessRenderPipeline"
  69710. */
  69711. getClassName(): string;
  69712. /**
  69713. * If all the render effects in the pipeline are supported
  69714. */
  69715. get isSupported(): boolean;
  69716. /**
  69717. * Adds an effect to the pipeline
  69718. * @param renderEffect the effect to add
  69719. */
  69720. addEffect(renderEffect: PostProcessRenderEffect): void;
  69721. /** @hidden */
  69722. _rebuild(): void;
  69723. /** @hidden */
  69724. _enableEffect(renderEffectName: string, cameras: Camera): void;
  69725. /** @hidden */
  69726. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  69727. /** @hidden */
  69728. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  69729. /** @hidden */
  69730. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  69731. /** @hidden */
  69732. _attachCameras(cameras: Camera, unique: boolean): void;
  69733. /** @hidden */
  69734. _attachCameras(cameras: Camera[], unique: boolean): void;
  69735. /** @hidden */
  69736. _detachCameras(cameras: Camera): void;
  69737. /** @hidden */
  69738. _detachCameras(cameras: Nullable<Camera[]>): void;
  69739. /** @hidden */
  69740. _update(): void;
  69741. /** @hidden */
  69742. _reset(): void;
  69743. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  69744. /**
  69745. * Sets the required values to the prepass renderer.
  69746. * @param prePassRenderer defines the prepass renderer to setup.
  69747. * @returns true if the pre pass is needed.
  69748. */
  69749. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  69750. /**
  69751. * Disposes of the pipeline
  69752. */
  69753. dispose(): void;
  69754. }
  69755. }
  69756. declare module BABYLON {
  69757. /**
  69758. * PostProcessRenderPipelineManager class
  69759. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69760. */
  69761. export class PostProcessRenderPipelineManager {
  69762. private _renderPipelines;
  69763. /**
  69764. * Initializes a PostProcessRenderPipelineManager
  69765. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69766. */
  69767. constructor();
  69768. /**
  69769. * Gets the list of supported render pipelines
  69770. */
  69771. get supportedPipelines(): PostProcessRenderPipeline[];
  69772. /**
  69773. * Adds a pipeline to the manager
  69774. * @param renderPipeline The pipeline to add
  69775. */
  69776. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  69777. /**
  69778. * Attaches a camera to the pipeline
  69779. * @param renderPipelineName The name of the pipeline to attach to
  69780. * @param cameras the camera to attach
  69781. * @param unique if the camera can be attached multiple times to the pipeline
  69782. */
  69783. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  69784. /**
  69785. * Detaches a camera from the pipeline
  69786. * @param renderPipelineName The name of the pipeline to detach from
  69787. * @param cameras the camera to detach
  69788. */
  69789. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  69790. /**
  69791. * Enables an effect by name on a pipeline
  69792. * @param renderPipelineName the name of the pipeline to enable the effect in
  69793. * @param renderEffectName the name of the effect to enable
  69794. * @param cameras the cameras that the effect should be enabled on
  69795. */
  69796. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  69797. /**
  69798. * Disables an effect by name on a pipeline
  69799. * @param renderPipelineName the name of the pipeline to disable the effect in
  69800. * @param renderEffectName the name of the effect to disable
  69801. * @param cameras the cameras that the effect should be disabled on
  69802. */
  69803. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  69804. /**
  69805. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  69806. */
  69807. update(): void;
  69808. /** @hidden */
  69809. _rebuild(): void;
  69810. /**
  69811. * Disposes of the manager and pipelines
  69812. */
  69813. dispose(): void;
  69814. }
  69815. }
  69816. declare module BABYLON {
  69817. interface Scene {
  69818. /** @hidden (Backing field) */
  69819. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  69820. /**
  69821. * Gets the postprocess render pipeline manager
  69822. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69823. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  69824. */
  69825. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  69826. }
  69827. /**
  69828. * Defines the Render Pipeline scene component responsible to rendering pipelines
  69829. */
  69830. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  69831. /**
  69832. * The component name helpfull to identify the component in the list of scene components.
  69833. */
  69834. readonly name: string;
  69835. /**
  69836. * The scene the component belongs to.
  69837. */
  69838. scene: Scene;
  69839. /**
  69840. * Creates a new instance of the component for the given scene
  69841. * @param scene Defines the scene to register the component in
  69842. */
  69843. constructor(scene: Scene);
  69844. /**
  69845. * Registers the component in a given scene
  69846. */
  69847. register(): void;
  69848. /**
  69849. * Rebuilds the elements related to this component in case of
  69850. * context lost for instance.
  69851. */
  69852. rebuild(): void;
  69853. /**
  69854. * Disposes the component and the associated ressources
  69855. */
  69856. dispose(): void;
  69857. private _gatherRenderTargets;
  69858. }
  69859. }
  69860. declare module BABYLON {
  69861. /**
  69862. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  69863. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  69864. */
  69865. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69866. private _scene;
  69867. private _camerasToBeAttached;
  69868. /**
  69869. * ID of the sharpen post process,
  69870. */
  69871. private readonly SharpenPostProcessId;
  69872. /**
  69873. * @ignore
  69874. * ID of the image processing post process;
  69875. */
  69876. readonly ImageProcessingPostProcessId: string;
  69877. /**
  69878. * @ignore
  69879. * ID of the Fast Approximate Anti-Aliasing post process;
  69880. */
  69881. readonly FxaaPostProcessId: string;
  69882. /**
  69883. * ID of the chromatic aberration post process,
  69884. */
  69885. private readonly ChromaticAberrationPostProcessId;
  69886. /**
  69887. * ID of the grain post process
  69888. */
  69889. private readonly GrainPostProcessId;
  69890. /**
  69891. * Sharpen post process which will apply a sharpen convolution to enhance edges
  69892. */
  69893. sharpen: SharpenPostProcess;
  69894. private _sharpenEffect;
  69895. private bloom;
  69896. /**
  69897. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  69898. */
  69899. depthOfField: DepthOfFieldEffect;
  69900. /**
  69901. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69902. */
  69903. fxaa: FxaaPostProcess;
  69904. /**
  69905. * Image post processing pass used to perform operations such as tone mapping or color grading.
  69906. */
  69907. imageProcessing: ImageProcessingPostProcess;
  69908. /**
  69909. * Chromatic aberration post process which will shift rgb colors in the image
  69910. */
  69911. chromaticAberration: ChromaticAberrationPostProcess;
  69912. private _chromaticAberrationEffect;
  69913. /**
  69914. * Grain post process which add noise to the image
  69915. */
  69916. grain: GrainPostProcess;
  69917. private _grainEffect;
  69918. /**
  69919. * Glow post process which adds a glow to emissive areas of the image
  69920. */
  69921. private _glowLayer;
  69922. /**
  69923. * Animations which can be used to tweak settings over a period of time
  69924. */
  69925. animations: Animation[];
  69926. private _imageProcessingConfigurationObserver;
  69927. private _sharpenEnabled;
  69928. private _bloomEnabled;
  69929. private _depthOfFieldEnabled;
  69930. private _depthOfFieldBlurLevel;
  69931. private _fxaaEnabled;
  69932. private _imageProcessingEnabled;
  69933. private _defaultPipelineTextureType;
  69934. private _bloomScale;
  69935. private _chromaticAberrationEnabled;
  69936. private _grainEnabled;
  69937. private _buildAllowed;
  69938. /**
  69939. * Gets active scene
  69940. */
  69941. get scene(): Scene;
  69942. /**
  69943. * Enable or disable the sharpen process from the pipeline
  69944. */
  69945. set sharpenEnabled(enabled: boolean);
  69946. get sharpenEnabled(): boolean;
  69947. private _resizeObserver;
  69948. private _hardwareScaleLevel;
  69949. private _bloomKernel;
  69950. /**
  69951. * Specifies the size of the bloom blur kernel, relative to the final output size
  69952. */
  69953. get bloomKernel(): number;
  69954. set bloomKernel(value: number);
  69955. /**
  69956. * Specifies the weight of the bloom in the final rendering
  69957. */
  69958. private _bloomWeight;
  69959. /**
  69960. * Specifies the luma threshold for the area that will be blurred by the bloom
  69961. */
  69962. private _bloomThreshold;
  69963. private _hdr;
  69964. /**
  69965. * The strength of the bloom.
  69966. */
  69967. set bloomWeight(value: number);
  69968. get bloomWeight(): number;
  69969. /**
  69970. * The strength of the bloom.
  69971. */
  69972. set bloomThreshold(value: number);
  69973. get bloomThreshold(): number;
  69974. /**
  69975. * The scale of the bloom, lower value will provide better performance.
  69976. */
  69977. set bloomScale(value: number);
  69978. get bloomScale(): number;
  69979. /**
  69980. * Enable or disable the bloom from the pipeline
  69981. */
  69982. set bloomEnabled(enabled: boolean);
  69983. get bloomEnabled(): boolean;
  69984. private _rebuildBloom;
  69985. /**
  69986. * If the depth of field is enabled.
  69987. */
  69988. get depthOfFieldEnabled(): boolean;
  69989. set depthOfFieldEnabled(enabled: boolean);
  69990. /**
  69991. * Blur level of the depth of field effect. (Higher blur will effect performance)
  69992. */
  69993. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  69994. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  69995. /**
  69996. * If the anti aliasing is enabled.
  69997. */
  69998. set fxaaEnabled(enabled: boolean);
  69999. get fxaaEnabled(): boolean;
  70000. private _samples;
  70001. /**
  70002. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70003. */
  70004. set samples(sampleCount: number);
  70005. get samples(): number;
  70006. /**
  70007. * If image processing is enabled.
  70008. */
  70009. set imageProcessingEnabled(enabled: boolean);
  70010. get imageProcessingEnabled(): boolean;
  70011. /**
  70012. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  70013. */
  70014. set glowLayerEnabled(enabled: boolean);
  70015. get glowLayerEnabled(): boolean;
  70016. /**
  70017. * Gets the glow layer (or null if not defined)
  70018. */
  70019. get glowLayer(): Nullable<GlowLayer>;
  70020. /**
  70021. * Enable or disable the chromaticAberration process from the pipeline
  70022. */
  70023. set chromaticAberrationEnabled(enabled: boolean);
  70024. get chromaticAberrationEnabled(): boolean;
  70025. /**
  70026. * Enable or disable the grain process from the pipeline
  70027. */
  70028. set grainEnabled(enabled: boolean);
  70029. get grainEnabled(): boolean;
  70030. /**
  70031. * @constructor
  70032. * @param name - The rendering pipeline name (default: "")
  70033. * @param hdr - If high dynamic range textures should be used (default: true)
  70034. * @param scene - The scene linked to this pipeline (default: the last created scene)
  70035. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  70036. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  70037. */
  70038. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  70039. /**
  70040. * Get the class name
  70041. * @returns "DefaultRenderingPipeline"
  70042. */
  70043. getClassName(): string;
  70044. /**
  70045. * Force the compilation of the entire pipeline.
  70046. */
  70047. prepare(): void;
  70048. private _hasCleared;
  70049. private _prevPostProcess;
  70050. private _prevPrevPostProcess;
  70051. private _setAutoClearAndTextureSharing;
  70052. private _depthOfFieldSceneObserver;
  70053. private _buildPipeline;
  70054. private _disposePostProcesses;
  70055. /**
  70056. * Adds a camera to the pipeline
  70057. * @param camera the camera to be added
  70058. */
  70059. addCamera(camera: Camera): void;
  70060. /**
  70061. * Removes a camera from the pipeline
  70062. * @param camera the camera to remove
  70063. */
  70064. removeCamera(camera: Camera): void;
  70065. /**
  70066. * Dispose of the pipeline and stop all post processes
  70067. */
  70068. dispose(): void;
  70069. /**
  70070. * Serialize the rendering pipeline (Used when exporting)
  70071. * @returns the serialized object
  70072. */
  70073. serialize(): any;
  70074. /**
  70075. * Parse the serialized pipeline
  70076. * @param source Source pipeline.
  70077. * @param scene The scene to load the pipeline to.
  70078. * @param rootUrl The URL of the serialized pipeline.
  70079. * @returns An instantiated pipeline from the serialized object.
  70080. */
  70081. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  70082. }
  70083. }
  70084. declare module BABYLON {
  70085. /** @hidden */
  70086. export var lensHighlightsPixelShader: {
  70087. name: string;
  70088. shader: string;
  70089. };
  70090. }
  70091. declare module BABYLON {
  70092. /** @hidden */
  70093. export var depthOfFieldPixelShader: {
  70094. name: string;
  70095. shader: string;
  70096. };
  70097. }
  70098. declare module BABYLON {
  70099. /**
  70100. * BABYLON.JS Chromatic Aberration GLSL Shader
  70101. * Author: Olivier Guyot
  70102. * Separates very slightly R, G and B colors on the edges of the screen
  70103. * Inspired by Francois Tarlier & Martins Upitis
  70104. */
  70105. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  70106. /**
  70107. * @ignore
  70108. * The chromatic aberration PostProcess id in the pipeline
  70109. */
  70110. LensChromaticAberrationEffect: string;
  70111. /**
  70112. * @ignore
  70113. * The highlights enhancing PostProcess id in the pipeline
  70114. */
  70115. HighlightsEnhancingEffect: string;
  70116. /**
  70117. * @ignore
  70118. * The depth-of-field PostProcess id in the pipeline
  70119. */
  70120. LensDepthOfFieldEffect: string;
  70121. private _scene;
  70122. private _depthTexture;
  70123. private _grainTexture;
  70124. private _chromaticAberrationPostProcess;
  70125. private _highlightsPostProcess;
  70126. private _depthOfFieldPostProcess;
  70127. private _edgeBlur;
  70128. private _grainAmount;
  70129. private _chromaticAberration;
  70130. private _distortion;
  70131. private _highlightsGain;
  70132. private _highlightsThreshold;
  70133. private _dofDistance;
  70134. private _dofAperture;
  70135. private _dofDarken;
  70136. private _dofPentagon;
  70137. private _blurNoise;
  70138. /**
  70139. * @constructor
  70140. *
  70141. * Effect parameters are as follow:
  70142. * {
  70143. * chromatic_aberration: number; // from 0 to x (1 for realism)
  70144. * edge_blur: number; // from 0 to x (1 for realism)
  70145. * distortion: number; // from 0 to x (1 for realism)
  70146. * grain_amount: number; // from 0 to 1
  70147. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  70148. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  70149. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  70150. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  70151. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  70152. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  70153. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  70154. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  70155. * }
  70156. * Note: if an effect parameter is unset, effect is disabled
  70157. *
  70158. * @param name The rendering pipeline name
  70159. * @param parameters - An object containing all parameters (see above)
  70160. * @param scene The scene linked to this pipeline
  70161. * @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)
  70162. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70163. */
  70164. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  70165. /**
  70166. * Get the class name
  70167. * @returns "LensRenderingPipeline"
  70168. */
  70169. getClassName(): string;
  70170. /**
  70171. * Gets associated scene
  70172. */
  70173. get scene(): Scene;
  70174. /**
  70175. * Gets or sets the edge blur
  70176. */
  70177. get edgeBlur(): number;
  70178. set edgeBlur(value: number);
  70179. /**
  70180. * Gets or sets the grain amount
  70181. */
  70182. get grainAmount(): number;
  70183. set grainAmount(value: number);
  70184. /**
  70185. * Gets or sets the chromatic aberration amount
  70186. */
  70187. get chromaticAberration(): number;
  70188. set chromaticAberration(value: number);
  70189. /**
  70190. * Gets or sets the depth of field aperture
  70191. */
  70192. get dofAperture(): number;
  70193. set dofAperture(value: number);
  70194. /**
  70195. * Gets or sets the edge distortion
  70196. */
  70197. get edgeDistortion(): number;
  70198. set edgeDistortion(value: number);
  70199. /**
  70200. * Gets or sets the depth of field distortion
  70201. */
  70202. get dofDistortion(): number;
  70203. set dofDistortion(value: number);
  70204. /**
  70205. * Gets or sets the darken out of focus amount
  70206. */
  70207. get darkenOutOfFocus(): number;
  70208. set darkenOutOfFocus(value: number);
  70209. /**
  70210. * Gets or sets a boolean indicating if blur noise is enabled
  70211. */
  70212. get blurNoise(): boolean;
  70213. set blurNoise(value: boolean);
  70214. /**
  70215. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  70216. */
  70217. get pentagonBokeh(): boolean;
  70218. set pentagonBokeh(value: boolean);
  70219. /**
  70220. * Gets or sets the highlight grain amount
  70221. */
  70222. get highlightsGain(): number;
  70223. set highlightsGain(value: number);
  70224. /**
  70225. * Gets or sets the highlight threshold
  70226. */
  70227. get highlightsThreshold(): number;
  70228. set highlightsThreshold(value: number);
  70229. /**
  70230. * Sets the amount of blur at the edges
  70231. * @param amount blur amount
  70232. */
  70233. setEdgeBlur(amount: number): void;
  70234. /**
  70235. * Sets edge blur to 0
  70236. */
  70237. disableEdgeBlur(): void;
  70238. /**
  70239. * Sets the amout of grain
  70240. * @param amount Amount of grain
  70241. */
  70242. setGrainAmount(amount: number): void;
  70243. /**
  70244. * Set grain amount to 0
  70245. */
  70246. disableGrain(): void;
  70247. /**
  70248. * Sets the chromatic aberration amount
  70249. * @param amount amount of chromatic aberration
  70250. */
  70251. setChromaticAberration(amount: number): void;
  70252. /**
  70253. * Sets chromatic aberration amount to 0
  70254. */
  70255. disableChromaticAberration(): void;
  70256. /**
  70257. * Sets the EdgeDistortion amount
  70258. * @param amount amount of EdgeDistortion
  70259. */
  70260. setEdgeDistortion(amount: number): void;
  70261. /**
  70262. * Sets edge distortion to 0
  70263. */
  70264. disableEdgeDistortion(): void;
  70265. /**
  70266. * Sets the FocusDistance amount
  70267. * @param amount amount of FocusDistance
  70268. */
  70269. setFocusDistance(amount: number): void;
  70270. /**
  70271. * Disables depth of field
  70272. */
  70273. disableDepthOfField(): void;
  70274. /**
  70275. * Sets the Aperture amount
  70276. * @param amount amount of Aperture
  70277. */
  70278. setAperture(amount: number): void;
  70279. /**
  70280. * Sets the DarkenOutOfFocus amount
  70281. * @param amount amount of DarkenOutOfFocus
  70282. */
  70283. setDarkenOutOfFocus(amount: number): void;
  70284. private _pentagonBokehIsEnabled;
  70285. /**
  70286. * Creates a pentagon bokeh effect
  70287. */
  70288. enablePentagonBokeh(): void;
  70289. /**
  70290. * Disables the pentagon bokeh effect
  70291. */
  70292. disablePentagonBokeh(): void;
  70293. /**
  70294. * Enables noise blur
  70295. */
  70296. enableNoiseBlur(): void;
  70297. /**
  70298. * Disables noise blur
  70299. */
  70300. disableNoiseBlur(): void;
  70301. /**
  70302. * Sets the HighlightsGain amount
  70303. * @param amount amount of HighlightsGain
  70304. */
  70305. setHighlightsGain(amount: number): void;
  70306. /**
  70307. * Sets the HighlightsThreshold amount
  70308. * @param amount amount of HighlightsThreshold
  70309. */
  70310. setHighlightsThreshold(amount: number): void;
  70311. /**
  70312. * Disables highlights
  70313. */
  70314. disableHighlights(): void;
  70315. /**
  70316. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  70317. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  70318. */
  70319. dispose(disableDepthRender?: boolean): void;
  70320. private _createChromaticAberrationPostProcess;
  70321. private _createHighlightsPostProcess;
  70322. private _createDepthOfFieldPostProcess;
  70323. private _createGrainTexture;
  70324. }
  70325. }
  70326. declare module BABYLON {
  70327. /** @hidden */
  70328. export var ssao2PixelShader: {
  70329. name: string;
  70330. shader: string;
  70331. };
  70332. }
  70333. declare module BABYLON {
  70334. /** @hidden */
  70335. export var ssaoCombinePixelShader: {
  70336. name: string;
  70337. shader: string;
  70338. };
  70339. }
  70340. declare module BABYLON {
  70341. /**
  70342. * Render pipeline to produce ssao effect
  70343. */
  70344. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  70345. /**
  70346. * @ignore
  70347. * The PassPostProcess id in the pipeline that contains the original scene color
  70348. */
  70349. SSAOOriginalSceneColorEffect: string;
  70350. /**
  70351. * @ignore
  70352. * The SSAO PostProcess id in the pipeline
  70353. */
  70354. SSAORenderEffect: string;
  70355. /**
  70356. * @ignore
  70357. * The horizontal blur PostProcess id in the pipeline
  70358. */
  70359. SSAOBlurHRenderEffect: string;
  70360. /**
  70361. * @ignore
  70362. * The vertical blur PostProcess id in the pipeline
  70363. */
  70364. SSAOBlurVRenderEffect: string;
  70365. /**
  70366. * @ignore
  70367. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  70368. */
  70369. SSAOCombineRenderEffect: string;
  70370. /**
  70371. * The output strength of the SSAO post-process. Default value is 1.0.
  70372. */
  70373. totalStrength: number;
  70374. /**
  70375. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  70376. */
  70377. maxZ: number;
  70378. /**
  70379. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  70380. */
  70381. minZAspect: number;
  70382. private _samples;
  70383. /**
  70384. * Number of samples used for the SSAO calculations. Default value is 8
  70385. */
  70386. set samples(n: number);
  70387. get samples(): number;
  70388. private _textureSamples;
  70389. /**
  70390. * Number of samples to use for antialiasing
  70391. */
  70392. set textureSamples(n: number);
  70393. get textureSamples(): number;
  70394. /**
  70395. * Force rendering the geometry through geometry buffer
  70396. */
  70397. private _forceGeometryBuffer;
  70398. /**
  70399. * Ratio object used for SSAO ratio and blur ratio
  70400. */
  70401. private _ratio;
  70402. /**
  70403. * Dynamically generated sphere sampler.
  70404. */
  70405. private _sampleSphere;
  70406. /**
  70407. * Blur filter offsets
  70408. */
  70409. private _samplerOffsets;
  70410. private _expensiveBlur;
  70411. /**
  70412. * If bilateral blur should be used
  70413. */
  70414. set expensiveBlur(b: boolean);
  70415. get expensiveBlur(): boolean;
  70416. /**
  70417. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  70418. */
  70419. radius: number;
  70420. /**
  70421. * The base color of the SSAO post-process
  70422. * The final result is "base + ssao" between [0, 1]
  70423. */
  70424. base: number;
  70425. /**
  70426. * Support test.
  70427. */
  70428. static get IsSupported(): boolean;
  70429. private _scene;
  70430. private _randomTexture;
  70431. private _originalColorPostProcess;
  70432. private _ssaoPostProcess;
  70433. private _blurHPostProcess;
  70434. private _blurVPostProcess;
  70435. private _ssaoCombinePostProcess;
  70436. private _prePassRenderer;
  70437. /**
  70438. * Gets active scene
  70439. */
  70440. get scene(): Scene;
  70441. /**
  70442. * @constructor
  70443. * @param name The rendering pipeline name
  70444. * @param scene The scene linked to this pipeline
  70445. * @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 }
  70446. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70447. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  70448. */
  70449. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  70450. /**
  70451. * Get the class name
  70452. * @returns "SSAO2RenderingPipeline"
  70453. */
  70454. getClassName(): string;
  70455. /**
  70456. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  70457. */
  70458. dispose(disableGeometryBufferRenderer?: boolean): void;
  70459. private _createBlurPostProcess;
  70460. /** @hidden */
  70461. _rebuild(): void;
  70462. private _bits;
  70463. private _radicalInverse_VdC;
  70464. private _hammersley;
  70465. private _hemisphereSample_uniform;
  70466. private _generateHemisphere;
  70467. private _getDefinesForSSAO;
  70468. private _createSSAOPostProcess;
  70469. private _createSSAOCombinePostProcess;
  70470. private _createRandomTexture;
  70471. /**
  70472. * Serialize the rendering pipeline (Used when exporting)
  70473. * @returns the serialized object
  70474. */
  70475. serialize(): any;
  70476. /**
  70477. * Parse the serialized pipeline
  70478. * @param source Source pipeline.
  70479. * @param scene The scene to load the pipeline to.
  70480. * @param rootUrl The URL of the serialized pipeline.
  70481. * @returns An instantiated pipeline from the serialized object.
  70482. */
  70483. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  70484. /**
  70485. * Sets the required values to the prepass renderer.
  70486. * @param prePassRenderer defines the prepass renderer to setup
  70487. * @returns true if the pre pass is needed.
  70488. */
  70489. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  70490. }
  70491. }
  70492. declare module BABYLON {
  70493. /** @hidden */
  70494. export var ssaoPixelShader: {
  70495. name: string;
  70496. shader: string;
  70497. };
  70498. }
  70499. declare module BABYLON {
  70500. /**
  70501. * Render pipeline to produce ssao effect
  70502. */
  70503. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  70504. /**
  70505. * @ignore
  70506. * The PassPostProcess id in the pipeline that contains the original scene color
  70507. */
  70508. SSAOOriginalSceneColorEffect: string;
  70509. /**
  70510. * @ignore
  70511. * The SSAO PostProcess id in the pipeline
  70512. */
  70513. SSAORenderEffect: string;
  70514. /**
  70515. * @ignore
  70516. * The horizontal blur PostProcess id in the pipeline
  70517. */
  70518. SSAOBlurHRenderEffect: string;
  70519. /**
  70520. * @ignore
  70521. * The vertical blur PostProcess id in the pipeline
  70522. */
  70523. SSAOBlurVRenderEffect: string;
  70524. /**
  70525. * @ignore
  70526. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  70527. */
  70528. SSAOCombineRenderEffect: string;
  70529. /**
  70530. * The output strength of the SSAO post-process. Default value is 1.0.
  70531. */
  70532. totalStrength: number;
  70533. /**
  70534. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  70535. */
  70536. radius: number;
  70537. /**
  70538. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  70539. * Must not be equal to fallOff and superior to fallOff.
  70540. * Default value is 0.0075
  70541. */
  70542. area: number;
  70543. /**
  70544. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  70545. * Must not be equal to area and inferior to area.
  70546. * Default value is 0.000001
  70547. */
  70548. fallOff: number;
  70549. /**
  70550. * The base color of the SSAO post-process
  70551. * The final result is "base + ssao" between [0, 1]
  70552. */
  70553. base: number;
  70554. private _scene;
  70555. private _depthTexture;
  70556. private _randomTexture;
  70557. private _originalColorPostProcess;
  70558. private _ssaoPostProcess;
  70559. private _blurHPostProcess;
  70560. private _blurVPostProcess;
  70561. private _ssaoCombinePostProcess;
  70562. private _firstUpdate;
  70563. /**
  70564. * Gets active scene
  70565. */
  70566. get scene(): Scene;
  70567. /**
  70568. * @constructor
  70569. * @param name - The rendering pipeline name
  70570. * @param scene - The scene linked to this pipeline
  70571. * @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 }
  70572. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  70573. */
  70574. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  70575. /**
  70576. * Get the class name
  70577. * @returns "SSAORenderingPipeline"
  70578. */
  70579. getClassName(): string;
  70580. /**
  70581. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  70582. */
  70583. dispose(disableDepthRender?: boolean): void;
  70584. private _createBlurPostProcess;
  70585. /** @hidden */
  70586. _rebuild(): void;
  70587. private _createSSAOPostProcess;
  70588. private _createSSAOCombinePostProcess;
  70589. private _createRandomTexture;
  70590. }
  70591. }
  70592. declare module BABYLON {
  70593. /** @hidden */
  70594. export var screenSpaceReflectionPixelShader: {
  70595. name: string;
  70596. shader: string;
  70597. };
  70598. }
  70599. declare module BABYLON {
  70600. /**
  70601. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  70602. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  70603. */
  70604. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  70605. /**
  70606. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  70607. */
  70608. threshold: number;
  70609. /**
  70610. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  70611. */
  70612. strength: number;
  70613. /**
  70614. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  70615. */
  70616. reflectionSpecularFalloffExponent: number;
  70617. /**
  70618. * 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]
  70619. */
  70620. step: number;
  70621. /**
  70622. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  70623. */
  70624. roughnessFactor: number;
  70625. private _geometryBufferRenderer;
  70626. private _enableSmoothReflections;
  70627. private _reflectionSamples;
  70628. private _smoothSteps;
  70629. /**
  70630. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  70631. * @param name The name of the effect.
  70632. * @param scene The scene containing the objects to calculate reflections.
  70633. * @param options The required width/height ratio to downsize to before computing the render pass.
  70634. * @param camera The camera to apply the render pass to.
  70635. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70636. * @param engine The engine which the post process will be applied. (default: current engine)
  70637. * @param reusable If the post process can be reused on the same frame. (default: false)
  70638. * @param textureType Type of textures used when performing the post process. (default: 0)
  70639. * @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)
  70640. */
  70641. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70642. /**
  70643. * Gets wether or not smoothing reflections is enabled.
  70644. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  70645. */
  70646. get enableSmoothReflections(): boolean;
  70647. /**
  70648. * Sets wether or not smoothing reflections is enabled.
  70649. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  70650. */
  70651. set enableSmoothReflections(enabled: boolean);
  70652. /**
  70653. * Gets the number of samples taken while computing reflections. More samples count is high,
  70654. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  70655. */
  70656. get reflectionSamples(): number;
  70657. /**
  70658. * Sets the number of samples taken while computing reflections. More samples count is high,
  70659. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  70660. */
  70661. set reflectionSamples(samples: number);
  70662. /**
  70663. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  70664. * more the post-process will require GPU power and can generate a drop in FPS.
  70665. * Default value (5.0) work pretty well in all cases but can be adjusted.
  70666. */
  70667. get smoothSteps(): number;
  70668. set smoothSteps(steps: number);
  70669. private _updateEffectDefines;
  70670. }
  70671. }
  70672. declare module BABYLON {
  70673. /** @hidden */
  70674. export var standardPixelShader: {
  70675. name: string;
  70676. shader: string;
  70677. };
  70678. }
  70679. declare module BABYLON {
  70680. /**
  70681. * Standard rendering pipeline
  70682. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  70683. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  70684. */
  70685. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  70686. /**
  70687. * Public members
  70688. */
  70689. /**
  70690. * Post-process which contains the original scene color before the pipeline applies all the effects
  70691. */
  70692. originalPostProcess: Nullable<PostProcess>;
  70693. /**
  70694. * Post-process used to down scale an image x4
  70695. */
  70696. downSampleX4PostProcess: Nullable<PostProcess>;
  70697. /**
  70698. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  70699. */
  70700. brightPassPostProcess: Nullable<PostProcess>;
  70701. /**
  70702. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  70703. */
  70704. blurHPostProcesses: PostProcess[];
  70705. /**
  70706. * Post-process array storing all the vertical blur post-processes used by the pipeline
  70707. */
  70708. blurVPostProcesses: PostProcess[];
  70709. /**
  70710. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  70711. */
  70712. textureAdderPostProcess: Nullable<PostProcess>;
  70713. /**
  70714. * Post-process used to create volumetric lighting effect
  70715. */
  70716. volumetricLightPostProcess: Nullable<PostProcess>;
  70717. /**
  70718. * Post-process used to smooth the previous volumetric light post-process on the X axis
  70719. */
  70720. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  70721. /**
  70722. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  70723. */
  70724. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  70725. /**
  70726. * Post-process used to merge the volumetric light effect and the real scene color
  70727. */
  70728. volumetricLightMergePostProces: Nullable<PostProcess>;
  70729. /**
  70730. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  70731. */
  70732. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  70733. /**
  70734. * Base post-process used to calculate the average luminance of the final image for HDR
  70735. */
  70736. luminancePostProcess: Nullable<PostProcess>;
  70737. /**
  70738. * Post-processes used to create down sample post-processes in order to get
  70739. * the average luminance of the final image for HDR
  70740. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  70741. */
  70742. luminanceDownSamplePostProcesses: PostProcess[];
  70743. /**
  70744. * Post-process used to create a HDR effect (light adaptation)
  70745. */
  70746. hdrPostProcess: Nullable<PostProcess>;
  70747. /**
  70748. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  70749. */
  70750. textureAdderFinalPostProcess: Nullable<PostProcess>;
  70751. /**
  70752. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  70753. */
  70754. lensFlareFinalPostProcess: Nullable<PostProcess>;
  70755. /**
  70756. * Post-process used to merge the final HDR post-process and the real scene color
  70757. */
  70758. hdrFinalPostProcess: Nullable<PostProcess>;
  70759. /**
  70760. * Post-process used to create a lens flare effect
  70761. */
  70762. lensFlarePostProcess: Nullable<PostProcess>;
  70763. /**
  70764. * Post-process that merges the result of the lens flare post-process and the real scene color
  70765. */
  70766. lensFlareComposePostProcess: Nullable<PostProcess>;
  70767. /**
  70768. * Post-process used to create a motion blur effect
  70769. */
  70770. motionBlurPostProcess: Nullable<PostProcess>;
  70771. /**
  70772. * Post-process used to create a depth of field effect
  70773. */
  70774. depthOfFieldPostProcess: Nullable<PostProcess>;
  70775. /**
  70776. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  70777. */
  70778. fxaaPostProcess: Nullable<FxaaPostProcess>;
  70779. /**
  70780. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  70781. */
  70782. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  70783. /**
  70784. * Represents the brightness threshold in order to configure the illuminated surfaces
  70785. */
  70786. brightThreshold: number;
  70787. /**
  70788. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  70789. */
  70790. blurWidth: number;
  70791. /**
  70792. * Sets if the blur for highlighted surfaces must be only horizontal
  70793. */
  70794. horizontalBlur: boolean;
  70795. /**
  70796. * Gets the overall exposure used by the pipeline
  70797. */
  70798. get exposure(): number;
  70799. /**
  70800. * Sets the overall exposure used by the pipeline
  70801. */
  70802. set exposure(value: number);
  70803. /**
  70804. * Texture used typically to simulate "dirty" on camera lens
  70805. */
  70806. lensTexture: Nullable<Texture>;
  70807. /**
  70808. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  70809. */
  70810. volumetricLightCoefficient: number;
  70811. /**
  70812. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  70813. */
  70814. volumetricLightPower: number;
  70815. /**
  70816. * Used the set the blur intensity to smooth the volumetric lights
  70817. */
  70818. volumetricLightBlurScale: number;
  70819. /**
  70820. * Light (spot or directional) used to generate the volumetric lights rays
  70821. * The source light must have a shadow generate so the pipeline can get its
  70822. * depth map
  70823. */
  70824. sourceLight: Nullable<SpotLight | DirectionalLight>;
  70825. /**
  70826. * For eye adaptation, represents the minimum luminance the eye can see
  70827. */
  70828. hdrMinimumLuminance: number;
  70829. /**
  70830. * For eye adaptation, represents the decrease luminance speed
  70831. */
  70832. hdrDecreaseRate: number;
  70833. /**
  70834. * For eye adaptation, represents the increase luminance speed
  70835. */
  70836. hdrIncreaseRate: number;
  70837. /**
  70838. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  70839. */
  70840. get hdrAutoExposure(): boolean;
  70841. /**
  70842. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  70843. */
  70844. set hdrAutoExposure(value: boolean);
  70845. /**
  70846. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  70847. */
  70848. lensColorTexture: Nullable<Texture>;
  70849. /**
  70850. * The overall strengh for the lens flare effect
  70851. */
  70852. lensFlareStrength: number;
  70853. /**
  70854. * Dispersion coefficient for lens flare ghosts
  70855. */
  70856. lensFlareGhostDispersal: number;
  70857. /**
  70858. * Main lens flare halo width
  70859. */
  70860. lensFlareHaloWidth: number;
  70861. /**
  70862. * Based on the lens distortion effect, defines how much the lens flare result
  70863. * is distorted
  70864. */
  70865. lensFlareDistortionStrength: number;
  70866. /**
  70867. * Configures the blur intensity used for for lens flare (halo)
  70868. */
  70869. lensFlareBlurWidth: number;
  70870. /**
  70871. * Lens star texture must be used to simulate rays on the flares and is available
  70872. * in the documentation
  70873. */
  70874. lensStarTexture: Nullable<Texture>;
  70875. /**
  70876. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  70877. * flare effect by taking account of the dirt texture
  70878. */
  70879. lensFlareDirtTexture: Nullable<Texture>;
  70880. /**
  70881. * Represents the focal length for the depth of field effect
  70882. */
  70883. depthOfFieldDistance: number;
  70884. /**
  70885. * Represents the blur intensity for the blurred part of the depth of field effect
  70886. */
  70887. depthOfFieldBlurWidth: number;
  70888. /**
  70889. * Gets how much the image is blurred by the movement while using the motion blur post-process
  70890. */
  70891. get motionStrength(): number;
  70892. /**
  70893. * Sets how much the image is blurred by the movement while using the motion blur post-process
  70894. */
  70895. set motionStrength(strength: number);
  70896. /**
  70897. * Gets wether or not the motion blur post-process is object based or screen based.
  70898. */
  70899. get objectBasedMotionBlur(): boolean;
  70900. /**
  70901. * Sets wether or not the motion blur post-process should be object based or screen based
  70902. */
  70903. set objectBasedMotionBlur(value: boolean);
  70904. /**
  70905. * List of animations for the pipeline (IAnimatable implementation)
  70906. */
  70907. animations: Animation[];
  70908. /**
  70909. * Private members
  70910. */
  70911. private _scene;
  70912. private _currentDepthOfFieldSource;
  70913. private _basePostProcess;
  70914. private _fixedExposure;
  70915. private _currentExposure;
  70916. private _hdrAutoExposure;
  70917. private _hdrCurrentLuminance;
  70918. private _motionStrength;
  70919. private _isObjectBasedMotionBlur;
  70920. private _floatTextureType;
  70921. private _camerasToBeAttached;
  70922. private _ratio;
  70923. private _bloomEnabled;
  70924. private _depthOfFieldEnabled;
  70925. private _vlsEnabled;
  70926. private _lensFlareEnabled;
  70927. private _hdrEnabled;
  70928. private _motionBlurEnabled;
  70929. private _fxaaEnabled;
  70930. private _screenSpaceReflectionsEnabled;
  70931. private _motionBlurSamples;
  70932. private _volumetricLightStepsCount;
  70933. private _samples;
  70934. /**
  70935. * @ignore
  70936. * Specifies if the bloom pipeline is enabled
  70937. */
  70938. get BloomEnabled(): boolean;
  70939. set BloomEnabled(enabled: boolean);
  70940. /**
  70941. * @ignore
  70942. * Specifies if the depth of field pipeline is enabed
  70943. */
  70944. get DepthOfFieldEnabled(): boolean;
  70945. set DepthOfFieldEnabled(enabled: boolean);
  70946. /**
  70947. * @ignore
  70948. * Specifies if the lens flare pipeline is enabed
  70949. */
  70950. get LensFlareEnabled(): boolean;
  70951. set LensFlareEnabled(enabled: boolean);
  70952. /**
  70953. * @ignore
  70954. * Specifies if the HDR pipeline is enabled
  70955. */
  70956. get HDREnabled(): boolean;
  70957. set HDREnabled(enabled: boolean);
  70958. /**
  70959. * @ignore
  70960. * Specifies if the volumetric lights scattering effect is enabled
  70961. */
  70962. get VLSEnabled(): boolean;
  70963. set VLSEnabled(enabled: boolean);
  70964. /**
  70965. * @ignore
  70966. * Specifies if the motion blur effect is enabled
  70967. */
  70968. get MotionBlurEnabled(): boolean;
  70969. set MotionBlurEnabled(enabled: boolean);
  70970. /**
  70971. * Specifies if anti-aliasing is enabled
  70972. */
  70973. get fxaaEnabled(): boolean;
  70974. set fxaaEnabled(enabled: boolean);
  70975. /**
  70976. * Specifies if screen space reflections are enabled.
  70977. */
  70978. get screenSpaceReflectionsEnabled(): boolean;
  70979. set screenSpaceReflectionsEnabled(enabled: boolean);
  70980. /**
  70981. * Specifies the number of steps used to calculate the volumetric lights
  70982. * Typically in interval [50, 200]
  70983. */
  70984. get volumetricLightStepsCount(): number;
  70985. set volumetricLightStepsCount(count: number);
  70986. /**
  70987. * Specifies the number of samples used for the motion blur effect
  70988. * Typically in interval [16, 64]
  70989. */
  70990. get motionBlurSamples(): number;
  70991. set motionBlurSamples(samples: number);
  70992. /**
  70993. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70994. */
  70995. get samples(): number;
  70996. set samples(sampleCount: number);
  70997. /**
  70998. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  70999. * @constructor
  71000. * @param name The rendering pipeline name
  71001. * @param scene The scene linked to this pipeline
  71002. * @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)
  71003. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  71004. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71005. */
  71006. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  71007. private _buildPipeline;
  71008. private _createDownSampleX4PostProcess;
  71009. private _createBrightPassPostProcess;
  71010. private _createBlurPostProcesses;
  71011. private _createTextureAdderPostProcess;
  71012. private _createVolumetricLightPostProcess;
  71013. private _createLuminancePostProcesses;
  71014. private _createHdrPostProcess;
  71015. private _createLensFlarePostProcess;
  71016. private _createDepthOfFieldPostProcess;
  71017. private _createMotionBlurPostProcess;
  71018. private _getDepthTexture;
  71019. private _disposePostProcesses;
  71020. /**
  71021. * Dispose of the pipeline and stop all post processes
  71022. */
  71023. dispose(): void;
  71024. /**
  71025. * Serialize the rendering pipeline (Used when exporting)
  71026. * @returns the serialized object
  71027. */
  71028. serialize(): any;
  71029. /**
  71030. * Parse the serialized pipeline
  71031. * @param source Source pipeline.
  71032. * @param scene The scene to load the pipeline to.
  71033. * @param rootUrl The URL of the serialized pipeline.
  71034. * @returns An instantiated pipeline from the serialized object.
  71035. */
  71036. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  71037. /**
  71038. * Luminance steps
  71039. */
  71040. static LuminanceSteps: number;
  71041. }
  71042. }
  71043. declare module BABYLON {
  71044. /** @hidden */
  71045. export var stereoscopicInterlacePixelShader: {
  71046. name: string;
  71047. shader: string;
  71048. };
  71049. }
  71050. declare module BABYLON {
  71051. /**
  71052. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  71053. */
  71054. export class StereoscopicInterlacePostProcessI extends PostProcess {
  71055. private _stepSize;
  71056. private _passedProcess;
  71057. /**
  71058. * Initializes a StereoscopicInterlacePostProcessI
  71059. * @param name The name of the effect.
  71060. * @param rigCameras The rig cameras to be appled to the post process
  71061. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  71062. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  71063. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71064. * @param engine The engine which the post process will be applied. (default: current engine)
  71065. * @param reusable If the post process can be reused on the same frame. (default: false)
  71066. */
  71067. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71068. }
  71069. /**
  71070. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  71071. */
  71072. export class StereoscopicInterlacePostProcess extends PostProcess {
  71073. private _stepSize;
  71074. private _passedProcess;
  71075. /**
  71076. * Initializes a StereoscopicInterlacePostProcess
  71077. * @param name The name of the effect.
  71078. * @param rigCameras The rig cameras to be appled to the post process
  71079. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  71080. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71081. * @param engine The engine which the post process will be applied. (default: current engine)
  71082. * @param reusable If the post process can be reused on the same frame. (default: false)
  71083. */
  71084. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71085. }
  71086. }
  71087. declare module BABYLON {
  71088. /** @hidden */
  71089. export var tonemapPixelShader: {
  71090. name: string;
  71091. shader: string;
  71092. };
  71093. }
  71094. declare module BABYLON {
  71095. /** Defines operator used for tonemapping */
  71096. export enum TonemappingOperator {
  71097. /** Hable */
  71098. Hable = 0,
  71099. /** Reinhard */
  71100. Reinhard = 1,
  71101. /** HejiDawson */
  71102. HejiDawson = 2,
  71103. /** Photographic */
  71104. Photographic = 3
  71105. }
  71106. /**
  71107. * Defines a post process to apply tone mapping
  71108. */
  71109. export class TonemapPostProcess extends PostProcess {
  71110. private _operator;
  71111. /** Defines the required exposure adjustement */
  71112. exposureAdjustment: number;
  71113. /**
  71114. * Creates a new TonemapPostProcess
  71115. * @param name defines the name of the postprocess
  71116. * @param _operator defines the operator to use
  71117. * @param exposureAdjustment defines the required exposure adjustement
  71118. * @param camera defines the camera to use (can be null)
  71119. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  71120. * @param engine defines the hosting engine (can be ignore if camera is set)
  71121. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71122. */
  71123. constructor(name: string, _operator: TonemappingOperator,
  71124. /** Defines the required exposure adjustement */
  71125. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  71126. }
  71127. }
  71128. declare module BABYLON {
  71129. /** @hidden */
  71130. export var volumetricLightScatteringPixelShader: {
  71131. name: string;
  71132. shader: string;
  71133. };
  71134. }
  71135. declare module BABYLON {
  71136. /** @hidden */
  71137. export var volumetricLightScatteringPassVertexShader: {
  71138. name: string;
  71139. shader: string;
  71140. };
  71141. }
  71142. declare module BABYLON {
  71143. /** @hidden */
  71144. export var volumetricLightScatteringPassPixelShader: {
  71145. name: string;
  71146. shader: string;
  71147. };
  71148. }
  71149. declare module BABYLON {
  71150. /**
  71151. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  71152. */
  71153. export class VolumetricLightScatteringPostProcess extends PostProcess {
  71154. private _volumetricLightScatteringPass;
  71155. private _volumetricLightScatteringRTT;
  71156. private _viewPort;
  71157. private _screenCoordinates;
  71158. private _cachedDefines;
  71159. /**
  71160. * If not undefined, the mesh position is computed from the attached node position
  71161. */
  71162. attachedNode: {
  71163. position: Vector3;
  71164. };
  71165. /**
  71166. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  71167. */
  71168. customMeshPosition: Vector3;
  71169. /**
  71170. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  71171. */
  71172. useCustomMeshPosition: boolean;
  71173. /**
  71174. * If the post-process should inverse the light scattering direction
  71175. */
  71176. invert: boolean;
  71177. /**
  71178. * The internal mesh used by the post-process
  71179. */
  71180. mesh: Mesh;
  71181. /**
  71182. * @hidden
  71183. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  71184. */
  71185. get useDiffuseColor(): boolean;
  71186. set useDiffuseColor(useDiffuseColor: boolean);
  71187. /**
  71188. * Array containing the excluded meshes not rendered in the internal pass
  71189. */
  71190. excludedMeshes: AbstractMesh[];
  71191. /**
  71192. * Controls the overall intensity of the post-process
  71193. */
  71194. exposure: number;
  71195. /**
  71196. * Dissipates each sample's contribution in range [0, 1]
  71197. */
  71198. decay: number;
  71199. /**
  71200. * Controls the overall intensity of each sample
  71201. */
  71202. weight: number;
  71203. /**
  71204. * Controls the density of each sample
  71205. */
  71206. density: number;
  71207. /**
  71208. * @constructor
  71209. * @param name The post-process name
  71210. * @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)
  71211. * @param camera The camera that the post-process will be attached to
  71212. * @param mesh The mesh used to create the light scattering
  71213. * @param samples The post-process quality, default 100
  71214. * @param samplingModeThe post-process filtering mode
  71215. * @param engine The babylon engine
  71216. * @param reusable If the post-process is reusable
  71217. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  71218. */
  71219. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  71220. /**
  71221. * Returns the string "VolumetricLightScatteringPostProcess"
  71222. * @returns "VolumetricLightScatteringPostProcess"
  71223. */
  71224. getClassName(): string;
  71225. private _isReady;
  71226. /**
  71227. * Sets the new light position for light scattering effect
  71228. * @param position The new custom light position
  71229. */
  71230. setCustomMeshPosition(position: Vector3): void;
  71231. /**
  71232. * Returns the light position for light scattering effect
  71233. * @return Vector3 The custom light position
  71234. */
  71235. getCustomMeshPosition(): Vector3;
  71236. /**
  71237. * Disposes the internal assets and detaches the post-process from the camera
  71238. */
  71239. dispose(camera: Camera): void;
  71240. /**
  71241. * Returns the render target texture used by the post-process
  71242. * @return the render target texture used by the post-process
  71243. */
  71244. getPass(): RenderTargetTexture;
  71245. private _meshExcluded;
  71246. private _createPass;
  71247. private _updateMeshScreenCoordinates;
  71248. /**
  71249. * Creates a default mesh for the Volumeric Light Scattering post-process
  71250. * @param name The mesh name
  71251. * @param scene The scene where to create the mesh
  71252. * @return the default mesh
  71253. */
  71254. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  71255. }
  71256. }
  71257. declare module BABYLON {
  71258. /** @hidden */
  71259. export var screenSpaceCurvaturePixelShader: {
  71260. name: string;
  71261. shader: string;
  71262. };
  71263. }
  71264. declare module BABYLON {
  71265. /**
  71266. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  71267. */
  71268. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  71269. /**
  71270. * Defines how much ridge the curvature effect displays.
  71271. */
  71272. ridge: number;
  71273. /**
  71274. * Defines how much valley the curvature effect displays.
  71275. */
  71276. valley: number;
  71277. private _geometryBufferRenderer;
  71278. /**
  71279. * Creates a new instance ScreenSpaceCurvaturePostProcess
  71280. * @param name The name of the effect.
  71281. * @param scene The scene containing the objects to blur according to their velocity.
  71282. * @param options The required width/height ratio to downsize to before computing the render pass.
  71283. * @param camera The camera to apply the render pass to.
  71284. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71285. * @param engine The engine which the post process will be applied. (default: current engine)
  71286. * @param reusable If the post process can be reused on the same frame. (default: false)
  71287. * @param textureType Type of textures used when performing the post process. (default: 0)
  71288. * @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)
  71289. */
  71290. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71291. /**
  71292. * Support test.
  71293. */
  71294. static get IsSupported(): boolean;
  71295. }
  71296. }
  71297. declare module BABYLON {
  71298. interface Scene {
  71299. /** @hidden (Backing field) */
  71300. _boundingBoxRenderer: BoundingBoxRenderer;
  71301. /** @hidden (Backing field) */
  71302. _forceShowBoundingBoxes: boolean;
  71303. /**
  71304. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  71305. */
  71306. forceShowBoundingBoxes: boolean;
  71307. /**
  71308. * Gets the bounding box renderer associated with the scene
  71309. * @returns a BoundingBoxRenderer
  71310. */
  71311. getBoundingBoxRenderer(): BoundingBoxRenderer;
  71312. }
  71313. interface AbstractMesh {
  71314. /** @hidden (Backing field) */
  71315. _showBoundingBox: boolean;
  71316. /**
  71317. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  71318. */
  71319. showBoundingBox: boolean;
  71320. }
  71321. /**
  71322. * Component responsible of rendering the bounding box of the meshes in a scene.
  71323. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  71324. */
  71325. export class BoundingBoxRenderer implements ISceneComponent {
  71326. /**
  71327. * The component name helpfull to identify the component in the list of scene components.
  71328. */
  71329. readonly name: string;
  71330. /**
  71331. * The scene the component belongs to.
  71332. */
  71333. scene: Scene;
  71334. /**
  71335. * Color of the bounding box lines placed in front of an object
  71336. */
  71337. frontColor: Color3;
  71338. /**
  71339. * Color of the bounding box lines placed behind an object
  71340. */
  71341. backColor: Color3;
  71342. /**
  71343. * Defines if the renderer should show the back lines or not
  71344. */
  71345. showBackLines: boolean;
  71346. /**
  71347. * Observable raised before rendering a bounding box
  71348. */
  71349. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  71350. /**
  71351. * Observable raised after rendering a bounding box
  71352. */
  71353. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  71354. /**
  71355. * @hidden
  71356. */
  71357. renderList: SmartArray<BoundingBox>;
  71358. private _colorShader;
  71359. private _vertexBuffers;
  71360. private _indexBuffer;
  71361. private _fillIndexBuffer;
  71362. private _fillIndexData;
  71363. /**
  71364. * Instantiates a new bounding box renderer in a scene.
  71365. * @param scene the scene the renderer renders in
  71366. */
  71367. constructor(scene: Scene);
  71368. /**
  71369. * Registers the component in a given scene
  71370. */
  71371. register(): void;
  71372. private _evaluateSubMesh;
  71373. private _activeMesh;
  71374. private _prepareRessources;
  71375. private _createIndexBuffer;
  71376. /**
  71377. * Rebuilds the elements related to this component in case of
  71378. * context lost for instance.
  71379. */
  71380. rebuild(): void;
  71381. /**
  71382. * @hidden
  71383. */
  71384. reset(): void;
  71385. /**
  71386. * Render the bounding boxes of a specific rendering group
  71387. * @param renderingGroupId defines the rendering group to render
  71388. */
  71389. render(renderingGroupId: number): void;
  71390. /**
  71391. * In case of occlusion queries, we can render the occlusion bounding box through this method
  71392. * @param mesh Define the mesh to render the occlusion bounding box for
  71393. */
  71394. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  71395. /**
  71396. * Dispose and release the resources attached to this renderer.
  71397. */
  71398. dispose(): void;
  71399. }
  71400. }
  71401. declare module BABYLON {
  71402. interface Scene {
  71403. /** @hidden (Backing field) */
  71404. _depthRenderer: {
  71405. [id: string]: DepthRenderer;
  71406. };
  71407. /**
  71408. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  71409. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  71410. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  71411. * @returns the created depth renderer
  71412. */
  71413. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  71414. /**
  71415. * Disables a depth renderer for a given camera
  71416. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  71417. */
  71418. disableDepthRenderer(camera?: Nullable<Camera>): void;
  71419. }
  71420. /**
  71421. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  71422. * in several rendering techniques.
  71423. */
  71424. export class DepthRendererSceneComponent implements ISceneComponent {
  71425. /**
  71426. * The component name helpfull to identify the component in the list of scene components.
  71427. */
  71428. readonly name: string;
  71429. /**
  71430. * The scene the component belongs to.
  71431. */
  71432. scene: Scene;
  71433. /**
  71434. * Creates a new instance of the component for the given scene
  71435. * @param scene Defines the scene to register the component in
  71436. */
  71437. constructor(scene: Scene);
  71438. /**
  71439. * Registers the component in a given scene
  71440. */
  71441. register(): void;
  71442. /**
  71443. * Rebuilds the elements related to this component in case of
  71444. * context lost for instance.
  71445. */
  71446. rebuild(): void;
  71447. /**
  71448. * Disposes the component and the associated ressources
  71449. */
  71450. dispose(): void;
  71451. private _gatherRenderTargets;
  71452. private _gatherActiveCameraRenderTargets;
  71453. }
  71454. }
  71455. declare module BABYLON {
  71456. interface AbstractScene {
  71457. /** @hidden (Backing field) */
  71458. _prePassRenderer: Nullable<PrePassRenderer>;
  71459. /**
  71460. * Gets or Sets the current prepass renderer associated to the scene.
  71461. */
  71462. prePassRenderer: Nullable<PrePassRenderer>;
  71463. /**
  71464. * Enables the prepass and associates it with the scene
  71465. * @returns the PrePassRenderer
  71466. */
  71467. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  71468. /**
  71469. * Disables the prepass associated with the scene
  71470. */
  71471. disablePrePassRenderer(): void;
  71472. }
  71473. /**
  71474. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  71475. * in several rendering techniques.
  71476. */
  71477. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  71478. /**
  71479. * The component name helpful to identify the component in the list of scene components.
  71480. */
  71481. readonly name: string;
  71482. /**
  71483. * The scene the component belongs to.
  71484. */
  71485. scene: Scene;
  71486. /**
  71487. * Creates a new instance of the component for the given scene
  71488. * @param scene Defines the scene to register the component in
  71489. */
  71490. constructor(scene: Scene);
  71491. /**
  71492. * Registers the component in a given scene
  71493. */
  71494. register(): void;
  71495. private _beforeCameraDraw;
  71496. private _afterCameraDraw;
  71497. private _beforeClearStage;
  71498. /**
  71499. * Serializes the component data to the specified json object
  71500. * @param serializationObject The object to serialize to
  71501. */
  71502. serialize(serializationObject: any): void;
  71503. /**
  71504. * Adds all the elements from the container to the scene
  71505. * @param container the container holding the elements
  71506. */
  71507. addFromContainer(container: AbstractScene): void;
  71508. /**
  71509. * Removes all the elements in the container from the scene
  71510. * @param container contains the elements to remove
  71511. * @param dispose if the removed element should be disposed (default: false)
  71512. */
  71513. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  71514. /**
  71515. * Rebuilds the elements related to this component in case of
  71516. * context lost for instance.
  71517. */
  71518. rebuild(): void;
  71519. /**
  71520. * Disposes the component and the associated ressources
  71521. */
  71522. dispose(): void;
  71523. }
  71524. }
  71525. declare module BABYLON {
  71526. /** @hidden */
  71527. export var outlinePixelShader: {
  71528. name: string;
  71529. shader: string;
  71530. };
  71531. }
  71532. declare module BABYLON {
  71533. /** @hidden */
  71534. export var outlineVertexShader: {
  71535. name: string;
  71536. shader: string;
  71537. };
  71538. }
  71539. declare module BABYLON {
  71540. interface Scene {
  71541. /** @hidden */
  71542. _outlineRenderer: OutlineRenderer;
  71543. /**
  71544. * Gets the outline renderer associated with the scene
  71545. * @returns a OutlineRenderer
  71546. */
  71547. getOutlineRenderer(): OutlineRenderer;
  71548. }
  71549. interface AbstractMesh {
  71550. /** @hidden (Backing field) */
  71551. _renderOutline: boolean;
  71552. /**
  71553. * Gets or sets a boolean indicating if the outline must be rendered as well
  71554. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  71555. */
  71556. renderOutline: boolean;
  71557. /** @hidden (Backing field) */
  71558. _renderOverlay: boolean;
  71559. /**
  71560. * Gets or sets a boolean indicating if the overlay must be rendered as well
  71561. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  71562. */
  71563. renderOverlay: boolean;
  71564. }
  71565. /**
  71566. * This class is responsible to draw bothe outline/overlay of meshes.
  71567. * It should not be used directly but through the available method on mesh.
  71568. */
  71569. export class OutlineRenderer implements ISceneComponent {
  71570. /**
  71571. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  71572. */
  71573. private static _StencilReference;
  71574. /**
  71575. * The name of the component. Each component must have a unique name.
  71576. */
  71577. name: string;
  71578. /**
  71579. * The scene the component belongs to.
  71580. */
  71581. scene: Scene;
  71582. /**
  71583. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  71584. */
  71585. zOffset: number;
  71586. private _engine;
  71587. private _effect;
  71588. private _cachedDefines;
  71589. private _savedDepthWrite;
  71590. /**
  71591. * Instantiates a new outline renderer. (There could be only one per scene).
  71592. * @param scene Defines the scene it belongs to
  71593. */
  71594. constructor(scene: Scene);
  71595. /**
  71596. * Register the component to one instance of a scene.
  71597. */
  71598. register(): void;
  71599. /**
  71600. * Rebuilds the elements related to this component in case of
  71601. * context lost for instance.
  71602. */
  71603. rebuild(): void;
  71604. /**
  71605. * Disposes the component and the associated ressources.
  71606. */
  71607. dispose(): void;
  71608. /**
  71609. * Renders the outline in the canvas.
  71610. * @param subMesh Defines the sumesh to render
  71611. * @param batch Defines the batch of meshes in case of instances
  71612. * @param useOverlay Defines if the rendering is for the overlay or the outline
  71613. */
  71614. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  71615. /**
  71616. * Returns whether or not the outline renderer is ready for a given submesh.
  71617. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  71618. * @param subMesh Defines the submesh to check readyness for
  71619. * @param useInstances Defines wheter wee are trying to render instances or not
  71620. * @returns true if ready otherwise false
  71621. */
  71622. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  71623. private _beforeRenderingMesh;
  71624. private _afterRenderingMesh;
  71625. }
  71626. }
  71627. declare module BABYLON {
  71628. /**
  71629. * Defines the basic options interface of a Sprite Frame Source Size.
  71630. */
  71631. export interface ISpriteJSONSpriteSourceSize {
  71632. /**
  71633. * number of the original width of the Frame
  71634. */
  71635. w: number;
  71636. /**
  71637. * number of the original height of the Frame
  71638. */
  71639. h: number;
  71640. }
  71641. /**
  71642. * Defines the basic options interface of a Sprite Frame Data.
  71643. */
  71644. export interface ISpriteJSONSpriteFrameData {
  71645. /**
  71646. * number of the x offset of the Frame
  71647. */
  71648. x: number;
  71649. /**
  71650. * number of the y offset of the Frame
  71651. */
  71652. y: number;
  71653. /**
  71654. * number of the width of the Frame
  71655. */
  71656. w: number;
  71657. /**
  71658. * number of the height of the Frame
  71659. */
  71660. h: number;
  71661. }
  71662. /**
  71663. * Defines the basic options interface of a JSON Sprite.
  71664. */
  71665. export interface ISpriteJSONSprite {
  71666. /**
  71667. * string name of the Frame
  71668. */
  71669. filename: string;
  71670. /**
  71671. * ISpriteJSONSpriteFrame basic object of the frame data
  71672. */
  71673. frame: ISpriteJSONSpriteFrameData;
  71674. /**
  71675. * boolean to flag is the frame was rotated.
  71676. */
  71677. rotated: boolean;
  71678. /**
  71679. * boolean to flag is the frame was trimmed.
  71680. */
  71681. trimmed: boolean;
  71682. /**
  71683. * ISpriteJSONSpriteFrame basic object of the source data
  71684. */
  71685. spriteSourceSize: ISpriteJSONSpriteFrameData;
  71686. /**
  71687. * ISpriteJSONSpriteFrame basic object of the source data
  71688. */
  71689. sourceSize: ISpriteJSONSpriteSourceSize;
  71690. }
  71691. /**
  71692. * Defines the basic options interface of a JSON atlas.
  71693. */
  71694. export interface ISpriteJSONAtlas {
  71695. /**
  71696. * Array of objects that contain the frame data.
  71697. */
  71698. frames: Array<ISpriteJSONSprite>;
  71699. /**
  71700. * object basic object containing the sprite meta data.
  71701. */
  71702. meta?: object;
  71703. }
  71704. }
  71705. declare module BABYLON {
  71706. /** @hidden */
  71707. export var spriteMapPixelShader: {
  71708. name: string;
  71709. shader: string;
  71710. };
  71711. }
  71712. declare module BABYLON {
  71713. /** @hidden */
  71714. export var spriteMapVertexShader: {
  71715. name: string;
  71716. shader: string;
  71717. };
  71718. }
  71719. declare module BABYLON {
  71720. /**
  71721. * Defines the basic options interface of a SpriteMap
  71722. */
  71723. export interface ISpriteMapOptions {
  71724. /**
  71725. * Vector2 of the number of cells in the grid.
  71726. */
  71727. stageSize?: Vector2;
  71728. /**
  71729. * Vector2 of the size of the output plane in World Units.
  71730. */
  71731. outputSize?: Vector2;
  71732. /**
  71733. * Vector3 of the position of the output plane in World Units.
  71734. */
  71735. outputPosition?: Vector3;
  71736. /**
  71737. * Vector3 of the rotation of the output plane.
  71738. */
  71739. outputRotation?: Vector3;
  71740. /**
  71741. * number of layers that the system will reserve in resources.
  71742. */
  71743. layerCount?: number;
  71744. /**
  71745. * number of max animation frames a single cell will reserve in resources.
  71746. */
  71747. maxAnimationFrames?: number;
  71748. /**
  71749. * number cell index of the base tile when the system compiles.
  71750. */
  71751. baseTile?: number;
  71752. /**
  71753. * boolean flip the sprite after its been repositioned by the framing data.
  71754. */
  71755. flipU?: boolean;
  71756. /**
  71757. * Vector3 scalar of the global RGB values of the SpriteMap.
  71758. */
  71759. colorMultiply?: Vector3;
  71760. }
  71761. /**
  71762. * Defines the IDisposable interface in order to be cleanable from resources.
  71763. */
  71764. export interface ISpriteMap extends IDisposable {
  71765. /**
  71766. * String name of the SpriteMap.
  71767. */
  71768. name: string;
  71769. /**
  71770. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  71771. */
  71772. atlasJSON: ISpriteJSONAtlas;
  71773. /**
  71774. * Texture of the SpriteMap.
  71775. */
  71776. spriteSheet: Texture;
  71777. /**
  71778. * The parameters to initialize the SpriteMap with.
  71779. */
  71780. options: ISpriteMapOptions;
  71781. }
  71782. /**
  71783. * Class used to manage a grid restricted sprite deployment on an Output plane.
  71784. */
  71785. export class SpriteMap implements ISpriteMap {
  71786. /** The Name of the spriteMap */
  71787. name: string;
  71788. /** The JSON file with the frame and meta data */
  71789. atlasJSON: ISpriteJSONAtlas;
  71790. /** The systems Sprite Sheet Texture */
  71791. spriteSheet: Texture;
  71792. /** Arguments passed with the Constructor */
  71793. options: ISpriteMapOptions;
  71794. /** Public Sprite Storage array, parsed from atlasJSON */
  71795. sprites: Array<ISpriteJSONSprite>;
  71796. /** Returns the Number of Sprites in the System */
  71797. get spriteCount(): number;
  71798. /** Returns the Position of Output Plane*/
  71799. get position(): Vector3;
  71800. /** Returns the Position of Output Plane*/
  71801. set position(v: Vector3);
  71802. /** Returns the Rotation of Output Plane*/
  71803. get rotation(): Vector3;
  71804. /** Returns the Rotation of Output Plane*/
  71805. set rotation(v: Vector3);
  71806. /** Sets the AnimationMap*/
  71807. get animationMap(): RawTexture;
  71808. /** Sets the AnimationMap*/
  71809. set animationMap(v: RawTexture);
  71810. /** Scene that the SpriteMap was created in */
  71811. private _scene;
  71812. /** Texture Buffer of Float32 that holds tile frame data*/
  71813. private _frameMap;
  71814. /** Texture Buffers of Float32 that holds tileMap data*/
  71815. private _tileMaps;
  71816. /** Texture Buffer of Float32 that holds Animation Data*/
  71817. private _animationMap;
  71818. /** Custom ShaderMaterial Central to the System*/
  71819. private _material;
  71820. /** Custom ShaderMaterial Central to the System*/
  71821. private _output;
  71822. /** Systems Time Ticker*/
  71823. private _time;
  71824. /**
  71825. * Creates a new SpriteMap
  71826. * @param name defines the SpriteMaps Name
  71827. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  71828. * @param spriteSheet is the Texture that the Sprites are on.
  71829. * @param options a basic deployment configuration
  71830. * @param scene The Scene that the map is deployed on
  71831. */
  71832. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  71833. /**
  71834. * Returns tileID location
  71835. * @returns Vector2 the cell position ID
  71836. */
  71837. getTileID(): Vector2;
  71838. /**
  71839. * Gets the UV location of the mouse over the SpriteMap.
  71840. * @returns Vector2 the UV position of the mouse interaction
  71841. */
  71842. getMousePosition(): Vector2;
  71843. /**
  71844. * Creates the "frame" texture Buffer
  71845. * -------------------------------------
  71846. * Structure of frames
  71847. * "filename": "Falling-Water-2.png",
  71848. * "frame": {"x":69,"y":103,"w":24,"h":32},
  71849. * "rotated": true,
  71850. * "trimmed": true,
  71851. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  71852. * "sourceSize": {"w":32,"h":32}
  71853. * @returns RawTexture of the frameMap
  71854. */
  71855. private _createFrameBuffer;
  71856. /**
  71857. * Creates the tileMap texture Buffer
  71858. * @param buffer normally and array of numbers, or a false to generate from scratch
  71859. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  71860. * @returns RawTexture of the tileMap
  71861. */
  71862. private _createTileBuffer;
  71863. /**
  71864. * Modifies the data of the tileMaps
  71865. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  71866. * @param pos is the iVector2 Coordinates of the Tile
  71867. * @param tile The SpriteIndex of the new Tile
  71868. */
  71869. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  71870. /**
  71871. * Creates the animationMap texture Buffer
  71872. * @param buffer normally and array of numbers, or a false to generate from scratch
  71873. * @returns RawTexture of the animationMap
  71874. */
  71875. private _createTileAnimationBuffer;
  71876. /**
  71877. * Modifies the data of the animationMap
  71878. * @param cellID is the Index of the Sprite
  71879. * @param _frame is the target Animation frame
  71880. * @param toCell is the Target Index of the next frame of the animation
  71881. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  71882. * @param speed is a global scalar of the time variable on the map.
  71883. */
  71884. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  71885. /**
  71886. * Exports the .tilemaps file
  71887. */
  71888. saveTileMaps(): void;
  71889. /**
  71890. * Imports the .tilemaps file
  71891. * @param url of the .tilemaps file
  71892. */
  71893. loadTileMaps(url: string): void;
  71894. /**
  71895. * Release associated resources
  71896. */
  71897. dispose(): void;
  71898. }
  71899. }
  71900. declare module BABYLON {
  71901. /**
  71902. * Class used to manage multiple sprites of different sizes on the same spritesheet
  71903. * @see https://doc.babylonjs.com/babylon101/sprites
  71904. */
  71905. export class SpritePackedManager extends SpriteManager {
  71906. /** defines the packed manager's name */
  71907. name: string;
  71908. /**
  71909. * Creates a new sprite manager from a packed sprite sheet
  71910. * @param name defines the manager's name
  71911. * @param imgUrl defines the sprite sheet url
  71912. * @param capacity defines the maximum allowed number of sprites
  71913. * @param scene defines the hosting scene
  71914. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  71915. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  71916. * @param samplingMode defines the smapling mode to use with spritesheet
  71917. * @param fromPacked set to true; do not alter
  71918. */
  71919. constructor(
  71920. /** defines the packed manager's name */
  71921. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  71922. }
  71923. }
  71924. declare module BABYLON {
  71925. /**
  71926. * Defines the list of states available for a task inside a AssetsManager
  71927. */
  71928. export enum AssetTaskState {
  71929. /**
  71930. * Initialization
  71931. */
  71932. INIT = 0,
  71933. /**
  71934. * Running
  71935. */
  71936. RUNNING = 1,
  71937. /**
  71938. * Done
  71939. */
  71940. DONE = 2,
  71941. /**
  71942. * Error
  71943. */
  71944. ERROR = 3
  71945. }
  71946. /**
  71947. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  71948. */
  71949. export abstract class AbstractAssetTask {
  71950. /**
  71951. * Task name
  71952. */ name: string;
  71953. /**
  71954. * Callback called when the task is successful
  71955. */
  71956. onSuccess: (task: any) => void;
  71957. /**
  71958. * Callback called when the task is not successful
  71959. */
  71960. onError: (task: any, message?: string, exception?: any) => void;
  71961. /**
  71962. * Creates a new AssetsManager
  71963. * @param name defines the name of the task
  71964. */
  71965. constructor(
  71966. /**
  71967. * Task name
  71968. */ name: string);
  71969. private _isCompleted;
  71970. private _taskState;
  71971. private _errorObject;
  71972. /**
  71973. * Get if the task is completed
  71974. */
  71975. get isCompleted(): boolean;
  71976. /**
  71977. * Gets the current state of the task
  71978. */
  71979. get taskState(): AssetTaskState;
  71980. /**
  71981. * Gets the current error object (if task is in error)
  71982. */
  71983. get errorObject(): {
  71984. message?: string;
  71985. exception?: any;
  71986. };
  71987. /**
  71988. * Internal only
  71989. * @hidden
  71990. */
  71991. _setErrorObject(message?: string, exception?: any): void;
  71992. /**
  71993. * Execute the current task
  71994. * @param scene defines the scene where you want your assets to be loaded
  71995. * @param onSuccess is a callback called when the task is successfully executed
  71996. * @param onError is a callback called if an error occurs
  71997. */
  71998. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71999. /**
  72000. * Execute the current task
  72001. * @param scene defines the scene where you want your assets to be loaded
  72002. * @param onSuccess is a callback called when the task is successfully executed
  72003. * @param onError is a callback called if an error occurs
  72004. */
  72005. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72006. /**
  72007. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  72008. * This can be used with failed tasks that have the reason for failure fixed.
  72009. */
  72010. reset(): void;
  72011. private onErrorCallback;
  72012. private onDoneCallback;
  72013. }
  72014. /**
  72015. * Define the interface used by progress events raised during assets loading
  72016. */
  72017. export interface IAssetsProgressEvent {
  72018. /**
  72019. * Defines the number of remaining tasks to process
  72020. */
  72021. remainingCount: number;
  72022. /**
  72023. * Defines the total number of tasks
  72024. */
  72025. totalCount: number;
  72026. /**
  72027. * Defines the task that was just processed
  72028. */
  72029. task: AbstractAssetTask;
  72030. }
  72031. /**
  72032. * Class used to share progress information about assets loading
  72033. */
  72034. export class AssetsProgressEvent implements IAssetsProgressEvent {
  72035. /**
  72036. * Defines the number of remaining tasks to process
  72037. */
  72038. remainingCount: number;
  72039. /**
  72040. * Defines the total number of tasks
  72041. */
  72042. totalCount: number;
  72043. /**
  72044. * Defines the task that was just processed
  72045. */
  72046. task: AbstractAssetTask;
  72047. /**
  72048. * Creates a AssetsProgressEvent
  72049. * @param remainingCount defines the number of remaining tasks to process
  72050. * @param totalCount defines the total number of tasks
  72051. * @param task defines the task that was just processed
  72052. */
  72053. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  72054. }
  72055. /**
  72056. * Define a task used by AssetsManager to load assets into a container
  72057. */
  72058. export class ContainerAssetTask extends AbstractAssetTask {
  72059. /**
  72060. * Defines the name of the task
  72061. */
  72062. name: string;
  72063. /**
  72064. * Defines the list of mesh's names you want to load
  72065. */
  72066. meshesNames: any;
  72067. /**
  72068. * Defines the root url to use as a base to load your meshes and associated resources
  72069. */
  72070. rootUrl: string;
  72071. /**
  72072. * Defines the filename or File of the scene to load from
  72073. */
  72074. sceneFilename: string | File;
  72075. /**
  72076. * Get the loaded asset container
  72077. */
  72078. loadedContainer: AssetContainer;
  72079. /**
  72080. * Gets the list of loaded meshes
  72081. */
  72082. loadedMeshes: Array<AbstractMesh>;
  72083. /**
  72084. * Gets the list of loaded particle systems
  72085. */
  72086. loadedParticleSystems: Array<IParticleSystem>;
  72087. /**
  72088. * Gets the list of loaded skeletons
  72089. */
  72090. loadedSkeletons: Array<Skeleton>;
  72091. /**
  72092. * Gets the list of loaded animation groups
  72093. */
  72094. loadedAnimationGroups: Array<AnimationGroup>;
  72095. /**
  72096. * Callback called when the task is successful
  72097. */
  72098. onSuccess: (task: ContainerAssetTask) => void;
  72099. /**
  72100. * Callback called when the task is successful
  72101. */
  72102. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  72103. /**
  72104. * Creates a new ContainerAssetTask
  72105. * @param name defines the name of the task
  72106. * @param meshesNames defines the list of mesh's names you want to load
  72107. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  72108. * @param sceneFilename defines the filename or File of the scene to load from
  72109. */
  72110. constructor(
  72111. /**
  72112. * Defines the name of the task
  72113. */
  72114. name: string,
  72115. /**
  72116. * Defines the list of mesh's names you want to load
  72117. */
  72118. meshesNames: any,
  72119. /**
  72120. * Defines the root url to use as a base to load your meshes and associated resources
  72121. */
  72122. rootUrl: string,
  72123. /**
  72124. * Defines the filename or File of the scene to load from
  72125. */
  72126. sceneFilename: string | File);
  72127. /**
  72128. * Execute the current task
  72129. * @param scene defines the scene where you want your assets to be loaded
  72130. * @param onSuccess is a callback called when the task is successfully executed
  72131. * @param onError is a callback called if an error occurs
  72132. */
  72133. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72134. }
  72135. /**
  72136. * Define a task used by AssetsManager to load meshes
  72137. */
  72138. export class MeshAssetTask extends AbstractAssetTask {
  72139. /**
  72140. * Defines the name of the task
  72141. */
  72142. name: string;
  72143. /**
  72144. * Defines the list of mesh's names you want to load
  72145. */
  72146. meshesNames: any;
  72147. /**
  72148. * Defines the root url to use as a base to load your meshes and associated resources
  72149. */
  72150. rootUrl: string;
  72151. /**
  72152. * Defines the filename or File of the scene to load from
  72153. */
  72154. sceneFilename: string | File;
  72155. /**
  72156. * Gets the list of loaded meshes
  72157. */
  72158. loadedMeshes: Array<AbstractMesh>;
  72159. /**
  72160. * Gets the list of loaded particle systems
  72161. */
  72162. loadedParticleSystems: Array<IParticleSystem>;
  72163. /**
  72164. * Gets the list of loaded skeletons
  72165. */
  72166. loadedSkeletons: Array<Skeleton>;
  72167. /**
  72168. * Gets the list of loaded animation groups
  72169. */
  72170. loadedAnimationGroups: Array<AnimationGroup>;
  72171. /**
  72172. * Callback called when the task is successful
  72173. */
  72174. onSuccess: (task: MeshAssetTask) => void;
  72175. /**
  72176. * Callback called when the task is successful
  72177. */
  72178. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  72179. /**
  72180. * Creates a new MeshAssetTask
  72181. * @param name defines the name of the task
  72182. * @param meshesNames defines the list of mesh's names you want to load
  72183. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  72184. * @param sceneFilename defines the filename or File of the scene to load from
  72185. */
  72186. constructor(
  72187. /**
  72188. * Defines the name of the task
  72189. */
  72190. name: string,
  72191. /**
  72192. * Defines the list of mesh's names you want to load
  72193. */
  72194. meshesNames: any,
  72195. /**
  72196. * Defines the root url to use as a base to load your meshes and associated resources
  72197. */
  72198. rootUrl: string,
  72199. /**
  72200. * Defines the filename or File of the scene to load from
  72201. */
  72202. sceneFilename: string | File);
  72203. /**
  72204. * Execute the current task
  72205. * @param scene defines the scene where you want your assets to be loaded
  72206. * @param onSuccess is a callback called when the task is successfully executed
  72207. * @param onError is a callback called if an error occurs
  72208. */
  72209. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72210. }
  72211. /**
  72212. * Define a task used by AssetsManager to load text content
  72213. */
  72214. export class TextFileAssetTask extends AbstractAssetTask {
  72215. /**
  72216. * Defines the name of the task
  72217. */
  72218. name: string;
  72219. /**
  72220. * Defines the location of the file to load
  72221. */
  72222. url: string;
  72223. /**
  72224. * Gets the loaded text string
  72225. */
  72226. text: string;
  72227. /**
  72228. * Callback called when the task is successful
  72229. */
  72230. onSuccess: (task: TextFileAssetTask) => void;
  72231. /**
  72232. * Callback called when the task is successful
  72233. */
  72234. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  72235. /**
  72236. * Creates a new TextFileAssetTask object
  72237. * @param name defines the name of the task
  72238. * @param url defines the location of the file to load
  72239. */
  72240. constructor(
  72241. /**
  72242. * Defines the name of the task
  72243. */
  72244. name: string,
  72245. /**
  72246. * Defines the location of the file to load
  72247. */
  72248. url: string);
  72249. /**
  72250. * Execute the current task
  72251. * @param scene defines the scene where you want your assets to be loaded
  72252. * @param onSuccess is a callback called when the task is successfully executed
  72253. * @param onError is a callback called if an error occurs
  72254. */
  72255. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72256. }
  72257. /**
  72258. * Define a task used by AssetsManager to load binary data
  72259. */
  72260. export class BinaryFileAssetTask extends AbstractAssetTask {
  72261. /**
  72262. * Defines the name of the task
  72263. */
  72264. name: string;
  72265. /**
  72266. * Defines the location of the file to load
  72267. */
  72268. url: string;
  72269. /**
  72270. * Gets the lodaded data (as an array buffer)
  72271. */
  72272. data: ArrayBuffer;
  72273. /**
  72274. * Callback called when the task is successful
  72275. */
  72276. onSuccess: (task: BinaryFileAssetTask) => void;
  72277. /**
  72278. * Callback called when the task is successful
  72279. */
  72280. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  72281. /**
  72282. * Creates a new BinaryFileAssetTask object
  72283. * @param name defines the name of the new task
  72284. * @param url defines the location of the file to load
  72285. */
  72286. constructor(
  72287. /**
  72288. * Defines the name of the task
  72289. */
  72290. name: string,
  72291. /**
  72292. * Defines the location of the file to load
  72293. */
  72294. url: string);
  72295. /**
  72296. * Execute the current task
  72297. * @param scene defines the scene where you want your assets to be loaded
  72298. * @param onSuccess is a callback called when the task is successfully executed
  72299. * @param onError is a callback called if an error occurs
  72300. */
  72301. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72302. }
  72303. /**
  72304. * Define a task used by AssetsManager to load images
  72305. */
  72306. export class ImageAssetTask extends AbstractAssetTask {
  72307. /**
  72308. * Defines the name of the task
  72309. */
  72310. name: string;
  72311. /**
  72312. * Defines the location of the image to load
  72313. */
  72314. url: string;
  72315. /**
  72316. * Gets the loaded images
  72317. */
  72318. image: HTMLImageElement;
  72319. /**
  72320. * Callback called when the task is successful
  72321. */
  72322. onSuccess: (task: ImageAssetTask) => void;
  72323. /**
  72324. * Callback called when the task is successful
  72325. */
  72326. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  72327. /**
  72328. * Creates a new ImageAssetTask
  72329. * @param name defines the name of the task
  72330. * @param url defines the location of the image to load
  72331. */
  72332. constructor(
  72333. /**
  72334. * Defines the name of the task
  72335. */
  72336. name: string,
  72337. /**
  72338. * Defines the location of the image to load
  72339. */
  72340. url: string);
  72341. /**
  72342. * Execute the current task
  72343. * @param scene defines the scene where you want your assets to be loaded
  72344. * @param onSuccess is a callback called when the task is successfully executed
  72345. * @param onError is a callback called if an error occurs
  72346. */
  72347. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72348. }
  72349. /**
  72350. * Defines the interface used by texture loading tasks
  72351. */
  72352. export interface ITextureAssetTask<TEX extends BaseTexture> {
  72353. /**
  72354. * Gets the loaded texture
  72355. */
  72356. texture: TEX;
  72357. }
  72358. /**
  72359. * Define a task used by AssetsManager to load 2D textures
  72360. */
  72361. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  72362. /**
  72363. * Defines the name of the task
  72364. */
  72365. name: string;
  72366. /**
  72367. * Defines the location of the file to load
  72368. */
  72369. url: string;
  72370. /**
  72371. * Defines if mipmap should not be generated (default is false)
  72372. */
  72373. noMipmap?: boolean | undefined;
  72374. /**
  72375. * Defines if texture must be inverted on Y axis (default is true)
  72376. */
  72377. invertY: boolean;
  72378. /**
  72379. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72380. */
  72381. samplingMode: number;
  72382. /**
  72383. * Gets the loaded texture
  72384. */
  72385. texture: Texture;
  72386. /**
  72387. * Callback called when the task is successful
  72388. */
  72389. onSuccess: (task: TextureAssetTask) => void;
  72390. /**
  72391. * Callback called when the task is successful
  72392. */
  72393. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  72394. /**
  72395. * Creates a new TextureAssetTask object
  72396. * @param name defines the name of the task
  72397. * @param url defines the location of the file to load
  72398. * @param noMipmap defines if mipmap should not be generated (default is false)
  72399. * @param invertY defines if texture must be inverted on Y axis (default is true)
  72400. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72401. */
  72402. constructor(
  72403. /**
  72404. * Defines the name of the task
  72405. */
  72406. name: string,
  72407. /**
  72408. * Defines the location of the file to load
  72409. */
  72410. url: string,
  72411. /**
  72412. * Defines if mipmap should not be generated (default is false)
  72413. */
  72414. noMipmap?: boolean | undefined,
  72415. /**
  72416. * Defines if texture must be inverted on Y axis (default is true)
  72417. */
  72418. invertY?: boolean,
  72419. /**
  72420. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72421. */
  72422. samplingMode?: number);
  72423. /**
  72424. * Execute the current task
  72425. * @param scene defines the scene where you want your assets to be loaded
  72426. * @param onSuccess is a callback called when the task is successfully executed
  72427. * @param onError is a callback called if an error occurs
  72428. */
  72429. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72430. }
  72431. /**
  72432. * Define a task used by AssetsManager to load cube textures
  72433. */
  72434. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  72435. /**
  72436. * Defines the name of the task
  72437. */
  72438. name: string;
  72439. /**
  72440. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72441. */
  72442. url: string;
  72443. /**
  72444. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72445. */
  72446. extensions?: string[] | undefined;
  72447. /**
  72448. * Defines if mipmaps should not be generated (default is false)
  72449. */
  72450. noMipmap?: boolean | undefined;
  72451. /**
  72452. * Defines the explicit list of files (undefined by default)
  72453. */
  72454. files?: string[] | undefined;
  72455. /**
  72456. * Gets the loaded texture
  72457. */
  72458. texture: CubeTexture;
  72459. /**
  72460. * Callback called when the task is successful
  72461. */
  72462. onSuccess: (task: CubeTextureAssetTask) => void;
  72463. /**
  72464. * Callback called when the task is successful
  72465. */
  72466. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  72467. /**
  72468. * Creates a new CubeTextureAssetTask
  72469. * @param name defines the name of the task
  72470. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72471. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72472. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72473. * @param files defines the explicit list of files (undefined by default)
  72474. */
  72475. constructor(
  72476. /**
  72477. * Defines the name of the task
  72478. */
  72479. name: string,
  72480. /**
  72481. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72482. */
  72483. url: string,
  72484. /**
  72485. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72486. */
  72487. extensions?: string[] | undefined,
  72488. /**
  72489. * Defines if mipmaps should not be generated (default is false)
  72490. */
  72491. noMipmap?: boolean | undefined,
  72492. /**
  72493. * Defines the explicit list of files (undefined by default)
  72494. */
  72495. files?: string[] | undefined);
  72496. /**
  72497. * Execute the current task
  72498. * @param scene defines the scene where you want your assets to be loaded
  72499. * @param onSuccess is a callback called when the task is successfully executed
  72500. * @param onError is a callback called if an error occurs
  72501. */
  72502. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72503. }
  72504. /**
  72505. * Define a task used by AssetsManager to load HDR cube textures
  72506. */
  72507. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  72508. /**
  72509. * Defines the name of the task
  72510. */
  72511. name: string;
  72512. /**
  72513. * Defines the location of the file to load
  72514. */
  72515. url: string;
  72516. /**
  72517. * Defines the desired size (the more it increases the longer the generation will be)
  72518. */
  72519. size: number;
  72520. /**
  72521. * Defines if mipmaps should not be generated (default is false)
  72522. */
  72523. noMipmap: boolean;
  72524. /**
  72525. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72526. */
  72527. generateHarmonics: boolean;
  72528. /**
  72529. * 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)
  72530. */
  72531. gammaSpace: boolean;
  72532. /**
  72533. * Internal Use Only
  72534. */
  72535. reserved: boolean;
  72536. /**
  72537. * Gets the loaded texture
  72538. */
  72539. texture: HDRCubeTexture;
  72540. /**
  72541. * Callback called when the task is successful
  72542. */
  72543. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  72544. /**
  72545. * Callback called when the task is successful
  72546. */
  72547. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  72548. /**
  72549. * Creates a new HDRCubeTextureAssetTask object
  72550. * @param name defines the name of the task
  72551. * @param url defines the location of the file to load
  72552. * @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.
  72553. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72554. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72555. * @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)
  72556. * @param reserved Internal use only
  72557. */
  72558. constructor(
  72559. /**
  72560. * Defines the name of the task
  72561. */
  72562. name: string,
  72563. /**
  72564. * Defines the location of the file to load
  72565. */
  72566. url: string,
  72567. /**
  72568. * Defines the desired size (the more it increases the longer the generation will be)
  72569. */
  72570. size: number,
  72571. /**
  72572. * Defines if mipmaps should not be generated (default is false)
  72573. */
  72574. noMipmap?: boolean,
  72575. /**
  72576. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72577. */
  72578. generateHarmonics?: boolean,
  72579. /**
  72580. * 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)
  72581. */
  72582. gammaSpace?: boolean,
  72583. /**
  72584. * Internal Use Only
  72585. */
  72586. reserved?: boolean);
  72587. /**
  72588. * Execute the current task
  72589. * @param scene defines the scene where you want your assets to be loaded
  72590. * @param onSuccess is a callback called when the task is successfully executed
  72591. * @param onError is a callback called if an error occurs
  72592. */
  72593. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72594. }
  72595. /**
  72596. * Define a task used by AssetsManager to load Equirectangular cube textures
  72597. */
  72598. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  72599. /**
  72600. * Defines the name of the task
  72601. */
  72602. name: string;
  72603. /**
  72604. * Defines the location of the file to load
  72605. */
  72606. url: string;
  72607. /**
  72608. * Defines the desired size (the more it increases the longer the generation will be)
  72609. */
  72610. size: number;
  72611. /**
  72612. * Defines if mipmaps should not be generated (default is false)
  72613. */
  72614. noMipmap: boolean;
  72615. /**
  72616. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  72617. * but the standard material would require them in Gamma space) (default is true)
  72618. */
  72619. gammaSpace: boolean;
  72620. /**
  72621. * Gets the loaded texture
  72622. */
  72623. texture: EquiRectangularCubeTexture;
  72624. /**
  72625. * Callback called when the task is successful
  72626. */
  72627. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  72628. /**
  72629. * Callback called when the task is successful
  72630. */
  72631. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  72632. /**
  72633. * Creates a new EquiRectangularCubeTextureAssetTask object
  72634. * @param name defines the name of the task
  72635. * @param url defines the location of the file to load
  72636. * @param size defines the desired size (the more it increases the longer the generation will be)
  72637. * If the size is omitted this implies you are using a preprocessed cubemap.
  72638. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72639. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  72640. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  72641. * (default is true)
  72642. */
  72643. constructor(
  72644. /**
  72645. * Defines the name of the task
  72646. */
  72647. name: string,
  72648. /**
  72649. * Defines the location of the file to load
  72650. */
  72651. url: string,
  72652. /**
  72653. * Defines the desired size (the more it increases the longer the generation will be)
  72654. */
  72655. size: number,
  72656. /**
  72657. * Defines if mipmaps should not be generated (default is false)
  72658. */
  72659. noMipmap?: boolean,
  72660. /**
  72661. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  72662. * but the standard material would require them in Gamma space) (default is true)
  72663. */
  72664. gammaSpace?: boolean);
  72665. /**
  72666. * Execute the current task
  72667. * @param scene defines the scene where you want your assets to be loaded
  72668. * @param onSuccess is a callback called when the task is successfully executed
  72669. * @param onError is a callback called if an error occurs
  72670. */
  72671. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72672. }
  72673. /**
  72674. * This class can be used to easily import assets into a scene
  72675. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  72676. */
  72677. export class AssetsManager {
  72678. private _scene;
  72679. private _isLoading;
  72680. protected _tasks: AbstractAssetTask[];
  72681. protected _waitingTasksCount: number;
  72682. protected _totalTasksCount: number;
  72683. /**
  72684. * Callback called when all tasks are processed
  72685. */
  72686. onFinish: (tasks: AbstractAssetTask[]) => void;
  72687. /**
  72688. * Callback called when a task is successful
  72689. */
  72690. onTaskSuccess: (task: AbstractAssetTask) => void;
  72691. /**
  72692. * Callback called when a task had an error
  72693. */
  72694. onTaskError: (task: AbstractAssetTask) => void;
  72695. /**
  72696. * Callback called when a task is done (whatever the result is)
  72697. */
  72698. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  72699. /**
  72700. * Observable called when all tasks are processed
  72701. */
  72702. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  72703. /**
  72704. * Observable called when a task had an error
  72705. */
  72706. onTaskErrorObservable: Observable<AbstractAssetTask>;
  72707. /**
  72708. * Observable called when all tasks were executed
  72709. */
  72710. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  72711. /**
  72712. * Observable called when a task is done (whatever the result is)
  72713. */
  72714. onProgressObservable: Observable<IAssetsProgressEvent>;
  72715. /**
  72716. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  72717. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  72718. */
  72719. useDefaultLoadingScreen: boolean;
  72720. /**
  72721. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  72722. * when all assets have been downloaded.
  72723. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  72724. */
  72725. autoHideLoadingUI: boolean;
  72726. /**
  72727. * Creates a new AssetsManager
  72728. * @param scene defines the scene to work on
  72729. */
  72730. constructor(scene: Scene);
  72731. /**
  72732. * Add a ContainerAssetTask to the list of active tasks
  72733. * @param taskName defines the name of the new task
  72734. * @param meshesNames defines the name of meshes to load
  72735. * @param rootUrl defines the root url to use to locate files
  72736. * @param sceneFilename defines the filename of the scene file
  72737. * @returns a new ContainerAssetTask object
  72738. */
  72739. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  72740. /**
  72741. * Add a MeshAssetTask to the list of active tasks
  72742. * @param taskName defines the name of the new task
  72743. * @param meshesNames defines the name of meshes to load
  72744. * @param rootUrl defines the root url to use to locate files
  72745. * @param sceneFilename defines the filename of the scene file
  72746. * @returns a new MeshAssetTask object
  72747. */
  72748. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  72749. /**
  72750. * Add a TextFileAssetTask to the list of active tasks
  72751. * @param taskName defines the name of the new task
  72752. * @param url defines the url of the file to load
  72753. * @returns a new TextFileAssetTask object
  72754. */
  72755. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  72756. /**
  72757. * Add a BinaryFileAssetTask to the list of active tasks
  72758. * @param taskName defines the name of the new task
  72759. * @param url defines the url of the file to load
  72760. * @returns a new BinaryFileAssetTask object
  72761. */
  72762. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  72763. /**
  72764. * Add a ImageAssetTask to the list of active tasks
  72765. * @param taskName defines the name of the new task
  72766. * @param url defines the url of the file to load
  72767. * @returns a new ImageAssetTask object
  72768. */
  72769. addImageTask(taskName: string, url: string): ImageAssetTask;
  72770. /**
  72771. * Add a TextureAssetTask to the list of active tasks
  72772. * @param taskName defines the name of the new task
  72773. * @param url defines the url of the file to load
  72774. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72775. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  72776. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  72777. * @returns a new TextureAssetTask object
  72778. */
  72779. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  72780. /**
  72781. * Add a CubeTextureAssetTask to the list of active tasks
  72782. * @param taskName defines the name of the new task
  72783. * @param url defines the url of the file to load
  72784. * @param extensions defines the extension to use to load the cube map (can be null)
  72785. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72786. * @param files defines the list of files to load (can be null)
  72787. * @returns a new CubeTextureAssetTask object
  72788. */
  72789. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  72790. /**
  72791. *
  72792. * Add a HDRCubeTextureAssetTask to the list of active tasks
  72793. * @param taskName defines the name of the new task
  72794. * @param url defines the url of the file to load
  72795. * @param size defines the size you want for the cubemap (can be null)
  72796. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72797. * @param generateHarmonics defines if you want to automatically generate (true by default)
  72798. * @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)
  72799. * @param reserved Internal use only
  72800. * @returns a new HDRCubeTextureAssetTask object
  72801. */
  72802. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  72803. /**
  72804. *
  72805. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  72806. * @param taskName defines the name of the new task
  72807. * @param url defines the url of the file to load
  72808. * @param size defines the size you want for the cubemap (can be null)
  72809. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72810. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  72811. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  72812. * @returns a new EquiRectangularCubeTextureAssetTask object
  72813. */
  72814. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  72815. /**
  72816. * Remove a task from the assets manager.
  72817. * @param task the task to remove
  72818. */
  72819. removeTask(task: AbstractAssetTask): void;
  72820. private _decreaseWaitingTasksCount;
  72821. private _runTask;
  72822. /**
  72823. * Reset the AssetsManager and remove all tasks
  72824. * @return the current instance of the AssetsManager
  72825. */
  72826. reset(): AssetsManager;
  72827. /**
  72828. * Start the loading process
  72829. * @return the current instance of the AssetsManager
  72830. */
  72831. load(): AssetsManager;
  72832. /**
  72833. * Start the loading process as an async operation
  72834. * @return a promise returning the list of failed tasks
  72835. */
  72836. loadAsync(): Promise<void>;
  72837. }
  72838. }
  72839. declare module BABYLON {
  72840. /**
  72841. * Wrapper class for promise with external resolve and reject.
  72842. */
  72843. export class Deferred<T> {
  72844. /**
  72845. * The promise associated with this deferred object.
  72846. */
  72847. readonly promise: Promise<T>;
  72848. private _resolve;
  72849. private _reject;
  72850. /**
  72851. * The resolve method of the promise associated with this deferred object.
  72852. */
  72853. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  72854. /**
  72855. * The reject method of the promise associated with this deferred object.
  72856. */
  72857. get reject(): (reason?: any) => void;
  72858. /**
  72859. * Constructor for this deferred object.
  72860. */
  72861. constructor();
  72862. }
  72863. }
  72864. declare module BABYLON {
  72865. /**
  72866. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  72867. */
  72868. export class MeshExploder {
  72869. private _centerMesh;
  72870. private _meshes;
  72871. private _meshesOrigins;
  72872. private _toCenterVectors;
  72873. private _scaledDirection;
  72874. private _newPosition;
  72875. private _centerPosition;
  72876. /**
  72877. * Explodes meshes from a center mesh.
  72878. * @param meshes The meshes to explode.
  72879. * @param centerMesh The mesh to be center of explosion.
  72880. */
  72881. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  72882. private _setCenterMesh;
  72883. /**
  72884. * Get class name
  72885. * @returns "MeshExploder"
  72886. */
  72887. getClassName(): string;
  72888. /**
  72889. * "Exploded meshes"
  72890. * @returns Array of meshes with the centerMesh at index 0.
  72891. */
  72892. getMeshes(): Array<Mesh>;
  72893. /**
  72894. * Explodes meshes giving a specific direction
  72895. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  72896. */
  72897. explode(direction?: number): void;
  72898. }
  72899. }
  72900. declare module BABYLON {
  72901. /**
  72902. * Class used to help managing file picking and drag'n'drop
  72903. */
  72904. export class FilesInput {
  72905. /**
  72906. * List of files ready to be loaded
  72907. */
  72908. static get FilesToLoad(): {
  72909. [key: string]: File;
  72910. };
  72911. /**
  72912. * Callback called when a file is processed
  72913. */
  72914. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  72915. private _engine;
  72916. private _currentScene;
  72917. private _sceneLoadedCallback;
  72918. private _progressCallback;
  72919. private _additionalRenderLoopLogicCallback;
  72920. private _textureLoadingCallback;
  72921. private _startingProcessingFilesCallback;
  72922. private _onReloadCallback;
  72923. private _errorCallback;
  72924. private _elementToMonitor;
  72925. private _sceneFileToLoad;
  72926. private _filesToLoad;
  72927. /**
  72928. * Creates a new FilesInput
  72929. * @param engine defines the rendering engine
  72930. * @param scene defines the hosting scene
  72931. * @param sceneLoadedCallback callback called when scene is loaded
  72932. * @param progressCallback callback called to track progress
  72933. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  72934. * @param textureLoadingCallback callback called when a texture is loading
  72935. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  72936. * @param onReloadCallback callback called when a reload is requested
  72937. * @param errorCallback callback call if an error occurs
  72938. */
  72939. 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>);
  72940. private _dragEnterHandler;
  72941. private _dragOverHandler;
  72942. private _dropHandler;
  72943. /**
  72944. * Calls this function to listen to drag'n'drop events on a specific DOM element
  72945. * @param elementToMonitor defines the DOM element to track
  72946. */
  72947. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  72948. /** Gets the current list of files to load */
  72949. get filesToLoad(): File[];
  72950. /**
  72951. * Release all associated resources
  72952. */
  72953. dispose(): void;
  72954. private renderFunction;
  72955. private drag;
  72956. private drop;
  72957. private _traverseFolder;
  72958. private _processFiles;
  72959. /**
  72960. * Load files from a drop event
  72961. * @param event defines the drop event to use as source
  72962. */
  72963. loadFiles(event: any): void;
  72964. private _processReload;
  72965. /**
  72966. * Reload the current scene from the loaded files
  72967. */
  72968. reload(): void;
  72969. }
  72970. }
  72971. declare module BABYLON {
  72972. /**
  72973. * Defines the root class used to create scene optimization to use with SceneOptimizer
  72974. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72975. */
  72976. export class SceneOptimization {
  72977. /**
  72978. * Defines the priority of this optimization (0 by default which means first in the list)
  72979. */
  72980. priority: number;
  72981. /**
  72982. * Gets a string describing the action executed by the current optimization
  72983. * @returns description string
  72984. */
  72985. getDescription(): string;
  72986. /**
  72987. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72988. * @param scene defines the current scene where to apply this optimization
  72989. * @param optimizer defines the current optimizer
  72990. * @returns true if everything that can be done was applied
  72991. */
  72992. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72993. /**
  72994. * Creates the SceneOptimization object
  72995. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72996. * @param desc defines the description associated with the optimization
  72997. */
  72998. constructor(
  72999. /**
  73000. * Defines the priority of this optimization (0 by default which means first in the list)
  73001. */
  73002. priority?: number);
  73003. }
  73004. /**
  73005. * Defines an optimization used to reduce the size of render target textures
  73006. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73007. */
  73008. export class TextureOptimization extends SceneOptimization {
  73009. /**
  73010. * Defines the priority of this optimization (0 by default which means first in the list)
  73011. */
  73012. priority: number;
  73013. /**
  73014. * 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
  73015. */
  73016. maximumSize: number;
  73017. /**
  73018. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73019. */
  73020. step: number;
  73021. /**
  73022. * Gets a string describing the action executed by the current optimization
  73023. * @returns description string
  73024. */
  73025. getDescription(): string;
  73026. /**
  73027. * Creates the TextureOptimization object
  73028. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73029. * @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
  73030. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73031. */
  73032. constructor(
  73033. /**
  73034. * Defines the priority of this optimization (0 by default which means first in the list)
  73035. */
  73036. priority?: number,
  73037. /**
  73038. * 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
  73039. */
  73040. maximumSize?: number,
  73041. /**
  73042. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  73043. */
  73044. step?: number);
  73045. /**
  73046. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73047. * @param scene defines the current scene where to apply this optimization
  73048. * @param optimizer defines the current optimizer
  73049. * @returns true if everything that can be done was applied
  73050. */
  73051. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73052. }
  73053. /**
  73054. * Defines an optimization used to increase or decrease the rendering resolution
  73055. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73056. */
  73057. export class HardwareScalingOptimization extends SceneOptimization {
  73058. /**
  73059. * Defines the priority of this optimization (0 by default which means first in the list)
  73060. */
  73061. priority: number;
  73062. /**
  73063. * Defines the maximum scale to use (2 by default)
  73064. */
  73065. maximumScale: number;
  73066. /**
  73067. * Defines the step to use between two passes (0.5 by default)
  73068. */
  73069. step: number;
  73070. private _currentScale;
  73071. private _directionOffset;
  73072. /**
  73073. * Gets a string describing the action executed by the current optimization
  73074. * @return description string
  73075. */
  73076. getDescription(): string;
  73077. /**
  73078. * Creates the HardwareScalingOptimization object
  73079. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73080. * @param maximumScale defines the maximum scale to use (2 by default)
  73081. * @param step defines the step to use between two passes (0.5 by default)
  73082. */
  73083. constructor(
  73084. /**
  73085. * Defines the priority of this optimization (0 by default which means first in the list)
  73086. */
  73087. priority?: number,
  73088. /**
  73089. * Defines the maximum scale to use (2 by default)
  73090. */
  73091. maximumScale?: number,
  73092. /**
  73093. * Defines the step to use between two passes (0.5 by default)
  73094. */
  73095. step?: number);
  73096. /**
  73097. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73098. * @param scene defines the current scene where to apply this optimization
  73099. * @param optimizer defines the current optimizer
  73100. * @returns true if everything that can be done was applied
  73101. */
  73102. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73103. }
  73104. /**
  73105. * Defines an optimization used to remove shadows
  73106. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73107. */
  73108. export class ShadowsOptimization extends SceneOptimization {
  73109. /**
  73110. * Gets a string describing the action executed by the current optimization
  73111. * @return description string
  73112. */
  73113. getDescription(): string;
  73114. /**
  73115. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73116. * @param scene defines the current scene where to apply this optimization
  73117. * @param optimizer defines the current optimizer
  73118. * @returns true if everything that can be done was applied
  73119. */
  73120. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73121. }
  73122. /**
  73123. * Defines an optimization used to turn post-processes off
  73124. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73125. */
  73126. export class PostProcessesOptimization extends SceneOptimization {
  73127. /**
  73128. * Gets a string describing the action executed by the current optimization
  73129. * @return description string
  73130. */
  73131. getDescription(): string;
  73132. /**
  73133. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73134. * @param scene defines the current scene where to apply this optimization
  73135. * @param optimizer defines the current optimizer
  73136. * @returns true if everything that can be done was applied
  73137. */
  73138. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73139. }
  73140. /**
  73141. * Defines an optimization used to turn lens flares off
  73142. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73143. */
  73144. export class LensFlaresOptimization extends SceneOptimization {
  73145. /**
  73146. * Gets a string describing the action executed by the current optimization
  73147. * @return description string
  73148. */
  73149. getDescription(): string;
  73150. /**
  73151. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73152. * @param scene defines the current scene where to apply this optimization
  73153. * @param optimizer defines the current optimizer
  73154. * @returns true if everything that can be done was applied
  73155. */
  73156. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73157. }
  73158. /**
  73159. * Defines an optimization based on user defined callback.
  73160. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73161. */
  73162. export class CustomOptimization extends SceneOptimization {
  73163. /**
  73164. * Callback called to apply the custom optimization.
  73165. */
  73166. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  73167. /**
  73168. * Callback called to get custom description
  73169. */
  73170. onGetDescription: () => string;
  73171. /**
  73172. * Gets a string describing the action executed by the current optimization
  73173. * @returns description string
  73174. */
  73175. getDescription(): string;
  73176. /**
  73177. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73178. * @param scene defines the current scene where to apply this optimization
  73179. * @param optimizer defines the current optimizer
  73180. * @returns true if everything that can be done was applied
  73181. */
  73182. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73183. }
  73184. /**
  73185. * Defines an optimization used to turn particles off
  73186. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73187. */
  73188. export class ParticlesOptimization extends SceneOptimization {
  73189. /**
  73190. * Gets a string describing the action executed by the current optimization
  73191. * @return description string
  73192. */
  73193. getDescription(): string;
  73194. /**
  73195. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73196. * @param scene defines the current scene where to apply this optimization
  73197. * @param optimizer defines the current optimizer
  73198. * @returns true if everything that can be done was applied
  73199. */
  73200. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73201. }
  73202. /**
  73203. * Defines an optimization used to turn render targets off
  73204. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73205. */
  73206. export class RenderTargetsOptimization extends SceneOptimization {
  73207. /**
  73208. * Gets a string describing the action executed by the current optimization
  73209. * @return description string
  73210. */
  73211. getDescription(): string;
  73212. /**
  73213. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73214. * @param scene defines the current scene where to apply this optimization
  73215. * @param optimizer defines the current optimizer
  73216. * @returns true if everything that can be done was applied
  73217. */
  73218. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  73219. }
  73220. /**
  73221. * Defines an optimization used to merge meshes with compatible materials
  73222. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73223. */
  73224. export class MergeMeshesOptimization extends SceneOptimization {
  73225. private static _UpdateSelectionTree;
  73226. /**
  73227. * Gets or sets a boolean which defines if optimization octree has to be updated
  73228. */
  73229. static get UpdateSelectionTree(): boolean;
  73230. /**
  73231. * Gets or sets a boolean which defines if optimization octree has to be updated
  73232. */
  73233. static set UpdateSelectionTree(value: boolean);
  73234. /**
  73235. * Gets a string describing the action executed by the current optimization
  73236. * @return description string
  73237. */
  73238. getDescription(): string;
  73239. private _canBeMerged;
  73240. /**
  73241. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73242. * @param scene defines the current scene where to apply this optimization
  73243. * @param optimizer defines the current optimizer
  73244. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  73245. * @returns true if everything that can be done was applied
  73246. */
  73247. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  73248. }
  73249. /**
  73250. * Defines a list of options used by SceneOptimizer
  73251. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73252. */
  73253. export class SceneOptimizerOptions {
  73254. /**
  73255. * Defines the target frame rate to reach (60 by default)
  73256. */
  73257. targetFrameRate: number;
  73258. /**
  73259. * Defines the interval between two checkes (2000ms by default)
  73260. */
  73261. trackerDuration: number;
  73262. /**
  73263. * Gets the list of optimizations to apply
  73264. */
  73265. optimizations: SceneOptimization[];
  73266. /**
  73267. * Creates a new list of options used by SceneOptimizer
  73268. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  73269. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  73270. */
  73271. constructor(
  73272. /**
  73273. * Defines the target frame rate to reach (60 by default)
  73274. */
  73275. targetFrameRate?: number,
  73276. /**
  73277. * Defines the interval between two checkes (2000ms by default)
  73278. */
  73279. trackerDuration?: number);
  73280. /**
  73281. * Add a new optimization
  73282. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  73283. * @returns the current SceneOptimizerOptions
  73284. */
  73285. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  73286. /**
  73287. * Add a new custom optimization
  73288. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  73289. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  73290. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73291. * @returns the current SceneOptimizerOptions
  73292. */
  73293. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  73294. /**
  73295. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  73296. * @param targetFrameRate defines the target frame rate (60 by default)
  73297. * @returns a SceneOptimizerOptions object
  73298. */
  73299. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73300. /**
  73301. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  73302. * @param targetFrameRate defines the target frame rate (60 by default)
  73303. * @returns a SceneOptimizerOptions object
  73304. */
  73305. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73306. /**
  73307. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  73308. * @param targetFrameRate defines the target frame rate (60 by default)
  73309. * @returns a SceneOptimizerOptions object
  73310. */
  73311. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73312. }
  73313. /**
  73314. * Class used to run optimizations in order to reach a target frame rate
  73315. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73316. */
  73317. export class SceneOptimizer implements IDisposable {
  73318. private _isRunning;
  73319. private _options;
  73320. private _scene;
  73321. private _currentPriorityLevel;
  73322. private _targetFrameRate;
  73323. private _trackerDuration;
  73324. private _currentFrameRate;
  73325. private _sceneDisposeObserver;
  73326. private _improvementMode;
  73327. /**
  73328. * Defines an observable called when the optimizer reaches the target frame rate
  73329. */
  73330. onSuccessObservable: Observable<SceneOptimizer>;
  73331. /**
  73332. * Defines an observable called when the optimizer enables an optimization
  73333. */
  73334. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  73335. /**
  73336. * Defines an observable called when the optimizer is not able to reach the target frame rate
  73337. */
  73338. onFailureObservable: Observable<SceneOptimizer>;
  73339. /**
  73340. * Gets a boolean indicating if the optimizer is in improvement mode
  73341. */
  73342. get isInImprovementMode(): boolean;
  73343. /**
  73344. * Gets the current priority level (0 at start)
  73345. */
  73346. get currentPriorityLevel(): number;
  73347. /**
  73348. * Gets the current frame rate checked by the SceneOptimizer
  73349. */
  73350. get currentFrameRate(): number;
  73351. /**
  73352. * Gets or sets the current target frame rate (60 by default)
  73353. */
  73354. get targetFrameRate(): number;
  73355. /**
  73356. * Gets or sets the current target frame rate (60 by default)
  73357. */
  73358. set targetFrameRate(value: number);
  73359. /**
  73360. * Gets or sets the current interval between two checks (every 2000ms by default)
  73361. */
  73362. get trackerDuration(): number;
  73363. /**
  73364. * Gets or sets the current interval between two checks (every 2000ms by default)
  73365. */
  73366. set trackerDuration(value: number);
  73367. /**
  73368. * Gets the list of active optimizations
  73369. */
  73370. get optimizations(): SceneOptimization[];
  73371. /**
  73372. * Creates a new SceneOptimizer
  73373. * @param scene defines the scene to work on
  73374. * @param options defines the options to use with the SceneOptimizer
  73375. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  73376. * @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)
  73377. */
  73378. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  73379. /**
  73380. * Stops the current optimizer
  73381. */
  73382. stop(): void;
  73383. /**
  73384. * Reset the optimizer to initial step (current priority level = 0)
  73385. */
  73386. reset(): void;
  73387. /**
  73388. * Start the optimizer. By default it will try to reach a specific framerate
  73389. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  73390. */
  73391. start(): void;
  73392. private _checkCurrentState;
  73393. /**
  73394. * Release all resources
  73395. */
  73396. dispose(): void;
  73397. /**
  73398. * Helper function to create a SceneOptimizer with one single line of code
  73399. * @param scene defines the scene to work on
  73400. * @param options defines the options to use with the SceneOptimizer
  73401. * @param onSuccess defines a callback to call on success
  73402. * @param onFailure defines a callback to call on failure
  73403. * @returns the new SceneOptimizer object
  73404. */
  73405. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  73406. }
  73407. }
  73408. declare module BABYLON {
  73409. /**
  73410. * Class used to serialize a scene into a string
  73411. */
  73412. export class SceneSerializer {
  73413. /**
  73414. * Clear cache used by a previous serialization
  73415. */
  73416. static ClearCache(): void;
  73417. /**
  73418. * Serialize a scene into a JSON compatible object
  73419. * @param scene defines the scene to serialize
  73420. * @returns a JSON compatible object
  73421. */
  73422. static Serialize(scene: Scene): any;
  73423. /**
  73424. * Serialize a mesh into a JSON compatible object
  73425. * @param toSerialize defines the mesh to serialize
  73426. * @param withParents defines if parents must be serialized as well
  73427. * @param withChildren defines if children must be serialized as well
  73428. * @returns a JSON compatible object
  73429. */
  73430. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  73431. }
  73432. }
  73433. declare module BABYLON {
  73434. /**
  73435. * Class used to host texture specific utilities
  73436. */
  73437. export class TextureTools {
  73438. /**
  73439. * Uses the GPU to create a copy texture rescaled at a given size
  73440. * @param texture Texture to copy from
  73441. * @param width defines the desired width
  73442. * @param height defines the desired height
  73443. * @param useBilinearMode defines if bilinear mode has to be used
  73444. * @return the generated texture
  73445. */
  73446. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  73447. }
  73448. }
  73449. declare module BABYLON {
  73450. /**
  73451. * This represents the different options available for the video capture.
  73452. */
  73453. export interface VideoRecorderOptions {
  73454. /** Defines the mime type of the video. */
  73455. mimeType: string;
  73456. /** Defines the FPS the video should be recorded at. */
  73457. fps: number;
  73458. /** Defines the chunk size for the recording data. */
  73459. recordChunckSize: number;
  73460. /** The audio tracks to attach to the recording. */
  73461. audioTracks?: MediaStreamTrack[];
  73462. }
  73463. /**
  73464. * This can help with recording videos from BabylonJS.
  73465. * This is based on the available WebRTC functionalities of the browser.
  73466. *
  73467. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  73468. */
  73469. export class VideoRecorder {
  73470. private static readonly _defaultOptions;
  73471. /**
  73472. * Returns whether or not the VideoRecorder is available in your browser.
  73473. * @param engine Defines the Babylon Engine.
  73474. * @returns true if supported otherwise false.
  73475. */
  73476. static IsSupported(engine: Engine): boolean;
  73477. private readonly _options;
  73478. private _canvas;
  73479. private _mediaRecorder;
  73480. private _recordedChunks;
  73481. private _fileName;
  73482. private _resolve;
  73483. private _reject;
  73484. /**
  73485. * True when a recording is already in progress.
  73486. */
  73487. get isRecording(): boolean;
  73488. /**
  73489. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  73490. * @param engine Defines the BabylonJS Engine you wish to record.
  73491. * @param options Defines options that can be used to customize the capture.
  73492. */
  73493. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  73494. /**
  73495. * Stops the current recording before the default capture timeout passed in the startRecording function.
  73496. */
  73497. stopRecording(): void;
  73498. /**
  73499. * Starts recording the canvas for a max duration specified in parameters.
  73500. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  73501. * If null no automatic download will start and you can rely on the promise to get the data back.
  73502. * @param maxDuration Defines the maximum recording time in seconds.
  73503. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  73504. * @return A promise callback at the end of the recording with the video data in Blob.
  73505. */
  73506. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  73507. /**
  73508. * Releases internal resources used during the recording.
  73509. */
  73510. dispose(): void;
  73511. private _handleDataAvailable;
  73512. private _handleError;
  73513. private _handleStop;
  73514. }
  73515. }
  73516. declare module BABYLON {
  73517. /**
  73518. * Class containing a set of static utilities functions for screenshots
  73519. */
  73520. export class ScreenshotTools {
  73521. /**
  73522. * Captures a screenshot of the current rendering
  73523. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73524. * @param engine defines the rendering engine
  73525. * @param camera defines the source camera
  73526. * @param size This parameter can be set to a single number or to an object with the
  73527. * following (optional) properties: precision, width, height. If a single number is passed,
  73528. * it will be used for both width and height. If an object is passed, the screenshot size
  73529. * will be derived from the parameters. The precision property is a multiplier allowing
  73530. * rendering at a higher or lower resolution
  73531. * @param successCallback defines the callback receives a single parameter which contains the
  73532. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  73533. * src parameter of an <img> to display it
  73534. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  73535. * Check your browser for supported MIME types
  73536. */
  73537. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  73538. /**
  73539. * Captures a screenshot of the current rendering
  73540. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73541. * @param engine defines the rendering engine
  73542. * @param camera defines the source camera
  73543. * @param size This parameter can be set to a single number or to an object with the
  73544. * following (optional) properties: precision, width, height. If a single number is passed,
  73545. * it will be used for both width and height. If an object is passed, the screenshot size
  73546. * will be derived from the parameters. The precision property is a multiplier allowing
  73547. * rendering at a higher or lower resolution
  73548. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  73549. * Check your browser for supported MIME types
  73550. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  73551. * to the src parameter of an <img> to display it
  73552. */
  73553. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  73554. /**
  73555. * Generates an image screenshot from the specified camera.
  73556. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73557. * @param engine The engine to use for rendering
  73558. * @param camera The camera to use for rendering
  73559. * @param size This parameter can be set to a single number or to an object with the
  73560. * following (optional) properties: precision, width, height. If a single number is passed,
  73561. * it will be used for both width and height. If an object is passed, the screenshot size
  73562. * will be derived from the parameters. The precision property is a multiplier allowing
  73563. * rendering at a higher or lower resolution
  73564. * @param successCallback The callback receives a single parameter which contains the
  73565. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  73566. * src parameter of an <img> to display it
  73567. * @param mimeType The MIME type of the screenshot image (default: image/png).
  73568. * Check your browser for supported MIME types
  73569. * @param samples Texture samples (default: 1)
  73570. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  73571. * @param fileName A name for for the downloaded file.
  73572. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  73573. */
  73574. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  73575. /**
  73576. * Generates an image screenshot from the specified camera.
  73577. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73578. * @param engine The engine to use for rendering
  73579. * @param camera The camera to use for rendering
  73580. * @param size This parameter can be set to a single number or to an object with the
  73581. * following (optional) properties: precision, width, height. If a single number is passed,
  73582. * it will be used for both width and height. If an object is passed, the screenshot size
  73583. * will be derived from the parameters. The precision property is a multiplier allowing
  73584. * rendering at a higher or lower resolution
  73585. * @param mimeType The MIME type of the screenshot image (default: image/png).
  73586. * Check your browser for supported MIME types
  73587. * @param samples Texture samples (default: 1)
  73588. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  73589. * @param fileName A name for for the downloaded file.
  73590. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  73591. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  73592. * to the src parameter of an <img> to display it
  73593. */
  73594. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  73595. /**
  73596. * Gets height and width for screenshot size
  73597. * @private
  73598. */
  73599. private static _getScreenshotSize;
  73600. }
  73601. }
  73602. declare module BABYLON {
  73603. /**
  73604. * Interface for a data buffer
  73605. */
  73606. export interface IDataBuffer {
  73607. /**
  73608. * Reads bytes from the data buffer.
  73609. * @param byteOffset The byte offset to read
  73610. * @param byteLength The byte length to read
  73611. * @returns A promise that resolves when the bytes are read
  73612. */
  73613. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  73614. /**
  73615. * The byte length of the buffer.
  73616. */
  73617. readonly byteLength: number;
  73618. }
  73619. /**
  73620. * Utility class for reading from a data buffer
  73621. */
  73622. export class DataReader {
  73623. /**
  73624. * The data buffer associated with this data reader.
  73625. */
  73626. readonly buffer: IDataBuffer;
  73627. /**
  73628. * The current byte offset from the beginning of the data buffer.
  73629. */
  73630. byteOffset: number;
  73631. private _dataView;
  73632. private _dataByteOffset;
  73633. /**
  73634. * Constructor
  73635. * @param buffer The buffer to read
  73636. */
  73637. constructor(buffer: IDataBuffer);
  73638. /**
  73639. * Loads the given byte length.
  73640. * @param byteLength The byte length to load
  73641. * @returns A promise that resolves when the load is complete
  73642. */
  73643. loadAsync(byteLength: number): Promise<void>;
  73644. /**
  73645. * Read a unsigned 32-bit integer from the currently loaded data range.
  73646. * @returns The 32-bit integer read
  73647. */
  73648. readUint32(): number;
  73649. /**
  73650. * Read a byte array from the currently loaded data range.
  73651. * @param byteLength The byte length to read
  73652. * @returns The byte array read
  73653. */
  73654. readUint8Array(byteLength: number): Uint8Array;
  73655. /**
  73656. * Read a string from the currently loaded data range.
  73657. * @param byteLength The byte length to read
  73658. * @returns The string read
  73659. */
  73660. readString(byteLength: number): string;
  73661. /**
  73662. * Skips the given byte length the currently loaded data range.
  73663. * @param byteLength The byte length to skip
  73664. */
  73665. skipBytes(byteLength: number): void;
  73666. }
  73667. }
  73668. declare module BABYLON {
  73669. /**
  73670. * Class for storing data to local storage if available or in-memory storage otherwise
  73671. */
  73672. export class DataStorage {
  73673. private static _Storage;
  73674. private static _GetStorage;
  73675. /**
  73676. * Reads a string from the data storage
  73677. * @param key The key to read
  73678. * @param defaultValue The value if the key doesn't exist
  73679. * @returns The string value
  73680. */
  73681. static ReadString(key: string, defaultValue: string): string;
  73682. /**
  73683. * Writes a string to the data storage
  73684. * @param key The key to write
  73685. * @param value The value to write
  73686. */
  73687. static WriteString(key: string, value: string): void;
  73688. /**
  73689. * Reads a boolean from the data storage
  73690. * @param key The key to read
  73691. * @param defaultValue The value if the key doesn't exist
  73692. * @returns The boolean value
  73693. */
  73694. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  73695. /**
  73696. * Writes a boolean to the data storage
  73697. * @param key The key to write
  73698. * @param value The value to write
  73699. */
  73700. static WriteBoolean(key: string, value: boolean): void;
  73701. /**
  73702. * Reads a number from the data storage
  73703. * @param key The key to read
  73704. * @param defaultValue The value if the key doesn't exist
  73705. * @returns The number value
  73706. */
  73707. static ReadNumber(key: string, defaultValue: number): number;
  73708. /**
  73709. * Writes a number to the data storage
  73710. * @param key The key to write
  73711. * @param value The value to write
  73712. */
  73713. static WriteNumber(key: string, value: number): void;
  73714. }
  73715. }
  73716. declare module BABYLON {
  73717. /**
  73718. * Class used to record delta files between 2 scene states
  73719. */
  73720. export class SceneRecorder {
  73721. private _trackedScene;
  73722. private _savedJSON;
  73723. /**
  73724. * Track a given scene. This means the current scene state will be considered the original state
  73725. * @param scene defines the scene to track
  73726. */
  73727. track(scene: Scene): void;
  73728. /**
  73729. * Get the delta between current state and original state
  73730. * @returns a string containing the delta
  73731. */
  73732. getDelta(): any;
  73733. private _compareArray;
  73734. private _compareObjects;
  73735. private _compareCollections;
  73736. private static GetShadowGeneratorById;
  73737. /**
  73738. * Apply a given delta to a given scene
  73739. * @param deltaJSON defines the JSON containing the delta
  73740. * @param scene defines the scene to apply the delta to
  73741. */
  73742. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  73743. private static _ApplyPropertiesToEntity;
  73744. private static _ApplyDeltaForEntity;
  73745. }
  73746. }
  73747. declare module BABYLON {
  73748. /**
  73749. * An interface for all Hit test features
  73750. */
  73751. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  73752. /**
  73753. * Triggered when new babylon (transformed) hit test results are available
  73754. */
  73755. onHitTestResultObservable: Observable<T[]>;
  73756. }
  73757. /**
  73758. * Options used for hit testing
  73759. */
  73760. export interface IWebXRLegacyHitTestOptions {
  73761. /**
  73762. * Only test when user interacted with the scene. Default - hit test every frame
  73763. */
  73764. testOnPointerDownOnly?: boolean;
  73765. /**
  73766. * The node to use to transform the local results to world coordinates
  73767. */
  73768. worldParentNode?: TransformNode;
  73769. }
  73770. /**
  73771. * Interface defining the babylon result of raycasting/hit-test
  73772. */
  73773. export interface IWebXRLegacyHitResult {
  73774. /**
  73775. * Transformation matrix that can be applied to a node that will put it in the hit point location
  73776. */
  73777. transformationMatrix: Matrix;
  73778. /**
  73779. * The native hit test result
  73780. */
  73781. xrHitResult: XRHitResult | XRHitTestResult;
  73782. }
  73783. /**
  73784. * The currently-working hit-test module.
  73785. * Hit test (or Ray-casting) is used to interact with the real world.
  73786. * For further information read here - https://github.com/immersive-web/hit-test
  73787. */
  73788. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  73789. /**
  73790. * options to use when constructing this feature
  73791. */
  73792. readonly options: IWebXRLegacyHitTestOptions;
  73793. private _direction;
  73794. private _mat;
  73795. private _onSelectEnabled;
  73796. private _origin;
  73797. /**
  73798. * The module's name
  73799. */
  73800. static readonly Name: string;
  73801. /**
  73802. * The (Babylon) version of this module.
  73803. * This is an integer representing the implementation version.
  73804. * This number does not correspond to the WebXR specs version
  73805. */
  73806. static readonly Version: number;
  73807. /**
  73808. * Populated with the last native XR Hit Results
  73809. */
  73810. lastNativeXRHitResults: XRHitResult[];
  73811. /**
  73812. * Triggered when new babylon (transformed) hit test results are available
  73813. */
  73814. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  73815. /**
  73816. * Creates a new instance of the (legacy version) hit test feature
  73817. * @param _xrSessionManager an instance of WebXRSessionManager
  73818. * @param options options to use when constructing this feature
  73819. */
  73820. constructor(_xrSessionManager: WebXRSessionManager,
  73821. /**
  73822. * options to use when constructing this feature
  73823. */
  73824. options?: IWebXRLegacyHitTestOptions);
  73825. /**
  73826. * execute a hit test with an XR Ray
  73827. *
  73828. * @param xrSession a native xrSession that will execute this hit test
  73829. * @param xrRay the ray (position and direction) to use for ray-casting
  73830. * @param referenceSpace native XR reference space to use for the hit-test
  73831. * @param filter filter function that will filter the results
  73832. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  73833. */
  73834. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  73835. /**
  73836. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  73837. * @param event the (select) event to use to select with
  73838. * @param referenceSpace the reference space to use for this hit test
  73839. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  73840. */
  73841. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  73842. /**
  73843. * attach this feature
  73844. * Will usually be called by the features manager
  73845. *
  73846. * @returns true if successful.
  73847. */
  73848. attach(): boolean;
  73849. /**
  73850. * detach this feature.
  73851. * Will usually be called by the features manager
  73852. *
  73853. * @returns true if successful.
  73854. */
  73855. detach(): boolean;
  73856. /**
  73857. * Dispose this feature and all of the resources attached
  73858. */
  73859. dispose(): void;
  73860. protected _onXRFrame(frame: XRFrame): void;
  73861. private _onHitTestResults;
  73862. private _onSelect;
  73863. }
  73864. }
  73865. declare module BABYLON {
  73866. /**
  73867. * Options used for hit testing (version 2)
  73868. */
  73869. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  73870. /**
  73871. * Do not create a permanent hit test. Will usually be used when only
  73872. * transient inputs are needed.
  73873. */
  73874. disablePermanentHitTest?: boolean;
  73875. /**
  73876. * Enable transient (for example touch-based) hit test inspections
  73877. */
  73878. enableTransientHitTest?: boolean;
  73879. /**
  73880. * Offset ray for the permanent hit test
  73881. */
  73882. offsetRay?: Vector3;
  73883. /**
  73884. * Offset ray for the transient hit test
  73885. */
  73886. transientOffsetRay?: Vector3;
  73887. /**
  73888. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  73889. */
  73890. useReferenceSpace?: boolean;
  73891. }
  73892. /**
  73893. * Interface defining the babylon result of hit-test
  73894. */
  73895. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  73896. /**
  73897. * The input source that generated this hit test (if transient)
  73898. */
  73899. inputSource?: XRInputSource;
  73900. /**
  73901. * Is this a transient hit test
  73902. */
  73903. isTransient?: boolean;
  73904. /**
  73905. * Position of the hit test result
  73906. */
  73907. position: Vector3;
  73908. /**
  73909. * Rotation of the hit test result
  73910. */
  73911. rotationQuaternion: Quaternion;
  73912. /**
  73913. * The native hit test result
  73914. */
  73915. xrHitResult: XRHitTestResult;
  73916. }
  73917. /**
  73918. * The currently-working hit-test module.
  73919. * Hit test (or Ray-casting) is used to interact with the real world.
  73920. * For further information read here - https://github.com/immersive-web/hit-test
  73921. *
  73922. * Tested on chrome (mobile) 80.
  73923. */
  73924. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  73925. /**
  73926. * options to use when constructing this feature
  73927. */
  73928. readonly options: IWebXRHitTestOptions;
  73929. private _tmpMat;
  73930. private _tmpPos;
  73931. private _tmpQuat;
  73932. private _transientXrHitTestSource;
  73933. private _xrHitTestSource;
  73934. private initHitTestSource;
  73935. /**
  73936. * The module's name
  73937. */
  73938. static readonly Name: string;
  73939. /**
  73940. * The (Babylon) version of this module.
  73941. * This is an integer representing the implementation version.
  73942. * This number does not correspond to the WebXR specs version
  73943. */
  73944. static readonly Version: number;
  73945. /**
  73946. * When set to true, each hit test will have its own position/rotation objects
  73947. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  73948. * the developers will clone them or copy them as they see fit.
  73949. */
  73950. autoCloneTransformation: boolean;
  73951. /**
  73952. * Triggered when new babylon (transformed) hit test results are available
  73953. */
  73954. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  73955. /**
  73956. * Use this to temporarily pause hit test checks.
  73957. */
  73958. paused: boolean;
  73959. /**
  73960. * Creates a new instance of the hit test feature
  73961. * @param _xrSessionManager an instance of WebXRSessionManager
  73962. * @param options options to use when constructing this feature
  73963. */
  73964. constructor(_xrSessionManager: WebXRSessionManager,
  73965. /**
  73966. * options to use when constructing this feature
  73967. */
  73968. options?: IWebXRHitTestOptions);
  73969. /**
  73970. * attach this feature
  73971. * Will usually be called by the features manager
  73972. *
  73973. * @returns true if successful.
  73974. */
  73975. attach(): boolean;
  73976. /**
  73977. * detach this feature.
  73978. * Will usually be called by the features manager
  73979. *
  73980. * @returns true if successful.
  73981. */
  73982. detach(): boolean;
  73983. /**
  73984. * Dispose this feature and all of the resources attached
  73985. */
  73986. dispose(): void;
  73987. protected _onXRFrame(frame: XRFrame): void;
  73988. private _processWebXRHitTestResult;
  73989. }
  73990. }
  73991. declare module BABYLON {
  73992. /**
  73993. * Configuration options of the anchor system
  73994. */
  73995. export interface IWebXRAnchorSystemOptions {
  73996. /**
  73997. * a node that will be used to convert local to world coordinates
  73998. */
  73999. worldParentNode?: TransformNode;
  74000. /**
  74001. * If set to true a reference of the created anchors will be kept until the next session starts
  74002. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  74003. */
  74004. doNotRemoveAnchorsOnSessionEnded?: boolean;
  74005. }
  74006. /**
  74007. * A babylon container for an XR Anchor
  74008. */
  74009. export interface IWebXRAnchor {
  74010. /**
  74011. * A babylon-assigned ID for this anchor
  74012. */
  74013. id: number;
  74014. /**
  74015. * Transformation matrix to apply to an object attached to this anchor
  74016. */
  74017. transformationMatrix: Matrix;
  74018. /**
  74019. * The native anchor object
  74020. */
  74021. xrAnchor: XRAnchor;
  74022. /**
  74023. * if defined, this object will be constantly updated by the anchor's position and rotation
  74024. */
  74025. attachedNode?: TransformNode;
  74026. }
  74027. /**
  74028. * An implementation of the anchor system for WebXR.
  74029. * For further information see https://github.com/immersive-web/anchors/
  74030. */
  74031. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  74032. private _options;
  74033. private _lastFrameDetected;
  74034. private _trackedAnchors;
  74035. private _referenceSpaceForFrameAnchors;
  74036. private _futureAnchors;
  74037. /**
  74038. * The module's name
  74039. */
  74040. static readonly Name: string;
  74041. /**
  74042. * The (Babylon) version of this module.
  74043. * This is an integer representing the implementation version.
  74044. * This number does not correspond to the WebXR specs version
  74045. */
  74046. static readonly Version: number;
  74047. /**
  74048. * Observers registered here will be executed when a new anchor was added to the session
  74049. */
  74050. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  74051. /**
  74052. * Observers registered here will be executed when an anchor was removed from the session
  74053. */
  74054. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  74055. /**
  74056. * Observers registered here will be executed when an existing anchor updates
  74057. * This can execute N times every frame
  74058. */
  74059. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  74060. /**
  74061. * Set the reference space to use for anchor creation, when not using a hit test.
  74062. * Will default to the session's reference space if not defined
  74063. */
  74064. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  74065. /**
  74066. * constructs a new anchor system
  74067. * @param _xrSessionManager an instance of WebXRSessionManager
  74068. * @param _options configuration object for this feature
  74069. */
  74070. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  74071. private _tmpVector;
  74072. private _tmpQuaternion;
  74073. private _populateTmpTransformation;
  74074. /**
  74075. * Create a new anchor point using a hit test result at a specific point in the scene
  74076. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  74077. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  74078. *
  74079. * @param hitTestResult The hit test result to use for this anchor creation
  74080. * @param position an optional position offset for this anchor
  74081. * @param rotationQuaternion an optional rotation offset for this anchor
  74082. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  74083. */
  74084. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  74085. /**
  74086. * Add a new anchor at a specific position and rotation
  74087. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  74088. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  74089. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  74090. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  74091. *
  74092. * @param position the position in which to add an anchor
  74093. * @param rotationQuaternion an optional rotation for the anchor transformation
  74094. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  74095. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  74096. */
  74097. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  74098. /**
  74099. * detach this feature.
  74100. * Will usually be called by the features manager
  74101. *
  74102. * @returns true if successful.
  74103. */
  74104. detach(): boolean;
  74105. /**
  74106. * Dispose this feature and all of the resources attached
  74107. */
  74108. dispose(): void;
  74109. protected _onXRFrame(frame: XRFrame): void;
  74110. /**
  74111. * avoiding using Array.find for global support.
  74112. * @param xrAnchor the plane to find in the array
  74113. */
  74114. private _findIndexInAnchorArray;
  74115. private _updateAnchorWithXRFrame;
  74116. private _createAnchorAtTransformation;
  74117. }
  74118. }
  74119. declare module BABYLON {
  74120. /**
  74121. * Options used in the plane detector module
  74122. */
  74123. export interface IWebXRPlaneDetectorOptions {
  74124. /**
  74125. * The node to use to transform the local results to world coordinates
  74126. */
  74127. worldParentNode?: TransformNode;
  74128. /**
  74129. * If set to true a reference of the created planes will be kept until the next session starts
  74130. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  74131. */
  74132. doNotRemovePlanesOnSessionEnded?: boolean;
  74133. }
  74134. /**
  74135. * A babylon interface for a WebXR plane.
  74136. * A Plane is actually a polygon, built from N points in space
  74137. *
  74138. * Supported in chrome 79, not supported in canary 81 ATM
  74139. */
  74140. export interface IWebXRPlane {
  74141. /**
  74142. * a babylon-assigned ID for this polygon
  74143. */
  74144. id: number;
  74145. /**
  74146. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  74147. */
  74148. polygonDefinition: Array<Vector3>;
  74149. /**
  74150. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  74151. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  74152. */
  74153. transformationMatrix: Matrix;
  74154. /**
  74155. * the native xr-plane object
  74156. */
  74157. xrPlane: XRPlane;
  74158. }
  74159. /**
  74160. * The plane detector is used to detect planes in the real world when in AR
  74161. * For more information see https://github.com/immersive-web/real-world-geometry/
  74162. */
  74163. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  74164. private _options;
  74165. private _detectedPlanes;
  74166. private _enabled;
  74167. private _lastFrameDetected;
  74168. /**
  74169. * The module's name
  74170. */
  74171. static readonly Name: string;
  74172. /**
  74173. * The (Babylon) version of this module.
  74174. * This is an integer representing the implementation version.
  74175. * This number does not correspond to the WebXR specs version
  74176. */
  74177. static readonly Version: number;
  74178. /**
  74179. * Observers registered here will be executed when a new plane was added to the session
  74180. */
  74181. onPlaneAddedObservable: Observable<IWebXRPlane>;
  74182. /**
  74183. * Observers registered here will be executed when a plane is no longer detected in the session
  74184. */
  74185. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  74186. /**
  74187. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  74188. * This can execute N times every frame
  74189. */
  74190. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  74191. /**
  74192. * construct a new Plane Detector
  74193. * @param _xrSessionManager an instance of xr Session manager
  74194. * @param _options configuration to use when constructing this feature
  74195. */
  74196. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  74197. /**
  74198. * detach this feature.
  74199. * Will usually be called by the features manager
  74200. *
  74201. * @returns true if successful.
  74202. */
  74203. detach(): boolean;
  74204. /**
  74205. * Dispose this feature and all of the resources attached
  74206. */
  74207. dispose(): void;
  74208. protected _onXRFrame(frame: XRFrame): void;
  74209. private _init;
  74210. private _updatePlaneWithXRPlane;
  74211. /**
  74212. * avoiding using Array.find for global support.
  74213. * @param xrPlane the plane to find in the array
  74214. */
  74215. private findIndexInPlaneArray;
  74216. }
  74217. }
  74218. declare module BABYLON {
  74219. /**
  74220. * Options interface for the background remover plugin
  74221. */
  74222. export interface IWebXRBackgroundRemoverOptions {
  74223. /**
  74224. * Further background meshes to disable when entering AR
  74225. */
  74226. backgroundMeshes?: AbstractMesh[];
  74227. /**
  74228. * flags to configure the removal of the environment helper.
  74229. * If not set, the entire background will be removed. If set, flags should be set as well.
  74230. */
  74231. environmentHelperRemovalFlags?: {
  74232. /**
  74233. * Should the skybox be removed (default false)
  74234. */
  74235. skyBox?: boolean;
  74236. /**
  74237. * Should the ground be removed (default false)
  74238. */
  74239. ground?: boolean;
  74240. };
  74241. /**
  74242. * don't disable the environment helper
  74243. */
  74244. ignoreEnvironmentHelper?: boolean;
  74245. }
  74246. /**
  74247. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  74248. */
  74249. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  74250. /**
  74251. * read-only options to be used in this module
  74252. */
  74253. readonly options: IWebXRBackgroundRemoverOptions;
  74254. /**
  74255. * The module's name
  74256. */
  74257. static readonly Name: string;
  74258. /**
  74259. * The (Babylon) version of this module.
  74260. * This is an integer representing the implementation version.
  74261. * This number does not correspond to the WebXR specs version
  74262. */
  74263. static readonly Version: number;
  74264. /**
  74265. * registered observers will be triggered when the background state changes
  74266. */
  74267. onBackgroundStateChangedObservable: Observable<boolean>;
  74268. /**
  74269. * constructs a new background remover module
  74270. * @param _xrSessionManager the session manager for this module
  74271. * @param options read-only options to be used in this module
  74272. */
  74273. constructor(_xrSessionManager: WebXRSessionManager,
  74274. /**
  74275. * read-only options to be used in this module
  74276. */
  74277. options?: IWebXRBackgroundRemoverOptions);
  74278. /**
  74279. * attach this feature
  74280. * Will usually be called by the features manager
  74281. *
  74282. * @returns true if successful.
  74283. */
  74284. attach(): boolean;
  74285. /**
  74286. * detach this feature.
  74287. * Will usually be called by the features manager
  74288. *
  74289. * @returns true if successful.
  74290. */
  74291. detach(): boolean;
  74292. /**
  74293. * Dispose this feature and all of the resources attached
  74294. */
  74295. dispose(): void;
  74296. protected _onXRFrame(_xrFrame: XRFrame): void;
  74297. private _setBackgroundState;
  74298. }
  74299. }
  74300. declare module BABYLON {
  74301. /**
  74302. * Options for the controller physics feature
  74303. */
  74304. export class IWebXRControllerPhysicsOptions {
  74305. /**
  74306. * Should the headset get its own impostor
  74307. */
  74308. enableHeadsetImpostor?: boolean;
  74309. /**
  74310. * Optional parameters for the headset impostor
  74311. */
  74312. headsetImpostorParams?: {
  74313. /**
  74314. * The type of impostor to create. Default is sphere
  74315. */
  74316. impostorType: number;
  74317. /**
  74318. * the size of the impostor. Defaults to 10cm
  74319. */
  74320. impostorSize?: number | {
  74321. width: number;
  74322. height: number;
  74323. depth: number;
  74324. };
  74325. /**
  74326. * Friction definitions
  74327. */
  74328. friction?: number;
  74329. /**
  74330. * Restitution
  74331. */
  74332. restitution?: number;
  74333. };
  74334. /**
  74335. * The physics properties of the future impostors
  74336. */
  74337. physicsProperties?: {
  74338. /**
  74339. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  74340. * Note that this requires a physics engine that supports mesh impostors!
  74341. */
  74342. useControllerMesh?: boolean;
  74343. /**
  74344. * The type of impostor to create. Default is sphere
  74345. */
  74346. impostorType?: number;
  74347. /**
  74348. * the size of the impostor. Defaults to 10cm
  74349. */
  74350. impostorSize?: number | {
  74351. width: number;
  74352. height: number;
  74353. depth: number;
  74354. };
  74355. /**
  74356. * Friction definitions
  74357. */
  74358. friction?: number;
  74359. /**
  74360. * Restitution
  74361. */
  74362. restitution?: number;
  74363. };
  74364. /**
  74365. * the xr input to use with this pointer selection
  74366. */
  74367. xrInput: WebXRInput;
  74368. }
  74369. /**
  74370. * Add physics impostor to your webxr controllers,
  74371. * including naive calculation of their linear and angular velocity
  74372. */
  74373. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  74374. private readonly _options;
  74375. private _attachController;
  74376. private _controllers;
  74377. private _debugMode;
  74378. private _delta;
  74379. private _headsetImpostor?;
  74380. private _headsetMesh?;
  74381. private _lastTimestamp;
  74382. private _tmpQuaternion;
  74383. private _tmpVector;
  74384. /**
  74385. * The module's name
  74386. */
  74387. static readonly Name: string;
  74388. /**
  74389. * The (Babylon) version of this module.
  74390. * This is an integer representing the implementation version.
  74391. * This number does not correspond to the webxr specs version
  74392. */
  74393. static readonly Version: number;
  74394. /**
  74395. * Construct a new Controller Physics Feature
  74396. * @param _xrSessionManager the corresponding xr session manager
  74397. * @param _options options to create this feature with
  74398. */
  74399. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  74400. /**
  74401. * @hidden
  74402. * enable debugging - will show console outputs and the impostor mesh
  74403. */
  74404. _enablePhysicsDebug(): void;
  74405. /**
  74406. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  74407. * @param xrController the controller to add
  74408. */
  74409. addController(xrController: WebXRInputSource): void;
  74410. /**
  74411. * attach this feature
  74412. * Will usually be called by the features manager
  74413. *
  74414. * @returns true if successful.
  74415. */
  74416. attach(): boolean;
  74417. /**
  74418. * detach this feature.
  74419. * Will usually be called by the features manager
  74420. *
  74421. * @returns true if successful.
  74422. */
  74423. detach(): boolean;
  74424. /**
  74425. * Get the headset impostor, if enabled
  74426. * @returns the impostor
  74427. */
  74428. getHeadsetImpostor(): PhysicsImpostor | undefined;
  74429. /**
  74430. * Get the physics impostor of a specific controller.
  74431. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  74432. * @param controller the controller or the controller id of which to get the impostor
  74433. * @returns the impostor or null
  74434. */
  74435. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  74436. /**
  74437. * Update the physics properties provided in the constructor
  74438. * @param newProperties the new properties object
  74439. */
  74440. setPhysicsProperties(newProperties: {
  74441. impostorType?: number;
  74442. impostorSize?: number | {
  74443. width: number;
  74444. height: number;
  74445. depth: number;
  74446. };
  74447. friction?: number;
  74448. restitution?: number;
  74449. }): void;
  74450. protected _onXRFrame(_xrFrame: any): void;
  74451. private _detachController;
  74452. }
  74453. }
  74454. declare module BABYLON {
  74455. /**
  74456. * The motion controller class for all microsoft mixed reality controllers
  74457. */
  74458. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  74459. protected readonly _mapping: {
  74460. defaultButton: {
  74461. valueNodeName: string;
  74462. unpressedNodeName: string;
  74463. pressedNodeName: string;
  74464. };
  74465. defaultAxis: {
  74466. valueNodeName: string;
  74467. minNodeName: string;
  74468. maxNodeName: string;
  74469. };
  74470. buttons: {
  74471. "xr-standard-trigger": {
  74472. rootNodeName: string;
  74473. componentProperty: string;
  74474. states: string[];
  74475. };
  74476. "xr-standard-squeeze": {
  74477. rootNodeName: string;
  74478. componentProperty: string;
  74479. states: string[];
  74480. };
  74481. "xr-standard-touchpad": {
  74482. rootNodeName: string;
  74483. labelAnchorNodeName: string;
  74484. touchPointNodeName: string;
  74485. };
  74486. "xr-standard-thumbstick": {
  74487. rootNodeName: string;
  74488. componentProperty: string;
  74489. states: string[];
  74490. };
  74491. };
  74492. axes: {
  74493. "xr-standard-touchpad": {
  74494. "x-axis": {
  74495. rootNodeName: string;
  74496. };
  74497. "y-axis": {
  74498. rootNodeName: string;
  74499. };
  74500. };
  74501. "xr-standard-thumbstick": {
  74502. "x-axis": {
  74503. rootNodeName: string;
  74504. };
  74505. "y-axis": {
  74506. rootNodeName: string;
  74507. };
  74508. };
  74509. };
  74510. };
  74511. /**
  74512. * The base url used to load the left and right controller models
  74513. */
  74514. static MODEL_BASE_URL: string;
  74515. /**
  74516. * The name of the left controller model file
  74517. */
  74518. static MODEL_LEFT_FILENAME: string;
  74519. /**
  74520. * The name of the right controller model file
  74521. */
  74522. static MODEL_RIGHT_FILENAME: string;
  74523. profileId: string;
  74524. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  74525. protected _getFilenameAndPath(): {
  74526. filename: string;
  74527. path: string;
  74528. };
  74529. protected _getModelLoadingConstraints(): boolean;
  74530. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74531. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74532. protected _updateModel(): void;
  74533. }
  74534. }
  74535. declare module BABYLON {
  74536. /**
  74537. * The motion controller class for oculus touch (quest, rift).
  74538. * This class supports legacy mapping as well the standard xr mapping
  74539. */
  74540. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  74541. private _forceLegacyControllers;
  74542. private _modelRootNode;
  74543. /**
  74544. * The base url used to load the left and right controller models
  74545. */
  74546. static MODEL_BASE_URL: string;
  74547. /**
  74548. * The name of the left controller model file
  74549. */
  74550. static MODEL_LEFT_FILENAME: string;
  74551. /**
  74552. * The name of the right controller model file
  74553. */
  74554. static MODEL_RIGHT_FILENAME: string;
  74555. /**
  74556. * Base Url for the Quest controller model.
  74557. */
  74558. static QUEST_MODEL_BASE_URL: string;
  74559. profileId: string;
  74560. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  74561. protected _getFilenameAndPath(): {
  74562. filename: string;
  74563. path: string;
  74564. };
  74565. protected _getModelLoadingConstraints(): boolean;
  74566. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74567. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74568. protected _updateModel(): void;
  74569. /**
  74570. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  74571. * between the touch and touch 2.
  74572. */
  74573. private _isQuest;
  74574. }
  74575. }
  74576. declare module BABYLON {
  74577. /**
  74578. * The motion controller class for the standard HTC-Vive controllers
  74579. */
  74580. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  74581. private _modelRootNode;
  74582. /**
  74583. * The base url used to load the left and right controller models
  74584. */
  74585. static MODEL_BASE_URL: string;
  74586. /**
  74587. * File name for the controller model.
  74588. */
  74589. static MODEL_FILENAME: string;
  74590. profileId: string;
  74591. /**
  74592. * Create a new Vive motion controller object
  74593. * @param scene the scene to use to create this controller
  74594. * @param gamepadObject the corresponding gamepad object
  74595. * @param handedness the handedness of the controller
  74596. */
  74597. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  74598. protected _getFilenameAndPath(): {
  74599. filename: string;
  74600. path: string;
  74601. };
  74602. protected _getModelLoadingConstraints(): boolean;
  74603. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74604. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74605. protected _updateModel(): void;
  74606. }
  74607. }
  74608. declare module BABYLON {
  74609. /**
  74610. * A cursor which tracks a point on a path
  74611. */
  74612. export class PathCursor {
  74613. private path;
  74614. /**
  74615. * Stores path cursor callbacks for when an onchange event is triggered
  74616. */
  74617. private _onchange;
  74618. /**
  74619. * The value of the path cursor
  74620. */
  74621. value: number;
  74622. /**
  74623. * The animation array of the path cursor
  74624. */
  74625. animations: Animation[];
  74626. /**
  74627. * Initializes the path cursor
  74628. * @param path The path to track
  74629. */
  74630. constructor(path: Path2);
  74631. /**
  74632. * Gets the cursor point on the path
  74633. * @returns A point on the path cursor at the cursor location
  74634. */
  74635. getPoint(): Vector3;
  74636. /**
  74637. * Moves the cursor ahead by the step amount
  74638. * @param step The amount to move the cursor forward
  74639. * @returns This path cursor
  74640. */
  74641. moveAhead(step?: number): PathCursor;
  74642. /**
  74643. * Moves the cursor behind by the step amount
  74644. * @param step The amount to move the cursor back
  74645. * @returns This path cursor
  74646. */
  74647. moveBack(step?: number): PathCursor;
  74648. /**
  74649. * Moves the cursor by the step amount
  74650. * If the step amount is greater than one, an exception is thrown
  74651. * @param step The amount to move the cursor
  74652. * @returns This path cursor
  74653. */
  74654. move(step: number): PathCursor;
  74655. /**
  74656. * Ensures that the value is limited between zero and one
  74657. * @returns This path cursor
  74658. */
  74659. private ensureLimits;
  74660. /**
  74661. * Runs onchange callbacks on change (used by the animation engine)
  74662. * @returns This path cursor
  74663. */
  74664. private raiseOnChange;
  74665. /**
  74666. * Executes a function on change
  74667. * @param f A path cursor onchange callback
  74668. * @returns This path cursor
  74669. */
  74670. onchange(f: (cursor: PathCursor) => void): PathCursor;
  74671. }
  74672. }
  74673. declare module BABYLON {
  74674. /** @hidden */
  74675. export var blurPixelShader: {
  74676. name: string;
  74677. shader: string;
  74678. };
  74679. }
  74680. declare module BABYLON {
  74681. /** @hidden */
  74682. export var pointCloudVertexDeclaration: {
  74683. name: string;
  74684. shader: string;
  74685. };
  74686. }
  74687. // Mixins
  74688. interface Window {
  74689. mozIndexedDB: IDBFactory;
  74690. webkitIndexedDB: IDBFactory;
  74691. msIndexedDB: IDBFactory;
  74692. webkitURL: typeof URL;
  74693. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  74694. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  74695. WebGLRenderingContext: WebGLRenderingContext;
  74696. MSGesture: MSGesture;
  74697. CANNON: any;
  74698. AudioContext: AudioContext;
  74699. webkitAudioContext: AudioContext;
  74700. PointerEvent: any;
  74701. Math: Math;
  74702. Uint8Array: Uint8ArrayConstructor;
  74703. Float32Array: Float32ArrayConstructor;
  74704. mozURL: typeof URL;
  74705. msURL: typeof URL;
  74706. VRFrameData: any; // WebVR, from specs 1.1
  74707. DracoDecoderModule: any;
  74708. setImmediate(handler: (...args: any[]) => void): number;
  74709. }
  74710. interface HTMLCanvasElement {
  74711. requestPointerLock(): void;
  74712. msRequestPointerLock?(): void;
  74713. mozRequestPointerLock?(): void;
  74714. webkitRequestPointerLock?(): void;
  74715. /** Track wether a record is in progress */
  74716. isRecording: boolean;
  74717. /** Capture Stream method defined by some browsers */
  74718. captureStream(fps?: number): MediaStream;
  74719. }
  74720. interface CanvasRenderingContext2D {
  74721. msImageSmoothingEnabled: boolean;
  74722. }
  74723. interface MouseEvent {
  74724. mozMovementX: number;
  74725. mozMovementY: number;
  74726. webkitMovementX: number;
  74727. webkitMovementY: number;
  74728. msMovementX: number;
  74729. msMovementY: number;
  74730. }
  74731. interface Navigator {
  74732. mozGetVRDevices: (any: any) => any;
  74733. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  74734. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  74735. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  74736. webkitGetGamepads(): Gamepad[];
  74737. msGetGamepads(): Gamepad[];
  74738. webkitGamepads(): Gamepad[];
  74739. }
  74740. interface HTMLVideoElement {
  74741. mozSrcObject: any;
  74742. }
  74743. interface Math {
  74744. fround(x: number): number;
  74745. imul(a: number, b: number): number;
  74746. }
  74747. interface WebGLRenderingContext {
  74748. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  74749. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  74750. vertexAttribDivisor(index: number, divisor: number): void;
  74751. createVertexArray(): any;
  74752. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  74753. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  74754. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  74755. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  74756. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  74757. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  74758. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  74759. // Queries
  74760. createQuery(): WebGLQuery;
  74761. deleteQuery(query: WebGLQuery): void;
  74762. beginQuery(target: number, query: WebGLQuery): void;
  74763. endQuery(target: number): void;
  74764. getQueryParameter(query: WebGLQuery, pname: number): any;
  74765. getQuery(target: number, pname: number): any;
  74766. MAX_SAMPLES: number;
  74767. RGBA8: number;
  74768. READ_FRAMEBUFFER: number;
  74769. DRAW_FRAMEBUFFER: number;
  74770. UNIFORM_BUFFER: number;
  74771. HALF_FLOAT_OES: number;
  74772. RGBA16F: number;
  74773. RGBA32F: number;
  74774. R32F: number;
  74775. RG32F: number;
  74776. RGB32F: number;
  74777. R16F: number;
  74778. RG16F: number;
  74779. RGB16F: number;
  74780. RED: number;
  74781. RG: number;
  74782. R8: number;
  74783. RG8: number;
  74784. UNSIGNED_INT_24_8: number;
  74785. DEPTH24_STENCIL8: number;
  74786. MIN: number;
  74787. MAX: number;
  74788. /* Multiple Render Targets */
  74789. drawBuffers(buffers: number[]): void;
  74790. readBuffer(src: number): void;
  74791. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  74792. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  74793. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  74794. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  74795. // Occlusion Query
  74796. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  74797. ANY_SAMPLES_PASSED: number;
  74798. QUERY_RESULT_AVAILABLE: number;
  74799. QUERY_RESULT: number;
  74800. }
  74801. interface WebGLProgram {
  74802. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  74803. }
  74804. interface EXT_disjoint_timer_query {
  74805. QUERY_COUNTER_BITS_EXT: number;
  74806. TIME_ELAPSED_EXT: number;
  74807. TIMESTAMP_EXT: number;
  74808. GPU_DISJOINT_EXT: number;
  74809. QUERY_RESULT_EXT: number;
  74810. QUERY_RESULT_AVAILABLE_EXT: number;
  74811. queryCounterEXT(query: WebGLQuery, target: number): void;
  74812. createQueryEXT(): WebGLQuery;
  74813. beginQueryEXT(target: number, query: WebGLQuery): void;
  74814. endQueryEXT(target: number): void;
  74815. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  74816. deleteQueryEXT(query: WebGLQuery): void;
  74817. }
  74818. interface WebGLUniformLocation {
  74819. _currentState: any;
  74820. }
  74821. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  74822. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  74823. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  74824. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  74825. interface WebGLRenderingContext {
  74826. readonly RASTERIZER_DISCARD: number;
  74827. readonly DEPTH_COMPONENT24: number;
  74828. readonly TEXTURE_3D: number;
  74829. readonly TEXTURE_2D_ARRAY: number;
  74830. readonly TEXTURE_COMPARE_FUNC: number;
  74831. readonly TEXTURE_COMPARE_MODE: number;
  74832. readonly COMPARE_REF_TO_TEXTURE: number;
  74833. readonly TEXTURE_WRAP_R: number;
  74834. readonly HALF_FLOAT: number;
  74835. readonly RGB8: number;
  74836. readonly RED_INTEGER: number;
  74837. readonly RG_INTEGER: number;
  74838. readonly RGB_INTEGER: number;
  74839. readonly RGBA_INTEGER: number;
  74840. readonly R8_SNORM: number;
  74841. readonly RG8_SNORM: number;
  74842. readonly RGB8_SNORM: number;
  74843. readonly RGBA8_SNORM: number;
  74844. readonly R8I: number;
  74845. readonly RG8I: number;
  74846. readonly RGB8I: number;
  74847. readonly RGBA8I: number;
  74848. readonly R8UI: number;
  74849. readonly RG8UI: number;
  74850. readonly RGB8UI: number;
  74851. readonly RGBA8UI: number;
  74852. readonly R16I: number;
  74853. readonly RG16I: number;
  74854. readonly RGB16I: number;
  74855. readonly RGBA16I: number;
  74856. readonly R16UI: number;
  74857. readonly RG16UI: number;
  74858. readonly RGB16UI: number;
  74859. readonly RGBA16UI: number;
  74860. readonly R32I: number;
  74861. readonly RG32I: number;
  74862. readonly RGB32I: number;
  74863. readonly RGBA32I: number;
  74864. readonly R32UI: number;
  74865. readonly RG32UI: number;
  74866. readonly RGB32UI: number;
  74867. readonly RGBA32UI: number;
  74868. readonly RGB10_A2UI: number;
  74869. readonly R11F_G11F_B10F: number;
  74870. readonly RGB9_E5: number;
  74871. readonly RGB10_A2: number;
  74872. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  74873. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  74874. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  74875. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  74876. readonly DEPTH_COMPONENT32F: number;
  74877. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  74878. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  74879. 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;
  74880. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  74881. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  74882. readonly TRANSFORM_FEEDBACK: number;
  74883. readonly INTERLEAVED_ATTRIBS: number;
  74884. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  74885. createTransformFeedback(): WebGLTransformFeedback;
  74886. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  74887. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  74888. beginTransformFeedback(primitiveMode: number): void;
  74889. endTransformFeedback(): void;
  74890. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  74891. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  74892. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  74893. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  74894. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  74895. }
  74896. interface ImageBitmap {
  74897. readonly width: number;
  74898. readonly height: number;
  74899. close(): void;
  74900. }
  74901. interface WebGLQuery extends WebGLObject {
  74902. }
  74903. declare var WebGLQuery: {
  74904. prototype: WebGLQuery;
  74905. new(): WebGLQuery;
  74906. };
  74907. interface WebGLSampler extends WebGLObject {
  74908. }
  74909. declare var WebGLSampler: {
  74910. prototype: WebGLSampler;
  74911. new(): WebGLSampler;
  74912. };
  74913. interface WebGLSync extends WebGLObject {
  74914. }
  74915. declare var WebGLSync: {
  74916. prototype: WebGLSync;
  74917. new(): WebGLSync;
  74918. };
  74919. interface WebGLTransformFeedback extends WebGLObject {
  74920. }
  74921. declare var WebGLTransformFeedback: {
  74922. prototype: WebGLTransformFeedback;
  74923. new(): WebGLTransformFeedback;
  74924. };
  74925. interface WebGLVertexArrayObject extends WebGLObject {
  74926. }
  74927. declare var WebGLVertexArrayObject: {
  74928. prototype: WebGLVertexArrayObject;
  74929. new(): WebGLVertexArrayObject;
  74930. };
  74931. // Type definitions for WebVR API
  74932. // Project: https://w3c.github.io/webvr/
  74933. // Definitions by: six a <https://github.com/lostfictions>
  74934. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  74935. interface VRDisplay extends EventTarget {
  74936. /**
  74937. * Dictionary of capabilities describing the VRDisplay.
  74938. */
  74939. readonly capabilities: VRDisplayCapabilities;
  74940. /**
  74941. * z-depth defining the far plane of the eye view frustum
  74942. * enables mapping of values in the render target depth
  74943. * attachment to scene coordinates. Initially set to 10000.0.
  74944. */
  74945. depthFar: number;
  74946. /**
  74947. * z-depth defining the near plane of the eye view frustum
  74948. * enables mapping of values in the render target depth
  74949. * attachment to scene coordinates. Initially set to 0.01.
  74950. */
  74951. depthNear: number;
  74952. /**
  74953. * An identifier for this distinct VRDisplay. Used as an
  74954. * association point in the Gamepad API.
  74955. */
  74956. readonly displayId: number;
  74957. /**
  74958. * A display name, a user-readable name identifying it.
  74959. */
  74960. readonly displayName: string;
  74961. readonly isConnected: boolean;
  74962. readonly isPresenting: boolean;
  74963. /**
  74964. * If this VRDisplay supports room-scale experiences, the optional
  74965. * stage attribute contains details on the room-scale parameters.
  74966. */
  74967. readonly stageParameters: VRStageParameters | null;
  74968. /**
  74969. * Passing the value returned by `requestAnimationFrame` to
  74970. * `cancelAnimationFrame` will unregister the callback.
  74971. * @param handle Define the hanle of the request to cancel
  74972. */
  74973. cancelAnimationFrame(handle: number): void;
  74974. /**
  74975. * Stops presenting to the VRDisplay.
  74976. * @returns a promise to know when it stopped
  74977. */
  74978. exitPresent(): Promise<void>;
  74979. /**
  74980. * Return the current VREyeParameters for the given eye.
  74981. * @param whichEye Define the eye we want the parameter for
  74982. * @returns the eye parameters
  74983. */
  74984. getEyeParameters(whichEye: string): VREyeParameters;
  74985. /**
  74986. * Populates the passed VRFrameData with the information required to render
  74987. * the current frame.
  74988. * @param frameData Define the data structure to populate
  74989. * @returns true if ok otherwise false
  74990. */
  74991. getFrameData(frameData: VRFrameData): boolean;
  74992. /**
  74993. * Get the layers currently being presented.
  74994. * @returns the list of VR layers
  74995. */
  74996. getLayers(): VRLayer[];
  74997. /**
  74998. * Return a VRPose containing the future predicted pose of the VRDisplay
  74999. * when the current frame will be presented. The value returned will not
  75000. * change until JavaScript has returned control to the browser.
  75001. *
  75002. * The VRPose will contain the position, orientation, velocity,
  75003. * and acceleration of each of these properties.
  75004. * @returns the pose object
  75005. */
  75006. getPose(): VRPose;
  75007. /**
  75008. * Return the current instantaneous pose of the VRDisplay, with no
  75009. * prediction applied.
  75010. * @returns the current instantaneous pose
  75011. */
  75012. getImmediatePose(): VRPose;
  75013. /**
  75014. * The callback passed to `requestAnimationFrame` will be called
  75015. * any time a new frame should be rendered. When the VRDisplay is
  75016. * presenting the callback will be called at the native refresh
  75017. * rate of the HMD. When not presenting this function acts
  75018. * identically to how window.requestAnimationFrame acts. Content should
  75019. * make no assumptions of frame rate or vsync behavior as the HMD runs
  75020. * asynchronously from other displays and at differing refresh rates.
  75021. * @param callback Define the eaction to run next frame
  75022. * @returns the request handle it
  75023. */
  75024. requestAnimationFrame(callback: FrameRequestCallback): number;
  75025. /**
  75026. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  75027. * Repeat calls while already presenting will update the VRLayers being displayed.
  75028. * @param layers Define the list of layer to present
  75029. * @returns a promise to know when the request has been fulfilled
  75030. */
  75031. requestPresent(layers: VRLayer[]): Promise<void>;
  75032. /**
  75033. * Reset the pose for this display, treating its current position and
  75034. * orientation as the "origin/zero" values. VRPose.position,
  75035. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  75036. * updated when calling resetPose(). This should be called in only
  75037. * sitting-space experiences.
  75038. */
  75039. resetPose(): void;
  75040. /**
  75041. * The VRLayer provided to the VRDisplay will be captured and presented
  75042. * in the HMD. Calling this function has the same effect on the source
  75043. * canvas as any other operation that uses its source image, and canvases
  75044. * created without preserveDrawingBuffer set to true will be cleared.
  75045. * @param pose Define the pose to submit
  75046. */
  75047. submitFrame(pose?: VRPose): void;
  75048. }
  75049. declare var VRDisplay: {
  75050. prototype: VRDisplay;
  75051. new(): VRDisplay;
  75052. };
  75053. interface VRLayer {
  75054. leftBounds?: number[] | Float32Array | null;
  75055. rightBounds?: number[] | Float32Array | null;
  75056. source?: HTMLCanvasElement | null;
  75057. }
  75058. interface VRDisplayCapabilities {
  75059. readonly canPresent: boolean;
  75060. readonly hasExternalDisplay: boolean;
  75061. readonly hasOrientation: boolean;
  75062. readonly hasPosition: boolean;
  75063. readonly maxLayers: number;
  75064. }
  75065. interface VREyeParameters {
  75066. /** @deprecated */
  75067. readonly fieldOfView: VRFieldOfView;
  75068. readonly offset: Float32Array;
  75069. readonly renderHeight: number;
  75070. readonly renderWidth: number;
  75071. }
  75072. interface VRFieldOfView {
  75073. readonly downDegrees: number;
  75074. readonly leftDegrees: number;
  75075. readonly rightDegrees: number;
  75076. readonly upDegrees: number;
  75077. }
  75078. interface VRFrameData {
  75079. readonly leftProjectionMatrix: Float32Array;
  75080. readonly leftViewMatrix: Float32Array;
  75081. readonly pose: VRPose;
  75082. readonly rightProjectionMatrix: Float32Array;
  75083. readonly rightViewMatrix: Float32Array;
  75084. readonly timestamp: number;
  75085. }
  75086. interface VRPose {
  75087. readonly angularAcceleration: Float32Array | null;
  75088. readonly angularVelocity: Float32Array | null;
  75089. readonly linearAcceleration: Float32Array | null;
  75090. readonly linearVelocity: Float32Array | null;
  75091. readonly orientation: Float32Array | null;
  75092. readonly position: Float32Array | null;
  75093. readonly timestamp: number;
  75094. }
  75095. interface VRStageParameters {
  75096. sittingToStandingTransform?: Float32Array;
  75097. sizeX?: number;
  75098. sizeY?: number;
  75099. }
  75100. interface Navigator {
  75101. getVRDisplays(): Promise<VRDisplay[]>;
  75102. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  75103. }
  75104. interface Window {
  75105. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  75106. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  75107. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  75108. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  75109. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  75110. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  75111. }
  75112. interface Gamepad {
  75113. readonly displayId: number;
  75114. }
  75115. type XRSessionMode =
  75116. | "inline"
  75117. | "immersive-vr"
  75118. | "immersive-ar";
  75119. type XRReferenceSpaceType =
  75120. | "viewer"
  75121. | "local"
  75122. | "local-floor"
  75123. | "bounded-floor"
  75124. | "unbounded";
  75125. type XREnvironmentBlendMode =
  75126. | "opaque"
  75127. | "additive"
  75128. | "alpha-blend";
  75129. type XRVisibilityState =
  75130. | "visible"
  75131. | "visible-blurred"
  75132. | "hidden";
  75133. type XRHandedness =
  75134. | "none"
  75135. | "left"
  75136. | "right";
  75137. type XRTargetRayMode =
  75138. | "gaze"
  75139. | "tracked-pointer"
  75140. | "screen";
  75141. type XREye =
  75142. | "none"
  75143. | "left"
  75144. | "right";
  75145. type XREventType =
  75146. | "devicechange"
  75147. | "visibilitychange"
  75148. | "end"
  75149. | "inputsourceschange"
  75150. | "select"
  75151. | "selectstart"
  75152. | "selectend"
  75153. | "squeeze"
  75154. | "squeezestart"
  75155. | "squeezeend"
  75156. | "reset";
  75157. interface XRSpace extends EventTarget {
  75158. }
  75159. interface XRRenderState {
  75160. depthNear?: number;
  75161. depthFar?: number;
  75162. inlineVerticalFieldOfView?: number;
  75163. baseLayer?: XRWebGLLayer;
  75164. }
  75165. interface XRInputSource {
  75166. handedness: XRHandedness;
  75167. targetRayMode: XRTargetRayMode;
  75168. targetRaySpace: XRSpace;
  75169. gripSpace: XRSpace | undefined;
  75170. gamepad: Gamepad | undefined;
  75171. profiles: Array<string>;
  75172. }
  75173. interface XRSessionInit {
  75174. optionalFeatures?: string[];
  75175. requiredFeatures?: string[];
  75176. }
  75177. interface XRSession {
  75178. addEventListener: Function;
  75179. removeEventListener: Function;
  75180. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  75181. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  75182. requestAnimationFrame: Function;
  75183. end(): Promise<void>;
  75184. renderState: XRRenderState;
  75185. inputSources: Array<XRInputSource>;
  75186. // hit test
  75187. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  75188. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  75189. // legacy AR hit test
  75190. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  75191. // legacy plane detection
  75192. updateWorldTrackingState(options: {
  75193. planeDetectionState?: { enabled: boolean; }
  75194. }): void;
  75195. }
  75196. interface XRReferenceSpace extends XRSpace {
  75197. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  75198. onreset: any;
  75199. }
  75200. type XRPlaneSet = Set<XRPlane>;
  75201. type XRAnchorSet = Set<XRAnchor>;
  75202. interface XRFrame {
  75203. session: XRSession;
  75204. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  75205. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  75206. // AR
  75207. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  75208. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  75209. // Anchors
  75210. trackedAnchors?: XRAnchorSet;
  75211. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  75212. // Planes
  75213. worldInformation: {
  75214. detectedPlanes?: XRPlaneSet;
  75215. };
  75216. }
  75217. interface XRViewerPose extends XRPose {
  75218. views: Array<XRView>;
  75219. }
  75220. interface XRPose {
  75221. transform: XRRigidTransform;
  75222. emulatedPosition: boolean;
  75223. }
  75224. interface XRWebGLLayerOptions {
  75225. antialias?: boolean;
  75226. depth?: boolean;
  75227. stencil?: boolean;
  75228. alpha?: boolean;
  75229. multiview?: boolean;
  75230. framebufferScaleFactor?: number;
  75231. }
  75232. declare var XRWebGLLayer: {
  75233. prototype: XRWebGLLayer;
  75234. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  75235. };
  75236. interface XRWebGLLayer {
  75237. framebuffer: WebGLFramebuffer;
  75238. framebufferWidth: number;
  75239. framebufferHeight: number;
  75240. getViewport: Function;
  75241. }
  75242. declare class XRRigidTransform {
  75243. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  75244. position: DOMPointReadOnly;
  75245. orientation: DOMPointReadOnly;
  75246. matrix: Float32Array;
  75247. inverse: XRRigidTransform;
  75248. }
  75249. interface XRView {
  75250. eye: XREye;
  75251. projectionMatrix: Float32Array;
  75252. transform: XRRigidTransform;
  75253. }
  75254. interface XRInputSourceChangeEvent {
  75255. session: XRSession;
  75256. removed: Array<XRInputSource>;
  75257. added: Array<XRInputSource>;
  75258. }
  75259. interface XRInputSourceEvent extends Event {
  75260. readonly frame: XRFrame;
  75261. readonly inputSource: XRInputSource;
  75262. }
  75263. // Experimental(er) features
  75264. declare class XRRay {
  75265. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  75266. origin: DOMPointReadOnly;
  75267. direction: DOMPointReadOnly;
  75268. matrix: Float32Array;
  75269. }
  75270. declare enum XRHitTestTrackableType {
  75271. "point",
  75272. "plane"
  75273. }
  75274. interface XRHitResult {
  75275. hitMatrix: Float32Array;
  75276. }
  75277. interface XRTransientInputHitTestResult {
  75278. readonly inputSource: XRInputSource;
  75279. readonly results: Array<XRHitTestResult>;
  75280. }
  75281. interface XRHitTestResult {
  75282. getPose(baseSpace: XRSpace): XRPose | undefined;
  75283. // When anchor system is enabled
  75284. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  75285. }
  75286. interface XRHitTestSource {
  75287. cancel(): void;
  75288. }
  75289. interface XRTransientInputHitTestSource {
  75290. cancel(): void;
  75291. }
  75292. interface XRHitTestOptionsInit {
  75293. space: XRSpace;
  75294. entityTypes?: Array<XRHitTestTrackableType>;
  75295. offsetRay?: XRRay;
  75296. }
  75297. interface XRTransientInputHitTestOptionsInit {
  75298. profile: string;
  75299. entityTypes?: Array<XRHitTestTrackableType>;
  75300. offsetRay?: XRRay;
  75301. }
  75302. interface XRAnchor {
  75303. anchorSpace: XRSpace;
  75304. delete(): void;
  75305. }
  75306. interface XRPlane {
  75307. orientation: "Horizontal" | "Vertical";
  75308. planeSpace: XRSpace;
  75309. polygon: Array<DOMPointReadOnly>;
  75310. lastChangedTime: number;
  75311. }
  75312. /**
  75313. * @ignore
  75314. */
  75315. declare module BABYLON.GLTF2.Exporter {
  75316. }
  75317. /**
  75318. * @ignore
  75319. */
  75320. declare module BABYLON.GLTF1 {
  75321. }
  75322. declare module BABYLON.GUI {
  75323. /**
  75324. * Class used to specific a value and its associated unit
  75325. */
  75326. export class ValueAndUnit {
  75327. /** defines the unit to store */
  75328. unit: number;
  75329. /** defines a boolean indicating if the value can be negative */
  75330. negativeValueAllowed: boolean;
  75331. private _value;
  75332. private _originalUnit;
  75333. /**
  75334. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  75335. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75336. */
  75337. ignoreAdaptiveScaling: boolean;
  75338. /**
  75339. * Creates a new ValueAndUnit
  75340. * @param value defines the value to store
  75341. * @param unit defines the unit to store
  75342. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  75343. */
  75344. constructor(value: number,
  75345. /** defines the unit to store */
  75346. unit?: number,
  75347. /** defines a boolean indicating if the value can be negative */
  75348. negativeValueAllowed?: boolean);
  75349. /** Gets a boolean indicating if the value is a percentage */
  75350. get isPercentage(): boolean;
  75351. /** Gets a boolean indicating if the value is store as pixel */
  75352. get isPixel(): boolean;
  75353. /** Gets direct internal value */
  75354. get internalValue(): number;
  75355. /**
  75356. * Gets value as pixel
  75357. * @param host defines the root host
  75358. * @param refValue defines the reference value for percentages
  75359. * @returns the value as pixel
  75360. */
  75361. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  75362. /**
  75363. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  75364. * @param value defines the value to store
  75365. * @param unit defines the unit to store
  75366. * @returns the current ValueAndUnit
  75367. */
  75368. updateInPlace(value: number, unit?: number): ValueAndUnit;
  75369. /**
  75370. * Gets the value accordingly to its unit
  75371. * @param host defines the root host
  75372. * @returns the value
  75373. */
  75374. getValue(host: AdvancedDynamicTexture): number;
  75375. /**
  75376. * Gets a string representation of the value
  75377. * @param host defines the root host
  75378. * @param decimals defines an optional number of decimals to display
  75379. * @returns a string
  75380. */
  75381. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  75382. /**
  75383. * Store a value parsed from a string
  75384. * @param source defines the source string
  75385. * @returns true if the value was successfully parsed
  75386. */
  75387. fromString(source: string | number): boolean;
  75388. private static _Regex;
  75389. private static _UNITMODE_PERCENTAGE;
  75390. private static _UNITMODE_PIXEL;
  75391. /** UNITMODE_PERCENTAGE */
  75392. static get UNITMODE_PERCENTAGE(): number;
  75393. /** UNITMODE_PIXEL */
  75394. static get UNITMODE_PIXEL(): number;
  75395. }
  75396. }
  75397. declare module BABYLON.GUI {
  75398. /**
  75399. * Define a style used by control to automatically setup properties based on a template.
  75400. * Only support font related properties so far
  75401. */
  75402. export class Style implements BABYLON.IDisposable {
  75403. private _fontFamily;
  75404. private _fontStyle;
  75405. private _fontWeight;
  75406. /** @hidden */
  75407. _host: AdvancedDynamicTexture;
  75408. /** @hidden */
  75409. _fontSize: ValueAndUnit;
  75410. /**
  75411. * BABYLON.Observable raised when the style values are changed
  75412. */
  75413. onChangedObservable: BABYLON.Observable<Style>;
  75414. /**
  75415. * Creates a new style object
  75416. * @param host defines the AdvancedDynamicTexture which hosts this style
  75417. */
  75418. constructor(host: AdvancedDynamicTexture);
  75419. /**
  75420. * Gets or sets the font size
  75421. */
  75422. get fontSize(): string | number;
  75423. set fontSize(value: string | number);
  75424. /**
  75425. * Gets or sets the font family
  75426. */
  75427. get fontFamily(): string;
  75428. set fontFamily(value: string);
  75429. /**
  75430. * Gets or sets the font style
  75431. */
  75432. get fontStyle(): string;
  75433. set fontStyle(value: string);
  75434. /** Gets or sets font weight */
  75435. get fontWeight(): string;
  75436. set fontWeight(value: string);
  75437. /** Dispose all associated resources */
  75438. dispose(): void;
  75439. }
  75440. }
  75441. declare module BABYLON.GUI {
  75442. /**
  75443. * Class used to transport BABYLON.Vector2 information for pointer events
  75444. */
  75445. export class Vector2WithInfo extends BABYLON.Vector2 {
  75446. /** defines the current mouse button index */
  75447. buttonIndex: number;
  75448. /**
  75449. * Creates a new Vector2WithInfo
  75450. * @param source defines the vector2 data to transport
  75451. * @param buttonIndex defines the current mouse button index
  75452. */
  75453. constructor(source: BABYLON.Vector2,
  75454. /** defines the current mouse button index */
  75455. buttonIndex?: number);
  75456. }
  75457. /** Class used to provide 2D matrix features */
  75458. export class Matrix2D {
  75459. /** Gets the internal array of 6 floats used to store matrix data */
  75460. m: Float32Array;
  75461. /**
  75462. * Creates a new matrix
  75463. * @param m00 defines value for (0, 0)
  75464. * @param m01 defines value for (0, 1)
  75465. * @param m10 defines value for (1, 0)
  75466. * @param m11 defines value for (1, 1)
  75467. * @param m20 defines value for (2, 0)
  75468. * @param m21 defines value for (2, 1)
  75469. */
  75470. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  75471. /**
  75472. * Fills the matrix from direct values
  75473. * @param m00 defines value for (0, 0)
  75474. * @param m01 defines value for (0, 1)
  75475. * @param m10 defines value for (1, 0)
  75476. * @param m11 defines value for (1, 1)
  75477. * @param m20 defines value for (2, 0)
  75478. * @param m21 defines value for (2, 1)
  75479. * @returns the current modified matrix
  75480. */
  75481. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  75482. /**
  75483. * Gets matrix determinant
  75484. * @returns the determinant
  75485. */
  75486. determinant(): number;
  75487. /**
  75488. * Inverses the matrix and stores it in a target matrix
  75489. * @param result defines the target matrix
  75490. * @returns the current matrix
  75491. */
  75492. invertToRef(result: Matrix2D): Matrix2D;
  75493. /**
  75494. * Multiplies the current matrix with another one
  75495. * @param other defines the second operand
  75496. * @param result defines the target matrix
  75497. * @returns the current matrix
  75498. */
  75499. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  75500. /**
  75501. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  75502. * @param x defines the x coordinate to transform
  75503. * @param y defines the x coordinate to transform
  75504. * @param result defines the target vector2
  75505. * @returns the current matrix
  75506. */
  75507. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  75508. /**
  75509. * Creates an identity matrix
  75510. * @returns a new matrix
  75511. */
  75512. static Identity(): Matrix2D;
  75513. /**
  75514. * Creates a translation matrix and stores it in a target matrix
  75515. * @param x defines the x coordinate of the translation
  75516. * @param y defines the y coordinate of the translation
  75517. * @param result defines the target matrix
  75518. */
  75519. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  75520. /**
  75521. * Creates a scaling matrix and stores it in a target matrix
  75522. * @param x defines the x coordinate of the scaling
  75523. * @param y defines the y coordinate of the scaling
  75524. * @param result defines the target matrix
  75525. */
  75526. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  75527. /**
  75528. * Creates a rotation matrix and stores it in a target matrix
  75529. * @param angle defines the rotation angle
  75530. * @param result defines the target matrix
  75531. */
  75532. static RotationToRef(angle: number, result: Matrix2D): void;
  75533. private static _TempPreTranslationMatrix;
  75534. private static _TempPostTranslationMatrix;
  75535. private static _TempRotationMatrix;
  75536. private static _TempScalingMatrix;
  75537. private static _TempCompose0;
  75538. private static _TempCompose1;
  75539. private static _TempCompose2;
  75540. /**
  75541. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  75542. * @param tx defines the x coordinate of the translation
  75543. * @param ty defines the y coordinate of the translation
  75544. * @param angle defines the rotation angle
  75545. * @param scaleX defines the x coordinate of the scaling
  75546. * @param scaleY defines the y coordinate of the scaling
  75547. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  75548. * @param result defines the target matrix
  75549. */
  75550. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  75551. }
  75552. }
  75553. declare module BABYLON.GUI {
  75554. /**
  75555. * Class used to store 2D control sizes
  75556. */
  75557. export class Measure {
  75558. /** defines left coordinate */
  75559. left: number;
  75560. /** defines top coordinate */
  75561. top: number;
  75562. /** defines width dimension */
  75563. width: number;
  75564. /** defines height dimension */
  75565. height: number;
  75566. /**
  75567. * Creates a new measure
  75568. * @param left defines left coordinate
  75569. * @param top defines top coordinate
  75570. * @param width defines width dimension
  75571. * @param height defines height dimension
  75572. */
  75573. constructor(
  75574. /** defines left coordinate */
  75575. left: number,
  75576. /** defines top coordinate */
  75577. top: number,
  75578. /** defines width dimension */
  75579. width: number,
  75580. /** defines height dimension */
  75581. height: number);
  75582. /**
  75583. * Copy from another measure
  75584. * @param other defines the other measure to copy from
  75585. */
  75586. copyFrom(other: Measure): void;
  75587. /**
  75588. * Copy from a group of 4 floats
  75589. * @param left defines left coordinate
  75590. * @param top defines top coordinate
  75591. * @param width defines width dimension
  75592. * @param height defines height dimension
  75593. */
  75594. copyFromFloats(left: number, top: number, width: number, height: number): void;
  75595. /**
  75596. * Computes the axis aligned bounding box measure for two given measures
  75597. * @param a Input measure
  75598. * @param b Input measure
  75599. * @param result the resulting bounding measure
  75600. */
  75601. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  75602. /**
  75603. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  75604. * @param transform the matrix to transform the measure before computing the AABB
  75605. * @param result the resulting AABB
  75606. */
  75607. transformToRef(transform: Matrix2D, result: Measure): void;
  75608. /**
  75609. * Check equality between this measure and another one
  75610. * @param other defines the other measures
  75611. * @returns true if both measures are equals
  75612. */
  75613. isEqualsTo(other: Measure): boolean;
  75614. /**
  75615. * Creates an empty measure
  75616. * @returns a new measure
  75617. */
  75618. static Empty(): Measure;
  75619. }
  75620. }
  75621. declare module BABYLON.GUI {
  75622. /**
  75623. * Interface used to define a control that can receive focus
  75624. */
  75625. export interface IFocusableControl {
  75626. /**
  75627. * Function called when the control receives the focus
  75628. */
  75629. onFocus(): void;
  75630. /**
  75631. * Function called when the control loses the focus
  75632. */
  75633. onBlur(): void;
  75634. /**
  75635. * Function called to let the control handle keyboard events
  75636. * @param evt defines the current keyboard event
  75637. */
  75638. processKeyboard(evt: KeyboardEvent): void;
  75639. /**
  75640. * Function called to get the list of controls that should not steal the focus from this control
  75641. * @returns an array of controls
  75642. */
  75643. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  75644. }
  75645. /**
  75646. * Class used to create texture to support 2D GUI elements
  75647. * @see https://doc.babylonjs.com/how_to/gui
  75648. */
  75649. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  75650. private _isDirty;
  75651. private _renderObserver;
  75652. private _resizeObserver;
  75653. private _preKeyboardObserver;
  75654. private _pointerMoveObserver;
  75655. private _pointerObserver;
  75656. private _canvasPointerOutObserver;
  75657. private _background;
  75658. /** @hidden */
  75659. _rootContainer: Container;
  75660. /** @hidden */
  75661. _lastPickedControl: Control;
  75662. /** @hidden */
  75663. _lastControlOver: {
  75664. [pointerId: number]: Control;
  75665. };
  75666. /** @hidden */
  75667. _lastControlDown: {
  75668. [pointerId: number]: Control;
  75669. };
  75670. /** @hidden */
  75671. _capturingControl: {
  75672. [pointerId: number]: Control;
  75673. };
  75674. /** @hidden */
  75675. _shouldBlockPointer: boolean;
  75676. /** @hidden */
  75677. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  75678. /** @hidden */
  75679. _linkedControls: Control[];
  75680. private _isFullscreen;
  75681. private _fullscreenViewport;
  75682. private _idealWidth;
  75683. private _idealHeight;
  75684. private _useSmallestIdeal;
  75685. private _renderAtIdealSize;
  75686. private _focusedControl;
  75687. private _blockNextFocusCheck;
  75688. private _renderScale;
  75689. private _rootElement;
  75690. private _cursorChanged;
  75691. private _defaultMousePointerId;
  75692. /** @hidden */
  75693. _numLayoutCalls: number;
  75694. /** Gets the number of layout calls made the last time the ADT has been rendered */
  75695. get numLayoutCalls(): number;
  75696. /** @hidden */
  75697. _numRenderCalls: number;
  75698. /** Gets the number of render calls made the last time the ADT has been rendered */
  75699. get numRenderCalls(): number;
  75700. /**
  75701. * Define type to string to ensure compatibility across browsers
  75702. * Safari doesn't support DataTransfer constructor
  75703. */
  75704. private _clipboardData;
  75705. /**
  75706. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  75707. */
  75708. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  75709. /**
  75710. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  75711. */
  75712. onControlPickedObservable: BABYLON.Observable<Control>;
  75713. /**
  75714. * BABYLON.Observable event triggered before layout is evaluated
  75715. */
  75716. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75717. /**
  75718. * BABYLON.Observable event triggered after the layout was evaluated
  75719. */
  75720. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75721. /**
  75722. * BABYLON.Observable event triggered before the texture is rendered
  75723. */
  75724. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75725. /**
  75726. * BABYLON.Observable event triggered after the texture was rendered
  75727. */
  75728. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75729. /**
  75730. * Gets or sets a boolean defining if alpha is stored as premultiplied
  75731. */
  75732. premulAlpha: boolean;
  75733. /**
  75734. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  75735. * Useful when you want more antialiasing
  75736. */
  75737. get renderScale(): number;
  75738. set renderScale(value: number);
  75739. /** Gets or sets the background color */
  75740. get background(): string;
  75741. set background(value: string);
  75742. /**
  75743. * Gets or sets the ideal width used to design controls.
  75744. * The GUI will then rescale everything accordingly
  75745. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75746. */
  75747. get idealWidth(): number;
  75748. set idealWidth(value: number);
  75749. /**
  75750. * Gets or sets the ideal height used to design controls.
  75751. * The GUI will then rescale everything accordingly
  75752. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75753. */
  75754. get idealHeight(): number;
  75755. set idealHeight(value: number);
  75756. /**
  75757. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  75758. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75759. */
  75760. get useSmallestIdeal(): boolean;
  75761. set useSmallestIdeal(value: boolean);
  75762. /**
  75763. * Gets or sets a boolean indicating if adaptive scaling must be used
  75764. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75765. */
  75766. get renderAtIdealSize(): boolean;
  75767. set renderAtIdealSize(value: boolean);
  75768. /**
  75769. * Gets the ratio used when in "ideal mode"
  75770. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75771. * */
  75772. get idealRatio(): number;
  75773. /**
  75774. * Gets the underlying layer used to render the texture when in fullscreen mode
  75775. */
  75776. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  75777. /**
  75778. * Gets the root container control
  75779. */
  75780. get rootContainer(): Container;
  75781. /**
  75782. * Returns an array containing the root container.
  75783. * This is mostly used to let the Inspector introspects the ADT
  75784. * @returns an array containing the rootContainer
  75785. */
  75786. getChildren(): Array<Container>;
  75787. /**
  75788. * Will return all controls that are inside this texture
  75789. * @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
  75790. * @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
  75791. * @return all child controls
  75792. */
  75793. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  75794. /**
  75795. * Gets or sets the current focused control
  75796. */
  75797. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  75798. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  75799. /**
  75800. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  75801. */
  75802. get isForeground(): boolean;
  75803. set isForeground(value: boolean);
  75804. /**
  75805. * Gets or set information about clipboardData
  75806. */
  75807. get clipboardData(): string;
  75808. set clipboardData(value: string);
  75809. /**
  75810. * Creates a new AdvancedDynamicTexture
  75811. * @param name defines the name of the texture
  75812. * @param width defines the width of the texture
  75813. * @param height defines the height of the texture
  75814. * @param scene defines the hosting scene
  75815. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  75816. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  75817. */
  75818. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  75819. /**
  75820. * Get the current class name of the texture useful for serialization or dynamic coding.
  75821. * @returns "AdvancedDynamicTexture"
  75822. */
  75823. getClassName(): string;
  75824. /**
  75825. * Function used to execute a function on all controls
  75826. * @param func defines the function to execute
  75827. * @param container defines the container where controls belong. If null the root container will be used
  75828. */
  75829. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  75830. private _useInvalidateRectOptimization;
  75831. /**
  75832. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  75833. */
  75834. get useInvalidateRectOptimization(): boolean;
  75835. set useInvalidateRectOptimization(value: boolean);
  75836. private _invalidatedRectangle;
  75837. /**
  75838. * Invalidates a rectangle area on the gui texture
  75839. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  75840. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  75841. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  75842. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  75843. */
  75844. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  75845. /**
  75846. * Marks the texture as dirty forcing a complete update
  75847. */
  75848. markAsDirty(): void;
  75849. /**
  75850. * Helper function used to create a new style
  75851. * @returns a new style
  75852. * @see https://doc.babylonjs.com/how_to/gui#styles
  75853. */
  75854. createStyle(): Style;
  75855. /**
  75856. * Adds a new control to the root container
  75857. * @param control defines the control to add
  75858. * @returns the current texture
  75859. */
  75860. addControl(control: Control): AdvancedDynamicTexture;
  75861. /**
  75862. * Removes a control from the root container
  75863. * @param control defines the control to remove
  75864. * @returns the current texture
  75865. */
  75866. removeControl(control: Control): AdvancedDynamicTexture;
  75867. /**
  75868. * Release all resources
  75869. */
  75870. dispose(): void;
  75871. private _onResize;
  75872. /** @hidden */
  75873. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  75874. /**
  75875. * Get screen coordinates for a vector3
  75876. * @param position defines the position to project
  75877. * @param worldMatrix defines the world matrix to use
  75878. * @returns the projected position
  75879. */
  75880. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  75881. private _checkUpdate;
  75882. private _clearMeasure;
  75883. private _render;
  75884. /** @hidden */
  75885. _changeCursor(cursor: string): void;
  75886. /** @hidden */
  75887. _registerLastControlDown(control: Control, pointerId: number): void;
  75888. private _doPicking;
  75889. /** @hidden */
  75890. _cleanControlAfterRemovalFromList(list: {
  75891. [pointerId: number]: Control;
  75892. }, control: Control): void;
  75893. /** @hidden */
  75894. _cleanControlAfterRemoval(control: Control): void;
  75895. /** Attach to all scene events required to support pointer events */
  75896. attach(): void;
  75897. /** @hidden */
  75898. private onClipboardCopy;
  75899. /** @hidden */
  75900. private onClipboardCut;
  75901. /** @hidden */
  75902. private onClipboardPaste;
  75903. /**
  75904. * Register the clipboard Events onto the canvas
  75905. */
  75906. registerClipboardEvents(): void;
  75907. /**
  75908. * Unregister the clipboard Events from the canvas
  75909. */
  75910. unRegisterClipboardEvents(): void;
  75911. /**
  75912. * Connect the texture to a hosting mesh to enable interactions
  75913. * @param mesh defines the mesh to attach to
  75914. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  75915. */
  75916. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  75917. /**
  75918. * Move the focus to a specific control
  75919. * @param control defines the control which will receive the focus
  75920. */
  75921. moveFocusToControl(control: IFocusableControl): void;
  75922. private _manageFocus;
  75923. private _attachToOnPointerOut;
  75924. /**
  75925. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  75926. * @param mesh defines the mesh which will receive the texture
  75927. * @param width defines the texture width (1024 by default)
  75928. * @param height defines the texture height (1024 by default)
  75929. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  75930. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  75931. * @returns a new AdvancedDynamicTexture
  75932. */
  75933. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  75934. /**
  75935. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  75936. * In this mode the texture will rely on a layer for its rendering.
  75937. * This allows it to be treated like any other layer.
  75938. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  75939. * LayerMask is set through advancedTexture.layer.layerMask
  75940. * @param name defines name for the texture
  75941. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  75942. * @param scene defines the hsoting scene
  75943. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  75944. * @returns a new AdvancedDynamicTexture
  75945. */
  75946. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  75947. }
  75948. }
  75949. declare module BABYLON.GUI {
  75950. /**
  75951. * Root class used for all 2D controls
  75952. * @see https://doc.babylonjs.com/how_to/gui#controls
  75953. */
  75954. export class Control {
  75955. /** defines the name of the control */
  75956. name?: string | undefined;
  75957. /**
  75958. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  75959. */
  75960. static AllowAlphaInheritance: boolean;
  75961. private _alpha;
  75962. private _alphaSet;
  75963. private _zIndex;
  75964. /** @hidden */
  75965. _host: AdvancedDynamicTexture;
  75966. /** Gets or sets the control parent */
  75967. parent: BABYLON.Nullable<Container>;
  75968. /** @hidden */
  75969. _currentMeasure: Measure;
  75970. private _fontFamily;
  75971. private _fontStyle;
  75972. private _fontWeight;
  75973. private _fontSize;
  75974. private _font;
  75975. /** @hidden */
  75976. _width: ValueAndUnit;
  75977. /** @hidden */
  75978. _height: ValueAndUnit;
  75979. /** @hidden */
  75980. protected _fontOffset: {
  75981. ascent: number;
  75982. height: number;
  75983. descent: number;
  75984. };
  75985. private _color;
  75986. private _style;
  75987. private _styleObserver;
  75988. /** @hidden */
  75989. protected _horizontalAlignment: number;
  75990. /** @hidden */
  75991. protected _verticalAlignment: number;
  75992. /** @hidden */
  75993. protected _isDirty: boolean;
  75994. /** @hidden */
  75995. protected _wasDirty: boolean;
  75996. /** @hidden */
  75997. _tempParentMeasure: Measure;
  75998. /** @hidden */
  75999. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  76000. /** @hidden */
  76001. protected _cachedParentMeasure: Measure;
  76002. private _paddingLeft;
  76003. private _paddingRight;
  76004. private _paddingTop;
  76005. private _paddingBottom;
  76006. /** @hidden */
  76007. _left: ValueAndUnit;
  76008. /** @hidden */
  76009. _top: ValueAndUnit;
  76010. private _scaleX;
  76011. private _scaleY;
  76012. private _rotation;
  76013. private _transformCenterX;
  76014. private _transformCenterY;
  76015. /** @hidden */
  76016. _transformMatrix: Matrix2D;
  76017. /** @hidden */
  76018. protected _invertTransformMatrix: Matrix2D;
  76019. /** @hidden */
  76020. protected _transformedPosition: BABYLON.Vector2;
  76021. private _isMatrixDirty;
  76022. private _cachedOffsetX;
  76023. private _cachedOffsetY;
  76024. private _isVisible;
  76025. private _isHighlighted;
  76026. /** @hidden */
  76027. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  76028. private _fontSet;
  76029. private _dummyVector2;
  76030. private _downCount;
  76031. private _enterCount;
  76032. private _doNotRender;
  76033. private _downPointerIds;
  76034. protected _isEnabled: boolean;
  76035. protected _disabledColor: string;
  76036. protected _disabledColorItem: string;
  76037. /** @hidden */
  76038. protected _rebuildLayout: boolean;
  76039. /** @hidden */
  76040. _customData: any;
  76041. /** @hidden */
  76042. _isClipped: boolean;
  76043. /** @hidden */
  76044. _automaticSize: boolean;
  76045. /** @hidden */
  76046. _tag: any;
  76047. /**
  76048. * 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
  76049. */
  76050. uniqueId: number;
  76051. /**
  76052. * Gets or sets an object used to store user defined information for the node
  76053. */
  76054. metadata: any;
  76055. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  76056. isHitTestVisible: boolean;
  76057. /** Gets or sets a boolean indicating if the control can block pointer events */
  76058. isPointerBlocker: boolean;
  76059. /** Gets or sets a boolean indicating if the control can be focusable */
  76060. isFocusInvisible: boolean;
  76061. /**
  76062. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  76063. * 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
  76064. */
  76065. clipChildren: boolean;
  76066. /**
  76067. * Gets or sets a boolean indicating that control content must be clipped
  76068. * 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
  76069. */
  76070. clipContent: boolean;
  76071. /**
  76072. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  76073. */
  76074. useBitmapCache: boolean;
  76075. private _cacheData;
  76076. private _shadowOffsetX;
  76077. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  76078. get shadowOffsetX(): number;
  76079. set shadowOffsetX(value: number);
  76080. private _shadowOffsetY;
  76081. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  76082. get shadowOffsetY(): number;
  76083. set shadowOffsetY(value: number);
  76084. private _shadowBlur;
  76085. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  76086. get shadowBlur(): number;
  76087. set shadowBlur(value: number);
  76088. private _shadowColor;
  76089. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  76090. get shadowColor(): string;
  76091. set shadowColor(value: string);
  76092. /** Gets or sets the cursor to use when the control is hovered */
  76093. hoverCursor: string;
  76094. /** @hidden */
  76095. protected _linkOffsetX: ValueAndUnit;
  76096. /** @hidden */
  76097. protected _linkOffsetY: ValueAndUnit;
  76098. /** Gets the control type name */
  76099. get typeName(): string;
  76100. /**
  76101. * Get the current class name of the control.
  76102. * @returns current class name
  76103. */
  76104. getClassName(): string;
  76105. /**
  76106. * An event triggered when pointer wheel is scrolled
  76107. */
  76108. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  76109. /**
  76110. * An event triggered when the pointer move over the control.
  76111. */
  76112. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  76113. /**
  76114. * An event triggered when the pointer move out of the control.
  76115. */
  76116. onPointerOutObservable: BABYLON.Observable<Control>;
  76117. /**
  76118. * An event triggered when the pointer taps the control
  76119. */
  76120. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  76121. /**
  76122. * An event triggered when pointer up
  76123. */
  76124. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  76125. /**
  76126. * An event triggered when a control is clicked on
  76127. */
  76128. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  76129. /**
  76130. * An event triggered when pointer enters the control
  76131. */
  76132. onPointerEnterObservable: BABYLON.Observable<Control>;
  76133. /**
  76134. * An event triggered when the control is marked as dirty
  76135. */
  76136. onDirtyObservable: BABYLON.Observable<Control>;
  76137. /**
  76138. * An event triggered before drawing the control
  76139. */
  76140. onBeforeDrawObservable: BABYLON.Observable<Control>;
  76141. /**
  76142. * An event triggered after the control was drawn
  76143. */
  76144. onAfterDrawObservable: BABYLON.Observable<Control>;
  76145. /**
  76146. * An event triggered when the control has been disposed
  76147. */
  76148. onDisposeObservable: BABYLON.Observable<Control>;
  76149. /**
  76150. * Get the hosting AdvancedDynamicTexture
  76151. */
  76152. get host(): AdvancedDynamicTexture;
  76153. /** Gets or set information about font offsets (used to render and align text) */
  76154. get fontOffset(): {
  76155. ascent: number;
  76156. height: number;
  76157. descent: number;
  76158. };
  76159. set fontOffset(offset: {
  76160. ascent: number;
  76161. height: number;
  76162. descent: number;
  76163. });
  76164. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  76165. get alpha(): number;
  76166. set alpha(value: number);
  76167. /**
  76168. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  76169. */
  76170. get isHighlighted(): boolean;
  76171. set isHighlighted(value: boolean);
  76172. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  76173. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  76174. */
  76175. get scaleX(): number;
  76176. set scaleX(value: number);
  76177. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  76178. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  76179. */
  76180. get scaleY(): number;
  76181. set scaleY(value: number);
  76182. /** Gets or sets the rotation angle (0 by default)
  76183. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  76184. */
  76185. get rotation(): number;
  76186. set rotation(value: number);
  76187. /** Gets or sets the transformation center on Y axis (0 by default)
  76188. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  76189. */
  76190. get transformCenterY(): number;
  76191. set transformCenterY(value: number);
  76192. /** Gets or sets the transformation center on X axis (0 by default)
  76193. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  76194. */
  76195. get transformCenterX(): number;
  76196. set transformCenterX(value: number);
  76197. /**
  76198. * Gets or sets the horizontal alignment
  76199. * @see https://doc.babylonjs.com/how_to/gui#alignments
  76200. */
  76201. get horizontalAlignment(): number;
  76202. set horizontalAlignment(value: number);
  76203. /**
  76204. * Gets or sets the vertical alignment
  76205. * @see https://doc.babylonjs.com/how_to/gui#alignments
  76206. */
  76207. get verticalAlignment(): number;
  76208. set verticalAlignment(value: number);
  76209. /**
  76210. * Gets or sets a fixed ratio for this control.
  76211. * When different from 0, the ratio is used to compute the "second" dimension.
  76212. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  76213. * second dimension is computed as first dimension * fixedRatio
  76214. */
  76215. fixedRatio: number;
  76216. private _fixedRatioMasterIsWidth;
  76217. /**
  76218. * Gets or sets control width
  76219. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76220. */
  76221. get width(): string | number;
  76222. set width(value: string | number);
  76223. /**
  76224. * Gets or sets the control width in pixel
  76225. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76226. */
  76227. get widthInPixels(): number;
  76228. set widthInPixels(value: number);
  76229. /**
  76230. * Gets or sets control height
  76231. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76232. */
  76233. get height(): string | number;
  76234. set height(value: string | number);
  76235. /**
  76236. * Gets or sets control height in pixel
  76237. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76238. */
  76239. get heightInPixels(): number;
  76240. set heightInPixels(value: number);
  76241. /** Gets or set font family */
  76242. get fontFamily(): string;
  76243. set fontFamily(value: string);
  76244. /** Gets or sets font style */
  76245. get fontStyle(): string;
  76246. set fontStyle(value: string);
  76247. /** Gets or sets font weight */
  76248. get fontWeight(): string;
  76249. set fontWeight(value: string);
  76250. /**
  76251. * Gets or sets style
  76252. * @see https://doc.babylonjs.com/how_to/gui#styles
  76253. */
  76254. get style(): BABYLON.Nullable<Style>;
  76255. set style(value: BABYLON.Nullable<Style>);
  76256. /** @hidden */
  76257. get _isFontSizeInPercentage(): boolean;
  76258. /** Gets or sets font size in pixels */
  76259. get fontSizeInPixels(): number;
  76260. set fontSizeInPixels(value: number);
  76261. /** Gets or sets font size */
  76262. get fontSize(): string | number;
  76263. set fontSize(value: string | number);
  76264. /** Gets or sets foreground color */
  76265. get color(): string;
  76266. set color(value: string);
  76267. /** Gets or sets z index which is used to reorder controls on the z axis */
  76268. get zIndex(): number;
  76269. set zIndex(value: number);
  76270. /** Gets or sets a boolean indicating if the control can be rendered */
  76271. get notRenderable(): boolean;
  76272. set notRenderable(value: boolean);
  76273. /** Gets or sets a boolean indicating if the control is visible */
  76274. get isVisible(): boolean;
  76275. set isVisible(value: boolean);
  76276. /** Gets a boolean indicating that the control needs to update its rendering */
  76277. get isDirty(): boolean;
  76278. /**
  76279. * Gets the current linked mesh (or null if none)
  76280. */
  76281. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  76282. /**
  76283. * Gets or sets a value indicating the padding to use on the left of the control
  76284. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76285. */
  76286. get paddingLeft(): string | number;
  76287. set paddingLeft(value: string | number);
  76288. /**
  76289. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  76290. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76291. */
  76292. get paddingLeftInPixels(): number;
  76293. set paddingLeftInPixels(value: number);
  76294. /**
  76295. * Gets or sets a value indicating the padding to use on the right of the control
  76296. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76297. */
  76298. get paddingRight(): string | number;
  76299. set paddingRight(value: string | number);
  76300. /**
  76301. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  76302. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76303. */
  76304. get paddingRightInPixels(): number;
  76305. set paddingRightInPixels(value: number);
  76306. /**
  76307. * Gets or sets a value indicating the padding to use on the top of the control
  76308. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76309. */
  76310. get paddingTop(): string | number;
  76311. set paddingTop(value: string | number);
  76312. /**
  76313. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  76314. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76315. */
  76316. get paddingTopInPixels(): number;
  76317. set paddingTopInPixels(value: number);
  76318. /**
  76319. * Gets or sets a value indicating the padding to use on the bottom of the control
  76320. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76321. */
  76322. get paddingBottom(): string | number;
  76323. set paddingBottom(value: string | number);
  76324. /**
  76325. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  76326. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76327. */
  76328. get paddingBottomInPixels(): number;
  76329. set paddingBottomInPixels(value: number);
  76330. /**
  76331. * Gets or sets a value indicating the left coordinate of the control
  76332. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76333. */
  76334. get left(): string | number;
  76335. set left(value: string | number);
  76336. /**
  76337. * Gets or sets a value indicating the left coordinate in pixels of the control
  76338. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76339. */
  76340. get leftInPixels(): number;
  76341. set leftInPixels(value: number);
  76342. /**
  76343. * Gets or sets a value indicating the top coordinate of the control
  76344. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76345. */
  76346. get top(): string | number;
  76347. set top(value: string | number);
  76348. /**
  76349. * Gets or sets a value indicating the top coordinate in pixels of the control
  76350. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76351. */
  76352. get topInPixels(): number;
  76353. set topInPixels(value: number);
  76354. /**
  76355. * Gets or sets a value indicating the offset on X axis to the linked mesh
  76356. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  76357. */
  76358. get linkOffsetX(): string | number;
  76359. set linkOffsetX(value: string | number);
  76360. /**
  76361. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  76362. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  76363. */
  76364. get linkOffsetXInPixels(): number;
  76365. set linkOffsetXInPixels(value: number);
  76366. /**
  76367. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  76368. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  76369. */
  76370. get linkOffsetY(): string | number;
  76371. set linkOffsetY(value: string | number);
  76372. /**
  76373. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  76374. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  76375. */
  76376. get linkOffsetYInPixels(): number;
  76377. set linkOffsetYInPixels(value: number);
  76378. /** Gets the center coordinate on X axis */
  76379. get centerX(): number;
  76380. /** Gets the center coordinate on Y axis */
  76381. get centerY(): number;
  76382. /** Gets or sets if control is Enabled*/
  76383. get isEnabled(): boolean;
  76384. set isEnabled(value: boolean);
  76385. /** Gets or sets background color of control if it's disabled*/
  76386. get disabledColor(): string;
  76387. set disabledColor(value: string);
  76388. /** Gets or sets front color of control if it's disabled*/
  76389. get disabledColorItem(): string;
  76390. set disabledColorItem(value: string);
  76391. /**
  76392. * Creates a new control
  76393. * @param name defines the name of the control
  76394. */
  76395. constructor(
  76396. /** defines the name of the control */
  76397. name?: string | undefined);
  76398. /** @hidden */
  76399. protected _getTypeName(): string;
  76400. /**
  76401. * Gets the first ascendant in the hierarchy of the given type
  76402. * @param className defines the required type
  76403. * @returns the ascendant or null if not found
  76404. */
  76405. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  76406. /** @hidden */
  76407. _resetFontCache(): void;
  76408. /**
  76409. * Determines if a container is an ascendant of the current control
  76410. * @param container defines the container to look for
  76411. * @returns true if the container is one of the ascendant of the control
  76412. */
  76413. isAscendant(container: Control): boolean;
  76414. /**
  76415. * Gets coordinates in local control space
  76416. * @param globalCoordinates defines the coordinates to transform
  76417. * @returns the new coordinates in local space
  76418. */
  76419. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  76420. /**
  76421. * Gets coordinates in local control space
  76422. * @param globalCoordinates defines the coordinates to transform
  76423. * @param result defines the target vector2 where to store the result
  76424. * @returns the current control
  76425. */
  76426. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  76427. /**
  76428. * Gets coordinates in parent local control space
  76429. * @param globalCoordinates defines the coordinates to transform
  76430. * @returns the new coordinates in parent local space
  76431. */
  76432. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  76433. /**
  76434. * Move the current control to a vector3 position projected onto the screen.
  76435. * @param position defines the target position
  76436. * @param scene defines the hosting scene
  76437. */
  76438. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  76439. /**
  76440. * Will store all controls that have this control as ascendant in a given array
  76441. * @param results defines the array where to store the descendants
  76442. * @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
  76443. * @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
  76444. */
  76445. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  76446. /**
  76447. * Will return all controls that have this control as ascendant
  76448. * @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
  76449. * @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
  76450. * @return all child controls
  76451. */
  76452. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  76453. /**
  76454. * Link current control with a target mesh
  76455. * @param mesh defines the mesh to link with
  76456. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  76457. */
  76458. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  76459. /** @hidden */
  76460. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  76461. /** @hidden */
  76462. _offsetLeft(offset: number): void;
  76463. /** @hidden */
  76464. _offsetTop(offset: number): void;
  76465. /** @hidden */
  76466. _markMatrixAsDirty(): void;
  76467. /** @hidden */
  76468. _flagDescendantsAsMatrixDirty(): void;
  76469. /** @hidden */
  76470. _intersectsRect(rect: Measure): boolean;
  76471. /** @hidden */
  76472. protected invalidateRect(): void;
  76473. /** @hidden */
  76474. _markAsDirty(force?: boolean): void;
  76475. /** @hidden */
  76476. _markAllAsDirty(): void;
  76477. /** @hidden */
  76478. _link(host: AdvancedDynamicTexture): void;
  76479. /** @hidden */
  76480. protected _transform(context?: CanvasRenderingContext2D): void;
  76481. /** @hidden */
  76482. _renderHighlight(context: CanvasRenderingContext2D): void;
  76483. /** @hidden */
  76484. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  76485. /** @hidden */
  76486. protected _applyStates(context: CanvasRenderingContext2D): void;
  76487. /** @hidden */
  76488. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  76489. /** @hidden */
  76490. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76491. protected _evaluateClippingState(parentMeasure: Measure): void;
  76492. /** @hidden */
  76493. _measure(): void;
  76494. /** @hidden */
  76495. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76496. /** @hidden */
  76497. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76498. /** @hidden */
  76499. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76500. /** @hidden */
  76501. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  76502. private static _ClipMeasure;
  76503. private _tmpMeasureA;
  76504. private _clip;
  76505. /** @hidden */
  76506. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  76507. /** @hidden */
  76508. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76509. /**
  76510. * Tests if a given coordinates belong to the current control
  76511. * @param x defines x coordinate to test
  76512. * @param y defines y coordinate to test
  76513. * @returns true if the coordinates are inside the control
  76514. */
  76515. contains(x: number, y: number): boolean;
  76516. /** @hidden */
  76517. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  76518. /** @hidden */
  76519. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76520. /** @hidden */
  76521. _onPointerEnter(target: Control): boolean;
  76522. /** @hidden */
  76523. _onPointerOut(target: Control, force?: boolean): void;
  76524. /** @hidden */
  76525. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76526. /** @hidden */
  76527. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76528. /** @hidden */
  76529. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  76530. /** @hidden */
  76531. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  76532. /** @hidden */
  76533. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  76534. private _prepareFont;
  76535. /** Releases associated resources */
  76536. dispose(): void;
  76537. private static _HORIZONTAL_ALIGNMENT_LEFT;
  76538. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  76539. private static _HORIZONTAL_ALIGNMENT_CENTER;
  76540. private static _VERTICAL_ALIGNMENT_TOP;
  76541. private static _VERTICAL_ALIGNMENT_BOTTOM;
  76542. private static _VERTICAL_ALIGNMENT_CENTER;
  76543. /** HORIZONTAL_ALIGNMENT_LEFT */
  76544. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  76545. /** HORIZONTAL_ALIGNMENT_RIGHT */
  76546. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  76547. /** HORIZONTAL_ALIGNMENT_CENTER */
  76548. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  76549. /** VERTICAL_ALIGNMENT_TOP */
  76550. static get VERTICAL_ALIGNMENT_TOP(): number;
  76551. /** VERTICAL_ALIGNMENT_BOTTOM */
  76552. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  76553. /** VERTICAL_ALIGNMENT_CENTER */
  76554. static get VERTICAL_ALIGNMENT_CENTER(): number;
  76555. private static _FontHeightSizes;
  76556. /** @hidden */
  76557. static _GetFontOffset(font: string): {
  76558. ascent: number;
  76559. height: number;
  76560. descent: number;
  76561. };
  76562. /**
  76563. * Creates a stack panel that can be used to render headers
  76564. * @param control defines the control to associate with the header
  76565. * @param text defines the text of the header
  76566. * @param size defines the size of the header
  76567. * @param options defines options used to configure the header
  76568. * @returns a new StackPanel
  76569. * @ignore
  76570. * @hidden
  76571. */
  76572. static AddHeader: (control: Control, text: string, size: string | number, options: {
  76573. isHorizontal: boolean;
  76574. controlFirst: boolean;
  76575. }) => any;
  76576. /** @hidden */
  76577. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  76578. }
  76579. }
  76580. declare module BABYLON.GUI {
  76581. /**
  76582. * Root class for 2D containers
  76583. * @see https://doc.babylonjs.com/how_to/gui#containers
  76584. */
  76585. export class Container extends Control {
  76586. name?: string | undefined;
  76587. /** @hidden */
  76588. _children: Control[];
  76589. /** @hidden */
  76590. protected _measureForChildren: Measure;
  76591. /** @hidden */
  76592. protected _background: string;
  76593. /** @hidden */
  76594. protected _adaptWidthToChildren: boolean;
  76595. /** @hidden */
  76596. protected _adaptHeightToChildren: boolean;
  76597. /**
  76598. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  76599. */
  76600. logLayoutCycleErrors: boolean;
  76601. /**
  76602. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  76603. */
  76604. maxLayoutCycle: number;
  76605. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  76606. get adaptHeightToChildren(): boolean;
  76607. set adaptHeightToChildren(value: boolean);
  76608. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  76609. get adaptWidthToChildren(): boolean;
  76610. set adaptWidthToChildren(value: boolean);
  76611. /** Gets or sets background color */
  76612. get background(): string;
  76613. set background(value: string);
  76614. /** Gets the list of children */
  76615. get children(): Control[];
  76616. /**
  76617. * Creates a new Container
  76618. * @param name defines the name of the container
  76619. */
  76620. constructor(name?: string | undefined);
  76621. protected _getTypeName(): string;
  76622. _flagDescendantsAsMatrixDirty(): void;
  76623. /**
  76624. * Gets a child using its name
  76625. * @param name defines the child name to look for
  76626. * @returns the child control if found
  76627. */
  76628. getChildByName(name: string): BABYLON.Nullable<Control>;
  76629. /**
  76630. * Gets a child using its type and its name
  76631. * @param name defines the child name to look for
  76632. * @param type defines the child type to look for
  76633. * @returns the child control if found
  76634. */
  76635. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  76636. /**
  76637. * Search for a specific control in children
  76638. * @param control defines the control to look for
  76639. * @returns true if the control is in child list
  76640. */
  76641. containsControl(control: Control): boolean;
  76642. /**
  76643. * Adds a new control to the current container
  76644. * @param control defines the control to add
  76645. * @returns the current container
  76646. */
  76647. addControl(control: BABYLON.Nullable<Control>): Container;
  76648. /**
  76649. * Removes all controls from the current container
  76650. * @returns the current container
  76651. */
  76652. clearControls(): Container;
  76653. /**
  76654. * Removes a control from the current container
  76655. * @param control defines the control to remove
  76656. * @returns the current container
  76657. */
  76658. removeControl(control: Control): Container;
  76659. /** @hidden */
  76660. _reOrderControl(control: Control): void;
  76661. /** @hidden */
  76662. _offsetLeft(offset: number): void;
  76663. /** @hidden */
  76664. _offsetTop(offset: number): void;
  76665. /** @hidden */
  76666. _markAllAsDirty(): void;
  76667. /** @hidden */
  76668. protected _localDraw(context: CanvasRenderingContext2D): void;
  76669. /** @hidden */
  76670. _link(host: AdvancedDynamicTexture): void;
  76671. /** @hidden */
  76672. protected _beforeLayout(): void;
  76673. /** @hidden */
  76674. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76675. /** @hidden */
  76676. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  76677. protected _postMeasure(): void;
  76678. /** @hidden */
  76679. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  76680. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  76681. /** @hidden */
  76682. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  76683. /** @hidden */
  76684. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76685. /** Releases associated resources */
  76686. dispose(): void;
  76687. }
  76688. }
  76689. declare module BABYLON.GUI {
  76690. /** Class used to create rectangle container */
  76691. export class Rectangle extends Container {
  76692. name?: string | undefined;
  76693. private _thickness;
  76694. private _cornerRadius;
  76695. /** Gets or sets border thickness */
  76696. get thickness(): number;
  76697. set thickness(value: number);
  76698. /** Gets or sets the corner radius angle */
  76699. get cornerRadius(): number;
  76700. set cornerRadius(value: number);
  76701. /**
  76702. * Creates a new Rectangle
  76703. * @param name defines the control name
  76704. */
  76705. constructor(name?: string | undefined);
  76706. protected _getTypeName(): string;
  76707. protected _localDraw(context: CanvasRenderingContext2D): void;
  76708. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76709. private _drawRoundedRect;
  76710. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  76711. }
  76712. }
  76713. declare module BABYLON.GUI {
  76714. /**
  76715. * Enum that determines the text-wrapping mode to use.
  76716. */
  76717. export enum TextWrapping {
  76718. /**
  76719. * Clip the text when it's larger than Control.width; this is the default mode.
  76720. */
  76721. Clip = 0,
  76722. /**
  76723. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  76724. */
  76725. WordWrap = 1,
  76726. /**
  76727. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  76728. */
  76729. Ellipsis = 2
  76730. }
  76731. /**
  76732. * Class used to create text block control
  76733. */
  76734. export class TextBlock extends Control {
  76735. /**
  76736. * Defines the name of the control
  76737. */
  76738. name?: string | undefined;
  76739. private _text;
  76740. private _textWrapping;
  76741. private _textHorizontalAlignment;
  76742. private _textVerticalAlignment;
  76743. private _lines;
  76744. private _resizeToFit;
  76745. private _lineSpacing;
  76746. private _outlineWidth;
  76747. private _outlineColor;
  76748. /**
  76749. * An event triggered after the text is changed
  76750. */
  76751. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  76752. /**
  76753. * An event triggered after the text was broken up into lines
  76754. */
  76755. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  76756. /**
  76757. * Function used to split a string into words. By default, a string is split at each space character found
  76758. */
  76759. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  76760. /**
  76761. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  76762. */
  76763. get lines(): any[];
  76764. /**
  76765. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  76766. */
  76767. get resizeToFit(): boolean;
  76768. /**
  76769. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  76770. */
  76771. set resizeToFit(value: boolean);
  76772. /**
  76773. * Gets or sets a boolean indicating if text must be wrapped
  76774. */
  76775. get textWrapping(): TextWrapping | boolean;
  76776. /**
  76777. * Gets or sets a boolean indicating if text must be wrapped
  76778. */
  76779. set textWrapping(value: TextWrapping | boolean);
  76780. /**
  76781. * Gets or sets text to display
  76782. */
  76783. get text(): string;
  76784. /**
  76785. * Gets or sets text to display
  76786. */
  76787. set text(value: string);
  76788. /**
  76789. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  76790. */
  76791. get textHorizontalAlignment(): number;
  76792. /**
  76793. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  76794. */
  76795. set textHorizontalAlignment(value: number);
  76796. /**
  76797. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  76798. */
  76799. get textVerticalAlignment(): number;
  76800. /**
  76801. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  76802. */
  76803. set textVerticalAlignment(value: number);
  76804. /**
  76805. * Gets or sets line spacing value
  76806. */
  76807. set lineSpacing(value: string | number);
  76808. /**
  76809. * Gets or sets line spacing value
  76810. */
  76811. get lineSpacing(): string | number;
  76812. /**
  76813. * Gets or sets outlineWidth of the text to display
  76814. */
  76815. get outlineWidth(): number;
  76816. /**
  76817. * Gets or sets outlineWidth of the text to display
  76818. */
  76819. set outlineWidth(value: number);
  76820. /**
  76821. * Gets or sets outlineColor of the text to display
  76822. */
  76823. get outlineColor(): string;
  76824. /**
  76825. * Gets or sets outlineColor of the text to display
  76826. */
  76827. set outlineColor(value: string);
  76828. /**
  76829. * Creates a new TextBlock object
  76830. * @param name defines the name of the control
  76831. * @param text defines the text to display (emptry string by default)
  76832. */
  76833. constructor(
  76834. /**
  76835. * Defines the name of the control
  76836. */
  76837. name?: string | undefined, text?: string);
  76838. protected _getTypeName(): string;
  76839. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76840. private _drawText;
  76841. /** @hidden */
  76842. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76843. protected _applyStates(context: CanvasRenderingContext2D): void;
  76844. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  76845. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  76846. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  76847. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  76848. protected _renderLines(context: CanvasRenderingContext2D): void;
  76849. /**
  76850. * Given a width constraint applied on the text block, find the expected height
  76851. * @returns expected height
  76852. */
  76853. computeExpectedHeight(): number;
  76854. dispose(): void;
  76855. }
  76856. }
  76857. declare module BABYLON.GUI {
  76858. /**
  76859. * Class used to create 2D images
  76860. */
  76861. export class Image extends Control {
  76862. name?: string | undefined;
  76863. private _workingCanvas;
  76864. private _domImage;
  76865. private _imageWidth;
  76866. private _imageHeight;
  76867. private _loaded;
  76868. private _stretch;
  76869. private _source;
  76870. private _autoScale;
  76871. private _sourceLeft;
  76872. private _sourceTop;
  76873. private _sourceWidth;
  76874. private _sourceHeight;
  76875. private _svgAttributesComputationCompleted;
  76876. private _isSVG;
  76877. private _cellWidth;
  76878. private _cellHeight;
  76879. private _cellId;
  76880. private _populateNinePatchSlicesFromImage;
  76881. private _sliceLeft;
  76882. private _sliceRight;
  76883. private _sliceTop;
  76884. private _sliceBottom;
  76885. private _detectPointerOnOpaqueOnly;
  76886. private _imageDataCache;
  76887. /**
  76888. * BABYLON.Observable notified when the content is loaded
  76889. */
  76890. onImageLoadedObservable: BABYLON.Observable<Image>;
  76891. /**
  76892. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  76893. */
  76894. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  76895. /**
  76896. * Gets a boolean indicating that the content is loaded
  76897. */
  76898. get isLoaded(): boolean;
  76899. /**
  76900. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  76901. */
  76902. get populateNinePatchSlicesFromImage(): boolean;
  76903. set populateNinePatchSlicesFromImage(value: boolean);
  76904. /**
  76905. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  76906. * Beware using this as this will comsume more memory as the image has to be stored twice
  76907. */
  76908. get detectPointerOnOpaqueOnly(): boolean;
  76909. set detectPointerOnOpaqueOnly(value: boolean);
  76910. /**
  76911. * Gets or sets the left value for slicing (9-patch)
  76912. */
  76913. get sliceLeft(): number;
  76914. set sliceLeft(value: number);
  76915. /**
  76916. * Gets or sets the right value for slicing (9-patch)
  76917. */
  76918. get sliceRight(): number;
  76919. set sliceRight(value: number);
  76920. /**
  76921. * Gets or sets the top value for slicing (9-patch)
  76922. */
  76923. get sliceTop(): number;
  76924. set sliceTop(value: number);
  76925. /**
  76926. * Gets or sets the bottom value for slicing (9-patch)
  76927. */
  76928. get sliceBottom(): number;
  76929. set sliceBottom(value: number);
  76930. /**
  76931. * Gets or sets the left coordinate in the source image
  76932. */
  76933. get sourceLeft(): number;
  76934. set sourceLeft(value: number);
  76935. /**
  76936. * Gets or sets the top coordinate in the source image
  76937. */
  76938. get sourceTop(): number;
  76939. set sourceTop(value: number);
  76940. /**
  76941. * Gets or sets the width to capture in the source image
  76942. */
  76943. get sourceWidth(): number;
  76944. set sourceWidth(value: number);
  76945. /**
  76946. * Gets or sets the height to capture in the source image
  76947. */
  76948. get sourceHeight(): number;
  76949. set sourceHeight(value: number);
  76950. /** Indicates if the format of the image is SVG */
  76951. get isSVG(): boolean;
  76952. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  76953. get svgAttributesComputationCompleted(): boolean;
  76954. /**
  76955. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  76956. * @see https://doc.babylonjs.com/how_to/gui#image
  76957. */
  76958. get autoScale(): boolean;
  76959. set autoScale(value: boolean);
  76960. /** Gets or sets the streching mode used by the image */
  76961. get stretch(): number;
  76962. set stretch(value: number);
  76963. /** @hidden */
  76964. _rotate90(n: number, preserveProperties?: boolean): Image;
  76965. private _handleRotationForSVGImage;
  76966. private _rotate90SourceProperties;
  76967. /**
  76968. * Gets or sets the internal DOM image used to render the control
  76969. */
  76970. set domImage(value: HTMLImageElement);
  76971. get domImage(): HTMLImageElement;
  76972. private _onImageLoaded;
  76973. private _extractNinePatchSliceDataFromImage;
  76974. /**
  76975. * Gets or sets image source url
  76976. */
  76977. set source(value: BABYLON.Nullable<string>);
  76978. /**
  76979. * Checks for svg document with icon id present
  76980. */
  76981. private _svgCheck;
  76982. /**
  76983. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  76984. * given external svg file and icon id
  76985. */
  76986. private _getSVGAttribs;
  76987. /**
  76988. * Gets or sets the cell width to use when animation sheet is enabled
  76989. * @see https://doc.babylonjs.com/how_to/gui#image
  76990. */
  76991. get cellWidth(): number;
  76992. set cellWidth(value: number);
  76993. /**
  76994. * Gets or sets the cell height to use when animation sheet is enabled
  76995. * @see https://doc.babylonjs.com/how_to/gui#image
  76996. */
  76997. get cellHeight(): number;
  76998. set cellHeight(value: number);
  76999. /**
  77000. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  77001. * @see https://doc.babylonjs.com/how_to/gui#image
  77002. */
  77003. get cellId(): number;
  77004. set cellId(value: number);
  77005. /**
  77006. * Creates a new Image
  77007. * @param name defines the control name
  77008. * @param url defines the image url
  77009. */
  77010. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  77011. /**
  77012. * Tests if a given coordinates belong to the current control
  77013. * @param x defines x coordinate to test
  77014. * @param y defines y coordinate to test
  77015. * @returns true if the coordinates are inside the control
  77016. */
  77017. contains(x: number, y: number): boolean;
  77018. protected _getTypeName(): string;
  77019. /** Force the control to synchronize with its content */
  77020. synchronizeSizeWithContent(): void;
  77021. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77022. private _prepareWorkingCanvasForOpaqueDetection;
  77023. private _drawImage;
  77024. _draw(context: CanvasRenderingContext2D): void;
  77025. private _renderCornerPatch;
  77026. private _renderNinePatch;
  77027. dispose(): void;
  77028. /** STRETCH_NONE */
  77029. static readonly STRETCH_NONE: number;
  77030. /** STRETCH_FILL */
  77031. static readonly STRETCH_FILL: number;
  77032. /** STRETCH_UNIFORM */
  77033. static readonly STRETCH_UNIFORM: number;
  77034. /** STRETCH_EXTEND */
  77035. static readonly STRETCH_EXTEND: number;
  77036. /** NINE_PATCH */
  77037. static readonly STRETCH_NINE_PATCH: number;
  77038. }
  77039. }
  77040. declare module BABYLON.GUI {
  77041. /**
  77042. * Class used to create 2D buttons
  77043. */
  77044. export class Button extends Rectangle {
  77045. name?: string | undefined;
  77046. /**
  77047. * Function called to generate a pointer enter animation
  77048. */
  77049. pointerEnterAnimation: () => void;
  77050. /**
  77051. * Function called to generate a pointer out animation
  77052. */
  77053. pointerOutAnimation: () => void;
  77054. /**
  77055. * Function called to generate a pointer down animation
  77056. */
  77057. pointerDownAnimation: () => void;
  77058. /**
  77059. * Function called to generate a pointer up animation
  77060. */
  77061. pointerUpAnimation: () => void;
  77062. /**
  77063. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  77064. */
  77065. delegatePickingToChildren: boolean;
  77066. private _image;
  77067. /**
  77068. * Returns the image part of the button (if any)
  77069. */
  77070. get image(): BABYLON.Nullable<Image>;
  77071. private _textBlock;
  77072. /**
  77073. * Returns the image part of the button (if any)
  77074. */
  77075. get textBlock(): BABYLON.Nullable<TextBlock>;
  77076. /**
  77077. * Creates a new Button
  77078. * @param name defines the name of the button
  77079. */
  77080. constructor(name?: string | undefined);
  77081. protected _getTypeName(): string;
  77082. /** @hidden */
  77083. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  77084. /** @hidden */
  77085. _onPointerEnter(target: Control): boolean;
  77086. /** @hidden */
  77087. _onPointerOut(target: Control, force?: boolean): void;
  77088. /** @hidden */
  77089. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77090. /** @hidden */
  77091. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77092. /**
  77093. * Creates a new button made with an image and a text
  77094. * @param name defines the name of the button
  77095. * @param text defines the text of the button
  77096. * @param imageUrl defines the url of the image
  77097. * @returns a new Button
  77098. */
  77099. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  77100. /**
  77101. * Creates a new button made with an image
  77102. * @param name defines the name of the button
  77103. * @param imageUrl defines the url of the image
  77104. * @returns a new Button
  77105. */
  77106. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  77107. /**
  77108. * Creates a new button made with a text
  77109. * @param name defines the name of the button
  77110. * @param text defines the text of the button
  77111. * @returns a new Button
  77112. */
  77113. static CreateSimpleButton(name: string, text: string): Button;
  77114. /**
  77115. * Creates a new button made with an image and a centered text
  77116. * @param name defines the name of the button
  77117. * @param text defines the text of the button
  77118. * @param imageUrl defines the url of the image
  77119. * @returns a new Button
  77120. */
  77121. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  77122. }
  77123. }
  77124. declare module BABYLON.GUI {
  77125. /**
  77126. * Class used to create a 2D stack panel container
  77127. */
  77128. export class StackPanel extends Container {
  77129. name?: string | undefined;
  77130. private _isVertical;
  77131. private _manualWidth;
  77132. private _manualHeight;
  77133. private _doNotTrackManualChanges;
  77134. /**
  77135. * Gets or sets a boolean indicating that layou warnings should be ignored
  77136. */
  77137. ignoreLayoutWarnings: boolean;
  77138. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  77139. get isVertical(): boolean;
  77140. set isVertical(value: boolean);
  77141. /**
  77142. * Gets or sets panel width.
  77143. * This value should not be set when in horizontal mode as it will be computed automatically
  77144. */
  77145. set width(value: string | number);
  77146. get width(): string | number;
  77147. /**
  77148. * Gets or sets panel height.
  77149. * This value should not be set when in vertical mode as it will be computed automatically
  77150. */
  77151. set height(value: string | number);
  77152. get height(): string | number;
  77153. /**
  77154. * Creates a new StackPanel
  77155. * @param name defines control name
  77156. */
  77157. constructor(name?: string | undefined);
  77158. protected _getTypeName(): string;
  77159. /** @hidden */
  77160. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77161. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77162. protected _postMeasure(): void;
  77163. }
  77164. }
  77165. declare module BABYLON.GUI {
  77166. /**
  77167. * Class used to represent a 2D checkbox
  77168. */
  77169. export class Checkbox extends Control {
  77170. name?: string | undefined;
  77171. private _isChecked;
  77172. private _background;
  77173. private _checkSizeRatio;
  77174. private _thickness;
  77175. /** Gets or sets border thickness */
  77176. get thickness(): number;
  77177. set thickness(value: number);
  77178. /**
  77179. * BABYLON.Observable raised when isChecked property changes
  77180. */
  77181. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  77182. /** Gets or sets a value indicating the ratio between overall size and check size */
  77183. get checkSizeRatio(): number;
  77184. set checkSizeRatio(value: number);
  77185. /** Gets or sets background color */
  77186. get background(): string;
  77187. set background(value: string);
  77188. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  77189. get isChecked(): boolean;
  77190. set isChecked(value: boolean);
  77191. /**
  77192. * Creates a new CheckBox
  77193. * @param name defines the control name
  77194. */
  77195. constructor(name?: string | undefined);
  77196. protected _getTypeName(): string;
  77197. /** @hidden */
  77198. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77199. /** @hidden */
  77200. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77201. /**
  77202. * Utility function to easily create a checkbox with a header
  77203. * @param title defines the label to use for the header
  77204. * @param onValueChanged defines the callback to call when value changes
  77205. * @returns a StackPanel containing the checkbox and a textBlock
  77206. */
  77207. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  77208. }
  77209. }
  77210. declare module BABYLON.GUI {
  77211. /**
  77212. * Class used to store key control properties
  77213. */
  77214. export class KeyPropertySet {
  77215. /** Width */
  77216. width?: string;
  77217. /** Height */
  77218. height?: string;
  77219. /** Left padding */
  77220. paddingLeft?: string;
  77221. /** Right padding */
  77222. paddingRight?: string;
  77223. /** Top padding */
  77224. paddingTop?: string;
  77225. /** Bottom padding */
  77226. paddingBottom?: string;
  77227. /** Foreground color */
  77228. color?: string;
  77229. /** Background color */
  77230. background?: string;
  77231. }
  77232. /**
  77233. * Class used to create virtual keyboard
  77234. */
  77235. export class VirtualKeyboard extends StackPanel {
  77236. /** BABYLON.Observable raised when a key is pressed */
  77237. onKeyPressObservable: BABYLON.Observable<string>;
  77238. /** Gets or sets default key button width */
  77239. defaultButtonWidth: string;
  77240. /** Gets or sets default key button height */
  77241. defaultButtonHeight: string;
  77242. /** Gets or sets default key button left padding */
  77243. defaultButtonPaddingLeft: string;
  77244. /** Gets or sets default key button right padding */
  77245. defaultButtonPaddingRight: string;
  77246. /** Gets or sets default key button top padding */
  77247. defaultButtonPaddingTop: string;
  77248. /** Gets or sets default key button bottom padding */
  77249. defaultButtonPaddingBottom: string;
  77250. /** Gets or sets default key button foreground color */
  77251. defaultButtonColor: string;
  77252. /** Gets or sets default key button background color */
  77253. defaultButtonBackground: string;
  77254. /** Gets or sets shift button foreground color */
  77255. shiftButtonColor: string;
  77256. /** Gets or sets shift button thickness*/
  77257. selectedShiftThickness: number;
  77258. /** Gets shift key state */
  77259. shiftState: number;
  77260. protected _getTypeName(): string;
  77261. private _createKey;
  77262. /**
  77263. * Adds a new row of keys
  77264. * @param keys defines the list of keys to add
  77265. * @param propertySets defines the associated property sets
  77266. */
  77267. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  77268. /**
  77269. * Set the shift key to a specific state
  77270. * @param shiftState defines the new shift state
  77271. */
  77272. applyShiftState(shiftState: number): void;
  77273. private _currentlyConnectedInputText;
  77274. private _connectedInputTexts;
  77275. private _onKeyPressObserver;
  77276. /** Gets the input text control currently attached to the keyboard */
  77277. get connectedInputText(): BABYLON.Nullable<InputText>;
  77278. /**
  77279. * Connects the keyboard with an input text control
  77280. *
  77281. * @param input defines the target control
  77282. */
  77283. connect(input: InputText): void;
  77284. /**
  77285. * Disconnects the keyboard from connected InputText controls
  77286. *
  77287. * @param input optionally defines a target control, otherwise all are disconnected
  77288. */
  77289. disconnect(input?: InputText): void;
  77290. private _removeConnectedInputObservables;
  77291. /**
  77292. * Release all resources
  77293. */
  77294. dispose(): void;
  77295. /**
  77296. * Creates a new keyboard using a default layout
  77297. *
  77298. * @param name defines control name
  77299. * @returns a new VirtualKeyboard
  77300. */
  77301. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  77302. }
  77303. }
  77304. declare module BABYLON.GUI {
  77305. /**
  77306. * Class used to create input text control
  77307. */
  77308. export class InputText extends Control implements IFocusableControl {
  77309. name?: string | undefined;
  77310. private _text;
  77311. private _placeholderText;
  77312. private _background;
  77313. private _focusedBackground;
  77314. private _focusedColor;
  77315. private _placeholderColor;
  77316. private _thickness;
  77317. private _margin;
  77318. private _autoStretchWidth;
  77319. private _maxWidth;
  77320. private _isFocused;
  77321. private _blinkTimeout;
  77322. private _blinkIsEven;
  77323. private _cursorOffset;
  77324. private _scrollLeft;
  77325. private _textWidth;
  77326. private _clickedCoordinate;
  77327. private _deadKey;
  77328. private _addKey;
  77329. private _currentKey;
  77330. private _isTextHighlightOn;
  77331. private _textHighlightColor;
  77332. private _highligherOpacity;
  77333. private _highlightedText;
  77334. private _startHighlightIndex;
  77335. private _endHighlightIndex;
  77336. private _cursorIndex;
  77337. private _onFocusSelectAll;
  77338. private _isPointerDown;
  77339. private _onClipboardObserver;
  77340. private _onPointerDblTapObserver;
  77341. /** @hidden */
  77342. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  77343. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  77344. promptMessage: string;
  77345. /** Force disable prompt on mobile device */
  77346. disableMobilePrompt: boolean;
  77347. /** BABYLON.Observable raised when the text changes */
  77348. onTextChangedObservable: BABYLON.Observable<InputText>;
  77349. /** BABYLON.Observable raised just before an entered character is to be added */
  77350. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  77351. /** BABYLON.Observable raised when the control gets the focus */
  77352. onFocusObservable: BABYLON.Observable<InputText>;
  77353. /** BABYLON.Observable raised when the control loses the focus */
  77354. onBlurObservable: BABYLON.Observable<InputText>;
  77355. /**Observable raised when the text is highlighted */
  77356. onTextHighlightObservable: BABYLON.Observable<InputText>;
  77357. /**Observable raised when copy event is triggered */
  77358. onTextCopyObservable: BABYLON.Observable<InputText>;
  77359. /** BABYLON.Observable raised when cut event is triggered */
  77360. onTextCutObservable: BABYLON.Observable<InputText>;
  77361. /** BABYLON.Observable raised when paste event is triggered */
  77362. onTextPasteObservable: BABYLON.Observable<InputText>;
  77363. /** BABYLON.Observable raised when a key event was processed */
  77364. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  77365. /** Gets or sets the maximum width allowed by the control */
  77366. get maxWidth(): string | number;
  77367. /** Gets the maximum width allowed by the control in pixels */
  77368. get maxWidthInPixels(): number;
  77369. set maxWidth(value: string | number);
  77370. /** Gets or sets the text highlighter transparency; default: 0.4 */
  77371. get highligherOpacity(): number;
  77372. set highligherOpacity(value: number);
  77373. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  77374. get onFocusSelectAll(): boolean;
  77375. set onFocusSelectAll(value: boolean);
  77376. /** Gets or sets the text hightlight color */
  77377. get textHighlightColor(): string;
  77378. set textHighlightColor(value: string);
  77379. /** Gets or sets control margin */
  77380. get margin(): string;
  77381. /** Gets control margin in pixels */
  77382. get marginInPixels(): number;
  77383. set margin(value: string);
  77384. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  77385. get autoStretchWidth(): boolean;
  77386. set autoStretchWidth(value: boolean);
  77387. /** Gets or sets border thickness */
  77388. get thickness(): number;
  77389. set thickness(value: number);
  77390. /** Gets or sets the background color when focused */
  77391. get focusedBackground(): string;
  77392. set focusedBackground(value: string);
  77393. /** Gets or sets the background color when focused */
  77394. get focusedColor(): string;
  77395. set focusedColor(value: string);
  77396. /** Gets or sets the background color */
  77397. get background(): string;
  77398. set background(value: string);
  77399. /** Gets or sets the placeholder color */
  77400. get placeholderColor(): string;
  77401. set placeholderColor(value: string);
  77402. /** Gets or sets the text displayed when the control is empty */
  77403. get placeholderText(): string;
  77404. set placeholderText(value: string);
  77405. /** Gets or sets the dead key flag */
  77406. get deadKey(): boolean;
  77407. set deadKey(flag: boolean);
  77408. /** Gets or sets the highlight text */
  77409. get highlightedText(): string;
  77410. set highlightedText(text: string);
  77411. /** Gets or sets if the current key should be added */
  77412. get addKey(): boolean;
  77413. set addKey(flag: boolean);
  77414. /** Gets or sets the value of the current key being entered */
  77415. get currentKey(): string;
  77416. set currentKey(key: string);
  77417. /** Gets or sets the text displayed in the control */
  77418. get text(): string;
  77419. set text(value: string);
  77420. /** Gets or sets control width */
  77421. get width(): string | number;
  77422. set width(value: string | number);
  77423. /**
  77424. * Creates a new InputText
  77425. * @param name defines the control name
  77426. * @param text defines the text of the control
  77427. */
  77428. constructor(name?: string | undefined, text?: string);
  77429. /** @hidden */
  77430. onBlur(): void;
  77431. /** @hidden */
  77432. onFocus(): void;
  77433. protected _getTypeName(): string;
  77434. /**
  77435. * Function called to get the list of controls that should not steal the focus from this control
  77436. * @returns an array of controls
  77437. */
  77438. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  77439. /** @hidden */
  77440. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  77441. /** @hidden */
  77442. private _updateValueFromCursorIndex;
  77443. /** @hidden */
  77444. private _processDblClick;
  77445. /** @hidden */
  77446. private _selectAllText;
  77447. /**
  77448. * Handles the keyboard event
  77449. * @param evt Defines the KeyboardEvent
  77450. */
  77451. processKeyboard(evt: KeyboardEvent): void;
  77452. /** @hidden */
  77453. private _onCopyText;
  77454. /** @hidden */
  77455. private _onCutText;
  77456. /** @hidden */
  77457. private _onPasteText;
  77458. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77459. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77460. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  77461. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77462. protected _beforeRenderText(text: string): string;
  77463. dispose(): void;
  77464. }
  77465. }
  77466. declare module BABYLON.GUI {
  77467. /**
  77468. * Class used to create a 2D grid container
  77469. */
  77470. export class Grid extends Container {
  77471. name?: string | undefined;
  77472. private _rowDefinitions;
  77473. private _columnDefinitions;
  77474. private _cells;
  77475. private _childControls;
  77476. /**
  77477. * Gets the number of columns
  77478. */
  77479. get columnCount(): number;
  77480. /**
  77481. * Gets the number of rows
  77482. */
  77483. get rowCount(): number;
  77484. /** Gets the list of children */
  77485. get children(): Control[];
  77486. /** Gets the list of cells (e.g. the containers) */
  77487. get cells(): {
  77488. [key: string]: Container;
  77489. };
  77490. /**
  77491. * Gets the definition of a specific row
  77492. * @param index defines the index of the row
  77493. * @returns the row definition
  77494. */
  77495. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  77496. /**
  77497. * Gets the definition of a specific column
  77498. * @param index defines the index of the column
  77499. * @returns the column definition
  77500. */
  77501. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  77502. /**
  77503. * Adds a new row to the grid
  77504. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  77505. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  77506. * @returns the current grid
  77507. */
  77508. addRowDefinition(height: number, isPixel?: boolean): Grid;
  77509. /**
  77510. * Adds a new column to the grid
  77511. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  77512. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  77513. * @returns the current grid
  77514. */
  77515. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  77516. /**
  77517. * Update a row definition
  77518. * @param index defines the index of the row to update
  77519. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  77520. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  77521. * @returns the current grid
  77522. */
  77523. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  77524. /**
  77525. * Update a column definition
  77526. * @param index defines the index of the column to update
  77527. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  77528. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  77529. * @returns the current grid
  77530. */
  77531. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  77532. /**
  77533. * Gets the list of children stored in a specific cell
  77534. * @param row defines the row to check
  77535. * @param column defines the column to check
  77536. * @returns the list of controls
  77537. */
  77538. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  77539. /**
  77540. * Gets a string representing the child cell info (row x column)
  77541. * @param child defines the control to get info from
  77542. * @returns a string containing the child cell info (row x column)
  77543. */
  77544. getChildCellInfo(child: Control): string;
  77545. private _removeCell;
  77546. private _offsetCell;
  77547. /**
  77548. * Remove a column definition at specified index
  77549. * @param index defines the index of the column to remove
  77550. * @returns the current grid
  77551. */
  77552. removeColumnDefinition(index: number): Grid;
  77553. /**
  77554. * Remove a row definition at specified index
  77555. * @param index defines the index of the row to remove
  77556. * @returns the current grid
  77557. */
  77558. removeRowDefinition(index: number): Grid;
  77559. /**
  77560. * Adds a new control to the current grid
  77561. * @param control defines the control to add
  77562. * @param row defines the row where to add the control (0 by default)
  77563. * @param column defines the column where to add the control (0 by default)
  77564. * @returns the current grid
  77565. */
  77566. addControl(control: Control, row?: number, column?: number): Grid;
  77567. /**
  77568. * Removes a control from the current container
  77569. * @param control defines the control to remove
  77570. * @returns the current container
  77571. */
  77572. removeControl(control: Control): Container;
  77573. /**
  77574. * Creates a new Grid
  77575. * @param name defines control name
  77576. */
  77577. constructor(name?: string | undefined);
  77578. protected _getTypeName(): string;
  77579. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  77580. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77581. _flagDescendantsAsMatrixDirty(): void;
  77582. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  77583. /** Releases associated resources */
  77584. dispose(): void;
  77585. }
  77586. }
  77587. declare module BABYLON.GUI {
  77588. /** Class used to create color pickers */
  77589. export class ColorPicker extends Control {
  77590. name?: string | undefined;
  77591. private static _Epsilon;
  77592. private _colorWheelCanvas;
  77593. private _value;
  77594. private _tmpColor;
  77595. private _pointerStartedOnSquare;
  77596. private _pointerStartedOnWheel;
  77597. private _squareLeft;
  77598. private _squareTop;
  77599. private _squareSize;
  77600. private _h;
  77601. private _s;
  77602. private _v;
  77603. private _lastPointerDownID;
  77604. /**
  77605. * BABYLON.Observable raised when the value changes
  77606. */
  77607. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  77608. /** Gets or sets the color of the color picker */
  77609. get value(): BABYLON.Color3;
  77610. set value(value: BABYLON.Color3);
  77611. /**
  77612. * Gets or sets control width
  77613. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77614. */
  77615. get width(): string | number;
  77616. set width(value: string | number);
  77617. /**
  77618. * Gets or sets control height
  77619. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77620. */
  77621. get height(): string | number;
  77622. /** Gets or sets control height */
  77623. set height(value: string | number);
  77624. /** Gets or sets control size */
  77625. get size(): string | number;
  77626. set size(value: string | number);
  77627. /**
  77628. * Creates a new ColorPicker
  77629. * @param name defines the control name
  77630. */
  77631. constructor(name?: string | undefined);
  77632. protected _getTypeName(): string;
  77633. /** @hidden */
  77634. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77635. private _updateSquareProps;
  77636. private _drawGradientSquare;
  77637. private _drawCircle;
  77638. private _createColorWheelCanvas;
  77639. /** @hidden */
  77640. _draw(context: CanvasRenderingContext2D): void;
  77641. private _pointerIsDown;
  77642. private _updateValueFromPointer;
  77643. private _isPointOnSquare;
  77644. private _isPointOnWheel;
  77645. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77646. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  77647. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77648. /**
  77649. * This function expands the color picker by creating a color picker dialog with manual
  77650. * color value input and the ability to save colors into an array to be used later in
  77651. * subsequent launches of the dialogue.
  77652. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  77653. * @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.
  77654. * @returns picked color as a hex string and the saved colors array as hex strings.
  77655. */
  77656. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  77657. pickerWidth?: string;
  77658. pickerHeight?: string;
  77659. headerHeight?: string;
  77660. lastColor?: string;
  77661. swatchLimit?: number;
  77662. numSwatchesPerLine?: number;
  77663. savedColors?: Array<string>;
  77664. }): Promise<{
  77665. savedColors?: string[];
  77666. pickedColor: string;
  77667. }>;
  77668. }
  77669. }
  77670. declare module BABYLON.GUI {
  77671. /** Class used to create 2D ellipse containers */
  77672. export class Ellipse extends Container {
  77673. name?: string | undefined;
  77674. private _thickness;
  77675. /** Gets or sets border thickness */
  77676. get thickness(): number;
  77677. set thickness(value: number);
  77678. /**
  77679. * Creates a new Ellipse
  77680. * @param name defines the control name
  77681. */
  77682. constructor(name?: string | undefined);
  77683. protected _getTypeName(): string;
  77684. protected _localDraw(context: CanvasRenderingContext2D): void;
  77685. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77686. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  77687. }
  77688. }
  77689. declare module BABYLON.GUI {
  77690. /**
  77691. * Class used to create a password control
  77692. */
  77693. export class InputPassword extends InputText {
  77694. protected _beforeRenderText(text: string): string;
  77695. }
  77696. }
  77697. declare module BABYLON.GUI {
  77698. /** Class used to render 2D lines */
  77699. export class Line extends Control {
  77700. name?: string | undefined;
  77701. private _lineWidth;
  77702. private _x1;
  77703. private _y1;
  77704. private _x2;
  77705. private _y2;
  77706. private _dash;
  77707. private _connectedControl;
  77708. private _connectedControlDirtyObserver;
  77709. /** Gets or sets the dash pattern */
  77710. get dash(): Array<number>;
  77711. set dash(value: Array<number>);
  77712. /** Gets or sets the control connected with the line end */
  77713. get connectedControl(): Control;
  77714. set connectedControl(value: Control);
  77715. /** Gets or sets start coordinates on X axis */
  77716. get x1(): string | number;
  77717. set x1(value: string | number);
  77718. /** Gets or sets start coordinates on Y axis */
  77719. get y1(): string | number;
  77720. set y1(value: string | number);
  77721. /** Gets or sets end coordinates on X axis */
  77722. get x2(): string | number;
  77723. set x2(value: string | number);
  77724. /** Gets or sets end coordinates on Y axis */
  77725. get y2(): string | number;
  77726. set y2(value: string | number);
  77727. /** Gets or sets line width */
  77728. get lineWidth(): number;
  77729. set lineWidth(value: number);
  77730. /** Gets or sets horizontal alignment */
  77731. set horizontalAlignment(value: number);
  77732. /** Gets or sets vertical alignment */
  77733. set verticalAlignment(value: number);
  77734. private get _effectiveX2();
  77735. private get _effectiveY2();
  77736. /**
  77737. * Creates a new Line
  77738. * @param name defines the control name
  77739. */
  77740. constructor(name?: string | undefined);
  77741. protected _getTypeName(): string;
  77742. _draw(context: CanvasRenderingContext2D): void;
  77743. _measure(): void;
  77744. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77745. /**
  77746. * Move one end of the line given 3D cartesian coordinates.
  77747. * @param position Targeted world position
  77748. * @param scene BABYLON.Scene
  77749. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  77750. */
  77751. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  77752. /**
  77753. * Move one end of the line to a position in screen absolute space.
  77754. * @param projectedPosition Position in screen absolute space (X, Y)
  77755. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  77756. */
  77757. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  77758. }
  77759. }
  77760. declare module BABYLON.GUI {
  77761. /**
  77762. * Class used to store a point for a MultiLine object.
  77763. * The point can be pure 2D coordinates, a mesh or a control
  77764. */
  77765. export class MultiLinePoint {
  77766. private _multiLine;
  77767. private _x;
  77768. private _y;
  77769. private _control;
  77770. private _mesh;
  77771. private _controlObserver;
  77772. private _meshObserver;
  77773. /** @hidden */
  77774. _point: BABYLON.Vector2;
  77775. /**
  77776. * Creates a new MultiLinePoint
  77777. * @param multiLine defines the source MultiLine object
  77778. */
  77779. constructor(multiLine: MultiLine);
  77780. /** Gets or sets x coordinate */
  77781. get x(): string | number;
  77782. set x(value: string | number);
  77783. /** Gets or sets y coordinate */
  77784. get y(): string | number;
  77785. set y(value: string | number);
  77786. /** Gets or sets the control associated with this point */
  77787. get control(): BABYLON.Nullable<Control>;
  77788. set control(value: BABYLON.Nullable<Control>);
  77789. /** Gets or sets the mesh associated with this point */
  77790. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  77791. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  77792. /** Resets links */
  77793. resetLinks(): void;
  77794. /**
  77795. * Gets a translation vector
  77796. * @returns the translation vector
  77797. */
  77798. translate(): BABYLON.Vector2;
  77799. private _translatePoint;
  77800. /** Release associated resources */
  77801. dispose(): void;
  77802. }
  77803. }
  77804. declare module BABYLON.GUI {
  77805. /**
  77806. * Class used to create multi line control
  77807. */
  77808. export class MultiLine extends Control {
  77809. name?: string | undefined;
  77810. private _lineWidth;
  77811. private _dash;
  77812. private _points;
  77813. private _minX;
  77814. private _minY;
  77815. private _maxX;
  77816. private _maxY;
  77817. /**
  77818. * Creates a new MultiLine
  77819. * @param name defines the control name
  77820. */
  77821. constructor(name?: string | undefined);
  77822. /** Gets or sets dash pattern */
  77823. get dash(): Array<number>;
  77824. set dash(value: Array<number>);
  77825. /**
  77826. * Gets point stored at specified index
  77827. * @param index defines the index to look for
  77828. * @returns the requested point if found
  77829. */
  77830. getAt(index: number): MultiLinePoint;
  77831. /** Function called when a point is updated */
  77832. onPointUpdate: () => void;
  77833. /**
  77834. * Adds new points to the point collection
  77835. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  77836. * @returns the list of created MultiLinePoint
  77837. */
  77838. add(...items: (AbstractMesh | Control | {
  77839. x: string | number;
  77840. y: string | number;
  77841. })[]): MultiLinePoint[];
  77842. /**
  77843. * Adds a new point to the point collection
  77844. * @param item defines the item (mesh, control or 2d coordiantes) to add
  77845. * @returns the created MultiLinePoint
  77846. */
  77847. push(item?: (AbstractMesh | Control | {
  77848. x: string | number;
  77849. y: string | number;
  77850. })): MultiLinePoint;
  77851. /**
  77852. * Remove a specific value or point from the active point collection
  77853. * @param value defines the value or point to remove
  77854. */
  77855. remove(value: number | MultiLinePoint): void;
  77856. /**
  77857. * Resets this object to initial state (no point)
  77858. */
  77859. reset(): void;
  77860. /**
  77861. * Resets all links
  77862. */
  77863. resetLinks(): void;
  77864. /** Gets or sets line width */
  77865. get lineWidth(): number;
  77866. set lineWidth(value: number);
  77867. set horizontalAlignment(value: number);
  77868. set verticalAlignment(value: number);
  77869. protected _getTypeName(): string;
  77870. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77871. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77872. _measure(): void;
  77873. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77874. dispose(): void;
  77875. }
  77876. }
  77877. declare module BABYLON.GUI {
  77878. /**
  77879. * Class used to create radio button controls
  77880. */
  77881. export class RadioButton extends Control {
  77882. name?: string | undefined;
  77883. private _isChecked;
  77884. private _background;
  77885. private _checkSizeRatio;
  77886. private _thickness;
  77887. /** Gets or sets border thickness */
  77888. get thickness(): number;
  77889. set thickness(value: number);
  77890. /** Gets or sets group name */
  77891. group: string;
  77892. /** BABYLON.Observable raised when isChecked is changed */
  77893. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  77894. /** Gets or sets a value indicating the ratio between overall size and check size */
  77895. get checkSizeRatio(): number;
  77896. set checkSizeRatio(value: number);
  77897. /** Gets or sets background color */
  77898. get background(): string;
  77899. set background(value: string);
  77900. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  77901. get isChecked(): boolean;
  77902. set isChecked(value: boolean);
  77903. /**
  77904. * Creates a new RadioButton
  77905. * @param name defines the control name
  77906. */
  77907. constructor(name?: string | undefined);
  77908. protected _getTypeName(): string;
  77909. _draw(context: CanvasRenderingContext2D): void;
  77910. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77911. /**
  77912. * Utility function to easily create a radio button with a header
  77913. * @param title defines the label to use for the header
  77914. * @param group defines the group to use for the radio button
  77915. * @param isChecked defines the initial state of the radio button
  77916. * @param onValueChanged defines the callback to call when value changes
  77917. * @returns a StackPanel containing the radio button and a textBlock
  77918. */
  77919. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  77920. }
  77921. }
  77922. declare module BABYLON.GUI {
  77923. /**
  77924. * Class used to create slider controls
  77925. */
  77926. export class BaseSlider extends Control {
  77927. name?: string | undefined;
  77928. protected _thumbWidth: ValueAndUnit;
  77929. private _minimum;
  77930. private _maximum;
  77931. private _value;
  77932. private _isVertical;
  77933. protected _barOffset: ValueAndUnit;
  77934. private _isThumbClamped;
  77935. protected _displayThumb: boolean;
  77936. private _step;
  77937. private _lastPointerDownID;
  77938. protected _effectiveBarOffset: number;
  77939. protected _renderLeft: number;
  77940. protected _renderTop: number;
  77941. protected _renderWidth: number;
  77942. protected _renderHeight: number;
  77943. protected _backgroundBoxLength: number;
  77944. protected _backgroundBoxThickness: number;
  77945. protected _effectiveThumbThickness: number;
  77946. /** BABYLON.Observable raised when the sldier value changes */
  77947. onValueChangedObservable: BABYLON.Observable<number>;
  77948. /** Gets or sets a boolean indicating if the thumb must be rendered */
  77949. get displayThumb(): boolean;
  77950. set displayThumb(value: boolean);
  77951. /** Gets or sets a step to apply to values (0 by default) */
  77952. get step(): number;
  77953. set step(value: number);
  77954. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  77955. get barOffset(): string | number;
  77956. /** Gets main bar offset in pixels*/
  77957. get barOffsetInPixels(): number;
  77958. set barOffset(value: string | number);
  77959. /** Gets or sets thumb width */
  77960. get thumbWidth(): string | number;
  77961. /** Gets thumb width in pixels */
  77962. get thumbWidthInPixels(): number;
  77963. set thumbWidth(value: string | number);
  77964. /** Gets or sets minimum value */
  77965. get minimum(): number;
  77966. set minimum(value: number);
  77967. /** Gets or sets maximum value */
  77968. get maximum(): number;
  77969. set maximum(value: number);
  77970. /** Gets or sets current value */
  77971. get value(): number;
  77972. set value(value: number);
  77973. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  77974. get isVertical(): boolean;
  77975. set isVertical(value: boolean);
  77976. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  77977. get isThumbClamped(): boolean;
  77978. set isThumbClamped(value: boolean);
  77979. /**
  77980. * Creates a new BaseSlider
  77981. * @param name defines the control name
  77982. */
  77983. constructor(name?: string | undefined);
  77984. protected _getTypeName(): string;
  77985. protected _getThumbPosition(): number;
  77986. protected _getThumbThickness(type: string): number;
  77987. protected _prepareRenderingData(type: string): void;
  77988. private _pointerIsDown;
  77989. /** @hidden */
  77990. protected _updateValueFromPointer(x: number, y: number): void;
  77991. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77992. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  77993. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77994. }
  77995. }
  77996. declare module BABYLON.GUI {
  77997. /**
  77998. * Class used to create slider controls
  77999. */
  78000. export class Slider extends BaseSlider {
  78001. name?: string | undefined;
  78002. private _background;
  78003. private _borderColor;
  78004. private _isThumbCircle;
  78005. protected _displayValueBar: boolean;
  78006. /** Gets or sets a boolean indicating if the value bar must be rendered */
  78007. get displayValueBar(): boolean;
  78008. set displayValueBar(value: boolean);
  78009. /** Gets or sets border color */
  78010. get borderColor(): string;
  78011. set borderColor(value: string);
  78012. /** Gets or sets background color */
  78013. get background(): string;
  78014. set background(value: string);
  78015. /** Gets or sets a boolean indicating if the thumb should be round or square */
  78016. get isThumbCircle(): boolean;
  78017. set isThumbCircle(value: boolean);
  78018. /**
  78019. * Creates a new Slider
  78020. * @param name defines the control name
  78021. */
  78022. constructor(name?: string | undefined);
  78023. protected _getTypeName(): string;
  78024. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78025. }
  78026. }
  78027. declare module BABYLON.GUI {
  78028. /** Class used to create a RadioGroup
  78029. * which contains groups of radio buttons
  78030. */
  78031. export class SelectorGroup {
  78032. /** name of SelectorGroup */
  78033. name: string;
  78034. private _groupPanel;
  78035. private _selectors;
  78036. private _groupHeader;
  78037. /**
  78038. * Creates a new SelectorGroup
  78039. * @param name of group, used as a group heading
  78040. */
  78041. constructor(
  78042. /** name of SelectorGroup */
  78043. name: string);
  78044. /** Gets the groupPanel of the SelectorGroup */
  78045. get groupPanel(): StackPanel;
  78046. /** Gets the selectors array */
  78047. get selectors(): StackPanel[];
  78048. /** Gets and sets the group header */
  78049. get header(): string;
  78050. set header(label: string);
  78051. /** @hidden */
  78052. private _addGroupHeader;
  78053. /** @hidden*/
  78054. _getSelector(selectorNb: number): StackPanel | undefined;
  78055. /** Removes the selector at the given position
  78056. * @param selectorNb the position of the selector within the group
  78057. */
  78058. removeSelector(selectorNb: number): void;
  78059. }
  78060. /** Class used to create a CheckboxGroup
  78061. * which contains groups of checkbox buttons
  78062. */
  78063. export class CheckboxGroup extends SelectorGroup {
  78064. /** Adds a checkbox as a control
  78065. * @param text is the label for the selector
  78066. * @param func is the function called when the Selector is checked
  78067. * @param checked is true when Selector is checked
  78068. */
  78069. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  78070. /** @hidden */
  78071. _setSelectorLabel(selectorNb: number, label: string): void;
  78072. /** @hidden */
  78073. _setSelectorLabelColor(selectorNb: number, color: string): void;
  78074. /** @hidden */
  78075. _setSelectorButtonColor(selectorNb: number, color: string): void;
  78076. /** @hidden */
  78077. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  78078. }
  78079. /** Class used to create a RadioGroup
  78080. * which contains groups of radio buttons
  78081. */
  78082. export class RadioGroup extends SelectorGroup {
  78083. private _selectNb;
  78084. /** Adds a radio button as a control
  78085. * @param label is the label for the selector
  78086. * @param func is the function called when the Selector is checked
  78087. * @param checked is true when Selector is checked
  78088. */
  78089. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  78090. /** @hidden */
  78091. _setSelectorLabel(selectorNb: number, label: string): void;
  78092. /** @hidden */
  78093. _setSelectorLabelColor(selectorNb: number, color: string): void;
  78094. /** @hidden */
  78095. _setSelectorButtonColor(selectorNb: number, color: string): void;
  78096. /** @hidden */
  78097. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  78098. }
  78099. /** Class used to create a SliderGroup
  78100. * which contains groups of slider buttons
  78101. */
  78102. export class SliderGroup extends SelectorGroup {
  78103. /**
  78104. * Adds a slider to the SelectorGroup
  78105. * @param label is the label for the SliderBar
  78106. * @param func is the function called when the Slider moves
  78107. * @param unit is a string describing the units used, eg degrees or metres
  78108. * @param min is the minimum value for the Slider
  78109. * @param max is the maximum value for the Slider
  78110. * @param value is the start value for the Slider between min and max
  78111. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  78112. */
  78113. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  78114. /** @hidden */
  78115. _setSelectorLabel(selectorNb: number, label: string): void;
  78116. /** @hidden */
  78117. _setSelectorLabelColor(selectorNb: number, color: string): void;
  78118. /** @hidden */
  78119. _setSelectorButtonColor(selectorNb: number, color: string): void;
  78120. /** @hidden */
  78121. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  78122. }
  78123. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  78124. * @see https://doc.babylonjs.com/how_to/selector
  78125. */
  78126. export class SelectionPanel extends Rectangle {
  78127. /** name of SelectionPanel */
  78128. name: string;
  78129. /** an array of SelectionGroups */
  78130. groups: SelectorGroup[];
  78131. private _panel;
  78132. private _buttonColor;
  78133. private _buttonBackground;
  78134. private _headerColor;
  78135. private _barColor;
  78136. private _barHeight;
  78137. private _spacerHeight;
  78138. private _labelColor;
  78139. private _groups;
  78140. private _bars;
  78141. /**
  78142. * Creates a new SelectionPanel
  78143. * @param name of SelectionPanel
  78144. * @param groups is an array of SelectionGroups
  78145. */
  78146. constructor(
  78147. /** name of SelectionPanel */
  78148. name: string,
  78149. /** an array of SelectionGroups */
  78150. groups?: SelectorGroup[]);
  78151. protected _getTypeName(): string;
  78152. /** Gets or sets the headerColor */
  78153. get headerColor(): string;
  78154. set headerColor(color: string);
  78155. private _setHeaderColor;
  78156. /** Gets or sets the button color */
  78157. get buttonColor(): string;
  78158. set buttonColor(color: string);
  78159. private _setbuttonColor;
  78160. /** Gets or sets the label color */
  78161. get labelColor(): string;
  78162. set labelColor(color: string);
  78163. private _setLabelColor;
  78164. /** Gets or sets the button background */
  78165. get buttonBackground(): string;
  78166. set buttonBackground(color: string);
  78167. private _setButtonBackground;
  78168. /** Gets or sets the color of separator bar */
  78169. get barColor(): string;
  78170. set barColor(color: string);
  78171. private _setBarColor;
  78172. /** Gets or sets the height of separator bar */
  78173. get barHeight(): string;
  78174. set barHeight(value: string);
  78175. private _setBarHeight;
  78176. /** Gets or sets the height of spacers*/
  78177. get spacerHeight(): string;
  78178. set spacerHeight(value: string);
  78179. private _setSpacerHeight;
  78180. /** Adds a bar between groups */
  78181. private _addSpacer;
  78182. /** Add a group to the selection panel
  78183. * @param group is the selector group to add
  78184. */
  78185. addGroup(group: SelectorGroup): void;
  78186. /** Remove the group from the given position
  78187. * @param groupNb is the position of the group in the list
  78188. */
  78189. removeGroup(groupNb: number): void;
  78190. /** Change a group header label
  78191. * @param label is the new group header label
  78192. * @param groupNb is the number of the group to relabel
  78193. * */
  78194. setHeaderName(label: string, groupNb: number): void;
  78195. /** Change selector label to the one given
  78196. * @param label is the new selector label
  78197. * @param groupNb is the number of the groupcontaining the selector
  78198. * @param selectorNb is the number of the selector within a group to relabel
  78199. * */
  78200. relabel(label: string, groupNb: number, selectorNb: number): void;
  78201. /** For a given group position remove the selector at the given position
  78202. * @param groupNb is the number of the group to remove the selector from
  78203. * @param selectorNb is the number of the selector within the group
  78204. */
  78205. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  78206. /** For a given group position of correct type add a checkbox button
  78207. * @param groupNb is the number of the group to remove the selector from
  78208. * @param label is the label for the selector
  78209. * @param func is the function called when the Selector is checked
  78210. * @param checked is true when Selector is checked
  78211. */
  78212. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  78213. /** For a given group position of correct type add a radio button
  78214. * @param groupNb is the number of the group to remove the selector from
  78215. * @param label is the label for the selector
  78216. * @param func is the function called when the Selector is checked
  78217. * @param checked is true when Selector is checked
  78218. */
  78219. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  78220. /**
  78221. * For a given slider group add a slider
  78222. * @param groupNb is the number of the group to add the slider to
  78223. * @param label is the label for the Slider
  78224. * @param func is the function called when the Slider moves
  78225. * @param unit is a string describing the units used, eg degrees or metres
  78226. * @param min is the minimum value for the Slider
  78227. * @param max is the maximum value for the Slider
  78228. * @param value is the start value for the Slider between min and max
  78229. * @param onVal is the function used to format the value displayed, eg radians to degrees
  78230. */
  78231. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  78232. }
  78233. }
  78234. declare module BABYLON.GUI {
  78235. /**
  78236. * Class used to hold a the container for ScrollViewer
  78237. * @hidden
  78238. */
  78239. export class _ScrollViewerWindow extends Container {
  78240. parentClientWidth: number;
  78241. parentClientHeight: number;
  78242. private _freezeControls;
  78243. private _parentMeasure;
  78244. private _oldLeft;
  78245. private _oldTop;
  78246. get freezeControls(): boolean;
  78247. set freezeControls(value: boolean);
  78248. private _bucketWidth;
  78249. private _bucketHeight;
  78250. private _buckets;
  78251. private _bucketLen;
  78252. get bucketWidth(): number;
  78253. get bucketHeight(): number;
  78254. setBucketSizes(width: number, height: number): void;
  78255. private _useBuckets;
  78256. private _makeBuckets;
  78257. private _dispatchInBuckets;
  78258. private _updateMeasures;
  78259. private _updateChildrenMeasures;
  78260. private _restoreMeasures;
  78261. /**
  78262. * Creates a new ScrollViewerWindow
  78263. * @param name of ScrollViewerWindow
  78264. */
  78265. constructor(name?: string);
  78266. protected _getTypeName(): string;
  78267. /** @hidden */
  78268. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78269. /** @hidden */
  78270. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  78271. private _scrollChildren;
  78272. private _scrollChildrenWithBuckets;
  78273. /** @hidden */
  78274. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  78275. protected _postMeasure(): void;
  78276. }
  78277. }
  78278. declare module BABYLON.GUI {
  78279. /**
  78280. * Class used to create slider controls
  78281. */
  78282. export class ScrollBar extends BaseSlider {
  78283. name?: string | undefined;
  78284. private _background;
  78285. private _borderColor;
  78286. private _tempMeasure;
  78287. /** Gets or sets border color */
  78288. get borderColor(): string;
  78289. set borderColor(value: string);
  78290. /** Gets or sets background color */
  78291. get background(): string;
  78292. set background(value: string);
  78293. /**
  78294. * Creates a new Slider
  78295. * @param name defines the control name
  78296. */
  78297. constructor(name?: string | undefined);
  78298. protected _getTypeName(): string;
  78299. protected _getThumbThickness(): number;
  78300. _draw(context: CanvasRenderingContext2D): void;
  78301. private _first;
  78302. private _originX;
  78303. private _originY;
  78304. /** @hidden */
  78305. protected _updateValueFromPointer(x: number, y: number): void;
  78306. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78307. }
  78308. }
  78309. declare module BABYLON.GUI {
  78310. /**
  78311. * Class used to create slider controls
  78312. */
  78313. export class ImageScrollBar extends BaseSlider {
  78314. name?: string | undefined;
  78315. private _backgroundBaseImage;
  78316. private _backgroundImage;
  78317. private _thumbImage;
  78318. private _thumbBaseImage;
  78319. private _thumbLength;
  78320. private _thumbHeight;
  78321. private _barImageHeight;
  78322. private _tempMeasure;
  78323. /** Number of 90° rotation to apply on the images when in vertical mode */
  78324. num90RotationInVerticalMode: number;
  78325. /**
  78326. * Gets or sets the image used to render the background for horizontal bar
  78327. */
  78328. get backgroundImage(): Image;
  78329. set backgroundImage(value: Image);
  78330. /**
  78331. * Gets or sets the image used to render the thumb
  78332. */
  78333. get thumbImage(): Image;
  78334. set thumbImage(value: Image);
  78335. /**
  78336. * Gets or sets the length of the thumb
  78337. */
  78338. get thumbLength(): number;
  78339. set thumbLength(value: number);
  78340. /**
  78341. * Gets or sets the height of the thumb
  78342. */
  78343. get thumbHeight(): number;
  78344. set thumbHeight(value: number);
  78345. /**
  78346. * Gets or sets the height of the bar image
  78347. */
  78348. get barImageHeight(): number;
  78349. set barImageHeight(value: number);
  78350. /**
  78351. * Creates a new ImageScrollBar
  78352. * @param name defines the control name
  78353. */
  78354. constructor(name?: string | undefined);
  78355. protected _getTypeName(): string;
  78356. protected _getThumbThickness(): number;
  78357. _draw(context: CanvasRenderingContext2D): void;
  78358. private _first;
  78359. private _originX;
  78360. private _originY;
  78361. /** @hidden */
  78362. protected _updateValueFromPointer(x: number, y: number): void;
  78363. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78364. }
  78365. }
  78366. declare module BABYLON.GUI {
  78367. /**
  78368. * Class used to hold a viewer window and sliders in a grid
  78369. */
  78370. export class ScrollViewer extends Rectangle {
  78371. private _grid;
  78372. private _horizontalBarSpace;
  78373. private _verticalBarSpace;
  78374. private _dragSpace;
  78375. private _horizontalBar;
  78376. private _verticalBar;
  78377. private _barColor;
  78378. private _barBackground;
  78379. private _barImage;
  78380. private _horizontalBarImage;
  78381. private _verticalBarImage;
  78382. private _barBackgroundImage;
  78383. private _horizontalBarBackgroundImage;
  78384. private _verticalBarBackgroundImage;
  78385. private _barSize;
  78386. private _window;
  78387. private _pointerIsOver;
  78388. private _wheelPrecision;
  78389. private _onWheelObserver;
  78390. private _clientWidth;
  78391. private _clientHeight;
  78392. private _useImageBar;
  78393. private _thumbLength;
  78394. private _thumbHeight;
  78395. private _barImageHeight;
  78396. private _horizontalBarImageHeight;
  78397. private _verticalBarImageHeight;
  78398. private _oldWindowContentsWidth;
  78399. private _oldWindowContentsHeight;
  78400. /**
  78401. * Gets the horizontal scrollbar
  78402. */
  78403. get horizontalBar(): ScrollBar | ImageScrollBar;
  78404. /**
  78405. * Gets the vertical scrollbar
  78406. */
  78407. get verticalBar(): ScrollBar | ImageScrollBar;
  78408. /**
  78409. * Adds a new control to the current container
  78410. * @param control defines the control to add
  78411. * @returns the current container
  78412. */
  78413. addControl(control: BABYLON.Nullable<Control>): Container;
  78414. /**
  78415. * Removes a control from the current container
  78416. * @param control defines the control to remove
  78417. * @returns the current container
  78418. */
  78419. removeControl(control: Control): Container;
  78420. /** Gets the list of children */
  78421. get children(): Control[];
  78422. _flagDescendantsAsMatrixDirty(): void;
  78423. /**
  78424. * Freezes or unfreezes the controls in the window.
  78425. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  78426. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  78427. */
  78428. get freezeControls(): boolean;
  78429. set freezeControls(value: boolean);
  78430. /** Gets the bucket width */
  78431. get bucketWidth(): number;
  78432. /** Gets the bucket height */
  78433. get bucketHeight(): number;
  78434. /**
  78435. * Sets the bucket sizes.
  78436. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  78437. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  78438. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  78439. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  78440. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  78441. * used), that's why it is not enabled by default.
  78442. * @param width width of the bucket
  78443. * @param height height of the bucket
  78444. */
  78445. setBucketSizes(width: number, height: number): void;
  78446. private _forceHorizontalBar;
  78447. private _forceVerticalBar;
  78448. /**
  78449. * Forces the horizontal scroll bar to be displayed
  78450. */
  78451. get forceHorizontalBar(): boolean;
  78452. set forceHorizontalBar(value: boolean);
  78453. /**
  78454. * Forces the vertical scroll bar to be displayed
  78455. */
  78456. get forceVerticalBar(): boolean;
  78457. set forceVerticalBar(value: boolean);
  78458. /**
  78459. * Creates a new ScrollViewer
  78460. * @param name of ScrollViewer
  78461. */
  78462. constructor(name?: string, isImageBased?: boolean);
  78463. /** Reset the scroll viewer window to initial size */
  78464. resetWindow(): void;
  78465. protected _getTypeName(): string;
  78466. private _buildClientSizes;
  78467. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78468. protected _postMeasure(): void;
  78469. /**
  78470. * Gets or sets the mouse wheel precision
  78471. * from 0 to 1 with a default value of 0.05
  78472. * */
  78473. get wheelPrecision(): number;
  78474. set wheelPrecision(value: number);
  78475. /** Gets or sets the scroll bar container background color */
  78476. get scrollBackground(): string;
  78477. set scrollBackground(color: string);
  78478. /** Gets or sets the bar color */
  78479. get barColor(): string;
  78480. set barColor(color: string);
  78481. /** Gets or sets the bar image */
  78482. get thumbImage(): Image;
  78483. set thumbImage(value: Image);
  78484. /** Gets or sets the horizontal bar image */
  78485. get horizontalThumbImage(): Image;
  78486. set horizontalThumbImage(value: Image);
  78487. /** Gets or sets the vertical bar image */
  78488. get verticalThumbImage(): Image;
  78489. set verticalThumbImage(value: Image);
  78490. /** Gets or sets the size of the bar */
  78491. get barSize(): number;
  78492. set barSize(value: number);
  78493. /** Gets or sets the length of the thumb */
  78494. get thumbLength(): number;
  78495. set thumbLength(value: number);
  78496. /** Gets or sets the height of the thumb */
  78497. get thumbHeight(): number;
  78498. set thumbHeight(value: number);
  78499. /** Gets or sets the height of the bar image */
  78500. get barImageHeight(): number;
  78501. set barImageHeight(value: number);
  78502. /** Gets or sets the height of the horizontal bar image */
  78503. get horizontalBarImageHeight(): number;
  78504. set horizontalBarImageHeight(value: number);
  78505. /** Gets or sets the height of the vertical bar image */
  78506. get verticalBarImageHeight(): number;
  78507. set verticalBarImageHeight(value: number);
  78508. /** Gets or sets the bar background */
  78509. get barBackground(): string;
  78510. set barBackground(color: string);
  78511. /** Gets or sets the bar background image */
  78512. get barImage(): Image;
  78513. set barImage(value: Image);
  78514. /** Gets or sets the horizontal bar background image */
  78515. get horizontalBarImage(): Image;
  78516. set horizontalBarImage(value: Image);
  78517. /** Gets or sets the vertical bar background image */
  78518. get verticalBarImage(): Image;
  78519. set verticalBarImage(value: Image);
  78520. private _setWindowPosition;
  78521. /** @hidden */
  78522. private _updateScroller;
  78523. _link(host: AdvancedDynamicTexture): void;
  78524. /** @hidden */
  78525. private _addBar;
  78526. /** @hidden */
  78527. private _attachWheel;
  78528. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  78529. /** Releases associated resources */
  78530. dispose(): void;
  78531. }
  78532. }
  78533. declare module BABYLON.GUI {
  78534. /** Class used to render a grid */
  78535. export class DisplayGrid extends Control {
  78536. name?: string | undefined;
  78537. private _cellWidth;
  78538. private _cellHeight;
  78539. private _minorLineTickness;
  78540. private _minorLineColor;
  78541. private _majorLineTickness;
  78542. private _majorLineColor;
  78543. private _majorLineFrequency;
  78544. private _background;
  78545. private _displayMajorLines;
  78546. private _displayMinorLines;
  78547. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  78548. get displayMinorLines(): boolean;
  78549. set displayMinorLines(value: boolean);
  78550. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  78551. get displayMajorLines(): boolean;
  78552. set displayMajorLines(value: boolean);
  78553. /** Gets or sets background color (Black by default) */
  78554. get background(): string;
  78555. set background(value: string);
  78556. /** Gets or sets the width of each cell (20 by default) */
  78557. get cellWidth(): number;
  78558. set cellWidth(value: number);
  78559. /** Gets or sets the height of each cell (20 by default) */
  78560. get cellHeight(): number;
  78561. set cellHeight(value: number);
  78562. /** Gets or sets the tickness of minor lines (1 by default) */
  78563. get minorLineTickness(): number;
  78564. set minorLineTickness(value: number);
  78565. /** Gets or sets the color of minor lines (DarkGray by default) */
  78566. get minorLineColor(): string;
  78567. set minorLineColor(value: string);
  78568. /** Gets or sets the tickness of major lines (2 by default) */
  78569. get majorLineTickness(): number;
  78570. set majorLineTickness(value: number);
  78571. /** Gets or sets the color of major lines (White by default) */
  78572. get majorLineColor(): string;
  78573. set majorLineColor(value: string);
  78574. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  78575. get majorLineFrequency(): number;
  78576. set majorLineFrequency(value: number);
  78577. /**
  78578. * Creates a new GridDisplayRectangle
  78579. * @param name defines the control name
  78580. */
  78581. constructor(name?: string | undefined);
  78582. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78583. protected _getTypeName(): string;
  78584. }
  78585. }
  78586. declare module BABYLON.GUI {
  78587. /**
  78588. * Class used to create slider controls based on images
  78589. */
  78590. export class ImageBasedSlider extends BaseSlider {
  78591. name?: string | undefined;
  78592. private _backgroundImage;
  78593. private _thumbImage;
  78594. private _valueBarImage;
  78595. private _tempMeasure;
  78596. get displayThumb(): boolean;
  78597. set displayThumb(value: boolean);
  78598. /**
  78599. * Gets or sets the image used to render the background
  78600. */
  78601. get backgroundImage(): Image;
  78602. set backgroundImage(value: Image);
  78603. /**
  78604. * Gets or sets the image used to render the value bar
  78605. */
  78606. get valueBarImage(): Image;
  78607. set valueBarImage(value: Image);
  78608. /**
  78609. * Gets or sets the image used to render the thumb
  78610. */
  78611. get thumbImage(): Image;
  78612. set thumbImage(value: Image);
  78613. /**
  78614. * Creates a new ImageBasedSlider
  78615. * @param name defines the control name
  78616. */
  78617. constructor(name?: string | undefined);
  78618. protected _getTypeName(): string;
  78619. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78620. }
  78621. }
  78622. declare module BABYLON.GUI {
  78623. /**
  78624. * Forcing an export so that this code will execute
  78625. * @hidden
  78626. */
  78627. const name = "Statics";
  78628. }
  78629. declare module BABYLON.GUI {
  78630. /**
  78631. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  78632. */
  78633. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  78634. /**
  78635. * Define the instrumented AdvancedDynamicTexture.
  78636. */
  78637. texture: AdvancedDynamicTexture;
  78638. private _captureRenderTime;
  78639. private _renderTime;
  78640. private _captureLayoutTime;
  78641. private _layoutTime;
  78642. private _onBeginRenderObserver;
  78643. private _onEndRenderObserver;
  78644. private _onBeginLayoutObserver;
  78645. private _onEndLayoutObserver;
  78646. /**
  78647. * Gets the perf counter used to capture render time
  78648. */
  78649. get renderTimeCounter(): BABYLON.PerfCounter;
  78650. /**
  78651. * Gets the perf counter used to capture layout time
  78652. */
  78653. get layoutTimeCounter(): BABYLON.PerfCounter;
  78654. /**
  78655. * Enable or disable the render time capture
  78656. */
  78657. get captureRenderTime(): boolean;
  78658. set captureRenderTime(value: boolean);
  78659. /**
  78660. * Enable or disable the layout time capture
  78661. */
  78662. get captureLayoutTime(): boolean;
  78663. set captureLayoutTime(value: boolean);
  78664. /**
  78665. * Instantiates a new advanced dynamic texture instrumentation.
  78666. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  78667. * @param texture Defines the AdvancedDynamicTexture to instrument
  78668. */
  78669. constructor(
  78670. /**
  78671. * Define the instrumented AdvancedDynamicTexture.
  78672. */
  78673. texture: AdvancedDynamicTexture);
  78674. /**
  78675. * Dispose and release associated resources.
  78676. */
  78677. dispose(): void;
  78678. }
  78679. }
  78680. declare module BABYLON.GUI {
  78681. /**
  78682. * Class used to load GUI via XML.
  78683. */
  78684. export class XmlLoader {
  78685. private _nodes;
  78686. private _nodeTypes;
  78687. private _isLoaded;
  78688. private _objectAttributes;
  78689. private _parentClass;
  78690. /**
  78691. * Create a new xml loader
  78692. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  78693. */
  78694. constructor(parentClass?: null);
  78695. private _getChainElement;
  78696. private _getClassAttribute;
  78697. private _createGuiElement;
  78698. private _parseGrid;
  78699. private _parseElement;
  78700. private _prepareSourceElement;
  78701. private _parseElementsFromSource;
  78702. private _parseXml;
  78703. /**
  78704. * Gets if the loading has finished.
  78705. * @returns whether the loading has finished or not
  78706. */
  78707. isLoaded(): boolean;
  78708. /**
  78709. * Gets a loaded node / control by id.
  78710. * @param id the Controls id set in the xml
  78711. * @returns element of type Control
  78712. */
  78713. getNodeById(id: string): any;
  78714. /**
  78715. * Gets all loaded nodes / controls
  78716. * @returns Array of controls
  78717. */
  78718. getNodes(): any;
  78719. /**
  78720. * Initiates the xml layout loading
  78721. * @param xmlFile defines the xml layout to load
  78722. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  78723. * @param callback defines the callback called on layout load.
  78724. */
  78725. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  78726. }
  78727. }
  78728. declare module BABYLON.GUI {
  78729. /**
  78730. * Class used to create containers for controls
  78731. */
  78732. export class Container3D extends Control3D {
  78733. private _blockLayout;
  78734. /**
  78735. * Gets the list of child controls
  78736. */
  78737. protected _children: Control3D[];
  78738. /**
  78739. * Gets the list of child controls
  78740. */
  78741. get children(): Array<Control3D>;
  78742. /**
  78743. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  78744. * This is helpful to optimize layout operation when adding multiple children in a row
  78745. */
  78746. get blockLayout(): boolean;
  78747. set blockLayout(value: boolean);
  78748. /**
  78749. * Creates a new container
  78750. * @param name defines the container name
  78751. */
  78752. constructor(name?: string);
  78753. /**
  78754. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  78755. * @returns the current container
  78756. */
  78757. updateLayout(): Container3D;
  78758. /**
  78759. * Gets a boolean indicating if the given control is in the children of this control
  78760. * @param control defines the control to check
  78761. * @returns true if the control is in the child list
  78762. */
  78763. containsControl(control: Control3D): boolean;
  78764. /**
  78765. * Adds a control to the children of this control
  78766. * @param control defines the control to add
  78767. * @returns the current container
  78768. */
  78769. addControl(control: Control3D): Container3D;
  78770. /**
  78771. * This function will be called everytime a new control is added
  78772. */
  78773. protected _arrangeChildren(): void;
  78774. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  78775. /**
  78776. * Removes a control from the children of this control
  78777. * @param control defines the control to remove
  78778. * @returns the current container
  78779. */
  78780. removeControl(control: Control3D): Container3D;
  78781. protected _getTypeName(): string;
  78782. /**
  78783. * Releases all associated resources
  78784. */
  78785. dispose(): void;
  78786. /** Control rotation will remain unchanged */
  78787. static readonly UNSET_ORIENTATION: number;
  78788. /** Control will rotate to make it look at sphere central axis */
  78789. static readonly FACEORIGIN_ORIENTATION: number;
  78790. /** Control will rotate to make it look back at sphere central axis */
  78791. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  78792. /** Control will rotate to look at z axis (0, 0, 1) */
  78793. static readonly FACEFORWARD_ORIENTATION: number;
  78794. /** Control will rotate to look at negative z axis (0, 0, -1) */
  78795. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  78796. }
  78797. }
  78798. declare module BABYLON.GUI {
  78799. /**
  78800. * Class used to manage 3D user interface
  78801. * @see https://doc.babylonjs.com/how_to/gui3d
  78802. */
  78803. export class GUI3DManager implements BABYLON.IDisposable {
  78804. private _scene;
  78805. private _sceneDisposeObserver;
  78806. private _utilityLayer;
  78807. private _rootContainer;
  78808. private _pointerObserver;
  78809. private _pointerOutObserver;
  78810. /** @hidden */
  78811. _lastPickedControl: Control3D;
  78812. /** @hidden */
  78813. _lastControlOver: {
  78814. [pointerId: number]: Control3D;
  78815. };
  78816. /** @hidden */
  78817. _lastControlDown: {
  78818. [pointerId: number]: Control3D;
  78819. };
  78820. /**
  78821. * BABYLON.Observable raised when the point picked by the pointer events changed
  78822. */
  78823. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  78824. /** @hidden */
  78825. _sharedMaterials: {
  78826. [key: string]: BABYLON.Material;
  78827. };
  78828. /** Gets the hosting scene */
  78829. get scene(): BABYLON.Scene;
  78830. /** Gets associated utility layer */
  78831. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  78832. /**
  78833. * Creates a new GUI3DManager
  78834. * @param scene
  78835. */
  78836. constructor(scene?: BABYLON.Scene);
  78837. private _handlePointerOut;
  78838. private _doPicking;
  78839. /**
  78840. * Gets the root container
  78841. */
  78842. get rootContainer(): Container3D;
  78843. /**
  78844. * Gets a boolean indicating if the given control is in the root child list
  78845. * @param control defines the control to check
  78846. * @returns true if the control is in the root child list
  78847. */
  78848. containsControl(control: Control3D): boolean;
  78849. /**
  78850. * Adds a control to the root child list
  78851. * @param control defines the control to add
  78852. * @returns the current manager
  78853. */
  78854. addControl(control: Control3D): GUI3DManager;
  78855. /**
  78856. * Removes a control from the root child list
  78857. * @param control defines the control to remove
  78858. * @returns the current container
  78859. */
  78860. removeControl(control: Control3D): GUI3DManager;
  78861. /**
  78862. * Releases all associated resources
  78863. */
  78864. dispose(): void;
  78865. }
  78866. }
  78867. declare module BABYLON.GUI {
  78868. /**
  78869. * Class used to transport BABYLON.Vector3 information for pointer events
  78870. */
  78871. export class Vector3WithInfo extends BABYLON.Vector3 {
  78872. /** defines the current mouse button index */
  78873. buttonIndex: number;
  78874. /**
  78875. * Creates a new Vector3WithInfo
  78876. * @param source defines the vector3 data to transport
  78877. * @param buttonIndex defines the current mouse button index
  78878. */
  78879. constructor(source: BABYLON.Vector3,
  78880. /** defines the current mouse button index */
  78881. buttonIndex?: number);
  78882. }
  78883. }
  78884. declare module BABYLON.GUI {
  78885. /**
  78886. * Class used as base class for controls
  78887. */
  78888. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  78889. /** Defines the control name */
  78890. name?: string | undefined;
  78891. /** @hidden */
  78892. _host: GUI3DManager;
  78893. private _node;
  78894. private _downCount;
  78895. private _enterCount;
  78896. private _downPointerIds;
  78897. private _isVisible;
  78898. /** Gets or sets the control position in world space */
  78899. get position(): BABYLON.Vector3;
  78900. set position(value: BABYLON.Vector3);
  78901. /** Gets or sets the control scaling in world space */
  78902. get scaling(): BABYLON.Vector3;
  78903. set scaling(value: BABYLON.Vector3);
  78904. /** Callback used to start pointer enter animation */
  78905. pointerEnterAnimation: () => void;
  78906. /** Callback used to start pointer out animation */
  78907. pointerOutAnimation: () => void;
  78908. /** Callback used to start pointer down animation */
  78909. pointerDownAnimation: () => void;
  78910. /** Callback used to start pointer up animation */
  78911. pointerUpAnimation: () => void;
  78912. /**
  78913. * An event triggered when the pointer move over the control
  78914. */
  78915. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  78916. /**
  78917. * An event triggered when the pointer move out of the control
  78918. */
  78919. onPointerOutObservable: BABYLON.Observable<Control3D>;
  78920. /**
  78921. * An event triggered when the pointer taps the control
  78922. */
  78923. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  78924. /**
  78925. * An event triggered when pointer is up
  78926. */
  78927. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  78928. /**
  78929. * An event triggered when a control is clicked on (with a mouse)
  78930. */
  78931. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  78932. /**
  78933. * An event triggered when pointer enters the control
  78934. */
  78935. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  78936. /**
  78937. * Gets or sets the parent container
  78938. */
  78939. parent: BABYLON.Nullable<Container3D>;
  78940. private _behaviors;
  78941. /**
  78942. * Gets the list of attached behaviors
  78943. * @see https://doc.babylonjs.com/features/behaviour
  78944. */
  78945. get behaviors(): BABYLON.Behavior<Control3D>[];
  78946. /**
  78947. * Attach a behavior to the control
  78948. * @see https://doc.babylonjs.com/features/behaviour
  78949. * @param behavior defines the behavior to attach
  78950. * @returns the current control
  78951. */
  78952. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  78953. /**
  78954. * Remove an attached behavior
  78955. * @see https://doc.babylonjs.com/features/behaviour
  78956. * @param behavior defines the behavior to attach
  78957. * @returns the current control
  78958. */
  78959. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  78960. /**
  78961. * Gets an attached behavior by name
  78962. * @param name defines the name of the behavior to look for
  78963. * @see https://doc.babylonjs.com/features/behaviour
  78964. * @returns null if behavior was not found else the requested behavior
  78965. */
  78966. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  78967. /** Gets or sets a boolean indicating if the control is visible */
  78968. get isVisible(): boolean;
  78969. set isVisible(value: boolean);
  78970. /**
  78971. * Creates a new control
  78972. * @param name defines the control name
  78973. */
  78974. constructor(
  78975. /** Defines the control name */
  78976. name?: string | undefined);
  78977. /**
  78978. * Gets a string representing the class name
  78979. */
  78980. get typeName(): string;
  78981. /**
  78982. * Get the current class name of the control.
  78983. * @returns current class name
  78984. */
  78985. getClassName(): string;
  78986. protected _getTypeName(): string;
  78987. /**
  78988. * Gets the transform node used by this control
  78989. */
  78990. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  78991. /**
  78992. * Gets the mesh used to render this control
  78993. */
  78994. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  78995. /**
  78996. * Link the control as child of the given node
  78997. * @param node defines the node to link to. Use null to unlink the control
  78998. * @returns the current control
  78999. */
  79000. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  79001. /** @hidden **/
  79002. _prepareNode(scene: BABYLON.Scene): void;
  79003. /**
  79004. * Node creation.
  79005. * Can be overriden by children
  79006. * @param scene defines the scene where the node must be attached
  79007. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  79008. */
  79009. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  79010. /**
  79011. * Affect a material to the given mesh
  79012. * @param mesh defines the mesh which will represent the control
  79013. */
  79014. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  79015. /** @hidden */
  79016. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  79017. /** @hidden */
  79018. _onPointerEnter(target: Control3D): boolean;
  79019. /** @hidden */
  79020. _onPointerOut(target: Control3D): void;
  79021. /** @hidden */
  79022. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  79023. /** @hidden */
  79024. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  79025. /** @hidden */
  79026. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  79027. /** @hidden */
  79028. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  79029. /** @hidden */
  79030. _disposeNode(): void;
  79031. /**
  79032. * Releases all associated resources
  79033. */
  79034. dispose(): void;
  79035. }
  79036. }
  79037. declare module BABYLON.GUI {
  79038. /**
  79039. * Class used as a root to all buttons
  79040. */
  79041. export class AbstractButton3D extends Control3D {
  79042. /**
  79043. * Creates a new button
  79044. * @param name defines the control name
  79045. */
  79046. constructor(name?: string);
  79047. protected _getTypeName(): string;
  79048. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  79049. }
  79050. }
  79051. declare module BABYLON.GUI {
  79052. /**
  79053. * Class used to create a button in 3D
  79054. */
  79055. export class Button3D extends AbstractButton3D {
  79056. /** @hidden */
  79057. protected _currentMaterial: BABYLON.Material;
  79058. private _facadeTexture;
  79059. private _content;
  79060. private _contentResolution;
  79061. private _contentScaleRatio;
  79062. /**
  79063. * Gets or sets the texture resolution used to render content (512 by default)
  79064. */
  79065. get contentResolution(): BABYLON.int;
  79066. set contentResolution(value: BABYLON.int);
  79067. /**
  79068. * Gets or sets the texture scale ratio used to render content (2 by default)
  79069. */
  79070. get contentScaleRatio(): number;
  79071. set contentScaleRatio(value: number);
  79072. protected _disposeFacadeTexture(): void;
  79073. protected _resetContent(): void;
  79074. /**
  79075. * Creates a new button
  79076. * @param name defines the control name
  79077. */
  79078. constructor(name?: string);
  79079. /**
  79080. * Gets or sets the GUI 2D content used to display the button's facade
  79081. */
  79082. get content(): Control;
  79083. set content(value: Control);
  79084. /**
  79085. * Apply the facade texture (created from the content property).
  79086. * This function can be overloaded by child classes
  79087. * @param facadeTexture defines the AdvancedDynamicTexture to use
  79088. */
  79089. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  79090. protected _getTypeName(): string;
  79091. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  79092. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  79093. /**
  79094. * Releases all associated resources
  79095. */
  79096. dispose(): void;
  79097. }
  79098. }
  79099. declare module BABYLON.GUI {
  79100. /**
  79101. * Abstract class used to create a container panel deployed on the surface of a volume
  79102. */
  79103. export abstract class VolumeBasedPanel extends Container3D {
  79104. private _columns;
  79105. private _rows;
  79106. private _rowThenColum;
  79107. private _orientation;
  79108. protected _cellWidth: number;
  79109. protected _cellHeight: number;
  79110. /**
  79111. * Gets or sets the distance between elements
  79112. */
  79113. margin: number;
  79114. /**
  79115. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  79116. * | Value | Type | Description |
  79117. * | ----- | ----------------------------------- | ----------- |
  79118. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  79119. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  79120. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  79121. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  79122. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  79123. */
  79124. get orientation(): number;
  79125. set orientation(value: number);
  79126. /**
  79127. * Gets or sets the number of columns requested (10 by default).
  79128. * The panel will automatically compute the number of rows based on number of child controls.
  79129. */
  79130. get columns(): BABYLON.int;
  79131. set columns(value: BABYLON.int);
  79132. /**
  79133. * Gets or sets a the number of rows requested.
  79134. * The panel will automatically compute the number of columns based on number of child controls.
  79135. */
  79136. get rows(): BABYLON.int;
  79137. set rows(value: BABYLON.int);
  79138. /**
  79139. * Creates new VolumeBasedPanel
  79140. */
  79141. constructor();
  79142. protected _arrangeChildren(): void;
  79143. /** Child classes must implement this function to provide correct control positioning */
  79144. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  79145. /** Child classes can implement this function to provide additional processing */
  79146. protected _finalProcessing(): void;
  79147. }
  79148. }
  79149. declare module BABYLON.GUI {
  79150. /**
  79151. * Class used to create a container panel deployed on the surface of a cylinder
  79152. */
  79153. export class CylinderPanel extends VolumeBasedPanel {
  79154. private _radius;
  79155. /**
  79156. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  79157. */
  79158. get radius(): BABYLON.float;
  79159. set radius(value: BABYLON.float);
  79160. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  79161. private _cylindricalMapping;
  79162. }
  79163. }
  79164. declare module BABYLON.GUI {
  79165. /** @hidden */
  79166. export var fluentVertexShader: {
  79167. name: string;
  79168. shader: string;
  79169. };
  79170. }
  79171. declare module BABYLON.GUI {
  79172. /** @hidden */
  79173. export var fluentPixelShader: {
  79174. name: string;
  79175. shader: string;
  79176. };
  79177. }
  79178. declare module BABYLON.GUI {
  79179. /** @hidden */
  79180. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  79181. INNERGLOW: boolean;
  79182. BORDER: boolean;
  79183. HOVERLIGHT: boolean;
  79184. TEXTURE: boolean;
  79185. constructor();
  79186. }
  79187. /**
  79188. * Class used to render controls with fluent desgin
  79189. */
  79190. export class FluentMaterial extends BABYLON.PushMaterial {
  79191. /**
  79192. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  79193. */
  79194. innerGlowColorIntensity: number;
  79195. /**
  79196. * Gets or sets the inner glow color (white by default)
  79197. */
  79198. innerGlowColor: BABYLON.Color3;
  79199. /**
  79200. * Gets or sets alpha value (default is 1.0)
  79201. */
  79202. alpha: number;
  79203. /**
  79204. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  79205. */
  79206. albedoColor: BABYLON.Color3;
  79207. /**
  79208. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  79209. */
  79210. renderBorders: boolean;
  79211. /**
  79212. * Gets or sets border width (default is 0.5)
  79213. */
  79214. borderWidth: number;
  79215. /**
  79216. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  79217. */
  79218. edgeSmoothingValue: number;
  79219. /**
  79220. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  79221. */
  79222. borderMinValue: number;
  79223. /**
  79224. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  79225. */
  79226. renderHoverLight: boolean;
  79227. /**
  79228. * Gets or sets the radius used to render the hover light (default is 1.0)
  79229. */
  79230. hoverRadius: number;
  79231. /**
  79232. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  79233. */
  79234. hoverColor: BABYLON.Color4;
  79235. /**
  79236. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  79237. */
  79238. hoverPosition: BABYLON.Vector3;
  79239. private _albedoTexture;
  79240. /** Gets or sets the texture to use for albedo color */
  79241. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  79242. /**
  79243. * Creates a new Fluent material
  79244. * @param name defines the name of the material
  79245. * @param scene defines the hosting scene
  79246. */
  79247. constructor(name: string, scene: BABYLON.Scene);
  79248. needAlphaBlending(): boolean;
  79249. needAlphaTesting(): boolean;
  79250. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79251. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79252. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79253. getActiveTextures(): BABYLON.BaseTexture[];
  79254. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79255. dispose(forceDisposeEffect?: boolean): void;
  79256. clone(name: string): FluentMaterial;
  79257. serialize(): any;
  79258. getClassName(): string;
  79259. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  79260. }
  79261. }
  79262. declare module BABYLON.GUI {
  79263. /**
  79264. * Class used to create a holographic button in 3D
  79265. */
  79266. export class HolographicButton extends Button3D {
  79267. private _backPlate;
  79268. private _textPlate;
  79269. private _frontPlate;
  79270. private _text;
  79271. private _imageUrl;
  79272. private _shareMaterials;
  79273. private _frontMaterial;
  79274. private _backMaterial;
  79275. private _plateMaterial;
  79276. private _pickedPointObserver;
  79277. private _tooltipFade;
  79278. private _tooltipTextBlock;
  79279. private _tooltipTexture;
  79280. private _tooltipMesh;
  79281. private _tooltipHoverObserver;
  79282. private _tooltipOutObserver;
  79283. private _disposeTooltip;
  79284. /**
  79285. * Rendering ground id of all the mesh in the button
  79286. */
  79287. set renderingGroupId(id: number);
  79288. get renderingGroupId(): number;
  79289. /**
  79290. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  79291. */
  79292. set tooltipText(text: BABYLON.Nullable<string>);
  79293. get tooltipText(): BABYLON.Nullable<string>;
  79294. /**
  79295. * Gets or sets text for the button
  79296. */
  79297. get text(): string;
  79298. set text(value: string);
  79299. /**
  79300. * Gets or sets the image url for the button
  79301. */
  79302. get imageUrl(): string;
  79303. set imageUrl(value: string);
  79304. /**
  79305. * Gets the back material used by this button
  79306. */
  79307. get backMaterial(): FluentMaterial;
  79308. /**
  79309. * Gets the front material used by this button
  79310. */
  79311. get frontMaterial(): FluentMaterial;
  79312. /**
  79313. * Gets the plate material used by this button
  79314. */
  79315. get plateMaterial(): BABYLON.StandardMaterial;
  79316. /**
  79317. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  79318. */
  79319. get shareMaterials(): boolean;
  79320. /**
  79321. * Creates a new button
  79322. * @param name defines the control name
  79323. */
  79324. constructor(name?: string, shareMaterials?: boolean);
  79325. protected _getTypeName(): string;
  79326. private _rebuildContent;
  79327. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  79328. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  79329. private _createBackMaterial;
  79330. private _createFrontMaterial;
  79331. private _createPlateMaterial;
  79332. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  79333. /**
  79334. * Releases all associated resources
  79335. */
  79336. dispose(): void;
  79337. }
  79338. }
  79339. declare module BABYLON.GUI {
  79340. /**
  79341. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  79342. */
  79343. export class MeshButton3D extends Button3D {
  79344. /** @hidden */
  79345. protected _currentMesh: BABYLON.Mesh;
  79346. /**
  79347. * Creates a new 3D button based on a mesh
  79348. * @param mesh mesh to become a 3D button
  79349. * @param name defines the control name
  79350. */
  79351. constructor(mesh: BABYLON.Mesh, name?: string);
  79352. protected _getTypeName(): string;
  79353. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  79354. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  79355. }
  79356. }
  79357. declare module BABYLON.GUI {
  79358. /**
  79359. * Class used to create a container panel deployed on the surface of a plane
  79360. */
  79361. export class PlanePanel extends VolumeBasedPanel {
  79362. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  79363. }
  79364. }
  79365. declare module BABYLON.GUI {
  79366. /**
  79367. * Class used to create a container panel where items get randomized planar mapping
  79368. */
  79369. export class ScatterPanel extends VolumeBasedPanel {
  79370. private _iteration;
  79371. /**
  79372. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  79373. */
  79374. get iteration(): BABYLON.float;
  79375. set iteration(value: BABYLON.float);
  79376. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  79377. private _scatterMapping;
  79378. protected _finalProcessing(): void;
  79379. }
  79380. }
  79381. declare module BABYLON.GUI {
  79382. /**
  79383. * Class used to create a container panel deployed on the surface of a sphere
  79384. */
  79385. export class SpherePanel extends VolumeBasedPanel {
  79386. private _radius;
  79387. /**
  79388. * Gets or sets the radius of the sphere where to project controls (5 by default)
  79389. */
  79390. get radius(): BABYLON.float;
  79391. set radius(value: BABYLON.float);
  79392. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  79393. private _sphericalMapping;
  79394. }
  79395. }
  79396. declare module BABYLON.GUI {
  79397. /**
  79398. * Class used to create a stack panel in 3D on XY plane
  79399. */
  79400. export class StackPanel3D extends Container3D {
  79401. private _isVertical;
  79402. /**
  79403. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  79404. */
  79405. get isVertical(): boolean;
  79406. set isVertical(value: boolean);
  79407. /**
  79408. * Gets or sets the distance between elements
  79409. */
  79410. margin: number;
  79411. /**
  79412. * Creates new StackPanel
  79413. * @param isVertical
  79414. */
  79415. constructor(isVertical?: boolean);
  79416. protected _arrangeChildren(): void;
  79417. }
  79418. }
  79419. declare module BABYLON {
  79420. /**
  79421. * Configuration for glTF validation
  79422. */
  79423. export interface IGLTFValidationConfiguration {
  79424. /**
  79425. * The url of the glTF validator.
  79426. */
  79427. url: string;
  79428. }
  79429. /**
  79430. * glTF validation
  79431. */
  79432. export class GLTFValidation {
  79433. /**
  79434. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  79435. */
  79436. static Configuration: IGLTFValidationConfiguration;
  79437. private static _LoadScriptPromise;
  79438. /**
  79439. * Validate a glTF asset using the glTF-Validator.
  79440. * @param data The JSON of a glTF or the array buffer of a binary glTF
  79441. * @param rootUrl The root url for the glTF
  79442. * @param fileName The file name for the glTF
  79443. * @param getExternalResource The callback to get external resources for the glTF validator
  79444. * @returns A promise that resolves with the glTF validation results once complete
  79445. */
  79446. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  79447. }
  79448. }
  79449. declare module BABYLON {
  79450. /**
  79451. * Mode that determines the coordinate system to use.
  79452. */
  79453. export enum GLTFLoaderCoordinateSystemMode {
  79454. /**
  79455. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  79456. */
  79457. AUTO = 0,
  79458. /**
  79459. * Sets the useRightHandedSystem flag on the scene.
  79460. */
  79461. FORCE_RIGHT_HANDED = 1
  79462. }
  79463. /**
  79464. * Mode that determines what animations will start.
  79465. */
  79466. export enum GLTFLoaderAnimationStartMode {
  79467. /**
  79468. * No animation will start.
  79469. */
  79470. NONE = 0,
  79471. /**
  79472. * The first animation will start.
  79473. */
  79474. FIRST = 1,
  79475. /**
  79476. * All animations will start.
  79477. */
  79478. ALL = 2
  79479. }
  79480. /**
  79481. * Interface that contains the data for the glTF asset.
  79482. */
  79483. export interface IGLTFLoaderData {
  79484. /**
  79485. * The object that represents the glTF JSON.
  79486. */
  79487. json: Object;
  79488. /**
  79489. * The BIN chunk of a binary glTF.
  79490. */
  79491. bin: Nullable<IDataBuffer>;
  79492. }
  79493. /**
  79494. * Interface for extending the loader.
  79495. */
  79496. export interface IGLTFLoaderExtension {
  79497. /**
  79498. * The name of this extension.
  79499. */
  79500. readonly name: string;
  79501. /**
  79502. * Defines whether this extension is enabled.
  79503. */
  79504. enabled: boolean;
  79505. /**
  79506. * Defines the order of this extension.
  79507. * The loader sorts the extensions using these values when loading.
  79508. */
  79509. order?: number;
  79510. }
  79511. /**
  79512. * Loader state.
  79513. */
  79514. export enum GLTFLoaderState {
  79515. /**
  79516. * The asset is loading.
  79517. */
  79518. LOADING = 0,
  79519. /**
  79520. * The asset is ready for rendering.
  79521. */
  79522. READY = 1,
  79523. /**
  79524. * The asset is completely loaded.
  79525. */
  79526. COMPLETE = 2
  79527. }
  79528. /** @hidden */
  79529. export interface IImportMeshAsyncOutput {
  79530. meshes: AbstractMesh[];
  79531. particleSystems: IParticleSystem[];
  79532. skeletons: Skeleton[];
  79533. animationGroups: AnimationGroup[];
  79534. lights: Light[];
  79535. transformNodes: TransformNode[];
  79536. }
  79537. /** @hidden */
  79538. export interface IGLTFLoader extends IDisposable {
  79539. readonly state: Nullable<GLTFLoaderState>;
  79540. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  79541. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  79542. }
  79543. /**
  79544. * File loader for loading glTF files into a scene.
  79545. */
  79546. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  79547. /** @hidden */
  79548. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  79549. /** @hidden */
  79550. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  79551. /**
  79552. * Raised when the asset has been parsed
  79553. */
  79554. onParsedObservable: Observable<IGLTFLoaderData>;
  79555. private _onParsedObserver;
  79556. /**
  79557. * Raised when the asset has been parsed
  79558. */
  79559. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  79560. /**
  79561. * 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.
  79562. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  79563. * Defaults to true.
  79564. * @hidden
  79565. */
  79566. static IncrementalLoading: boolean;
  79567. /**
  79568. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  79569. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  79570. * @hidden
  79571. */
  79572. static HomogeneousCoordinates: boolean;
  79573. /**
  79574. * The coordinate system mode. Defaults to AUTO.
  79575. */
  79576. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  79577. /**
  79578. * The animation start mode. Defaults to FIRST.
  79579. */
  79580. animationStartMode: GLTFLoaderAnimationStartMode;
  79581. /**
  79582. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  79583. */
  79584. compileMaterials: boolean;
  79585. /**
  79586. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  79587. */
  79588. useClipPlane: boolean;
  79589. /**
  79590. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  79591. */
  79592. compileShadowGenerators: boolean;
  79593. /**
  79594. * Defines if the Alpha blended materials are only applied as coverage.
  79595. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  79596. * If true, no extra effects are applied to transparent pixels.
  79597. */
  79598. transparencyAsCoverage: boolean;
  79599. /**
  79600. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  79601. * Enabling will disable offline support and glTF validator.
  79602. * Defaults to false.
  79603. */
  79604. useRangeRequests: boolean;
  79605. /**
  79606. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  79607. */
  79608. createInstances: boolean;
  79609. /**
  79610. * 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.
  79611. */
  79612. alwaysComputeBoundingBox: boolean;
  79613. /**
  79614. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  79615. */
  79616. loadAllMaterials: boolean;
  79617. /**
  79618. * Function called before loading a url referenced by the asset.
  79619. */
  79620. preprocessUrlAsync: (url: string) => Promise<string>;
  79621. /**
  79622. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  79623. */
  79624. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  79625. private _onMeshLoadedObserver;
  79626. /**
  79627. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  79628. */
  79629. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  79630. /**
  79631. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  79632. */
  79633. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  79634. private _onTextureLoadedObserver;
  79635. /**
  79636. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  79637. */
  79638. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  79639. /**
  79640. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  79641. */
  79642. readonly onMaterialLoadedObservable: Observable<Material>;
  79643. private _onMaterialLoadedObserver;
  79644. /**
  79645. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  79646. */
  79647. set onMaterialLoaded(callback: (material: Material) => void);
  79648. /**
  79649. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  79650. */
  79651. readonly onCameraLoadedObservable: Observable<Camera>;
  79652. private _onCameraLoadedObserver;
  79653. /**
  79654. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  79655. */
  79656. set onCameraLoaded(callback: (camera: Camera) => void);
  79657. /**
  79658. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  79659. * For assets with LODs, raised when all of the LODs are complete.
  79660. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  79661. */
  79662. readonly onCompleteObservable: Observable<void>;
  79663. private _onCompleteObserver;
  79664. /**
  79665. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  79666. * For assets with LODs, raised when all of the LODs are complete.
  79667. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  79668. */
  79669. set onComplete(callback: () => void);
  79670. /**
  79671. * Observable raised when an error occurs.
  79672. */
  79673. readonly onErrorObservable: Observable<any>;
  79674. private _onErrorObserver;
  79675. /**
  79676. * Callback raised when an error occurs.
  79677. */
  79678. set onError(callback: (reason: any) => void);
  79679. /**
  79680. * Observable raised after the loader is disposed.
  79681. */
  79682. readonly onDisposeObservable: Observable<void>;
  79683. private _onDisposeObserver;
  79684. /**
  79685. * Callback raised after the loader is disposed.
  79686. */
  79687. set onDispose(callback: () => void);
  79688. /**
  79689. * Observable raised after a loader extension is created.
  79690. * Set additional options for a loader extension in this event.
  79691. */
  79692. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  79693. private _onExtensionLoadedObserver;
  79694. /**
  79695. * Callback raised after a loader extension is created.
  79696. */
  79697. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  79698. /**
  79699. * Defines if the loader logging is enabled.
  79700. */
  79701. get loggingEnabled(): boolean;
  79702. set loggingEnabled(value: boolean);
  79703. /**
  79704. * Defines if the loader should capture performance counters.
  79705. */
  79706. get capturePerformanceCounters(): boolean;
  79707. set capturePerformanceCounters(value: boolean);
  79708. /**
  79709. * Defines if the loader should validate the asset.
  79710. */
  79711. validate: boolean;
  79712. /**
  79713. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  79714. */
  79715. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  79716. private _onValidatedObserver;
  79717. /**
  79718. * Callback raised after a loader extension is created.
  79719. */
  79720. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  79721. private _loader;
  79722. private _progressCallback?;
  79723. private _requests;
  79724. private static magicBase64Encoded;
  79725. /**
  79726. * Name of the loader ("gltf")
  79727. */
  79728. name: string;
  79729. /** @hidden */
  79730. extensions: ISceneLoaderPluginExtensions;
  79731. /**
  79732. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  79733. */
  79734. dispose(): void;
  79735. /** @hidden */
  79736. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  79737. /** @hidden */
  79738. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  79739. /** @hidden */
  79740. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  79741. meshes: AbstractMesh[];
  79742. particleSystems: IParticleSystem[];
  79743. skeletons: Skeleton[];
  79744. animationGroups: AnimationGroup[];
  79745. }>;
  79746. /** @hidden */
  79747. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  79748. /** @hidden */
  79749. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  79750. /** @hidden */
  79751. canDirectLoad(data: string): boolean;
  79752. /** @hidden */
  79753. directLoad(scene: Scene, data: string): Promise<any>;
  79754. /**
  79755. * The callback that allows custom handling of the root url based on the response url.
  79756. * @param rootUrl the original root url
  79757. * @param responseURL the response url if available
  79758. * @returns the new root url
  79759. */
  79760. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  79761. /** @hidden */
  79762. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  79763. /**
  79764. * The loader state or null if the loader is not active.
  79765. */
  79766. get loaderState(): Nullable<GLTFLoaderState>;
  79767. /**
  79768. * Returns a promise that resolves when the asset is completely loaded.
  79769. * @returns a promise that resolves when the asset is completely loaded.
  79770. */
  79771. whenCompleteAsync(): Promise<void>;
  79772. /** @hidden */
  79773. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  79774. /** @hidden */
  79775. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  79776. private _onProgress;
  79777. private _validate;
  79778. private _getLoader;
  79779. private _parseJson;
  79780. private _unpackBinaryAsync;
  79781. private _unpackBinaryV1Async;
  79782. private _unpackBinaryV2Async;
  79783. private static _parseVersion;
  79784. private static _compareVersion;
  79785. private static readonly _logSpaces;
  79786. private _logIndentLevel;
  79787. private _loggingEnabled;
  79788. /** @hidden */
  79789. _log: (message: string) => void;
  79790. /** @hidden */
  79791. _logOpen(message: string): void;
  79792. /** @hidden */
  79793. _logClose(): void;
  79794. private _logEnabled;
  79795. private _logDisabled;
  79796. private _capturePerformanceCounters;
  79797. /** @hidden */
  79798. _startPerformanceCounter: (counterName: string) => void;
  79799. /** @hidden */
  79800. _endPerformanceCounter: (counterName: string) => void;
  79801. private _startPerformanceCounterEnabled;
  79802. private _startPerformanceCounterDisabled;
  79803. private _endPerformanceCounterEnabled;
  79804. private _endPerformanceCounterDisabled;
  79805. }
  79806. }
  79807. declare module BABYLON.GLTF1 {
  79808. /**
  79809. * Enums
  79810. * @hidden
  79811. */
  79812. export enum EComponentType {
  79813. BYTE = 5120,
  79814. UNSIGNED_BYTE = 5121,
  79815. SHORT = 5122,
  79816. UNSIGNED_SHORT = 5123,
  79817. FLOAT = 5126
  79818. }
  79819. /** @hidden */
  79820. export enum EShaderType {
  79821. FRAGMENT = 35632,
  79822. VERTEX = 35633
  79823. }
  79824. /** @hidden */
  79825. export enum EParameterType {
  79826. BYTE = 5120,
  79827. UNSIGNED_BYTE = 5121,
  79828. SHORT = 5122,
  79829. UNSIGNED_SHORT = 5123,
  79830. INT = 5124,
  79831. UNSIGNED_INT = 5125,
  79832. FLOAT = 5126,
  79833. FLOAT_VEC2 = 35664,
  79834. FLOAT_VEC3 = 35665,
  79835. FLOAT_VEC4 = 35666,
  79836. INT_VEC2 = 35667,
  79837. INT_VEC3 = 35668,
  79838. INT_VEC4 = 35669,
  79839. BOOL = 35670,
  79840. BOOL_VEC2 = 35671,
  79841. BOOL_VEC3 = 35672,
  79842. BOOL_VEC4 = 35673,
  79843. FLOAT_MAT2 = 35674,
  79844. FLOAT_MAT3 = 35675,
  79845. FLOAT_MAT4 = 35676,
  79846. SAMPLER_2D = 35678
  79847. }
  79848. /** @hidden */
  79849. export enum ETextureWrapMode {
  79850. CLAMP_TO_EDGE = 33071,
  79851. MIRRORED_REPEAT = 33648,
  79852. REPEAT = 10497
  79853. }
  79854. /** @hidden */
  79855. export enum ETextureFilterType {
  79856. NEAREST = 9728,
  79857. LINEAR = 9728,
  79858. NEAREST_MIPMAP_NEAREST = 9984,
  79859. LINEAR_MIPMAP_NEAREST = 9985,
  79860. NEAREST_MIPMAP_LINEAR = 9986,
  79861. LINEAR_MIPMAP_LINEAR = 9987
  79862. }
  79863. /** @hidden */
  79864. export enum ETextureFormat {
  79865. ALPHA = 6406,
  79866. RGB = 6407,
  79867. RGBA = 6408,
  79868. LUMINANCE = 6409,
  79869. LUMINANCE_ALPHA = 6410
  79870. }
  79871. /** @hidden */
  79872. export enum ECullingType {
  79873. FRONT = 1028,
  79874. BACK = 1029,
  79875. FRONT_AND_BACK = 1032
  79876. }
  79877. /** @hidden */
  79878. export enum EBlendingFunction {
  79879. ZERO = 0,
  79880. ONE = 1,
  79881. SRC_COLOR = 768,
  79882. ONE_MINUS_SRC_COLOR = 769,
  79883. DST_COLOR = 774,
  79884. ONE_MINUS_DST_COLOR = 775,
  79885. SRC_ALPHA = 770,
  79886. ONE_MINUS_SRC_ALPHA = 771,
  79887. DST_ALPHA = 772,
  79888. ONE_MINUS_DST_ALPHA = 773,
  79889. CONSTANT_COLOR = 32769,
  79890. ONE_MINUS_CONSTANT_COLOR = 32770,
  79891. CONSTANT_ALPHA = 32771,
  79892. ONE_MINUS_CONSTANT_ALPHA = 32772,
  79893. SRC_ALPHA_SATURATE = 776
  79894. }
  79895. /** @hidden */
  79896. export interface IGLTFProperty {
  79897. extensions?: {
  79898. [key: string]: any;
  79899. };
  79900. extras?: Object;
  79901. }
  79902. /** @hidden */
  79903. export interface IGLTFChildRootProperty extends IGLTFProperty {
  79904. name?: string;
  79905. }
  79906. /** @hidden */
  79907. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  79908. bufferView: string;
  79909. byteOffset: number;
  79910. byteStride: number;
  79911. count: number;
  79912. type: string;
  79913. componentType: EComponentType;
  79914. max?: number[];
  79915. min?: number[];
  79916. name?: string;
  79917. }
  79918. /** @hidden */
  79919. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  79920. buffer: string;
  79921. byteOffset: number;
  79922. byteLength: number;
  79923. byteStride: number;
  79924. target?: number;
  79925. }
  79926. /** @hidden */
  79927. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  79928. uri: string;
  79929. byteLength?: number;
  79930. type?: string;
  79931. }
  79932. /** @hidden */
  79933. export interface IGLTFShader extends IGLTFChildRootProperty {
  79934. uri: string;
  79935. type: EShaderType;
  79936. }
  79937. /** @hidden */
  79938. export interface IGLTFProgram extends IGLTFChildRootProperty {
  79939. attributes: string[];
  79940. fragmentShader: string;
  79941. vertexShader: string;
  79942. }
  79943. /** @hidden */
  79944. export interface IGLTFTechniqueParameter {
  79945. type: number;
  79946. count?: number;
  79947. semantic?: string;
  79948. node?: string;
  79949. value?: number | boolean | string | Array<any>;
  79950. source?: string;
  79951. babylonValue?: any;
  79952. }
  79953. /** @hidden */
  79954. export interface IGLTFTechniqueCommonProfile {
  79955. lightingModel: string;
  79956. texcoordBindings: Object;
  79957. parameters?: Array<any>;
  79958. }
  79959. /** @hidden */
  79960. export interface IGLTFTechniqueStatesFunctions {
  79961. blendColor?: number[];
  79962. blendEquationSeparate?: number[];
  79963. blendFuncSeparate?: number[];
  79964. colorMask: boolean[];
  79965. cullFace: number[];
  79966. }
  79967. /** @hidden */
  79968. export interface IGLTFTechniqueStates {
  79969. enable: number[];
  79970. functions: IGLTFTechniqueStatesFunctions;
  79971. }
  79972. /** @hidden */
  79973. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  79974. parameters: {
  79975. [key: string]: IGLTFTechniqueParameter;
  79976. };
  79977. program: string;
  79978. attributes: {
  79979. [key: string]: string;
  79980. };
  79981. uniforms: {
  79982. [key: string]: string;
  79983. };
  79984. states: IGLTFTechniqueStates;
  79985. }
  79986. /** @hidden */
  79987. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  79988. technique?: string;
  79989. values: string[];
  79990. }
  79991. /** @hidden */
  79992. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  79993. attributes: {
  79994. [key: string]: string;
  79995. };
  79996. indices: string;
  79997. material: string;
  79998. mode?: number;
  79999. }
  80000. /** @hidden */
  80001. export interface IGLTFMesh extends IGLTFChildRootProperty {
  80002. primitives: IGLTFMeshPrimitive[];
  80003. }
  80004. /** @hidden */
  80005. export interface IGLTFImage extends IGLTFChildRootProperty {
  80006. uri: string;
  80007. }
  80008. /** @hidden */
  80009. export interface IGLTFSampler extends IGLTFChildRootProperty {
  80010. magFilter?: number;
  80011. minFilter?: number;
  80012. wrapS?: number;
  80013. wrapT?: number;
  80014. }
  80015. /** @hidden */
  80016. export interface IGLTFTexture extends IGLTFChildRootProperty {
  80017. sampler: string;
  80018. source: string;
  80019. format?: ETextureFormat;
  80020. internalFormat?: ETextureFormat;
  80021. target?: number;
  80022. type?: number;
  80023. babylonTexture?: Texture;
  80024. }
  80025. /** @hidden */
  80026. export interface IGLTFAmbienLight {
  80027. color?: number[];
  80028. }
  80029. /** @hidden */
  80030. export interface IGLTFDirectionalLight {
  80031. color?: number[];
  80032. }
  80033. /** @hidden */
  80034. export interface IGLTFPointLight {
  80035. color?: number[];
  80036. constantAttenuation?: number;
  80037. linearAttenuation?: number;
  80038. quadraticAttenuation?: number;
  80039. }
  80040. /** @hidden */
  80041. export interface IGLTFSpotLight {
  80042. color?: number[];
  80043. constantAttenuation?: number;
  80044. fallOfAngle?: number;
  80045. fallOffExponent?: number;
  80046. linearAttenuation?: number;
  80047. quadraticAttenuation?: number;
  80048. }
  80049. /** @hidden */
  80050. export interface IGLTFLight extends IGLTFChildRootProperty {
  80051. type: string;
  80052. }
  80053. /** @hidden */
  80054. export interface IGLTFCameraOrthographic {
  80055. xmag: number;
  80056. ymag: number;
  80057. zfar: number;
  80058. znear: number;
  80059. }
  80060. /** @hidden */
  80061. export interface IGLTFCameraPerspective {
  80062. aspectRatio: number;
  80063. yfov: number;
  80064. zfar: number;
  80065. znear: number;
  80066. }
  80067. /** @hidden */
  80068. export interface IGLTFCamera extends IGLTFChildRootProperty {
  80069. type: string;
  80070. }
  80071. /** @hidden */
  80072. export interface IGLTFAnimationChannelTarget {
  80073. id: string;
  80074. path: string;
  80075. }
  80076. /** @hidden */
  80077. export interface IGLTFAnimationChannel {
  80078. sampler: string;
  80079. target: IGLTFAnimationChannelTarget;
  80080. }
  80081. /** @hidden */
  80082. export interface IGLTFAnimationSampler {
  80083. input: string;
  80084. output: string;
  80085. interpolation?: string;
  80086. }
  80087. /** @hidden */
  80088. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  80089. channels?: IGLTFAnimationChannel[];
  80090. parameters?: {
  80091. [key: string]: string;
  80092. };
  80093. samplers?: {
  80094. [key: string]: IGLTFAnimationSampler;
  80095. };
  80096. }
  80097. /** @hidden */
  80098. export interface IGLTFNodeInstanceSkin {
  80099. skeletons: string[];
  80100. skin: string;
  80101. meshes: string[];
  80102. }
  80103. /** @hidden */
  80104. export interface IGLTFSkins extends IGLTFChildRootProperty {
  80105. bindShapeMatrix: number[];
  80106. inverseBindMatrices: string;
  80107. jointNames: string[];
  80108. babylonSkeleton?: Skeleton;
  80109. }
  80110. /** @hidden */
  80111. export interface IGLTFNode extends IGLTFChildRootProperty {
  80112. camera?: string;
  80113. children: string[];
  80114. skin?: string;
  80115. jointName?: string;
  80116. light?: string;
  80117. matrix: number[];
  80118. mesh?: string;
  80119. meshes?: string[];
  80120. rotation?: number[];
  80121. scale?: number[];
  80122. translation?: number[];
  80123. babylonNode?: Node;
  80124. }
  80125. /** @hidden */
  80126. export interface IGLTFScene extends IGLTFChildRootProperty {
  80127. nodes: string[];
  80128. }
  80129. /** @hidden */
  80130. export interface IGLTFRuntime {
  80131. extensions: {
  80132. [key: string]: any;
  80133. };
  80134. accessors: {
  80135. [key: string]: IGLTFAccessor;
  80136. };
  80137. buffers: {
  80138. [key: string]: IGLTFBuffer;
  80139. };
  80140. bufferViews: {
  80141. [key: string]: IGLTFBufferView;
  80142. };
  80143. meshes: {
  80144. [key: string]: IGLTFMesh;
  80145. };
  80146. lights: {
  80147. [key: string]: IGLTFLight;
  80148. };
  80149. cameras: {
  80150. [key: string]: IGLTFCamera;
  80151. };
  80152. nodes: {
  80153. [key: string]: IGLTFNode;
  80154. };
  80155. images: {
  80156. [key: string]: IGLTFImage;
  80157. };
  80158. textures: {
  80159. [key: string]: IGLTFTexture;
  80160. };
  80161. shaders: {
  80162. [key: string]: IGLTFShader;
  80163. };
  80164. programs: {
  80165. [key: string]: IGLTFProgram;
  80166. };
  80167. samplers: {
  80168. [key: string]: IGLTFSampler;
  80169. };
  80170. techniques: {
  80171. [key: string]: IGLTFTechnique;
  80172. };
  80173. materials: {
  80174. [key: string]: IGLTFMaterial;
  80175. };
  80176. animations: {
  80177. [key: string]: IGLTFAnimation;
  80178. };
  80179. skins: {
  80180. [key: string]: IGLTFSkins;
  80181. };
  80182. currentScene?: Object;
  80183. scenes: {
  80184. [key: string]: IGLTFScene;
  80185. };
  80186. extensionsUsed: string[];
  80187. extensionsRequired?: string[];
  80188. buffersCount: number;
  80189. shaderscount: number;
  80190. scene: Scene;
  80191. rootUrl: string;
  80192. loadedBufferCount: number;
  80193. loadedBufferViews: {
  80194. [name: string]: ArrayBufferView;
  80195. };
  80196. loadedShaderCount: number;
  80197. importOnlyMeshes: boolean;
  80198. importMeshesNames?: string[];
  80199. dummyNodes: Node[];
  80200. forAssetContainer: boolean;
  80201. }
  80202. /** @hidden */
  80203. export interface INodeToRoot {
  80204. bone: Bone;
  80205. node: IGLTFNode;
  80206. id: string;
  80207. }
  80208. /** @hidden */
  80209. export interface IJointNode {
  80210. node: IGLTFNode;
  80211. id: string;
  80212. }
  80213. }
  80214. declare module BABYLON.GLTF1 {
  80215. /**
  80216. * Utils functions for GLTF
  80217. * @hidden
  80218. */
  80219. export class GLTFUtils {
  80220. /**
  80221. * Sets the given "parameter" matrix
  80222. * @param scene: the Scene object
  80223. * @param source: the source node where to pick the matrix
  80224. * @param parameter: the GLTF technique parameter
  80225. * @param uniformName: the name of the shader's uniform
  80226. * @param shaderMaterial: the shader material
  80227. */
  80228. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  80229. /**
  80230. * Sets the given "parameter" matrix
  80231. * @param shaderMaterial: the shader material
  80232. * @param uniform: the name of the shader's uniform
  80233. * @param value: the value of the uniform
  80234. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  80235. */
  80236. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  80237. /**
  80238. * Returns the wrap mode of the texture
  80239. * @param mode: the mode value
  80240. */
  80241. static GetWrapMode(mode: number): number;
  80242. /**
  80243. * Returns the byte stride giving an accessor
  80244. * @param accessor: the GLTF accessor objet
  80245. */
  80246. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  80247. /**
  80248. * Returns the texture filter mode giving a mode value
  80249. * @param mode: the filter mode value
  80250. */
  80251. static GetTextureFilterMode(mode: number): ETextureFilterType;
  80252. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  80253. /**
  80254. * Returns a buffer from its accessor
  80255. * @param gltfRuntime: the GLTF runtime
  80256. * @param accessor: the GLTF accessor
  80257. */
  80258. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  80259. /**
  80260. * Decodes a buffer view into a string
  80261. * @param view: the buffer view
  80262. */
  80263. static DecodeBufferToText(view: ArrayBufferView): string;
  80264. /**
  80265. * Returns the default material of gltf. Related to
  80266. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  80267. * @param scene: the Babylon.js scene
  80268. */
  80269. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  80270. private static _DefaultMaterial;
  80271. }
  80272. }
  80273. declare module BABYLON.GLTF1 {
  80274. /**
  80275. * Implementation of the base glTF spec
  80276. * @hidden
  80277. */
  80278. export class GLTFLoaderBase {
  80279. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  80280. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  80281. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  80282. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  80283. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  80284. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  80285. }
  80286. /**
  80287. * glTF V1 Loader
  80288. * @hidden
  80289. */
  80290. export class GLTFLoader implements IGLTFLoader {
  80291. static Extensions: {
  80292. [name: string]: GLTFLoaderExtension;
  80293. };
  80294. static RegisterExtension(extension: GLTFLoaderExtension): void;
  80295. state: Nullable<GLTFLoaderState>;
  80296. dispose(): void;
  80297. private _importMeshAsync;
  80298. /**
  80299. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  80300. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  80301. * @param scene the scene the meshes should be added to
  80302. * @param forAssetContainer defines if the entities must be stored in the scene
  80303. * @param data gltf data containing information of the meshes in a loaded file
  80304. * @param rootUrl root url to load from
  80305. * @param onProgress event that fires when loading progress has occured
  80306. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  80307. */
  80308. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  80309. private _loadAsync;
  80310. /**
  80311. * Imports all objects from a loaded gltf file and adds them to the scene
  80312. * @param scene the scene the objects should be added to
  80313. * @param data gltf data containing information of the meshes in a loaded file
  80314. * @param rootUrl root url to load from
  80315. * @param onProgress event that fires when loading progress has occured
  80316. * @returns a promise which completes when objects have been loaded to the scene
  80317. */
  80318. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  80319. private _loadShadersAsync;
  80320. private _loadBuffersAsync;
  80321. private _createNodes;
  80322. }
  80323. /** @hidden */
  80324. export abstract class GLTFLoaderExtension {
  80325. private _name;
  80326. constructor(name: string);
  80327. get name(): string;
  80328. /**
  80329. * Defines an override for loading the runtime
  80330. * Return true to stop further extensions from loading the runtime
  80331. */
  80332. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  80333. /**
  80334. * Defines an onverride for creating gltf runtime
  80335. * Return true to stop further extensions from creating the runtime
  80336. */
  80337. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  80338. /**
  80339. * Defines an override for loading buffers
  80340. * Return true to stop further extensions from loading this buffer
  80341. */
  80342. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  80343. /**
  80344. * Defines an override for loading texture buffers
  80345. * Return true to stop further extensions from loading this texture data
  80346. */
  80347. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  80348. /**
  80349. * Defines an override for creating textures
  80350. * Return true to stop further extensions from loading this texture
  80351. */
  80352. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  80353. /**
  80354. * Defines an override for loading shader strings
  80355. * Return true to stop further extensions from loading this shader data
  80356. */
  80357. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  80358. /**
  80359. * Defines an override for loading materials
  80360. * Return true to stop further extensions from loading this material
  80361. */
  80362. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  80363. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  80364. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  80365. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  80366. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  80367. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  80368. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  80369. private static LoadTextureBufferAsync;
  80370. private static CreateTextureAsync;
  80371. private static ApplyExtensions;
  80372. }
  80373. }
  80374. declare module BABYLON.GLTF1 {
  80375. /** @hidden */
  80376. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  80377. private _bin;
  80378. constructor();
  80379. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  80380. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  80381. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  80382. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  80383. }
  80384. }
  80385. declare module BABYLON.GLTF1 {
  80386. /** @hidden */
  80387. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  80388. constructor();
  80389. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  80390. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  80391. private _loadTexture;
  80392. }
  80393. }
  80394. declare module BABYLON.GLTF2.Loader {
  80395. /**
  80396. * Loader interface with an index field.
  80397. */
  80398. export interface IArrayItem {
  80399. /**
  80400. * The index of this item in the array.
  80401. */
  80402. index: number;
  80403. }
  80404. /**
  80405. * Loader interface with additional members.
  80406. */
  80407. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  80408. /** @hidden */
  80409. _data?: Promise<ArrayBufferView>;
  80410. /** @hidden */
  80411. _babylonVertexBuffer?: Promise<VertexBuffer>;
  80412. }
  80413. /**
  80414. * Loader interface with additional members.
  80415. */
  80416. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  80417. }
  80418. /** @hidden */
  80419. export interface _IAnimationSamplerData {
  80420. input: Float32Array;
  80421. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  80422. output: Float32Array;
  80423. }
  80424. /**
  80425. * Loader interface with additional members.
  80426. */
  80427. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  80428. /** @hidden */
  80429. _data?: Promise<_IAnimationSamplerData>;
  80430. }
  80431. /**
  80432. * Loader interface with additional members.
  80433. */
  80434. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  80435. channels: IAnimationChannel[];
  80436. samplers: IAnimationSampler[];
  80437. /** @hidden */
  80438. _babylonAnimationGroup?: AnimationGroup;
  80439. }
  80440. /**
  80441. * Loader interface with additional members.
  80442. */
  80443. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  80444. /** @hidden */
  80445. _data?: Promise<ArrayBufferView>;
  80446. }
  80447. /**
  80448. * Loader interface with additional members.
  80449. */
  80450. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  80451. /** @hidden */
  80452. _data?: Promise<ArrayBufferView>;
  80453. /** @hidden */
  80454. _babylonBuffer?: Promise<Buffer>;
  80455. }
  80456. /**
  80457. * Loader interface with additional members.
  80458. */
  80459. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  80460. }
  80461. /**
  80462. * Loader interface with additional members.
  80463. */
  80464. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  80465. /** @hidden */
  80466. _data?: Promise<ArrayBufferView>;
  80467. }
  80468. /**
  80469. * Loader interface with additional members.
  80470. */
  80471. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  80472. }
  80473. /**
  80474. * Loader interface with additional members.
  80475. */
  80476. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  80477. }
  80478. /**
  80479. * Loader interface with additional members.
  80480. */
  80481. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  80482. baseColorTexture?: ITextureInfo;
  80483. metallicRoughnessTexture?: ITextureInfo;
  80484. }
  80485. /**
  80486. * Loader interface with additional members.
  80487. */
  80488. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  80489. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  80490. normalTexture?: IMaterialNormalTextureInfo;
  80491. occlusionTexture?: IMaterialOcclusionTextureInfo;
  80492. emissiveTexture?: ITextureInfo;
  80493. /** @hidden */
  80494. _data?: {
  80495. [babylonDrawMode: number]: {
  80496. babylonMaterial: Material;
  80497. babylonMeshes: AbstractMesh[];
  80498. promise: Promise<void>;
  80499. };
  80500. };
  80501. }
  80502. /**
  80503. * Loader interface with additional members.
  80504. */
  80505. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  80506. primitives: IMeshPrimitive[];
  80507. }
  80508. /**
  80509. * Loader interface with additional members.
  80510. */
  80511. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  80512. /** @hidden */
  80513. _instanceData?: {
  80514. babylonSourceMesh: Mesh;
  80515. promise: Promise<any>;
  80516. };
  80517. }
  80518. /**
  80519. * Loader interface with additional members.
  80520. */
  80521. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  80522. /**
  80523. * The parent glTF node.
  80524. */
  80525. parent?: INode;
  80526. /** @hidden */
  80527. _babylonTransformNode?: TransformNode;
  80528. /** @hidden */
  80529. _primitiveBabylonMeshes?: AbstractMesh[];
  80530. /** @hidden */
  80531. _babylonBones?: Bone[];
  80532. /** @hidden */
  80533. _numMorphTargets?: number;
  80534. }
  80535. /** @hidden */
  80536. export interface _ISamplerData {
  80537. noMipMaps: boolean;
  80538. samplingMode: number;
  80539. wrapU: number;
  80540. wrapV: number;
  80541. }
  80542. /**
  80543. * Loader interface with additional members.
  80544. */
  80545. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  80546. /** @hidden */
  80547. _data?: _ISamplerData;
  80548. }
  80549. /**
  80550. * Loader interface with additional members.
  80551. */
  80552. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  80553. }
  80554. /**
  80555. * Loader interface with additional members.
  80556. */
  80557. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  80558. /** @hidden */
  80559. _data?: {
  80560. babylonSkeleton: Skeleton;
  80561. promise: Promise<void>;
  80562. };
  80563. }
  80564. /**
  80565. * Loader interface with additional members.
  80566. */
  80567. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  80568. }
  80569. /**
  80570. * Loader interface with additional members.
  80571. */
  80572. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  80573. }
  80574. /**
  80575. * Loader interface with additional members.
  80576. */
  80577. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  80578. accessors?: IAccessor[];
  80579. animations?: IAnimation[];
  80580. buffers?: IBuffer[];
  80581. bufferViews?: IBufferView[];
  80582. cameras?: ICamera[];
  80583. images?: IImage[];
  80584. materials?: IMaterial[];
  80585. meshes?: IMesh[];
  80586. nodes?: INode[];
  80587. samplers?: ISampler[];
  80588. scenes?: IScene[];
  80589. skins?: ISkin[];
  80590. textures?: ITexture[];
  80591. }
  80592. }
  80593. declare module BABYLON.GLTF2 {
  80594. /**
  80595. * Interface for a glTF loader extension.
  80596. */
  80597. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  80598. /**
  80599. * Called after the loader state changes to LOADING.
  80600. */
  80601. onLoading?(): void;
  80602. /**
  80603. * Called after the loader state changes to READY.
  80604. */
  80605. onReady?(): void;
  80606. /**
  80607. * Define this method to modify the default behavior when loading scenes.
  80608. * @param context The context when loading the asset
  80609. * @param scene The glTF scene property
  80610. * @returns A promise that resolves when the load is complete or null if not handled
  80611. */
  80612. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  80613. /**
  80614. * Define this method to modify the default behavior when loading nodes.
  80615. * @param context The context when loading the asset
  80616. * @param node The glTF node property
  80617. * @param assign A function called synchronously after parsing the glTF properties
  80618. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  80619. */
  80620. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80621. /**
  80622. * Define this method to modify the default behavior when loading cameras.
  80623. * @param context The context when loading the asset
  80624. * @param camera The glTF camera property
  80625. * @param assign A function called synchronously after parsing the glTF properties
  80626. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  80627. */
  80628. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  80629. /**
  80630. * @hidden
  80631. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  80632. * @param context The context when loading the asset
  80633. * @param primitive The glTF mesh primitive property
  80634. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  80635. */
  80636. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  80637. /**
  80638. * @hidden
  80639. * Define this method to modify the default behavior when loading data for mesh primitives.
  80640. * @param context The context when loading the asset
  80641. * @param name The mesh name when loading the asset
  80642. * @param node The glTF node when loading the asset
  80643. * @param mesh The glTF mesh when loading the asset
  80644. * @param primitive The glTF mesh primitive property
  80645. * @param assign A function called synchronously after parsing the glTF properties
  80646. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  80647. */
  80648. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  80649. /**
  80650. * @hidden
  80651. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  80652. * @param context The context when loading the asset
  80653. * @param material The glTF material property
  80654. * @param assign A function called synchronously after parsing the glTF properties
  80655. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  80656. */
  80657. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  80658. /**
  80659. * Define this method to modify the default behavior when creating materials.
  80660. * @param context The context when loading the asset
  80661. * @param material The glTF material property
  80662. * @param babylonDrawMode The draw mode for the Babylon material
  80663. * @returns The Babylon material or null if not handled
  80664. */
  80665. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  80666. /**
  80667. * Define this method to modify the default behavior when loading material properties.
  80668. * @param context The context when loading the asset
  80669. * @param material The glTF material property
  80670. * @param babylonMaterial The Babylon material
  80671. * @returns A promise that resolves when the load is complete or null if not handled
  80672. */
  80673. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80674. /**
  80675. * Define this method to modify the default behavior when loading texture infos.
  80676. * @param context The context when loading the asset
  80677. * @param textureInfo The glTF texture info property
  80678. * @param assign A function called synchronously after parsing the glTF properties
  80679. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  80680. */
  80681. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80682. /**
  80683. * @hidden
  80684. * Define this method to modify the default behavior when loading textures.
  80685. * @param context The context when loading the asset
  80686. * @param texture The glTF texture property
  80687. * @param assign A function called synchronously after parsing the glTF properties
  80688. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  80689. */
  80690. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80691. /**
  80692. * Define this method to modify the default behavior when loading animations.
  80693. * @param context The context when loading the asset
  80694. * @param animation The glTF animation property
  80695. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  80696. */
  80697. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  80698. /**
  80699. * @hidden
  80700. * Define this method to modify the default behavior when loading skins.
  80701. * @param context The context when loading the asset
  80702. * @param node The glTF node property
  80703. * @param skin The glTF skin property
  80704. * @returns A promise that resolves when the load is complete or null if not handled
  80705. */
  80706. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  80707. /**
  80708. * @hidden
  80709. * Define this method to modify the default behavior when loading uris.
  80710. * @param context The context when loading the asset
  80711. * @param property The glTF property associated with the uri
  80712. * @param uri The uri to load
  80713. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  80714. */
  80715. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  80716. /**
  80717. * Define this method to modify the default behavior when loading buffer views.
  80718. * @param context The context when loading the asset
  80719. * @param bufferView The glTF buffer view property
  80720. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  80721. */
  80722. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  80723. /**
  80724. * Define this method to modify the default behavior when loading buffers.
  80725. * @param context The context when loading the asset
  80726. * @param buffer The glTF buffer property
  80727. * @param byteOffset The byte offset to load
  80728. * @param byteLength The byte length to load
  80729. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  80730. */
  80731. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  80732. }
  80733. }
  80734. declare module BABYLON.GLTF2 {
  80735. /**
  80736. * Helper class for working with arrays when loading the glTF asset
  80737. */
  80738. export class ArrayItem {
  80739. /**
  80740. * Gets an item from the given array.
  80741. * @param context The context when loading the asset
  80742. * @param array The array to get the item from
  80743. * @param index The index to the array
  80744. * @returns The array item
  80745. */
  80746. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  80747. /**
  80748. * Assign an `index` field to each item of the given array.
  80749. * @param array The array of items
  80750. */
  80751. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  80752. }
  80753. /**
  80754. * The glTF 2.0 loader
  80755. */
  80756. export class GLTFLoader implements IGLTFLoader {
  80757. /** @hidden */
  80758. _completePromises: Promise<any>[];
  80759. /** @hidden */
  80760. _forAssetContainer: boolean;
  80761. /** Storage */
  80762. _babylonLights: Light[];
  80763. /** @hidden */
  80764. _disableInstancedMesh: number;
  80765. private _disposed;
  80766. private _parent;
  80767. private _state;
  80768. private _extensions;
  80769. private _rootUrl;
  80770. private _fileName;
  80771. private _uniqueRootUrl;
  80772. private _gltf;
  80773. private _bin;
  80774. private _babylonScene;
  80775. private _rootBabylonMesh;
  80776. private _defaultBabylonMaterialData;
  80777. private static _RegisteredExtensions;
  80778. /**
  80779. * The default glTF sampler.
  80780. */
  80781. static readonly DefaultSampler: ISampler;
  80782. /**
  80783. * Registers a loader extension.
  80784. * @param name The name of the loader extension.
  80785. * @param factory The factory function that creates the loader extension.
  80786. */
  80787. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  80788. /**
  80789. * Unregisters a loader extension.
  80790. * @param name The name of the loader extension.
  80791. * @returns A boolean indicating whether the extension has been unregistered
  80792. */
  80793. static UnregisterExtension(name: string): boolean;
  80794. /**
  80795. * The loader state.
  80796. */
  80797. get state(): Nullable<GLTFLoaderState>;
  80798. /**
  80799. * The object that represents the glTF JSON.
  80800. */
  80801. get gltf(): IGLTF;
  80802. /**
  80803. * The BIN chunk of a binary glTF.
  80804. */
  80805. get bin(): Nullable<IDataBuffer>;
  80806. /**
  80807. * The parent file loader.
  80808. */
  80809. get parent(): GLTFFileLoader;
  80810. /**
  80811. * The Babylon scene when loading the asset.
  80812. */
  80813. get babylonScene(): Scene;
  80814. /**
  80815. * The root Babylon mesh when loading the asset.
  80816. */
  80817. get rootBabylonMesh(): Mesh;
  80818. /** @hidden */
  80819. constructor(parent: GLTFFileLoader);
  80820. /** @hidden */
  80821. dispose(): void;
  80822. /** @hidden */
  80823. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  80824. /** @hidden */
  80825. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  80826. private _loadAsync;
  80827. private _loadData;
  80828. private _setupData;
  80829. private _loadExtensions;
  80830. private _checkExtensions;
  80831. private _setState;
  80832. private _createRootNode;
  80833. /**
  80834. * Loads a glTF scene.
  80835. * @param context The context when loading the asset
  80836. * @param scene The glTF scene property
  80837. * @returns A promise that resolves when the load is complete
  80838. */
  80839. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  80840. private _forEachPrimitive;
  80841. private _getMeshes;
  80842. private _getTransformNodes;
  80843. private _getSkeletons;
  80844. private _getAnimationGroups;
  80845. private _startAnimations;
  80846. /**
  80847. * Loads a glTF node.
  80848. * @param context The context when loading the asset
  80849. * @param node The glTF node property
  80850. * @param assign A function called synchronously after parsing the glTF properties
  80851. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  80852. */
  80853. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  80854. private _loadMeshAsync;
  80855. /**
  80856. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  80857. * @param context The context when loading the asset
  80858. * @param name The mesh name when loading the asset
  80859. * @param node The glTF node when loading the asset
  80860. * @param mesh The glTF mesh when loading the asset
  80861. * @param primitive The glTF mesh primitive property
  80862. * @param assign A function called synchronously after parsing the glTF properties
  80863. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  80864. */
  80865. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  80866. private _loadVertexDataAsync;
  80867. private _createMorphTargets;
  80868. private _loadMorphTargetsAsync;
  80869. private _loadMorphTargetVertexDataAsync;
  80870. private static _LoadTransform;
  80871. private _loadSkinAsync;
  80872. private _loadBones;
  80873. private _loadBone;
  80874. private _loadSkinInverseBindMatricesDataAsync;
  80875. private _updateBoneMatrices;
  80876. private _getNodeMatrix;
  80877. /**
  80878. * Loads a glTF camera.
  80879. * @param context The context when loading the asset
  80880. * @param camera The glTF camera property
  80881. * @param assign A function called synchronously after parsing the glTF properties
  80882. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  80883. */
  80884. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  80885. private _loadAnimationsAsync;
  80886. /**
  80887. * Loads a glTF animation.
  80888. * @param context The context when loading the asset
  80889. * @param animation The glTF animation property
  80890. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  80891. */
  80892. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  80893. /**
  80894. * @hidden Loads a glTF animation channel.
  80895. * @param context The context when loading the asset
  80896. * @param animationContext The context of the animation when loading the asset
  80897. * @param animation The glTF animation property
  80898. * @param channel The glTF animation channel property
  80899. * @param babylonAnimationGroup The babylon animation group property
  80900. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  80901. * @returns A void promise when the channel load is complete
  80902. */
  80903. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  80904. private _loadAnimationSamplerAsync;
  80905. private _loadBufferAsync;
  80906. /**
  80907. * Loads a glTF buffer view.
  80908. * @param context The context when loading the asset
  80909. * @param bufferView The glTF buffer view property
  80910. * @returns A promise that resolves with the loaded data when the load is complete
  80911. */
  80912. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  80913. private _loadAccessorAsync;
  80914. /** @hidden */
  80915. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  80916. private _loadIndicesAccessorAsync;
  80917. private _loadVertexBufferViewAsync;
  80918. private _loadVertexAccessorAsync;
  80919. private _loadMaterialMetallicRoughnessPropertiesAsync;
  80920. /** @hidden */
  80921. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  80922. private _createDefaultMaterial;
  80923. /**
  80924. * Creates a Babylon material from a glTF material.
  80925. * @param context The context when loading the asset
  80926. * @param material The glTF material property
  80927. * @param babylonDrawMode The draw mode for the Babylon material
  80928. * @returns The Babylon material
  80929. */
  80930. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  80931. /**
  80932. * Loads properties from a glTF material into a Babylon material.
  80933. * @param context The context when loading the asset
  80934. * @param material The glTF material property
  80935. * @param babylonMaterial The Babylon material
  80936. * @returns A promise that resolves when the load is complete
  80937. */
  80938. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  80939. /**
  80940. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  80941. * @param context The context when loading the asset
  80942. * @param material The glTF material property
  80943. * @param babylonMaterial The Babylon material
  80944. * @returns A promise that resolves when the load is complete
  80945. */
  80946. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  80947. /**
  80948. * Loads the alpha properties from a glTF material into a Babylon material.
  80949. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  80950. * @param context The context when loading the asset
  80951. * @param material The glTF material property
  80952. * @param babylonMaterial The Babylon material
  80953. */
  80954. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  80955. /**
  80956. * Loads a glTF texture info.
  80957. * @param context The context when loading the asset
  80958. * @param textureInfo The glTF texture info property
  80959. * @param assign A function called synchronously after parsing the glTF properties
  80960. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  80961. */
  80962. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  80963. /** @hidden */
  80964. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  80965. /** @hidden */
  80966. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  80967. private _loadSampler;
  80968. /**
  80969. * Loads a glTF image.
  80970. * @param context The context when loading the asset
  80971. * @param image The glTF image property
  80972. * @returns A promise that resolves with the loaded data when the load is complete
  80973. */
  80974. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  80975. /**
  80976. * Loads a glTF uri.
  80977. * @param context The context when loading the asset
  80978. * @param property The glTF property associated with the uri
  80979. * @param uri The base64 or relative uri
  80980. * @returns A promise that resolves with the loaded data when the load is complete
  80981. */
  80982. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  80983. /**
  80984. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  80985. * @param babylonObject the Babylon object with metadata
  80986. * @param pointer the JSON pointer
  80987. */
  80988. static AddPointerMetadata(babylonObject: {
  80989. metadata: any;
  80990. }, pointer: string): void;
  80991. private static _GetTextureWrapMode;
  80992. private static _GetTextureSamplingMode;
  80993. private static _GetTypedArrayConstructor;
  80994. private static _GetTypedArray;
  80995. private static _GetNumComponents;
  80996. private static _ValidateUri;
  80997. /** @hidden */
  80998. static _GetDrawMode(context: string, mode: number | undefined): number;
  80999. private _compileMaterialsAsync;
  81000. private _compileShadowGeneratorsAsync;
  81001. private _forEachExtensions;
  81002. private _applyExtensions;
  81003. private _extensionsOnLoading;
  81004. private _extensionsOnReady;
  81005. private _extensionsLoadSceneAsync;
  81006. private _extensionsLoadNodeAsync;
  81007. private _extensionsLoadCameraAsync;
  81008. private _extensionsLoadVertexDataAsync;
  81009. private _extensionsLoadMeshPrimitiveAsync;
  81010. private _extensionsLoadMaterialAsync;
  81011. private _extensionsCreateMaterial;
  81012. private _extensionsLoadMaterialPropertiesAsync;
  81013. private _extensionsLoadTextureInfoAsync;
  81014. private _extensionsLoadTextureAsync;
  81015. private _extensionsLoadAnimationAsync;
  81016. private _extensionsLoadSkinAsync;
  81017. private _extensionsLoadUriAsync;
  81018. private _extensionsLoadBufferViewAsync;
  81019. private _extensionsLoadBufferAsync;
  81020. /**
  81021. * Helper method called by a loader extension to load an glTF extension.
  81022. * @param context The context when loading the asset
  81023. * @param property The glTF property to load the extension from
  81024. * @param extensionName The name of the extension to load
  81025. * @param actionAsync The action to run
  81026. * @returns The promise returned by actionAsync or null if the extension does not exist
  81027. */
  81028. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  81029. /**
  81030. * Helper method called by a loader extension to load a glTF extra.
  81031. * @param context The context when loading the asset
  81032. * @param property The glTF property to load the extra from
  81033. * @param extensionName The name of the extension to load
  81034. * @param actionAsync The action to run
  81035. * @returns The promise returned by actionAsync or null if the extra does not exist
  81036. */
  81037. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  81038. /**
  81039. * Checks for presence of an extension.
  81040. * @param name The name of the extension to check
  81041. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  81042. */
  81043. isExtensionUsed(name: string): boolean;
  81044. /**
  81045. * Increments the indentation level and logs a message.
  81046. * @param message The message to log
  81047. */
  81048. logOpen(message: string): void;
  81049. /**
  81050. * Decrements the indentation level.
  81051. */
  81052. logClose(): void;
  81053. /**
  81054. * Logs a message
  81055. * @param message The message to log
  81056. */
  81057. log(message: string): void;
  81058. /**
  81059. * Starts a performance counter.
  81060. * @param counterName The name of the performance counter
  81061. */
  81062. startPerformanceCounter(counterName: string): void;
  81063. /**
  81064. * Ends a performance counter.
  81065. * @param counterName The name of the performance counter
  81066. */
  81067. endPerformanceCounter(counterName: string): void;
  81068. }
  81069. }
  81070. declare module BABYLON.GLTF2.Loader.Extensions {
  81071. /** @hidden */
  81072. interface IEXTLightsImageBased_LightImageBased {
  81073. _babylonTexture?: BaseTexture;
  81074. _loaded?: Promise<void>;
  81075. }
  81076. /**
  81077. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  81078. */
  81079. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  81080. /**
  81081. * The name of this extension.
  81082. */
  81083. readonly name: string;
  81084. /**
  81085. * Defines whether this extension is enabled.
  81086. */
  81087. enabled: boolean;
  81088. private _loader;
  81089. private _lights?;
  81090. /** @hidden */
  81091. constructor(loader: GLTFLoader);
  81092. /** @hidden */
  81093. dispose(): void;
  81094. /** @hidden */
  81095. onLoading(): void;
  81096. /** @hidden */
  81097. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  81098. private _loadLightAsync;
  81099. }
  81100. }
  81101. declare module BABYLON.GLTF2.Loader.Extensions {
  81102. /**
  81103. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  81104. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  81105. * !!! Experimental Extension Subject to Changes !!!
  81106. */
  81107. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  81108. /**
  81109. * The name of this extension.
  81110. */
  81111. readonly name: string;
  81112. /**
  81113. * Defines whether this extension is enabled.
  81114. */
  81115. enabled: boolean;
  81116. private _loader;
  81117. /** @hidden */
  81118. constructor(loader: GLTFLoader);
  81119. /** @hidden */
  81120. dispose(): void;
  81121. /** @hidden */
  81122. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81123. }
  81124. }
  81125. declare module BABYLON.GLTF2.Loader.Extensions {
  81126. /**
  81127. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  81128. */
  81129. export class EXT_texture_webp implements IGLTFLoaderExtension {
  81130. /** The name of this extension. */
  81131. readonly name: string;
  81132. /** Defines whether this extension is enabled. */
  81133. enabled: boolean;
  81134. private _loader;
  81135. /** @hidden */
  81136. constructor(loader: GLTFLoader);
  81137. /** @hidden */
  81138. dispose(): void;
  81139. /** @hidden */
  81140. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  81141. }
  81142. }
  81143. declare module BABYLON.GLTF2.Loader.Extensions {
  81144. /**
  81145. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  81146. */
  81147. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  81148. /**
  81149. * The name of this extension.
  81150. */
  81151. readonly name: string;
  81152. /**
  81153. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  81154. */
  81155. dracoCompression?: DracoCompression;
  81156. /**
  81157. * Defines whether this extension is enabled.
  81158. */
  81159. enabled: boolean;
  81160. private _loader;
  81161. /** @hidden */
  81162. constructor(loader: GLTFLoader);
  81163. /** @hidden */
  81164. dispose(): void;
  81165. /** @hidden */
  81166. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  81167. }
  81168. }
  81169. declare module BABYLON.GLTF2.Loader.Extensions {
  81170. /**
  81171. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  81172. */
  81173. export class KHR_lights implements IGLTFLoaderExtension {
  81174. /**
  81175. * The name of this extension.
  81176. */
  81177. readonly name: string;
  81178. /**
  81179. * Defines whether this extension is enabled.
  81180. */
  81181. enabled: boolean;
  81182. private _loader;
  81183. private _lights?;
  81184. /** @hidden */
  81185. constructor(loader: GLTFLoader);
  81186. /** @hidden */
  81187. dispose(): void;
  81188. /** @hidden */
  81189. onLoading(): void;
  81190. /** @hidden */
  81191. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81192. }
  81193. }
  81194. declare module BABYLON.GLTF2.Loader.Extensions {
  81195. /**
  81196. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  81197. */
  81198. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  81199. /**
  81200. * The name of this extension.
  81201. */
  81202. readonly name: string;
  81203. /**
  81204. * Defines whether this extension is enabled.
  81205. */
  81206. enabled: boolean;
  81207. /**
  81208. * Defines a number that determines the order the extensions are applied.
  81209. */
  81210. order: number;
  81211. private _loader;
  81212. /** @hidden */
  81213. constructor(loader: GLTFLoader);
  81214. /** @hidden */
  81215. dispose(): void;
  81216. /** @hidden */
  81217. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81218. private _loadSpecularGlossinessPropertiesAsync;
  81219. }
  81220. }
  81221. declare module BABYLON.GLTF2.Loader.Extensions {
  81222. /**
  81223. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  81224. */
  81225. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  81226. /**
  81227. * The name of this extension.
  81228. */
  81229. readonly name: string;
  81230. /**
  81231. * Defines whether this extension is enabled.
  81232. */
  81233. enabled: boolean;
  81234. /**
  81235. * Defines a number that determines the order the extensions are applied.
  81236. */
  81237. order: number;
  81238. private _loader;
  81239. /** @hidden */
  81240. constructor(loader: GLTFLoader);
  81241. /** @hidden */
  81242. dispose(): void;
  81243. /** @hidden */
  81244. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81245. private _loadUnlitPropertiesAsync;
  81246. }
  81247. }
  81248. declare module BABYLON.GLTF2.Loader.Extensions {
  81249. /**
  81250. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  81251. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  81252. * !!! Experimental Extension Subject to Changes !!!
  81253. */
  81254. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  81255. /**
  81256. * The name of this extension.
  81257. */
  81258. readonly name: string;
  81259. /**
  81260. * Defines whether this extension is enabled.
  81261. */
  81262. enabled: boolean;
  81263. /**
  81264. * Defines a number that determines the order the extensions are applied.
  81265. */
  81266. order: number;
  81267. private _loader;
  81268. /** @hidden */
  81269. constructor(loader: GLTFLoader);
  81270. /** @hidden */
  81271. dispose(): void;
  81272. /** @hidden */
  81273. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81274. private _loadClearCoatPropertiesAsync;
  81275. }
  81276. }
  81277. declare module BABYLON.GLTF2.Loader.Extensions {
  81278. /**
  81279. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  81280. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  81281. * !!! Experimental Extension Subject to Changes !!!
  81282. */
  81283. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  81284. /**
  81285. * The name of this extension.
  81286. */
  81287. readonly name: string;
  81288. /**
  81289. * Defines whether this extension is enabled.
  81290. */
  81291. enabled: boolean;
  81292. /**
  81293. * Defines a number that determines the order the extensions are applied.
  81294. */
  81295. order: number;
  81296. private _loader;
  81297. /** @hidden */
  81298. constructor(loader: GLTFLoader);
  81299. /** @hidden */
  81300. dispose(): void;
  81301. /** @hidden */
  81302. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81303. private _loadSheenPropertiesAsync;
  81304. }
  81305. }
  81306. declare module BABYLON.GLTF2.Loader.Extensions {
  81307. /**
  81308. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  81309. * !!! Experimental Extension Subject to Changes !!!
  81310. */
  81311. export class KHR_materials_specular implements IGLTFLoaderExtension {
  81312. /**
  81313. * The name of this extension.
  81314. */
  81315. readonly name: string;
  81316. /**
  81317. * Defines whether this extension is enabled.
  81318. */
  81319. enabled: boolean;
  81320. /**
  81321. * Defines a number that determines the order the extensions are applied.
  81322. */
  81323. order: number;
  81324. private _loader;
  81325. /** @hidden */
  81326. constructor(loader: GLTFLoader);
  81327. /** @hidden */
  81328. dispose(): void;
  81329. /** @hidden */
  81330. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81331. private _loadSpecularPropertiesAsync;
  81332. }
  81333. }
  81334. declare module BABYLON.GLTF2.Loader.Extensions {
  81335. /**
  81336. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  81337. * !!! Experimental Extension Subject to Changes !!!
  81338. */
  81339. export class KHR_materials_ior implements IGLTFLoaderExtension {
  81340. /**
  81341. * Default ior Value from the spec.
  81342. */
  81343. private static readonly _DEFAULT_IOR;
  81344. /**
  81345. * The name of this extension.
  81346. */
  81347. readonly name: string;
  81348. /**
  81349. * Defines whether this extension is enabled.
  81350. */
  81351. enabled: boolean;
  81352. /**
  81353. * Defines a number that determines the order the extensions are applied.
  81354. */
  81355. order: number;
  81356. private _loader;
  81357. /** @hidden */
  81358. constructor(loader: GLTFLoader);
  81359. /** @hidden */
  81360. dispose(): void;
  81361. /** @hidden */
  81362. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81363. private _loadIorPropertiesAsync;
  81364. }
  81365. }
  81366. declare module BABYLON.GLTF2.Loader.Extensions {
  81367. /**
  81368. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  81369. * !!! Experimental Extension Subject to Changes !!!
  81370. */
  81371. export class KHR_materials_variants implements IGLTFLoaderExtension {
  81372. /**
  81373. * The name of this extension.
  81374. */
  81375. readonly name: string;
  81376. /**
  81377. * Defines whether this extension is enabled.
  81378. */
  81379. enabled: boolean;
  81380. private _loader;
  81381. /** @hidden */
  81382. constructor(loader: GLTFLoader);
  81383. /** @hidden */
  81384. dispose(): void;
  81385. /**
  81386. * Gets the list of available variant names for this asset.
  81387. * @param rootMesh The glTF root mesh
  81388. * @returns the list of all the variant names for this model
  81389. */
  81390. static GetAvailableVariants(rootMesh: Mesh): string[];
  81391. /**
  81392. * Gets the list of available variant names for this asset.
  81393. * @param rootMesh The glTF root mesh
  81394. * @returns the list of all the variant names for this model
  81395. */
  81396. getAvailableVariants(rootMesh: Mesh): string[];
  81397. /**
  81398. * Select a variant given a variant name or a list of variant names.
  81399. * @param rootMesh The glTF root mesh
  81400. * @param variantName The variant name(s) to select.
  81401. */
  81402. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  81403. /**
  81404. * Select a variant given a variant name or a list of variant names.
  81405. * @param rootMesh The glTF root mesh
  81406. * @param variantName The variant name(s) to select.
  81407. */
  81408. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  81409. /**
  81410. * Reset back to the original before selecting a variant.
  81411. * @param rootMesh The glTF root mesh
  81412. */
  81413. static Reset(rootMesh: Mesh): void;
  81414. /**
  81415. * Reset back to the original before selecting a variant.
  81416. * @param rootMesh The glTF root mesh
  81417. */
  81418. reset(rootMesh: Mesh): void;
  81419. /**
  81420. * Gets the last selected variant name(s) or null if original.
  81421. * @param rootMesh The glTF root mesh
  81422. * @returns The selected variant name(s).
  81423. */
  81424. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  81425. /**
  81426. * Gets the last selected variant name(s) or null if original.
  81427. * @param rootMesh The glTF root mesh
  81428. * @returns The selected variant name(s).
  81429. */
  81430. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  81431. private static _GetExtensionMetadata;
  81432. /** @hidden */
  81433. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  81434. }
  81435. }
  81436. declare module BABYLON.GLTF2.Loader.Extensions {
  81437. /**
  81438. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  81439. * !!! Experimental Extension Subject to Changes !!!
  81440. */
  81441. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  81442. /**
  81443. * The name of this extension.
  81444. */
  81445. readonly name: string;
  81446. /**
  81447. * Defines whether this extension is enabled.
  81448. */
  81449. enabled: boolean;
  81450. /**
  81451. * Defines a number that determines the order the extensions are applied.
  81452. */
  81453. order: number;
  81454. private _loader;
  81455. /** @hidden */
  81456. constructor(loader: GLTFLoader);
  81457. /** @hidden */
  81458. dispose(): void;
  81459. /** @hidden */
  81460. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81461. private _loadTransparentPropertiesAsync;
  81462. }
  81463. }
  81464. declare module BABYLON.GLTF2.Loader.Extensions {
  81465. /**
  81466. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  81467. */
  81468. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  81469. /**
  81470. * The name of this extension.
  81471. */
  81472. readonly name: string;
  81473. /**
  81474. * Defines whether this extension is enabled.
  81475. */
  81476. enabled: boolean;
  81477. /** @hidden */
  81478. constructor(loader: GLTFLoader);
  81479. /** @hidden */
  81480. dispose(): void;
  81481. }
  81482. }
  81483. declare module BABYLON.GLTF2.Loader.Extensions {
  81484. /**
  81485. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  81486. * !!! Experimental Extension Subject to Changes !!!
  81487. */
  81488. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  81489. /** The name of this extension. */
  81490. readonly name: string;
  81491. /** Defines whether this extension is enabled. */
  81492. enabled: boolean;
  81493. private _loader;
  81494. /** @hidden */
  81495. constructor(loader: GLTFLoader);
  81496. /** @hidden */
  81497. dispose(): void;
  81498. /** @hidden */
  81499. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  81500. }
  81501. }
  81502. declare module BABYLON.GLTF2.Loader.Extensions {
  81503. /**
  81504. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  81505. */
  81506. export class KHR_texture_transform implements IGLTFLoaderExtension {
  81507. /**
  81508. * The name of this extension.
  81509. */
  81510. readonly name: string;
  81511. /**
  81512. * Defines whether this extension is enabled.
  81513. */
  81514. enabled: boolean;
  81515. private _loader;
  81516. /** @hidden */
  81517. constructor(loader: GLTFLoader);
  81518. /** @hidden */
  81519. dispose(): void;
  81520. /** @hidden */
  81521. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  81522. }
  81523. }
  81524. declare module BABYLON.GLTF2.Loader.Extensions {
  81525. /**
  81526. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  81527. * !!! Experimental Extension Subject to Changes !!!
  81528. */
  81529. export class KHR_xmp implements IGLTFLoaderExtension {
  81530. /**
  81531. * The name of this extension.
  81532. */
  81533. readonly name: string;
  81534. /**
  81535. * Defines whether this extension is enabled.
  81536. */
  81537. enabled: boolean;
  81538. /**
  81539. * Defines a number that determines the order the extensions are applied.
  81540. */
  81541. order: number;
  81542. private _loader;
  81543. /** @hidden */
  81544. constructor(loader: GLTFLoader);
  81545. /** @hidden */
  81546. dispose(): void;
  81547. /**
  81548. * Called after the loader state changes to LOADING.
  81549. */
  81550. onLoading(): void;
  81551. }
  81552. }
  81553. declare module BABYLON.GLTF2.Loader.Extensions {
  81554. /**
  81555. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  81556. */
  81557. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  81558. /**
  81559. * The name of this extension.
  81560. */
  81561. readonly name: string;
  81562. /**
  81563. * Defines whether this extension is enabled.
  81564. */
  81565. enabled: boolean;
  81566. private _loader;
  81567. private _clips;
  81568. private _emitters;
  81569. /** @hidden */
  81570. constructor(loader: GLTFLoader);
  81571. /** @hidden */
  81572. dispose(): void;
  81573. /** @hidden */
  81574. onLoading(): void;
  81575. /** @hidden */
  81576. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  81577. /** @hidden */
  81578. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81579. /** @hidden */
  81580. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  81581. private _loadClipAsync;
  81582. private _loadEmitterAsync;
  81583. private _getEventAction;
  81584. private _loadAnimationEventAsync;
  81585. }
  81586. }
  81587. declare module BABYLON.GLTF2.Loader.Extensions {
  81588. /**
  81589. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  81590. */
  81591. export class MSFT_lod implements IGLTFLoaderExtension {
  81592. /**
  81593. * The name of this extension.
  81594. */
  81595. readonly name: string;
  81596. /**
  81597. * Defines whether this extension is enabled.
  81598. */
  81599. enabled: boolean;
  81600. /**
  81601. * Defines a number that determines the order the extensions are applied.
  81602. */
  81603. order: number;
  81604. /**
  81605. * Maximum number of LODs to load, starting from the lowest LOD.
  81606. */
  81607. maxLODsToLoad: number;
  81608. /**
  81609. * Observable raised when all node LODs of one level are loaded.
  81610. * The event data is the index of the loaded LOD starting from zero.
  81611. * Dispose the loader to cancel the loading of the next level of LODs.
  81612. */
  81613. onNodeLODsLoadedObservable: Observable<number>;
  81614. /**
  81615. * Observable raised when all material LODs of one level are loaded.
  81616. * The event data is the index of the loaded LOD starting from zero.
  81617. * Dispose the loader to cancel the loading of the next level of LODs.
  81618. */
  81619. onMaterialLODsLoadedObservable: Observable<number>;
  81620. private _loader;
  81621. private _bufferLODs;
  81622. private _nodeIndexLOD;
  81623. private _nodeSignalLODs;
  81624. private _nodePromiseLODs;
  81625. private _nodeBufferLODs;
  81626. private _materialIndexLOD;
  81627. private _materialSignalLODs;
  81628. private _materialPromiseLODs;
  81629. private _materialBufferLODs;
  81630. /** @hidden */
  81631. constructor(loader: GLTFLoader);
  81632. /** @hidden */
  81633. dispose(): void;
  81634. /** @hidden */
  81635. onReady(): void;
  81636. /** @hidden */
  81637. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  81638. /** @hidden */
  81639. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81640. /** @hidden */
  81641. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  81642. /** @hidden */
  81643. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  81644. /** @hidden */
  81645. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  81646. private _loadBufferLOD;
  81647. /**
  81648. * Gets an array of LOD properties from lowest to highest.
  81649. */
  81650. private _getLODs;
  81651. private _disposeTransformNode;
  81652. private _disposeMaterials;
  81653. }
  81654. }
  81655. declare module BABYLON.GLTF2.Loader.Extensions {
  81656. /** @hidden */
  81657. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  81658. readonly name: string;
  81659. enabled: boolean;
  81660. private _loader;
  81661. constructor(loader: GLTFLoader);
  81662. dispose(): void;
  81663. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81664. }
  81665. }
  81666. declare module BABYLON.GLTF2.Loader.Extensions {
  81667. /** @hidden */
  81668. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  81669. readonly name: string;
  81670. enabled: boolean;
  81671. private _loader;
  81672. constructor(loader: GLTFLoader);
  81673. dispose(): void;
  81674. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81675. }
  81676. }
  81677. declare module BABYLON.GLTF2.Loader.Extensions {
  81678. /**
  81679. * Store glTF extras (if present) in BJS objects' metadata
  81680. */
  81681. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  81682. /**
  81683. * The name of this extension.
  81684. */
  81685. readonly name: string;
  81686. /**
  81687. * Defines whether this extension is enabled.
  81688. */
  81689. enabled: boolean;
  81690. private _loader;
  81691. private _assignExtras;
  81692. /** @hidden */
  81693. constructor(loader: GLTFLoader);
  81694. /** @hidden */
  81695. dispose(): void;
  81696. /** @hidden */
  81697. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81698. /** @hidden */
  81699. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  81700. /** @hidden */
  81701. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  81702. }
  81703. }
  81704. declare module BABYLON {
  81705. /**
  81706. * Class reading and parsing the MTL file bundled with the obj file.
  81707. */
  81708. export class MTLFileLoader {
  81709. /**
  81710. * Invert Y-Axis of referenced textures on load
  81711. */
  81712. static INVERT_TEXTURE_Y: boolean;
  81713. /**
  81714. * All material loaded from the mtl will be set here
  81715. */
  81716. materials: StandardMaterial[];
  81717. /**
  81718. * This function will read the mtl file and create each material described inside
  81719. * This function could be improve by adding :
  81720. * -some component missing (Ni, Tf...)
  81721. * -including the specific options available
  81722. *
  81723. * @param scene defines the scene the material will be created in
  81724. * @param data defines the mtl data to parse
  81725. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  81726. * @param forAssetContainer defines if the material should be registered in the scene
  81727. */
  81728. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  81729. /**
  81730. * Gets the texture for the material.
  81731. *
  81732. * If the material is imported from input file,
  81733. * We sanitize the url to ensure it takes the textre from aside the material.
  81734. *
  81735. * @param rootUrl The root url to load from
  81736. * @param value The value stored in the mtl
  81737. * @return The Texture
  81738. */
  81739. private static _getTexture;
  81740. }
  81741. }
  81742. declare module BABYLON {
  81743. /**
  81744. * Options for loading OBJ/MTL files
  81745. */
  81746. type MeshLoadOptions = {
  81747. /**
  81748. * Defines if UVs are optimized by default during load.
  81749. */
  81750. OptimizeWithUV: boolean;
  81751. /**
  81752. * Defines custom scaling of UV coordinates of loaded meshes.
  81753. */
  81754. UVScaling: Vector2;
  81755. /**
  81756. * Invert model on y-axis (does a model scaling inversion)
  81757. */
  81758. InvertY: boolean;
  81759. /**
  81760. * Invert Y-Axis of referenced textures on load
  81761. */
  81762. InvertTextureY: boolean;
  81763. /**
  81764. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  81765. */
  81766. ImportVertexColors: boolean;
  81767. /**
  81768. * Compute the normals for the model, even if normals are present in the file.
  81769. */
  81770. ComputeNormals: boolean;
  81771. /**
  81772. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  81773. */
  81774. SkipMaterials: boolean;
  81775. /**
  81776. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  81777. */
  81778. MaterialLoadingFailsSilently: boolean;
  81779. };
  81780. /**
  81781. * OBJ file type loader.
  81782. * This is a babylon scene loader plugin.
  81783. */
  81784. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  81785. /**
  81786. * Defines if UVs are optimized by default during load.
  81787. */
  81788. static OPTIMIZE_WITH_UV: boolean;
  81789. /**
  81790. * Invert model on y-axis (does a model scaling inversion)
  81791. */
  81792. static INVERT_Y: boolean;
  81793. /**
  81794. * Invert Y-Axis of referenced textures on load
  81795. */
  81796. static get INVERT_TEXTURE_Y(): boolean;
  81797. static set INVERT_TEXTURE_Y(value: boolean);
  81798. /**
  81799. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  81800. */
  81801. static IMPORT_VERTEX_COLORS: boolean;
  81802. /**
  81803. * Compute the normals for the model, even if normals are present in the file.
  81804. */
  81805. static COMPUTE_NORMALS: boolean;
  81806. /**
  81807. * Defines custom scaling of UV coordinates of loaded meshes.
  81808. */
  81809. static UV_SCALING: Vector2;
  81810. /**
  81811. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  81812. */
  81813. static SKIP_MATERIALS: boolean;
  81814. /**
  81815. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  81816. *
  81817. * Defaults to true for backwards compatibility.
  81818. */
  81819. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  81820. /**
  81821. * Defines the name of the plugin.
  81822. */
  81823. name: string;
  81824. /**
  81825. * Defines the extension the plugin is able to load.
  81826. */
  81827. extensions: string;
  81828. /** @hidden */
  81829. obj: RegExp;
  81830. /** @hidden */
  81831. group: RegExp;
  81832. /** @hidden */
  81833. mtllib: RegExp;
  81834. /** @hidden */
  81835. usemtl: RegExp;
  81836. /** @hidden */
  81837. smooth: RegExp;
  81838. /** @hidden */
  81839. vertexPattern: RegExp;
  81840. /** @hidden */
  81841. normalPattern: RegExp;
  81842. /** @hidden */
  81843. uvPattern: RegExp;
  81844. /** @hidden */
  81845. facePattern1: RegExp;
  81846. /** @hidden */
  81847. facePattern2: RegExp;
  81848. /** @hidden */
  81849. facePattern3: RegExp;
  81850. /** @hidden */
  81851. facePattern4: RegExp;
  81852. /** @hidden */
  81853. facePattern5: RegExp;
  81854. private _forAssetContainer;
  81855. private _meshLoadOptions;
  81856. /**
  81857. * Creates loader for .OBJ files
  81858. *
  81859. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  81860. */
  81861. constructor(meshLoadOptions?: MeshLoadOptions);
  81862. private static get currentMeshLoadOptions();
  81863. /**
  81864. * Calls synchronously the MTL file attached to this obj.
  81865. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  81866. * Without this function materials are not displayed in the first frame (but displayed after).
  81867. * In consequence it is impossible to get material information in your HTML file
  81868. *
  81869. * @param url The URL of the MTL file
  81870. * @param rootUrl
  81871. * @param onSuccess Callback function to be called when the MTL file is loaded
  81872. * @private
  81873. */
  81874. private _loadMTL;
  81875. /**
  81876. * Instantiates a OBJ file loader plugin.
  81877. * @returns the created plugin
  81878. */
  81879. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  81880. /**
  81881. * If the data string can be loaded directly.
  81882. *
  81883. * @param data string containing the file data
  81884. * @returns if the data can be loaded directly
  81885. */
  81886. canDirectLoad(data: string): boolean;
  81887. /**
  81888. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  81889. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  81890. * @param scene the scene the meshes should be added to
  81891. * @param data the OBJ data to load
  81892. * @param rootUrl root url to load from
  81893. * @param onProgress event that fires when loading progress has occured
  81894. * @param fileName Defines the name of the file to load
  81895. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  81896. */
  81897. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  81898. meshes: AbstractMesh[];
  81899. particleSystems: IParticleSystem[];
  81900. skeletons: Skeleton[];
  81901. animationGroups: AnimationGroup[];
  81902. }>;
  81903. /**
  81904. * Imports all objects from the loaded OBJ data and adds them to the scene
  81905. * @param scene the scene the objects should be added to
  81906. * @param data the OBJ data to load
  81907. * @param rootUrl root url to load from
  81908. * @param onProgress event that fires when loading progress has occured
  81909. * @param fileName Defines the name of the file to load
  81910. * @returns a promise which completes when objects have been loaded to the scene
  81911. */
  81912. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  81913. /**
  81914. * Load into an asset container.
  81915. * @param scene The scene to load into
  81916. * @param data The data to import
  81917. * @param rootUrl The root url for scene and resources
  81918. * @param onProgress The callback when the load progresses
  81919. * @param fileName Defines the name of the file to load
  81920. * @returns The loaded asset container
  81921. */
  81922. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  81923. /**
  81924. * Read the OBJ file and create an Array of meshes.
  81925. * Each mesh contains all information given by the OBJ and the MTL file.
  81926. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  81927. *
  81928. * @param meshesNames
  81929. * @param scene Scene The scene where are displayed the data
  81930. * @param data String The content of the obj file
  81931. * @param rootUrl String The path to the folder
  81932. * @returns Array<AbstractMesh>
  81933. * @private
  81934. */
  81935. private _parseSolid;
  81936. }
  81937. }
  81938. declare module BABYLON {
  81939. /**
  81940. * STL file type loader.
  81941. * This is a babylon scene loader plugin.
  81942. */
  81943. export class STLFileLoader implements ISceneLoaderPlugin {
  81944. /** @hidden */
  81945. solidPattern: RegExp;
  81946. /** @hidden */
  81947. facetsPattern: RegExp;
  81948. /** @hidden */
  81949. normalPattern: RegExp;
  81950. /** @hidden */
  81951. vertexPattern: RegExp;
  81952. /**
  81953. * Defines the name of the plugin.
  81954. */
  81955. name: string;
  81956. /**
  81957. * Defines the extensions the stl loader is able to load.
  81958. * force data to come in as an ArrayBuffer
  81959. * we'll convert to string if it looks like it's an ASCII .stl
  81960. */
  81961. extensions: ISceneLoaderPluginExtensions;
  81962. /**
  81963. * Import meshes into a scene.
  81964. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  81965. * @param scene The scene to import into
  81966. * @param data The data to import
  81967. * @param rootUrl The root url for scene and resources
  81968. * @param meshes The meshes array to import into
  81969. * @param particleSystems The particle systems array to import into
  81970. * @param skeletons The skeletons array to import into
  81971. * @param onError The callback when import fails
  81972. * @returns True if successful or false otherwise
  81973. */
  81974. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  81975. /**
  81976. * Load into a scene.
  81977. * @param scene The scene to load into
  81978. * @param data The data to import
  81979. * @param rootUrl The root url for scene and resources
  81980. * @param onError The callback when import fails
  81981. * @returns true if successful or false otherwise
  81982. */
  81983. load(scene: Scene, data: any, rootUrl: string): boolean;
  81984. /**
  81985. * Load into an asset container.
  81986. * @param scene The scene to load into
  81987. * @param data The data to import
  81988. * @param rootUrl The root url for scene and resources
  81989. * @param onError The callback when import fails
  81990. * @returns The loaded asset container
  81991. */
  81992. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  81993. private _isBinary;
  81994. private _parseBinary;
  81995. private _parseASCII;
  81996. }
  81997. }
  81998. declare module BABYLON {
  81999. /**
  82000. * Class for generating OBJ data from a Babylon scene.
  82001. */
  82002. export class OBJExport {
  82003. /**
  82004. * Exports the geometry of a Mesh array in .OBJ file format (text)
  82005. * @param mesh defines the list of meshes to serialize
  82006. * @param materials defines if materials should be exported
  82007. * @param matlibname defines the name of the associated mtl file
  82008. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  82009. * @returns the OBJ content
  82010. */
  82011. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  82012. /**
  82013. * Exports the material(s) of a mesh in .MTL file format (text)
  82014. * @param mesh defines the mesh to extract the material from
  82015. * @returns the mtl content
  82016. */
  82017. static MTL(mesh: Mesh): string;
  82018. }
  82019. }
  82020. declare module BABYLON {
  82021. /** @hidden */
  82022. export var __IGLTFExporterExtension: number;
  82023. /**
  82024. * Interface for extending the exporter
  82025. * @hidden
  82026. */
  82027. export interface IGLTFExporterExtension {
  82028. /**
  82029. * The name of this extension
  82030. */
  82031. readonly name: string;
  82032. /**
  82033. * Defines whether this extension is enabled
  82034. */
  82035. enabled: boolean;
  82036. /**
  82037. * Defines whether this extension is required
  82038. */
  82039. required: boolean;
  82040. }
  82041. }
  82042. declare module BABYLON.GLTF2.Exporter {
  82043. /** @hidden */
  82044. export var __IGLTFExporterExtensionV2: number;
  82045. /**
  82046. * Interface for a glTF exporter extension
  82047. * @hidden
  82048. */
  82049. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  82050. /**
  82051. * Define this method to modify the default behavior before exporting a texture
  82052. * @param context The context when loading the asset
  82053. * @param babylonTexture The Babylon.js texture
  82054. * @param mimeType The mime-type of the generated image
  82055. * @returns A promise that resolves with the exported texture
  82056. */
  82057. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  82058. /**
  82059. * Define this method to get notified when a texture info is created
  82060. * @param context The context when loading the asset
  82061. * @param textureInfo The glTF texture info
  82062. * @param babylonTexture The Babylon.js texture
  82063. */
  82064. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  82065. /**
  82066. * Define this method to modify the default behavior when exporting texture info
  82067. * @param context The context when loading the asset
  82068. * @param meshPrimitive glTF mesh primitive
  82069. * @param babylonSubMesh Babylon submesh
  82070. * @param binaryWriter glTF serializer binary writer instance
  82071. * @returns nullable IMeshPrimitive promise
  82072. */
  82073. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  82074. /**
  82075. * Define this method to modify the default behavior when exporting a node
  82076. * @param context The context when exporting the node
  82077. * @param node glTF node
  82078. * @param babylonNode BabylonJS node
  82079. * @returns nullable INode promise
  82080. */
  82081. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  82082. [key: number]: number;
  82083. }): Promise<Nullable<INode>>;
  82084. /**
  82085. * Define this method to modify the default behavior when exporting a material
  82086. * @param material glTF material
  82087. * @param babylonMaterial BabylonJS material
  82088. * @returns nullable IMaterial promise
  82089. */
  82090. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  82091. /**
  82092. * Define this method to return additional textures to export from a material
  82093. * @param material glTF material
  82094. * @param babylonMaterial BabylonJS material
  82095. * @returns List of textures
  82096. */
  82097. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  82098. /** Gets a boolean indicating that this extension was used */
  82099. wasUsed: boolean;
  82100. /** Gets a boolean indicating that this extension is required for the file to work */
  82101. required: boolean;
  82102. /**
  82103. * Called after the exporter state changes to EXPORTING
  82104. */
  82105. onExporting?(): void;
  82106. }
  82107. }
  82108. declare module BABYLON.GLTF2.Exporter {
  82109. /**
  82110. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  82111. * @hidden
  82112. */
  82113. export class _GLTFMaterialExporter {
  82114. /**
  82115. * Represents the dielectric specular values for R, G and B
  82116. */
  82117. private static readonly _DielectricSpecular;
  82118. /**
  82119. * Allows the maximum specular power to be defined for material calculations
  82120. */
  82121. private static readonly _MaxSpecularPower;
  82122. /**
  82123. * Mapping to store textures
  82124. */
  82125. private _textureMap;
  82126. /**
  82127. * Numeric tolerance value
  82128. */
  82129. private static readonly _Epsilon;
  82130. /**
  82131. * Reference to the glTF Exporter
  82132. */
  82133. private _exporter;
  82134. constructor(exporter: _Exporter);
  82135. /**
  82136. * Specifies if two colors are approximately equal in value
  82137. * @param color1 first color to compare to
  82138. * @param color2 second color to compare to
  82139. * @param epsilon threshold value
  82140. */
  82141. private static FuzzyEquals;
  82142. /**
  82143. * Gets the materials from a Babylon scene and converts them to glTF materials
  82144. * @param scene babylonjs scene
  82145. * @param mimeType texture mime type
  82146. * @param images array of images
  82147. * @param textures array of textures
  82148. * @param materials array of materials
  82149. * @param imageData mapping of texture names to base64 textures
  82150. * @param hasTextureCoords specifies if texture coordinates are present on the material
  82151. */
  82152. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  82153. /**
  82154. * Makes a copy of the glTF material without the texture parameters
  82155. * @param originalMaterial original glTF material
  82156. * @returns glTF material without texture parameters
  82157. */
  82158. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  82159. /**
  82160. * Specifies if the material has any texture parameters present
  82161. * @param material glTF Material
  82162. * @returns boolean specifying if texture parameters are present
  82163. */
  82164. _hasTexturesPresent(material: IMaterial): boolean;
  82165. /**
  82166. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  82167. * @param babylonStandardMaterial
  82168. * @returns glTF Metallic Roughness Material representation
  82169. */
  82170. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  82171. /**
  82172. * Computes the metallic factor
  82173. * @param diffuse diffused value
  82174. * @param specular specular value
  82175. * @param oneMinusSpecularStrength one minus the specular strength
  82176. * @returns metallic value
  82177. */
  82178. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  82179. /**
  82180. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  82181. * @param glTFMaterial glTF material
  82182. * @param babylonMaterial Babylon material
  82183. */
  82184. private static _SetAlphaMode;
  82185. /**
  82186. * Converts a Babylon Standard Material to a glTF Material
  82187. * @param babylonStandardMaterial BJS Standard Material
  82188. * @param mimeType mime type to use for the textures
  82189. * @param images array of glTF image interfaces
  82190. * @param textures array of glTF texture interfaces
  82191. * @param materials array of glTF material interfaces
  82192. * @param imageData map of image file name to data
  82193. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82194. */
  82195. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  82196. private _finishMaterial;
  82197. /**
  82198. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  82199. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  82200. * @param mimeType mime type to use for the textures
  82201. * @param images array of glTF image interfaces
  82202. * @param textures array of glTF texture interfaces
  82203. * @param materials array of glTF material interfaces
  82204. * @param imageData map of image file name to data
  82205. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82206. */
  82207. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  82208. /**
  82209. * Converts an image typed array buffer to a base64 image
  82210. * @param buffer typed array buffer
  82211. * @param width width of the image
  82212. * @param height height of the image
  82213. * @param mimeType mimetype of the image
  82214. * @returns base64 image string
  82215. */
  82216. private _createBase64FromCanvasAsync;
  82217. /**
  82218. * Generates a white texture based on the specified width and height
  82219. * @param width width of the texture in pixels
  82220. * @param height height of the texture in pixels
  82221. * @param scene babylonjs scene
  82222. * @returns white texture
  82223. */
  82224. private _createWhiteTexture;
  82225. /**
  82226. * 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
  82227. * @param texture1 first texture to resize
  82228. * @param texture2 second texture to resize
  82229. * @param scene babylonjs scene
  82230. * @returns resized textures or null
  82231. */
  82232. private _resizeTexturesToSameDimensions;
  82233. /**
  82234. * Converts an array of pixels to a Float32Array
  82235. * Throws an error if the pixel format is not supported
  82236. * @param pixels - array buffer containing pixel values
  82237. * @returns Float32 of pixels
  82238. */
  82239. private _convertPixelArrayToFloat32;
  82240. /**
  82241. * Convert Specular Glossiness Textures to Metallic Roughness
  82242. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  82243. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  82244. * @param diffuseTexture texture used to store diffuse information
  82245. * @param specularGlossinessTexture texture used to store specular and glossiness information
  82246. * @param factors specular glossiness material factors
  82247. * @param mimeType the mime type to use for the texture
  82248. * @returns pbr metallic roughness interface or null
  82249. */
  82250. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  82251. /**
  82252. * Converts specular glossiness material properties to metallic roughness
  82253. * @param specularGlossiness interface with specular glossiness material properties
  82254. * @returns interface with metallic roughness material properties
  82255. */
  82256. private _convertSpecularGlossinessToMetallicRoughness;
  82257. /**
  82258. * Calculates the surface reflectance, independent of lighting conditions
  82259. * @param color Color source to calculate brightness from
  82260. * @returns number representing the perceived brightness, or zero if color is undefined
  82261. */
  82262. private _getPerceivedBrightness;
  82263. /**
  82264. * Returns the maximum color component value
  82265. * @param color
  82266. * @returns maximum color component value, or zero if color is null or undefined
  82267. */
  82268. private _getMaxComponent;
  82269. /**
  82270. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  82271. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  82272. * @param mimeType mime type to use for the textures
  82273. * @param images array of glTF image interfaces
  82274. * @param textures array of glTF texture interfaces
  82275. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  82276. * @param imageData map of image file name to data
  82277. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82278. * @returns glTF PBR Metallic Roughness factors
  82279. */
  82280. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  82281. private _getGLTFTextureSampler;
  82282. private _getGLTFTextureWrapMode;
  82283. private _getGLTFTextureWrapModesSampler;
  82284. /**
  82285. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  82286. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  82287. * @param mimeType mime type to use for the textures
  82288. * @param images array of glTF image interfaces
  82289. * @param textures array of glTF texture interfaces
  82290. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  82291. * @param imageData map of image file name to data
  82292. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82293. * @returns glTF PBR Metallic Roughness factors
  82294. */
  82295. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  82296. /**
  82297. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  82298. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  82299. * @param mimeType mime type to use for the textures
  82300. * @param images array of glTF image interfaces
  82301. * @param textures array of glTF texture interfaces
  82302. * @param materials array of glTF material interfaces
  82303. * @param imageData map of image file name to data
  82304. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82305. */
  82306. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  82307. private setMetallicRoughnessPbrMaterial;
  82308. private getPixelsFromTexture;
  82309. /**
  82310. * Extracts a texture from a Babylon texture into file data and glTF data
  82311. * @param babylonTexture Babylon texture to extract
  82312. * @param mimeType Mime Type of the babylonTexture
  82313. * @return glTF texture info, or null if the texture format is not supported
  82314. */
  82315. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  82316. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  82317. /**
  82318. * Builds a texture from base64 string
  82319. * @param base64Texture base64 texture string
  82320. * @param baseTextureName Name to use for the texture
  82321. * @param mimeType image mime type for the texture
  82322. * @param images array of images
  82323. * @param textures array of textures
  82324. * @param imageData map of image data
  82325. * @returns glTF texture info, or null if the texture format is not supported
  82326. */
  82327. private _getTextureInfoFromBase64;
  82328. }
  82329. }
  82330. declare module BABYLON {
  82331. /**
  82332. * Class for holding and downloading glTF file data
  82333. */
  82334. export class GLTFData {
  82335. /**
  82336. * Object which contains the file name as the key and its data as the value
  82337. */
  82338. glTFFiles: {
  82339. [fileName: string]: string | Blob;
  82340. };
  82341. /**
  82342. * Initializes the glTF file object
  82343. */
  82344. constructor();
  82345. /**
  82346. * Downloads the glTF data as files based on their names and data
  82347. */
  82348. downloadFiles(): void;
  82349. }
  82350. }
  82351. declare module BABYLON {
  82352. /**
  82353. * Holds a collection of exporter options and parameters
  82354. */
  82355. export interface IExportOptions {
  82356. /**
  82357. * Function which indicates whether a babylon node should be exported or not
  82358. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  82359. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  82360. */
  82361. shouldExportNode?(node: Node): boolean;
  82362. /**
  82363. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  82364. * @param metadata source metadata to read from
  82365. * @returns the data to store to glTF node extras
  82366. */
  82367. metadataSelector?(metadata: any): any;
  82368. /**
  82369. * The sample rate to bake animation curves
  82370. */
  82371. animationSampleRate?: number;
  82372. /**
  82373. * Begin serialization without waiting for the scene to be ready
  82374. */
  82375. exportWithoutWaitingForScene?: boolean;
  82376. /**
  82377. * Indicates if coordinate system swapping root nodes should be included in export
  82378. */
  82379. includeCoordinateSystemConversionNodes?: boolean;
  82380. }
  82381. /**
  82382. * Class for generating glTF data from a Babylon scene.
  82383. */
  82384. export class GLTF2Export {
  82385. /**
  82386. * Exports the geometry of the scene to .gltf file format asynchronously
  82387. * @param scene Babylon scene with scene hierarchy information
  82388. * @param filePrefix File prefix to use when generating the glTF file
  82389. * @param options Exporter options
  82390. * @returns Returns an object with a .gltf file and associates texture names
  82391. * as keys and their data and paths as values
  82392. */
  82393. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  82394. private static _PreExportAsync;
  82395. private static _PostExportAsync;
  82396. /**
  82397. * Exports the geometry of the scene to .glb file format asychronously
  82398. * @param scene Babylon scene with scene hierarchy information
  82399. * @param filePrefix File prefix to use when generating glb file
  82400. * @param options Exporter options
  82401. * @returns Returns an object with a .glb filename as key and data as value
  82402. */
  82403. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  82404. }
  82405. }
  82406. declare module BABYLON.GLTF2.Exporter {
  82407. /**
  82408. * @hidden
  82409. */
  82410. export class _GLTFUtilities {
  82411. /**
  82412. * Creates a buffer view based on the supplied arguments
  82413. * @param bufferIndex index value of the specified buffer
  82414. * @param byteOffset byte offset value
  82415. * @param byteLength byte length of the bufferView
  82416. * @param byteStride byte distance between conequential elements
  82417. * @param name name of the buffer view
  82418. * @returns bufferView for glTF
  82419. */
  82420. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  82421. /**
  82422. * Creates an accessor based on the supplied arguments
  82423. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  82424. * @param name The name of the accessor
  82425. * @param type The type of the accessor
  82426. * @param componentType The datatype of components in the attribute
  82427. * @param count The number of attributes referenced by this accessor
  82428. * @param byteOffset The offset relative to the start of the bufferView in bytes
  82429. * @param min Minimum value of each component in this attribute
  82430. * @param max Maximum value of each component in this attribute
  82431. * @returns accessor for glTF
  82432. */
  82433. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  82434. /**
  82435. * Calculates the minimum and maximum values of an array of position floats
  82436. * @param positions Positions array of a mesh
  82437. * @param vertexStart Starting vertex offset to calculate min and max values
  82438. * @param vertexCount Number of vertices to check for min and max values
  82439. * @returns min number array and max number array
  82440. */
  82441. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  82442. min: number[];
  82443. max: number[];
  82444. };
  82445. /**
  82446. * Converts a new right-handed Vector3
  82447. * @param vector vector3 array
  82448. * @returns right-handed Vector3
  82449. */
  82450. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  82451. /**
  82452. * Converts a Vector3 to right-handed
  82453. * @param vector Vector3 to convert to right-handed
  82454. */
  82455. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  82456. /**
  82457. * Converts a three element number array to right-handed
  82458. * @param vector number array to convert to right-handed
  82459. */
  82460. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  82461. /**
  82462. * Converts a new right-handed Vector3
  82463. * @param vector vector3 array
  82464. * @returns right-handed Vector3
  82465. */
  82466. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  82467. /**
  82468. * Converts a Vector3 to right-handed
  82469. * @param vector Vector3 to convert to right-handed
  82470. */
  82471. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  82472. /**
  82473. * Converts a three element number array to right-handed
  82474. * @param vector number array to convert to right-handed
  82475. */
  82476. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  82477. /**
  82478. * Converts a Vector4 to right-handed
  82479. * @param vector Vector4 to convert to right-handed
  82480. */
  82481. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  82482. /**
  82483. * Converts a Vector4 to right-handed
  82484. * @param vector Vector4 to convert to right-handed
  82485. */
  82486. static _GetRightHandedArray4FromRef(vector: number[]): void;
  82487. /**
  82488. * Converts a Quaternion to right-handed
  82489. * @param quaternion Source quaternion to convert to right-handed
  82490. */
  82491. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  82492. /**
  82493. * Converts a Quaternion to right-handed
  82494. * @param quaternion Source quaternion to convert to right-handed
  82495. */
  82496. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  82497. static _NormalizeTangentFromRef(tangent: Vector4): void;
  82498. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  82499. }
  82500. }
  82501. declare module BABYLON.GLTF2.Exporter {
  82502. /**
  82503. * Converts Babylon Scene into glTF 2.0.
  82504. * @hidden
  82505. */
  82506. export class _Exporter {
  82507. /**
  82508. * Stores the glTF to export
  82509. */
  82510. _glTF: IGLTF;
  82511. /**
  82512. * Stores all generated buffer views, which represents views into the main glTF buffer data
  82513. */
  82514. _bufferViews: IBufferView[];
  82515. /**
  82516. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  82517. */
  82518. _accessors: IAccessor[];
  82519. /**
  82520. * Stores all the generated nodes, which contains transform and/or mesh information per node
  82521. */
  82522. _nodes: INode[];
  82523. /**
  82524. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  82525. */
  82526. private _scenes;
  82527. /**
  82528. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  82529. */
  82530. private _meshes;
  82531. /**
  82532. * Stores all the generated material information, which represents the appearance of each primitive
  82533. */
  82534. _materials: IMaterial[];
  82535. _materialMap: {
  82536. [materialID: number]: number;
  82537. };
  82538. /**
  82539. * Stores all the generated texture information, which is referenced by glTF materials
  82540. */
  82541. _textures: ITexture[];
  82542. /**
  82543. * Stores all the generated image information, which is referenced by glTF textures
  82544. */
  82545. _images: IImage[];
  82546. /**
  82547. * Stores all the texture samplers
  82548. */
  82549. _samplers: ISampler[];
  82550. /**
  82551. * Stores all the generated glTF skins
  82552. */
  82553. _skins: ISkin[];
  82554. /**
  82555. * Stores all the generated animation samplers, which is referenced by glTF animations
  82556. */
  82557. /**
  82558. * Stores the animations for glTF models
  82559. */
  82560. private _animations;
  82561. /**
  82562. * Stores the total amount of bytes stored in the glTF buffer
  82563. */
  82564. private _totalByteLength;
  82565. /**
  82566. * Stores a reference to the Babylon scene containing the source geometry and material information
  82567. */
  82568. _babylonScene: Scene;
  82569. /**
  82570. * Stores a map of the image data, where the key is the file name and the value
  82571. * is the image data
  82572. */
  82573. _imageData: {
  82574. [fileName: string]: {
  82575. data: Uint8Array;
  82576. mimeType: ImageMimeType;
  82577. };
  82578. };
  82579. /**
  82580. * Stores a map of the unique id of a node to its index in the node array
  82581. */
  82582. _nodeMap: {
  82583. [key: number]: number;
  82584. };
  82585. /**
  82586. * Specifies if the source Babylon scene was left handed, and needed conversion.
  82587. */
  82588. _convertToRightHandedSystem: boolean;
  82589. /**
  82590. * Specifies if a Babylon node should be converted to right-handed on export
  82591. */
  82592. _convertToRightHandedSystemMap: {
  82593. [nodeId: number]: boolean;
  82594. };
  82595. _includeCoordinateSystemConversionNodes: boolean;
  82596. /**
  82597. * Baked animation sample rate
  82598. */
  82599. private _animationSampleRate;
  82600. private _options;
  82601. private _localEngine;
  82602. _glTFMaterialExporter: _GLTFMaterialExporter;
  82603. private _extensions;
  82604. private static _ExtensionNames;
  82605. private static _ExtensionFactories;
  82606. private _applyExtension;
  82607. private _applyExtensions;
  82608. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  82609. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  82610. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  82611. [key: number]: number;
  82612. }): Promise<Nullable<INode>>;
  82613. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  82614. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  82615. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  82616. private _forEachExtensions;
  82617. private _extensionsOnExporting;
  82618. /**
  82619. * Load glTF serializer extensions
  82620. */
  82621. private _loadExtensions;
  82622. /**
  82623. * Creates a glTF Exporter instance, which can accept optional exporter options
  82624. * @param babylonScene Babylon scene object
  82625. * @param options Options to modify the behavior of the exporter
  82626. */
  82627. constructor(babylonScene: Scene, options?: IExportOptions);
  82628. dispose(): void;
  82629. /**
  82630. * Registers a glTF exporter extension
  82631. * @param name Name of the extension to export
  82632. * @param factory The factory function that creates the exporter extension
  82633. */
  82634. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  82635. /**
  82636. * Un-registers an exporter extension
  82637. * @param name The name fo the exporter extension
  82638. * @returns A boolean indicating whether the extension has been un-registered
  82639. */
  82640. static UnregisterExtension(name: string): boolean;
  82641. /**
  82642. * Lazy load a local engine
  82643. */
  82644. _getLocalEngine(): Engine;
  82645. private reorderIndicesBasedOnPrimitiveMode;
  82646. /**
  82647. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  82648. * clock-wise during export to glTF
  82649. * @param submesh BabylonJS submesh
  82650. * @param primitiveMode Primitive mode of the mesh
  82651. * @param sideOrientation the winding order of the submesh
  82652. * @param vertexBufferKind The type of vertex attribute
  82653. * @param meshAttributeArray The vertex attribute data
  82654. * @param byteOffset The offset to the binary data
  82655. * @param binaryWriter The binary data for the glTF file
  82656. * @param convertToRightHandedSystem Converts the values to right-handed
  82657. */
  82658. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  82659. /**
  82660. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  82661. * clock-wise during export to glTF
  82662. * @param submesh BabylonJS submesh
  82663. * @param primitiveMode Primitive mode of the mesh
  82664. * @param sideOrientation the winding order of the submesh
  82665. * @param vertexBufferKind The type of vertex attribute
  82666. * @param meshAttributeArray The vertex attribute data
  82667. * @param byteOffset The offset to the binary data
  82668. * @param binaryWriter The binary data for the glTF file
  82669. * @param convertToRightHandedSystem Converts the values to right-handed
  82670. */
  82671. private reorderTriangleFillMode;
  82672. /**
  82673. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  82674. * clock-wise during export to glTF
  82675. * @param submesh BabylonJS submesh
  82676. * @param primitiveMode Primitive mode of the mesh
  82677. * @param sideOrientation the winding order of the submesh
  82678. * @param vertexBufferKind The type of vertex attribute
  82679. * @param meshAttributeArray The vertex attribute data
  82680. * @param byteOffset The offset to the binary data
  82681. * @param binaryWriter The binary data for the glTF file
  82682. * @param convertToRightHandedSystem Converts the values to right-handed
  82683. */
  82684. private reorderTriangleStripDrawMode;
  82685. /**
  82686. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  82687. * clock-wise during export to glTF
  82688. * @param submesh BabylonJS submesh
  82689. * @param primitiveMode Primitive mode of the mesh
  82690. * @param sideOrientation the winding order of the submesh
  82691. * @param vertexBufferKind The type of vertex attribute
  82692. * @param meshAttributeArray The vertex attribute data
  82693. * @param byteOffset The offset to the binary data
  82694. * @param binaryWriter The binary data for the glTF file
  82695. * @param convertToRightHandedSystem Converts the values to right-handed
  82696. */
  82697. private reorderTriangleFanMode;
  82698. /**
  82699. * Writes the vertex attribute data to binary
  82700. * @param vertices The vertices to write to the binary writer
  82701. * @param byteOffset The offset into the binary writer to overwrite binary data
  82702. * @param vertexAttributeKind The vertex attribute type
  82703. * @param meshAttributeArray The vertex attribute data
  82704. * @param binaryWriter The writer containing the binary data
  82705. * @param convertToRightHandedSystem Converts the values to right-handed
  82706. */
  82707. private writeVertexAttributeData;
  82708. /**
  82709. * Writes mesh attribute data to a data buffer
  82710. * Returns the bytelength of the data
  82711. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  82712. * @param meshAttributeArray Array containing the attribute data
  82713. * @param byteStride Specifies the space between data
  82714. * @param binaryWriter The buffer to write the binary data to
  82715. * @param convertToRightHandedSystem Converts the values to right-handed
  82716. */
  82717. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  82718. /**
  82719. * Generates glTF json data
  82720. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  82721. * @param glTFPrefix Text to use when prefixing a glTF file
  82722. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  82723. * @returns json data as string
  82724. */
  82725. private generateJSON;
  82726. /**
  82727. * Generates data for .gltf and .bin files based on the glTF prefix string
  82728. * @param glTFPrefix Text to use when prefixing a glTF file
  82729. * @param dispose Dispose the exporter
  82730. * @returns GLTFData with glTF file data
  82731. */
  82732. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  82733. /**
  82734. * Creates a binary buffer for glTF
  82735. * @returns array buffer for binary data
  82736. */
  82737. private _generateBinaryAsync;
  82738. /**
  82739. * Pads the number to a multiple of 4
  82740. * @param num number to pad
  82741. * @returns padded number
  82742. */
  82743. private _getPadding;
  82744. /**
  82745. * @hidden
  82746. */
  82747. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  82748. /**
  82749. * Sets the TRS for each node
  82750. * @param node glTF Node for storing the transformation data
  82751. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  82752. * @param convertToRightHandedSystem Converts the values to right-handed
  82753. */
  82754. private setNodeTransformation;
  82755. private getVertexBufferFromMesh;
  82756. /**
  82757. * Creates a bufferview based on the vertices type for the Babylon mesh
  82758. * @param kind Indicates the type of vertices data
  82759. * @param componentType Indicates the numerical type used to store the data
  82760. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  82761. * @param binaryWriter The buffer to write the bufferview data to
  82762. * @param convertToRightHandedSystem Converts the values to right-handed
  82763. */
  82764. private createBufferViewKind;
  82765. /**
  82766. * The primitive mode of the Babylon mesh
  82767. * @param babylonMesh The BabylonJS mesh
  82768. */
  82769. private getMeshPrimitiveMode;
  82770. /**
  82771. * Sets the primitive mode of the glTF mesh primitive
  82772. * @param meshPrimitive glTF mesh primitive
  82773. * @param primitiveMode The primitive mode
  82774. */
  82775. private setPrimitiveMode;
  82776. /**
  82777. * Sets the vertex attribute accessor based of the glTF mesh primitive
  82778. * @param meshPrimitive glTF mesh primitive
  82779. * @param attributeKind vertex attribute
  82780. * @returns boolean specifying if uv coordinates are present
  82781. */
  82782. private setAttributeKind;
  82783. /**
  82784. * Sets data for the primitive attributes of each submesh
  82785. * @param mesh glTF Mesh object to store the primitive attribute information
  82786. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  82787. * @param binaryWriter Buffer to write the attribute data to
  82788. * @param convertToRightHandedSystem Converts the values to right-handed
  82789. */
  82790. private setPrimitiveAttributesAsync;
  82791. /**
  82792. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  82793. * @param node The node to check
  82794. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  82795. */
  82796. private isBabylonCoordinateSystemConvertingNode;
  82797. /**
  82798. * Creates a glTF scene based on the array of meshes
  82799. * Returns the the total byte offset
  82800. * @param babylonScene Babylon scene to get the mesh data from
  82801. * @param binaryWriter Buffer to write binary data to
  82802. */
  82803. private createSceneAsync;
  82804. /**
  82805. * Creates a mapping of Node unique id to node index and handles animations
  82806. * @param babylonScene Babylon Scene
  82807. * @param nodes Babylon transform nodes
  82808. * @param binaryWriter Buffer to write binary data to
  82809. * @returns Node mapping of unique id to index
  82810. */
  82811. private createNodeMapAndAnimationsAsync;
  82812. /**
  82813. * Creates a glTF node from a Babylon mesh
  82814. * @param babylonMesh Source Babylon mesh
  82815. * @param binaryWriter Buffer for storing geometry data
  82816. * @param convertToRightHandedSystem Converts the values to right-handed
  82817. * @param nodeMap Node mapping of unique id to glTF node index
  82818. * @returns glTF node
  82819. */
  82820. private createNodeAsync;
  82821. /**
  82822. * Creates a glTF skin from a Babylon skeleton
  82823. * @param babylonScene Babylon Scene
  82824. * @param nodes Babylon transform nodes
  82825. * @param binaryWriter Buffer to write binary data to
  82826. * @returns Node mapping of unique id to index
  82827. */
  82828. private createSkinsAsync;
  82829. }
  82830. /**
  82831. * @hidden
  82832. *
  82833. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  82834. */
  82835. export class _BinaryWriter {
  82836. /**
  82837. * Array buffer which stores all binary data
  82838. */
  82839. private _arrayBuffer;
  82840. /**
  82841. * View of the array buffer
  82842. */
  82843. private _dataView;
  82844. /**
  82845. * byte offset of data in array buffer
  82846. */
  82847. private _byteOffset;
  82848. /**
  82849. * Initialize binary writer with an initial byte length
  82850. * @param byteLength Initial byte length of the array buffer
  82851. */
  82852. constructor(byteLength: number);
  82853. /**
  82854. * Resize the array buffer to the specified byte length
  82855. * @param byteLength
  82856. */
  82857. private resizeBuffer;
  82858. /**
  82859. * Get an array buffer with the length of the byte offset
  82860. * @returns ArrayBuffer resized to the byte offset
  82861. */
  82862. getArrayBuffer(): ArrayBuffer;
  82863. /**
  82864. * Get the byte offset of the array buffer
  82865. * @returns byte offset
  82866. */
  82867. getByteOffset(): number;
  82868. /**
  82869. * Stores an UInt8 in the array buffer
  82870. * @param entry
  82871. * @param byteOffset If defined, specifies where to set the value as an offset.
  82872. */
  82873. setUInt8(entry: number, byteOffset?: number): void;
  82874. /**
  82875. * Stores an UInt16 in the array buffer
  82876. * @param entry
  82877. * @param byteOffset If defined, specifies where to set the value as an offset.
  82878. */
  82879. setUInt16(entry: number, byteOffset?: number): void;
  82880. /**
  82881. * Gets an UInt32 in the array buffer
  82882. * @param entry
  82883. * @param byteOffset If defined, specifies where to set the value as an offset.
  82884. */
  82885. getUInt32(byteOffset: number): number;
  82886. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  82887. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  82888. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  82889. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  82890. /**
  82891. * Stores a Float32 in the array buffer
  82892. * @param entry
  82893. */
  82894. setFloat32(entry: number, byteOffset?: number): void;
  82895. /**
  82896. * Stores an UInt32 in the array buffer
  82897. * @param entry
  82898. * @param byteOffset If defined, specifies where to set the value as an offset.
  82899. */
  82900. setUInt32(entry: number, byteOffset?: number): void;
  82901. }
  82902. }
  82903. declare module BABYLON.GLTF2.Exporter {
  82904. /**
  82905. * @hidden
  82906. * Interface to store animation data.
  82907. */
  82908. export interface _IAnimationData {
  82909. /**
  82910. * Keyframe data.
  82911. */
  82912. inputs: number[];
  82913. /**
  82914. * Value data.
  82915. */
  82916. outputs: number[][];
  82917. /**
  82918. * Animation interpolation data.
  82919. */
  82920. samplerInterpolation: AnimationSamplerInterpolation;
  82921. /**
  82922. * Minimum keyframe value.
  82923. */
  82924. inputsMin: number;
  82925. /**
  82926. * Maximum keyframe value.
  82927. */
  82928. inputsMax: number;
  82929. }
  82930. /**
  82931. * @hidden
  82932. */
  82933. export interface _IAnimationInfo {
  82934. /**
  82935. * The target channel for the animation
  82936. */
  82937. animationChannelTargetPath: AnimationChannelTargetPath;
  82938. /**
  82939. * The glTF accessor type for the data.
  82940. */
  82941. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  82942. /**
  82943. * Specifies if quaternions should be used.
  82944. */
  82945. useQuaternion: boolean;
  82946. }
  82947. /**
  82948. * @hidden
  82949. * Utility class for generating glTF animation data from BabylonJS.
  82950. */
  82951. export class _GLTFAnimation {
  82952. /**
  82953. * @ignore
  82954. *
  82955. * Creates glTF channel animation from BabylonJS animation.
  82956. * @param babylonTransformNode - BabylonJS mesh.
  82957. * @param animation - animation.
  82958. * @param animationChannelTargetPath - The target animation channel.
  82959. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  82960. * @param useQuaternion - Specifies if quaternions are used.
  82961. * @returns nullable IAnimationData
  82962. */
  82963. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  82964. private static _DeduceAnimationInfo;
  82965. /**
  82966. * @ignore
  82967. * Create node animations from the transform node animations
  82968. * @param babylonNode
  82969. * @param runtimeGLTFAnimation
  82970. * @param idleGLTFAnimations
  82971. * @param nodeMap
  82972. * @param nodes
  82973. * @param binaryWriter
  82974. * @param bufferViews
  82975. * @param accessors
  82976. * @param convertToRightHandedSystem
  82977. * @param animationSampleRate
  82978. */
  82979. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  82980. [key: number]: number;
  82981. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  82982. /**
  82983. * @ignore
  82984. * Create node animations from the animation groups
  82985. * @param babylonScene
  82986. * @param glTFAnimations
  82987. * @param nodeMap
  82988. * @param nodes
  82989. * @param binaryWriter
  82990. * @param bufferViews
  82991. * @param accessors
  82992. * @param convertToRightHandedSystemMap
  82993. * @param animationSampleRate
  82994. */
  82995. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  82996. [key: number]: number;
  82997. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  82998. [nodeId: number]: boolean;
  82999. }, animationSampleRate: number): void;
  83000. private static AddAnimation;
  83001. /**
  83002. * Create a baked animation
  83003. * @param babylonTransformNode BabylonJS mesh
  83004. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  83005. * @param animationChannelTargetPath animation target channel
  83006. * @param minFrame minimum animation frame
  83007. * @param maxFrame maximum animation frame
  83008. * @param fps frames per second of the animation
  83009. * @param inputs input key frames of the animation
  83010. * @param outputs output key frame data of the animation
  83011. * @param convertToRightHandedSystem converts the values to right-handed
  83012. * @param useQuaternion specifies if quaternions should be used
  83013. */
  83014. private static _CreateBakedAnimation;
  83015. private static _ConvertFactorToVector3OrQuaternion;
  83016. private static _SetInterpolatedValue;
  83017. /**
  83018. * Creates linear animation from the animation key frames
  83019. * @param babylonTransformNode BabylonJS mesh
  83020. * @param animation BabylonJS animation
  83021. * @param animationChannelTargetPath The target animation channel
  83022. * @param frameDelta The difference between the last and first frame of the animation
  83023. * @param inputs Array to store the key frame times
  83024. * @param outputs Array to store the key frame data
  83025. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  83026. * @param useQuaternion Specifies if quaternions are used in the animation
  83027. */
  83028. private static _CreateLinearOrStepAnimation;
  83029. /**
  83030. * Creates cubic spline animation from the animation key frames
  83031. * @param babylonTransformNode BabylonJS mesh
  83032. * @param animation BabylonJS animation
  83033. * @param animationChannelTargetPath The target animation channel
  83034. * @param frameDelta The difference between the last and first frame of the animation
  83035. * @param inputs Array to store the key frame times
  83036. * @param outputs Array to store the key frame data
  83037. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  83038. * @param useQuaternion Specifies if quaternions are used in the animation
  83039. */
  83040. private static _CreateCubicSplineAnimation;
  83041. private static _GetBasePositionRotationOrScale;
  83042. /**
  83043. * Adds a key frame value
  83044. * @param keyFrame
  83045. * @param animation
  83046. * @param outputs
  83047. * @param animationChannelTargetPath
  83048. * @param basePositionRotationOrScale
  83049. * @param convertToRightHandedSystem
  83050. * @param useQuaternion
  83051. */
  83052. private static _AddKeyframeValue;
  83053. /**
  83054. * Determine the interpolation based on the key frames
  83055. * @param keyFrames
  83056. * @param animationChannelTargetPath
  83057. * @param useQuaternion
  83058. */
  83059. private static _DeduceInterpolation;
  83060. /**
  83061. * Adds an input tangent or output tangent to the output data
  83062. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  83063. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  83064. * @param outputs The animation data by keyframe
  83065. * @param animationChannelTargetPath The target animation channel
  83066. * @param interpolation The interpolation type
  83067. * @param keyFrame The key frame with the animation data
  83068. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  83069. * @param useQuaternion Specifies if quaternions are used
  83070. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  83071. */
  83072. private static AddSplineTangent;
  83073. /**
  83074. * Get the minimum and maximum key frames' frame values
  83075. * @param keyFrames animation key frames
  83076. * @returns the minimum and maximum key frame value
  83077. */
  83078. private static calculateMinMaxKeyFrames;
  83079. }
  83080. }
  83081. declare module BABYLON.GLTF2.Exporter {
  83082. /** @hidden */
  83083. export var textureTransformPixelShader: {
  83084. name: string;
  83085. shader: string;
  83086. };
  83087. }
  83088. declare module BABYLON.GLTF2.Exporter.Extensions {
  83089. /**
  83090. * @hidden
  83091. */
  83092. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  83093. private _recordedTextures;
  83094. /** Name of this extension */
  83095. readonly name: string;
  83096. /** Defines whether this extension is enabled */
  83097. enabled: boolean;
  83098. /** Defines whether this extension is required */
  83099. required: boolean;
  83100. /** Reference to the glTF exporter */
  83101. private _wasUsed;
  83102. constructor(exporter: _Exporter);
  83103. dispose(): void;
  83104. /** @hidden */
  83105. get wasUsed(): boolean;
  83106. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  83107. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  83108. /**
  83109. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  83110. * @param babylonTexture
  83111. * @param offset
  83112. * @param rotation
  83113. * @param scale
  83114. * @param scene
  83115. */
  83116. private _textureTransformTextureAsync;
  83117. }
  83118. }
  83119. declare module BABYLON.GLTF2.Exporter.Extensions {
  83120. /**
  83121. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  83122. */
  83123. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  83124. /** The name of this extension. */
  83125. readonly name: string;
  83126. /** Defines whether this extension is enabled. */
  83127. enabled: boolean;
  83128. /** Defines whether this extension is required */
  83129. required: boolean;
  83130. /** Reference to the glTF exporter */
  83131. private _exporter;
  83132. private _lights;
  83133. /** @hidden */
  83134. constructor(exporter: _Exporter);
  83135. /** @hidden */
  83136. dispose(): void;
  83137. /** @hidden */
  83138. get wasUsed(): boolean;
  83139. /** @hidden */
  83140. onExporting(): void;
  83141. /**
  83142. * Define this method to modify the default behavior when exporting a node
  83143. * @param context The context when exporting the node
  83144. * @param node glTF node
  83145. * @param babylonNode BabylonJS node
  83146. * @param nodeMap Node mapping of unique id to glTF node index
  83147. * @returns nullable INode promise
  83148. */
  83149. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  83150. [key: number]: number;
  83151. }): Promise<Nullable<INode>>;
  83152. }
  83153. }
  83154. declare module BABYLON.GLTF2.Exporter.Extensions {
  83155. /**
  83156. * @hidden
  83157. */
  83158. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  83159. /** Name of this extension */
  83160. readonly name: string;
  83161. /** Defines whether this extension is enabled */
  83162. enabled: boolean;
  83163. /** Defines whether this extension is required */
  83164. required: boolean;
  83165. /** Reference to the glTF exporter */
  83166. private _textureInfos;
  83167. private _exportedTextures;
  83168. private _wasUsed;
  83169. constructor(exporter: _Exporter);
  83170. dispose(): void;
  83171. /** @hidden */
  83172. get wasUsed(): boolean;
  83173. private _getTextureIndex;
  83174. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  83175. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  83176. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  83177. }
  83178. }
  83179. declare module BABYLON.GLTF2.Exporter.Extensions {
  83180. /**
  83181. * @hidden
  83182. */
  83183. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  83184. /** Name of this extension */
  83185. readonly name: string;
  83186. /** Defines whether this extension is enabled */
  83187. enabled: boolean;
  83188. /** Defines whether this extension is required */
  83189. required: boolean;
  83190. private _wasUsed;
  83191. constructor(exporter: _Exporter);
  83192. /** @hidden */
  83193. get wasUsed(): boolean;
  83194. dispose(): void;
  83195. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  83196. }
  83197. }
  83198. declare module BABYLON {
  83199. /**
  83200. * Class for generating STL data from a Babylon scene.
  83201. */
  83202. export class STLExport {
  83203. /**
  83204. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  83205. * @param meshes list defines the mesh to serialize
  83206. * @param download triggers the automatic download of the file.
  83207. * @param fileName changes the downloads fileName.
  83208. * @param binary changes the STL to a binary type.
  83209. * @param isLittleEndian toggle for binary type exporter.
  83210. * @returns the STL as UTF8 string
  83211. */
  83212. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  83213. }
  83214. }
  83215. declare module "babylonjs-gltf2interface" {
  83216. export = BABYLON.GLTF2;
  83217. }
  83218. /**
  83219. * Module for glTF 2.0 Interface
  83220. */
  83221. declare module BABYLON.GLTF2 {
  83222. /**
  83223. * The datatype of the components in the attribute
  83224. */
  83225. const enum AccessorComponentType {
  83226. /**
  83227. * Byte
  83228. */
  83229. BYTE = 5120,
  83230. /**
  83231. * Unsigned Byte
  83232. */
  83233. UNSIGNED_BYTE = 5121,
  83234. /**
  83235. * Short
  83236. */
  83237. SHORT = 5122,
  83238. /**
  83239. * Unsigned Short
  83240. */
  83241. UNSIGNED_SHORT = 5123,
  83242. /**
  83243. * Unsigned Int
  83244. */
  83245. UNSIGNED_INT = 5125,
  83246. /**
  83247. * Float
  83248. */
  83249. FLOAT = 5126,
  83250. }
  83251. /**
  83252. * Specifies if the attirbute is a scalar, vector, or matrix
  83253. */
  83254. const enum AccessorType {
  83255. /**
  83256. * Scalar
  83257. */
  83258. SCALAR = "SCALAR",
  83259. /**
  83260. * Vector2
  83261. */
  83262. VEC2 = "VEC2",
  83263. /**
  83264. * Vector3
  83265. */
  83266. VEC3 = "VEC3",
  83267. /**
  83268. * Vector4
  83269. */
  83270. VEC4 = "VEC4",
  83271. /**
  83272. * Matrix2x2
  83273. */
  83274. MAT2 = "MAT2",
  83275. /**
  83276. * Matrix3x3
  83277. */
  83278. MAT3 = "MAT3",
  83279. /**
  83280. * Matrix4x4
  83281. */
  83282. MAT4 = "MAT4",
  83283. }
  83284. /**
  83285. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  83286. */
  83287. const enum AnimationChannelTargetPath {
  83288. /**
  83289. * Translation
  83290. */
  83291. TRANSLATION = "translation",
  83292. /**
  83293. * Rotation
  83294. */
  83295. ROTATION = "rotation",
  83296. /**
  83297. * Scale
  83298. */
  83299. SCALE = "scale",
  83300. /**
  83301. * Weights
  83302. */
  83303. WEIGHTS = "weights",
  83304. }
  83305. /**
  83306. * Interpolation algorithm
  83307. */
  83308. const enum AnimationSamplerInterpolation {
  83309. /**
  83310. * The animated values are linearly interpolated between keyframes
  83311. */
  83312. LINEAR = "LINEAR",
  83313. /**
  83314. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  83315. */
  83316. STEP = "STEP",
  83317. /**
  83318. * The animation's interpolation is computed using a cubic spline with specified tangents
  83319. */
  83320. CUBICSPLINE = "CUBICSPLINE",
  83321. }
  83322. /**
  83323. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  83324. */
  83325. const enum CameraType {
  83326. /**
  83327. * A perspective camera containing properties to create a perspective projection matrix
  83328. */
  83329. PERSPECTIVE = "perspective",
  83330. /**
  83331. * An orthographic camera containing properties to create an orthographic projection matrix
  83332. */
  83333. ORTHOGRAPHIC = "orthographic",
  83334. }
  83335. /**
  83336. * The mime-type of the image
  83337. */
  83338. const enum ImageMimeType {
  83339. /**
  83340. * JPEG Mime-type
  83341. */
  83342. JPEG = "image/jpeg",
  83343. /**
  83344. * PNG Mime-type
  83345. */
  83346. PNG = "image/png",
  83347. }
  83348. /**
  83349. * The alpha rendering mode of the material
  83350. */
  83351. const enum MaterialAlphaMode {
  83352. /**
  83353. * The alpha value is ignored and the rendered output is fully opaque
  83354. */
  83355. OPAQUE = "OPAQUE",
  83356. /**
  83357. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  83358. */
  83359. MASK = "MASK",
  83360. /**
  83361. * 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)
  83362. */
  83363. BLEND = "BLEND",
  83364. }
  83365. /**
  83366. * The type of the primitives to render
  83367. */
  83368. const enum MeshPrimitiveMode {
  83369. /**
  83370. * Points
  83371. */
  83372. POINTS = 0,
  83373. /**
  83374. * Lines
  83375. */
  83376. LINES = 1,
  83377. /**
  83378. * Line Loop
  83379. */
  83380. LINE_LOOP = 2,
  83381. /**
  83382. * Line Strip
  83383. */
  83384. LINE_STRIP = 3,
  83385. /**
  83386. * Triangles
  83387. */
  83388. TRIANGLES = 4,
  83389. /**
  83390. * Triangle Strip
  83391. */
  83392. TRIANGLE_STRIP = 5,
  83393. /**
  83394. * Triangle Fan
  83395. */
  83396. TRIANGLE_FAN = 6,
  83397. }
  83398. /**
  83399. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  83400. */
  83401. const enum TextureMagFilter {
  83402. /**
  83403. * Nearest
  83404. */
  83405. NEAREST = 9728,
  83406. /**
  83407. * Linear
  83408. */
  83409. LINEAR = 9729,
  83410. }
  83411. /**
  83412. * Minification filter. All valid values correspond to WebGL enums
  83413. */
  83414. const enum TextureMinFilter {
  83415. /**
  83416. * Nearest
  83417. */
  83418. NEAREST = 9728,
  83419. /**
  83420. * Linear
  83421. */
  83422. LINEAR = 9729,
  83423. /**
  83424. * Nearest Mip-Map Nearest
  83425. */
  83426. NEAREST_MIPMAP_NEAREST = 9984,
  83427. /**
  83428. * Linear Mipmap Nearest
  83429. */
  83430. LINEAR_MIPMAP_NEAREST = 9985,
  83431. /**
  83432. * Nearest Mipmap Linear
  83433. */
  83434. NEAREST_MIPMAP_LINEAR = 9986,
  83435. /**
  83436. * Linear Mipmap Linear
  83437. */
  83438. LINEAR_MIPMAP_LINEAR = 9987,
  83439. }
  83440. /**
  83441. * S (U) wrapping mode. All valid values correspond to WebGL enums
  83442. */
  83443. const enum TextureWrapMode {
  83444. /**
  83445. * Clamp to Edge
  83446. */
  83447. CLAMP_TO_EDGE = 33071,
  83448. /**
  83449. * Mirrored Repeat
  83450. */
  83451. MIRRORED_REPEAT = 33648,
  83452. /**
  83453. * Repeat
  83454. */
  83455. REPEAT = 10497,
  83456. }
  83457. /**
  83458. * glTF Property
  83459. */
  83460. interface IProperty {
  83461. /**
  83462. * Dictionary object with extension-specific objects
  83463. */
  83464. extensions?: {
  83465. [key: string]: any;
  83466. };
  83467. /**
  83468. * Application-Specific data
  83469. */
  83470. extras?: any;
  83471. }
  83472. /**
  83473. * glTF Child of Root Property
  83474. */
  83475. interface IChildRootProperty extends IProperty {
  83476. /**
  83477. * The user-defined name of this object
  83478. */
  83479. name?: string;
  83480. }
  83481. /**
  83482. * Indices of those attributes that deviate from their initialization value
  83483. */
  83484. interface IAccessorSparseIndices extends IProperty {
  83485. /**
  83486. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  83487. */
  83488. bufferView: number;
  83489. /**
  83490. * The offset relative to the start of the bufferView in bytes. Must be aligned
  83491. */
  83492. byteOffset?: number;
  83493. /**
  83494. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  83495. */
  83496. componentType: AccessorComponentType;
  83497. }
  83498. /**
  83499. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  83500. */
  83501. interface IAccessorSparseValues extends IProperty {
  83502. /**
  83503. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  83504. */
  83505. bufferView: number;
  83506. /**
  83507. * The offset relative to the start of the bufferView in bytes. Must be aligned
  83508. */
  83509. byteOffset?: number;
  83510. }
  83511. /**
  83512. * Sparse storage of attributes that deviate from their initialization value
  83513. */
  83514. interface IAccessorSparse extends IProperty {
  83515. /**
  83516. * The number of attributes encoded in this sparse accessor
  83517. */
  83518. count: number;
  83519. /**
  83520. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  83521. */
  83522. indices: IAccessorSparseIndices;
  83523. /**
  83524. * 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
  83525. */
  83526. values: IAccessorSparseValues;
  83527. }
  83528. /**
  83529. * 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
  83530. */
  83531. interface IAccessor extends IChildRootProperty {
  83532. /**
  83533. * The index of the bufferview
  83534. */
  83535. bufferView?: number;
  83536. /**
  83537. * The offset relative to the start of the bufferView in bytes
  83538. */
  83539. byteOffset?: number;
  83540. /**
  83541. * The datatype of components in the attribute
  83542. */
  83543. componentType: AccessorComponentType;
  83544. /**
  83545. * Specifies whether integer data values should be normalized
  83546. */
  83547. normalized?: boolean;
  83548. /**
  83549. * The number of attributes referenced by this accessor
  83550. */
  83551. count: number;
  83552. /**
  83553. * Specifies if the attribute is a scalar, vector, or matrix
  83554. */
  83555. type: AccessorType;
  83556. /**
  83557. * Maximum value of each component in this attribute
  83558. */
  83559. max?: number[];
  83560. /**
  83561. * Minimum value of each component in this attribute
  83562. */
  83563. min?: number[];
  83564. /**
  83565. * Sparse storage of attributes that deviate from their initialization value
  83566. */
  83567. sparse?: IAccessorSparse;
  83568. }
  83569. /**
  83570. * Targets an animation's sampler at a node's property
  83571. */
  83572. interface IAnimationChannel extends IProperty {
  83573. /**
  83574. * The index of a sampler in this animation used to compute the value for the target
  83575. */
  83576. sampler: number;
  83577. /**
  83578. * The index of the node and TRS property to target
  83579. */
  83580. target: IAnimationChannelTarget;
  83581. }
  83582. /**
  83583. * The index of the node and TRS property that an animation channel targets
  83584. */
  83585. interface IAnimationChannelTarget extends IProperty {
  83586. /**
  83587. * The index of the node to target
  83588. */
  83589. node: number;
  83590. /**
  83591. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  83592. */
  83593. path: AnimationChannelTargetPath;
  83594. }
  83595. /**
  83596. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  83597. */
  83598. interface IAnimationSampler extends IProperty {
  83599. /**
  83600. * The index of an accessor containing keyframe input values, e.g., time
  83601. */
  83602. input: number;
  83603. /**
  83604. * Interpolation algorithm
  83605. */
  83606. interpolation?: AnimationSamplerInterpolation;
  83607. /**
  83608. * The index of an accessor, containing keyframe output values
  83609. */
  83610. output: number;
  83611. }
  83612. /**
  83613. * A keyframe animation
  83614. */
  83615. interface IAnimation extends IChildRootProperty {
  83616. /**
  83617. * An array of channels, each of which targets an animation's sampler at a node's property
  83618. */
  83619. channels: IAnimationChannel[];
  83620. /**
  83621. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  83622. */
  83623. samplers: IAnimationSampler[];
  83624. }
  83625. /**
  83626. * Metadata about the glTF asset
  83627. */
  83628. interface IAsset extends IChildRootProperty {
  83629. /**
  83630. * A copyright message suitable for display to credit the content creator
  83631. */
  83632. copyright?: string;
  83633. /**
  83634. * Tool that generated this glTF model. Useful for debugging
  83635. */
  83636. generator?: string;
  83637. /**
  83638. * The glTF version that this asset targets
  83639. */
  83640. version: string;
  83641. /**
  83642. * The minimum glTF version that this asset targets
  83643. */
  83644. minVersion?: string;
  83645. }
  83646. /**
  83647. * A buffer points to binary geometry, animation, or skins
  83648. */
  83649. interface IBuffer extends IChildRootProperty {
  83650. /**
  83651. * 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
  83652. */
  83653. uri?: string;
  83654. /**
  83655. * The length of the buffer in bytes
  83656. */
  83657. byteLength: number;
  83658. }
  83659. /**
  83660. * A view into a buffer generally representing a subset of the buffer
  83661. */
  83662. interface IBufferView extends IChildRootProperty {
  83663. /**
  83664. * The index of the buffer
  83665. */
  83666. buffer: number;
  83667. /**
  83668. * The offset into the buffer in bytes
  83669. */
  83670. byteOffset?: number;
  83671. /**
  83672. * The lenth of the bufferView in bytes
  83673. */
  83674. byteLength: number;
  83675. /**
  83676. * The stride, in bytes
  83677. */
  83678. byteStride?: number;
  83679. }
  83680. /**
  83681. * An orthographic camera containing properties to create an orthographic projection matrix
  83682. */
  83683. interface ICameraOrthographic extends IProperty {
  83684. /**
  83685. * The floating-point horizontal magnification of the view. Must not be zero
  83686. */
  83687. xmag: number;
  83688. /**
  83689. * The floating-point vertical magnification of the view. Must not be zero
  83690. */
  83691. ymag: number;
  83692. /**
  83693. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  83694. */
  83695. zfar: number;
  83696. /**
  83697. * The floating-point distance to the near clipping plane
  83698. */
  83699. znear: number;
  83700. }
  83701. /**
  83702. * A perspective camera containing properties to create a perspective projection matrix
  83703. */
  83704. interface ICameraPerspective extends IProperty {
  83705. /**
  83706. * The floating-point aspect ratio of the field of view
  83707. */
  83708. aspectRatio?: number;
  83709. /**
  83710. * The floating-point vertical field of view in radians
  83711. */
  83712. yfov: number;
  83713. /**
  83714. * The floating-point distance to the far clipping plane
  83715. */
  83716. zfar?: number;
  83717. /**
  83718. * The floating-point distance to the near clipping plane
  83719. */
  83720. znear: number;
  83721. }
  83722. /**
  83723. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  83724. */
  83725. interface ICamera extends IChildRootProperty {
  83726. /**
  83727. * An orthographic camera containing properties to create an orthographic projection matrix
  83728. */
  83729. orthographic?: ICameraOrthographic;
  83730. /**
  83731. * A perspective camera containing properties to create a perspective projection matrix
  83732. */
  83733. perspective?: ICameraPerspective;
  83734. /**
  83735. * Specifies if the camera uses a perspective or orthographic projection
  83736. */
  83737. type: CameraType;
  83738. }
  83739. /**
  83740. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  83741. */
  83742. interface IImage extends IChildRootProperty {
  83743. /**
  83744. * 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
  83745. */
  83746. uri?: string;
  83747. /**
  83748. * The image's MIME type
  83749. */
  83750. mimeType?: ImageMimeType;
  83751. /**
  83752. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  83753. */
  83754. bufferView?: number;
  83755. }
  83756. /**
  83757. * Material Normal Texture Info
  83758. */
  83759. interface IMaterialNormalTextureInfo extends ITextureInfo {
  83760. /**
  83761. * The scalar multiplier applied to each normal vector of the normal texture
  83762. */
  83763. scale?: number;
  83764. }
  83765. /**
  83766. * Material Occlusion Texture Info
  83767. */
  83768. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  83769. /**
  83770. * A scalar multiplier controlling the amount of occlusion applied
  83771. */
  83772. strength?: number;
  83773. }
  83774. /**
  83775. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  83776. */
  83777. interface IMaterialPbrMetallicRoughness {
  83778. /**
  83779. * The material's base color factor
  83780. */
  83781. baseColorFactor?: number[];
  83782. /**
  83783. * The base color texture
  83784. */
  83785. baseColorTexture?: ITextureInfo;
  83786. /**
  83787. * The metalness of the material
  83788. */
  83789. metallicFactor?: number;
  83790. /**
  83791. * The roughness of the material
  83792. */
  83793. roughnessFactor?: number;
  83794. /**
  83795. * The metallic-roughness texture
  83796. */
  83797. metallicRoughnessTexture?: ITextureInfo;
  83798. }
  83799. /**
  83800. * The material appearance of a primitive
  83801. */
  83802. interface IMaterial extends IChildRootProperty {
  83803. /**
  83804. * 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
  83805. */
  83806. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  83807. /**
  83808. * The normal map texture
  83809. */
  83810. normalTexture?: IMaterialNormalTextureInfo;
  83811. /**
  83812. * The occlusion map texture
  83813. */
  83814. occlusionTexture?: IMaterialOcclusionTextureInfo;
  83815. /**
  83816. * The emissive map texture
  83817. */
  83818. emissiveTexture?: ITextureInfo;
  83819. /**
  83820. * 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
  83821. */
  83822. emissiveFactor?: number[];
  83823. /**
  83824. * The alpha rendering mode of the material
  83825. */
  83826. alphaMode?: MaterialAlphaMode;
  83827. /**
  83828. * The alpha cutoff value of the material
  83829. */
  83830. alphaCutoff?: number;
  83831. /**
  83832. * Specifies whether the material is double sided
  83833. */
  83834. doubleSided?: boolean;
  83835. }
  83836. /**
  83837. * Geometry to be rendered with the given material
  83838. */
  83839. interface IMeshPrimitive extends IProperty {
  83840. /**
  83841. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  83842. */
  83843. attributes: {
  83844. [name: string]: number;
  83845. };
  83846. /**
  83847. * The index of the accessor that contains the indices
  83848. */
  83849. indices?: number;
  83850. /**
  83851. * The index of the material to apply to this primitive when rendering
  83852. */
  83853. material?: number;
  83854. /**
  83855. * The type of primitives to render. All valid values correspond to WebGL enums
  83856. */
  83857. mode?: MeshPrimitiveMode;
  83858. /**
  83859. * 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
  83860. */
  83861. targets?: {
  83862. [name: string]: number;
  83863. }[];
  83864. }
  83865. /**
  83866. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  83867. */
  83868. interface IMesh extends IChildRootProperty {
  83869. /**
  83870. * An array of primitives, each defining geometry to be rendered with a material
  83871. */
  83872. primitives: IMeshPrimitive[];
  83873. /**
  83874. * Array of weights to be applied to the Morph Targets
  83875. */
  83876. weights?: number[];
  83877. }
  83878. /**
  83879. * A node in the node hierarchy
  83880. */
  83881. interface INode extends IChildRootProperty {
  83882. /**
  83883. * The index of the camera referenced by this node
  83884. */
  83885. camera?: number;
  83886. /**
  83887. * The indices of this node's children
  83888. */
  83889. children?: number[];
  83890. /**
  83891. * The index of the skin referenced by this node
  83892. */
  83893. skin?: number;
  83894. /**
  83895. * A floating-point 4x4 transformation matrix stored in column-major order
  83896. */
  83897. matrix?: number[];
  83898. /**
  83899. * The index of the mesh in this node
  83900. */
  83901. mesh?: number;
  83902. /**
  83903. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  83904. */
  83905. rotation?: number[];
  83906. /**
  83907. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  83908. */
  83909. scale?: number[];
  83910. /**
  83911. * The node's translation along the x, y, and z axes
  83912. */
  83913. translation?: number[];
  83914. /**
  83915. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  83916. */
  83917. weights?: number[];
  83918. }
  83919. /**
  83920. * Texture sampler properties for filtering and wrapping modes
  83921. */
  83922. interface ISampler extends IChildRootProperty {
  83923. /**
  83924. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  83925. */
  83926. magFilter?: TextureMagFilter;
  83927. /**
  83928. * Minification filter. All valid values correspond to WebGL enums
  83929. */
  83930. minFilter?: TextureMinFilter;
  83931. /**
  83932. * S (U) wrapping mode. All valid values correspond to WebGL enums
  83933. */
  83934. wrapS?: TextureWrapMode;
  83935. /**
  83936. * T (V) wrapping mode. All valid values correspond to WebGL enums
  83937. */
  83938. wrapT?: TextureWrapMode;
  83939. }
  83940. /**
  83941. * The root nodes of a scene
  83942. */
  83943. interface IScene extends IChildRootProperty {
  83944. /**
  83945. * The indices of each root node
  83946. */
  83947. nodes: number[];
  83948. }
  83949. /**
  83950. * Joints and matrices defining a skin
  83951. */
  83952. interface ISkin extends IChildRootProperty {
  83953. /**
  83954. * 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
  83955. */
  83956. inverseBindMatrices?: number;
  83957. /**
  83958. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  83959. */
  83960. skeleton?: number;
  83961. /**
  83962. * 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)
  83963. */
  83964. joints: number[];
  83965. }
  83966. /**
  83967. * A texture and its sampler
  83968. */
  83969. interface ITexture extends IChildRootProperty {
  83970. /**
  83971. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  83972. */
  83973. sampler?: number;
  83974. /**
  83975. * The index of the image used by this texture
  83976. */
  83977. source: number;
  83978. }
  83979. /**
  83980. * Reference to a texture
  83981. */
  83982. interface ITextureInfo extends IProperty {
  83983. /**
  83984. * The index of the texture
  83985. */
  83986. index: number;
  83987. /**
  83988. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  83989. */
  83990. texCoord?: number;
  83991. }
  83992. /**
  83993. * The root object for a glTF asset
  83994. */
  83995. interface IGLTF extends IProperty {
  83996. /**
  83997. * An array of accessors. An accessor is a typed view into a bufferView
  83998. */
  83999. accessors?: IAccessor[];
  84000. /**
  84001. * An array of keyframe animations
  84002. */
  84003. animations?: IAnimation[];
  84004. /**
  84005. * Metadata about the glTF asset
  84006. */
  84007. asset: IAsset;
  84008. /**
  84009. * An array of buffers. A buffer points to binary geometry, animation, or skins
  84010. */
  84011. buffers?: IBuffer[];
  84012. /**
  84013. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  84014. */
  84015. bufferViews?: IBufferView[];
  84016. /**
  84017. * An array of cameras
  84018. */
  84019. cameras?: ICamera[];
  84020. /**
  84021. * Names of glTF extensions used somewhere in this asset
  84022. */
  84023. extensionsUsed?: string[];
  84024. /**
  84025. * Names of glTF extensions required to properly load this asset
  84026. */
  84027. extensionsRequired?: string[];
  84028. /**
  84029. * An array of images. An image defines data used to create a texture
  84030. */
  84031. images?: IImage[];
  84032. /**
  84033. * An array of materials. A material defines the appearance of a primitive
  84034. */
  84035. materials?: IMaterial[];
  84036. /**
  84037. * An array of meshes. A mesh is a set of primitives to be rendered
  84038. */
  84039. meshes?: IMesh[];
  84040. /**
  84041. * An array of nodes
  84042. */
  84043. nodes?: INode[];
  84044. /**
  84045. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  84046. */
  84047. samplers?: ISampler[];
  84048. /**
  84049. * The index of the default scene
  84050. */
  84051. scene?: number;
  84052. /**
  84053. * An array of scenes
  84054. */
  84055. scenes?: IScene[];
  84056. /**
  84057. * An array of skins. A skin is defined by joints and matrices
  84058. */
  84059. skins?: ISkin[];
  84060. /**
  84061. * An array of textures
  84062. */
  84063. textures?: ITexture[];
  84064. }
  84065. /**
  84066. * The glTF validation results
  84067. * @ignore
  84068. */
  84069. interface IGLTFValidationResults {
  84070. info: {
  84071. generator: string;
  84072. hasAnimations: boolean;
  84073. hasDefaultScene: boolean;
  84074. hasMaterials: boolean;
  84075. hasMorphTargets: boolean;
  84076. hasSkins: boolean;
  84077. hasTextures: boolean;
  84078. maxAttributesUsed: number;
  84079. primitivesCount: number
  84080. };
  84081. issues: {
  84082. messages: Array<string>;
  84083. numErrors: number;
  84084. numHints: number;
  84085. numInfos: number;
  84086. numWarnings: number;
  84087. truncated: boolean
  84088. };
  84089. mimeType: string;
  84090. uri: string;
  84091. validatedAt: string;
  84092. validatorVersion: string;
  84093. }
  84094. /**
  84095. * The glTF validation options
  84096. */
  84097. interface IGLTFValidationOptions {
  84098. /** Uri to use */
  84099. uri?: string;
  84100. /** Function used to load external resources */
  84101. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  84102. /** Boolean indicating that we need to validate accessor data */
  84103. validateAccessorData?: boolean;
  84104. /** max number of issues allowed */
  84105. maxIssues?: number;
  84106. /** Ignored issues */
  84107. ignoredIssues?: Array<string>;
  84108. /** Value to override severy settings */
  84109. severityOverrides?: Object;
  84110. }
  84111. /**
  84112. * The glTF validator object
  84113. * @ignore
  84114. */
  84115. interface IGLTFValidator {
  84116. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  84117. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  84118. }
  84119. /**
  84120. * Interfaces from the EXT_lights_image_based extension
  84121. */
  84122. /** @hidden */
  84123. interface IEXTLightsImageBased_LightReferenceImageBased {
  84124. light: number;
  84125. }
  84126. /** @hidden */
  84127. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  84128. intensity: number;
  84129. rotation: number[];
  84130. specularImageSize: number;
  84131. specularImages: number[][];
  84132. irradianceCoefficients: number[][];
  84133. }
  84134. /** @hidden */
  84135. interface IEXTLightsImageBased {
  84136. lights: IEXTLightsImageBased_LightImageBased[];
  84137. }
  84138. /**
  84139. * Interfaces from the EXT_mesh_gpu_instancing extension
  84140. * !!! Experimental Extension Subject to Changes !!!
  84141. */
  84142. /** @hidden */
  84143. interface IEXTMeshGpuInstancing {
  84144. mesh?: number;
  84145. attributes: { [name: string]: number };
  84146. }
  84147. /**
  84148. * Interfaces from the KHR_draco_mesh_compression extension
  84149. */
  84150. /** @hidden */
  84151. interface IKHRDracoMeshCompression {
  84152. bufferView: number;
  84153. attributes: { [name: string]: number };
  84154. }
  84155. /**
  84156. * Interfaces from the KHR_lights_punctual extension
  84157. */
  84158. /** @hidden */
  84159. const enum IKHRLightsPunctual_LightType {
  84160. DIRECTIONAL = "directional",
  84161. POINT = "point",
  84162. SPOT = "spot"
  84163. }
  84164. /** @hidden */
  84165. interface IKHRLightsPunctual_LightReference {
  84166. light: number;
  84167. }
  84168. /** @hidden */
  84169. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  84170. type: IKHRLightsPunctual_LightType;
  84171. color?: number[];
  84172. intensity?: number;
  84173. range?: number;
  84174. spot?: {
  84175. innerConeAngle?: number;
  84176. outerConeAngle?: number;
  84177. };
  84178. }
  84179. /** @hidden */
  84180. interface IKHRLightsPunctual {
  84181. lights: IKHRLightsPunctual_Light[];
  84182. }
  84183. /**
  84184. * Interfaces from the KHR_materials_clearcoat extension
  84185. * !!! Experimental Extension Subject to Changes !!!
  84186. */
  84187. /** @hidden */
  84188. interface IKHRMaterialsClearcoat {
  84189. clearcoatFactor: number;
  84190. clearcoatTexture: ITextureInfo;
  84191. clearcoatRoughnessFactor: number;
  84192. clearcoatRoughnessTexture: ITextureInfo;
  84193. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  84194. }
  84195. /**
  84196. * Interfaces from the KHR_materials_ior extension
  84197. * !!! Experimental Extension Subject to Changes !!!
  84198. */
  84199. /** @hidden */
  84200. interface IKHRMaterialsIor {
  84201. ior: number;
  84202. }
  84203. /**
  84204. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  84205. */
  84206. /** @hidden */
  84207. interface IKHRMaterialsPbrSpecularGlossiness {
  84208. diffuseFactor: number[];
  84209. diffuseTexture: ITextureInfo;
  84210. specularFactor: number[];
  84211. glossinessFactor: number;
  84212. specularGlossinessTexture: ITextureInfo;
  84213. }
  84214. /**
  84215. * Interfaces from the KHR_materials_sheen extension
  84216. * !!! Experimental Extension Subject to Changes !!!
  84217. */
  84218. /** @hidden */
  84219. interface IKHRMaterialsSheen {
  84220. sheenColorFactor?: number[];
  84221. sheenTexture?: ITextureInfo;
  84222. sheenRoughnessFactor?: number;
  84223. }
  84224. /**
  84225. * Interfaces from the KHR_materials_specular extension
  84226. * !!! Experimental Extension Subject to Changes !!!
  84227. */
  84228. /** @hidden */
  84229. interface IKHRMaterialsSpecular {
  84230. specularFactor: number;
  84231. specularColorFactor: number[];
  84232. specularTexture: ITextureInfo;
  84233. }
  84234. /**
  84235. * Interfaces from the KHR_materials_transmission extension
  84236. * !!! Experimental Extension Subject to Changes !!!
  84237. */
  84238. /** @hidden */
  84239. interface IKHRMaterialsTransmission {
  84240. transmissionFactor?: number;
  84241. transmissionTexture?: ITextureInfo;
  84242. }
  84243. /**
  84244. * Interfaces from the KHR_materials_variants extension
  84245. * !!! Experimental Extension Subject to Changes !!!
  84246. */
  84247. /** @hidden */
  84248. interface IKHRMaterialVariants_Mapping {
  84249. variants: string[];
  84250. material: number;
  84251. }
  84252. /** @hidden */
  84253. interface IKHRMaterialVariants {
  84254. mapping: IKHRMaterialVariants_Mapping[];
  84255. }
  84256. /**
  84257. * Interfaces from the KHR_texture_basisu extension
  84258. * !!! Experimental Extension Subject to Changes !!!
  84259. */
  84260. /** @hidden */
  84261. interface IKHRTextureBasisU {
  84262. source: number;
  84263. }
  84264. /**
  84265. * Interfaces from the EXT_texture_webp extension
  84266. */
  84267. /** @hidden */
  84268. interface IEXTTextureWebP {
  84269. source: number;
  84270. }
  84271. /**
  84272. * Interfaces from the KHR_texture_transform extension
  84273. */
  84274. /** @hidden */
  84275. interface IKHRTextureTransform {
  84276. offset?: number[];
  84277. rotation?: number;
  84278. scale?: number[];
  84279. texCoord?: number;
  84280. }
  84281. /**
  84282. * Interfaces from the KHR_xmp extension
  84283. * !!! Experimental Extension Subject to Changes !!!
  84284. */
  84285. /** @hidden */
  84286. interface IKHRXmp_Data {
  84287. [key: string]: unknown;
  84288. }
  84289. /** @hidden */
  84290. interface IKHRXmp_Gltf {
  84291. packets: IKHRXmp_Data[];
  84292. }
  84293. /** @hidden */
  84294. interface IKHRXmp_Node {
  84295. packet: number;
  84296. }
  84297. /**
  84298. * Interfaces from the MSFT_audio_emitter extension
  84299. */
  84300. /** @hidden */
  84301. interface IMSFTAudioEmitter_ClipReference {
  84302. clip: number;
  84303. weight?: number;
  84304. }
  84305. /** @hidden */
  84306. interface IMSFTAudioEmitter_EmittersReference {
  84307. emitters: number[];
  84308. }
  84309. /** @hidden */
  84310. const enum IMSFTAudioEmitter_DistanceModel {
  84311. linear = "linear",
  84312. inverse = "inverse",
  84313. exponential = "exponential",
  84314. }
  84315. /** @hidden */
  84316. interface IMSFTAudioEmitter_Emitter {
  84317. name?: string;
  84318. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  84319. refDistance?: number;
  84320. maxDistance?: number;
  84321. rolloffFactor?: number;
  84322. innerAngle?: number;
  84323. outerAngle?: number;
  84324. loop?: boolean;
  84325. volume?: number;
  84326. clips: IMSFTAudioEmitter_ClipReference[];
  84327. }
  84328. /** @hidden */
  84329. const enum IMSFTAudioEmitter_AudioMimeType {
  84330. WAV = "audio/wav",
  84331. }
  84332. /** @hidden */
  84333. interface IMSFTAudioEmitter_Clip extends IProperty {
  84334. uri?: string;
  84335. bufferView?: number;
  84336. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  84337. }
  84338. /** @hidden */
  84339. const enum IMSFTAudioEmitter_AnimationEventAction {
  84340. play = "play",
  84341. pause = "pause",
  84342. stop = "stop",
  84343. }
  84344. /** @hidden */
  84345. interface IMSFTAudioEmitter_AnimationEvent {
  84346. action: IMSFTAudioEmitter_AnimationEventAction;
  84347. emitter: number;
  84348. time: number;
  84349. startOffset?: number;
  84350. }
  84351. /**
  84352. * Interfaces from the MSFT_lod extension
  84353. */
  84354. /** @hidden */
  84355. interface IMSFTLOD {
  84356. ids: number[];
  84357. }
  84358. }
  84359. declare module BABYLON {
  84360. /** @hidden */
  84361. export var cellPixelShader: {
  84362. name: string;
  84363. shader: string;
  84364. };
  84365. }
  84366. declare module BABYLON {
  84367. /** @hidden */
  84368. export var cellVertexShader: {
  84369. name: string;
  84370. shader: string;
  84371. };
  84372. }
  84373. declare module BABYLON {
  84374. export class CellMaterial extends BABYLON.PushMaterial {
  84375. private _diffuseTexture;
  84376. diffuseTexture: BABYLON.BaseTexture;
  84377. diffuseColor: BABYLON.Color3;
  84378. _computeHighLevel: boolean;
  84379. computeHighLevel: boolean;
  84380. private _disableLighting;
  84381. disableLighting: boolean;
  84382. private _maxSimultaneousLights;
  84383. maxSimultaneousLights: number;
  84384. constructor(name: string, scene: BABYLON.Scene);
  84385. needAlphaBlending(): boolean;
  84386. needAlphaTesting(): boolean;
  84387. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84388. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84389. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84390. getAnimatables(): BABYLON.IAnimatable[];
  84391. getActiveTextures(): BABYLON.BaseTexture[];
  84392. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84393. dispose(forceDisposeEffect?: boolean): void;
  84394. getClassName(): string;
  84395. clone(name: string): CellMaterial;
  84396. serialize(): any;
  84397. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  84398. }
  84399. }
  84400. declare module BABYLON {
  84401. export class CustomShaderStructure {
  84402. FragmentStore: string;
  84403. VertexStore: string;
  84404. constructor();
  84405. }
  84406. export class ShaderSpecialParts {
  84407. constructor();
  84408. Fragment_Begin: string;
  84409. Fragment_Definitions: string;
  84410. Fragment_MainBegin: string;
  84411. Fragment_Custom_Diffuse: string;
  84412. Fragment_Before_Lights: string;
  84413. Fragment_Before_Fog: string;
  84414. Fragment_Custom_Alpha: string;
  84415. Fragment_Before_FragColor: string;
  84416. Vertex_Begin: string;
  84417. Vertex_Definitions: string;
  84418. Vertex_MainBegin: string;
  84419. Vertex_Before_PositionUpdated: string;
  84420. Vertex_Before_NormalUpdated: string;
  84421. Vertex_After_WorldPosComputed: string;
  84422. Vertex_MainEnd: string;
  84423. }
  84424. export class CustomMaterial extends BABYLON.StandardMaterial {
  84425. static ShaderIndexer: number;
  84426. CustomParts: ShaderSpecialParts;
  84427. _isCreatedShader: boolean;
  84428. _createdShaderName: string;
  84429. _customUniform: string[];
  84430. _newUniforms: string[];
  84431. _newUniformInstances: {
  84432. [name: string]: any;
  84433. };
  84434. _newSamplerInstances: {
  84435. [name: string]: BABYLON.Texture;
  84436. };
  84437. _customAttributes: string[];
  84438. FragmentShader: string;
  84439. VertexShader: string;
  84440. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  84441. ReviewUniform(name: string, arr: string[]): string[];
  84442. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  84443. constructor(name: string, scene: BABYLON.Scene);
  84444. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  84445. AddAttribute(name: string): CustomMaterial;
  84446. Fragment_Begin(shaderPart: string): CustomMaterial;
  84447. Fragment_Definitions(shaderPart: string): CustomMaterial;
  84448. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  84449. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  84450. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  84451. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  84452. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  84453. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  84454. Vertex_Begin(shaderPart: string): CustomMaterial;
  84455. Vertex_Definitions(shaderPart: string): CustomMaterial;
  84456. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  84457. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  84458. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  84459. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  84460. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  84461. }
  84462. }
  84463. declare module BABYLON {
  84464. export class ShaderAlebdoParts {
  84465. constructor();
  84466. Fragment_Begin: string;
  84467. Fragment_Definitions: string;
  84468. Fragment_MainBegin: string;
  84469. Fragment_Custom_Albedo: string;
  84470. Fragment_Before_Lights: string;
  84471. Fragment_Custom_MetallicRoughness: string;
  84472. Fragment_Custom_MicroSurface: string;
  84473. Fragment_Before_Fog: string;
  84474. Fragment_Custom_Alpha: string;
  84475. Fragment_Before_FragColor: string;
  84476. Vertex_Begin: string;
  84477. Vertex_Definitions: string;
  84478. Vertex_MainBegin: string;
  84479. Vertex_Before_PositionUpdated: string;
  84480. Vertex_Before_NormalUpdated: string;
  84481. Vertex_After_WorldPosComputed: string;
  84482. Vertex_MainEnd: string;
  84483. }
  84484. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  84485. static ShaderIndexer: number;
  84486. CustomParts: ShaderAlebdoParts;
  84487. _isCreatedShader: boolean;
  84488. _createdShaderName: string;
  84489. _customUniform: string[];
  84490. _newUniforms: string[];
  84491. _newUniformInstances: {
  84492. [name: string]: any;
  84493. };
  84494. _newSamplerInstances: {
  84495. [name: string]: BABYLON.Texture;
  84496. };
  84497. _customAttributes: string[];
  84498. FragmentShader: string;
  84499. VertexShader: string;
  84500. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  84501. ReviewUniform(name: string, arr: string[]): string[];
  84502. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  84503. constructor(name: string, scene: BABYLON.Scene);
  84504. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  84505. AddAttribute(name: string): PBRCustomMaterial;
  84506. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  84507. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  84508. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  84509. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  84510. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  84511. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  84512. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  84513. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  84514. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  84515. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  84516. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  84517. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  84518. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  84519. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  84520. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  84521. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  84522. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  84523. }
  84524. }
  84525. declare module BABYLON {
  84526. /** @hidden */
  84527. export var firePixelShader: {
  84528. name: string;
  84529. shader: string;
  84530. };
  84531. }
  84532. declare module BABYLON {
  84533. /** @hidden */
  84534. export var fireVertexShader: {
  84535. name: string;
  84536. shader: string;
  84537. };
  84538. }
  84539. declare module BABYLON {
  84540. export class FireMaterial extends BABYLON.PushMaterial {
  84541. private _diffuseTexture;
  84542. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  84543. private _distortionTexture;
  84544. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  84545. private _opacityTexture;
  84546. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  84547. diffuseColor: BABYLON.Color3;
  84548. speed: number;
  84549. private _scaledDiffuse;
  84550. private _lastTime;
  84551. constructor(name: string, scene: BABYLON.Scene);
  84552. needAlphaBlending(): boolean;
  84553. needAlphaTesting(): boolean;
  84554. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84555. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84556. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84557. getAnimatables(): BABYLON.IAnimatable[];
  84558. getActiveTextures(): BABYLON.BaseTexture[];
  84559. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84560. getClassName(): string;
  84561. dispose(forceDisposeEffect?: boolean): void;
  84562. clone(name: string): FireMaterial;
  84563. serialize(): any;
  84564. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  84565. }
  84566. }
  84567. declare module BABYLON {
  84568. /** @hidden */
  84569. export var furPixelShader: {
  84570. name: string;
  84571. shader: string;
  84572. };
  84573. }
  84574. declare module BABYLON {
  84575. /** @hidden */
  84576. export var furVertexShader: {
  84577. name: string;
  84578. shader: string;
  84579. };
  84580. }
  84581. declare module BABYLON {
  84582. export class FurMaterial extends BABYLON.PushMaterial {
  84583. private _diffuseTexture;
  84584. diffuseTexture: BABYLON.BaseTexture;
  84585. private _heightTexture;
  84586. heightTexture: BABYLON.BaseTexture;
  84587. diffuseColor: BABYLON.Color3;
  84588. furLength: number;
  84589. furAngle: number;
  84590. furColor: BABYLON.Color3;
  84591. furOffset: number;
  84592. furSpacing: number;
  84593. furGravity: BABYLON.Vector3;
  84594. furSpeed: number;
  84595. furDensity: number;
  84596. furOcclusion: number;
  84597. furTexture: BABYLON.DynamicTexture;
  84598. private _disableLighting;
  84599. disableLighting: boolean;
  84600. private _maxSimultaneousLights;
  84601. maxSimultaneousLights: number;
  84602. highLevelFur: boolean;
  84603. _meshes: BABYLON.AbstractMesh[];
  84604. private _furTime;
  84605. constructor(name: string, scene: BABYLON.Scene);
  84606. get furTime(): number;
  84607. set furTime(furTime: number);
  84608. needAlphaBlending(): boolean;
  84609. needAlphaTesting(): boolean;
  84610. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84611. updateFur(): void;
  84612. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84613. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84614. getAnimatables(): BABYLON.IAnimatable[];
  84615. getActiveTextures(): BABYLON.BaseTexture[];
  84616. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84617. dispose(forceDisposeEffect?: boolean): void;
  84618. clone(name: string): FurMaterial;
  84619. serialize(): any;
  84620. getClassName(): string;
  84621. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  84622. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  84623. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  84624. }
  84625. }
  84626. declare module BABYLON {
  84627. /** @hidden */
  84628. export var gradientPixelShader: {
  84629. name: string;
  84630. shader: string;
  84631. };
  84632. }
  84633. declare module BABYLON {
  84634. /** @hidden */
  84635. export var gradientVertexShader: {
  84636. name: string;
  84637. shader: string;
  84638. };
  84639. }
  84640. declare module BABYLON {
  84641. export class GradientMaterial extends BABYLON.PushMaterial {
  84642. private _maxSimultaneousLights;
  84643. maxSimultaneousLights: number;
  84644. topColor: BABYLON.Color3;
  84645. topColorAlpha: number;
  84646. bottomColor: BABYLON.Color3;
  84647. bottomColorAlpha: number;
  84648. offset: number;
  84649. scale: number;
  84650. smoothness: number;
  84651. private _disableLighting;
  84652. disableLighting: boolean;
  84653. constructor(name: string, scene: BABYLON.Scene);
  84654. needAlphaBlending(): boolean;
  84655. needAlphaTesting(): boolean;
  84656. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84657. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84658. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84659. getAnimatables(): BABYLON.IAnimatable[];
  84660. dispose(forceDisposeEffect?: boolean): void;
  84661. clone(name: string): GradientMaterial;
  84662. serialize(): any;
  84663. getClassName(): string;
  84664. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  84665. }
  84666. }
  84667. declare module BABYLON {
  84668. /** @hidden */
  84669. export var gridPixelShader: {
  84670. name: string;
  84671. shader: string;
  84672. };
  84673. }
  84674. declare module BABYLON {
  84675. /** @hidden */
  84676. export var gridVertexShader: {
  84677. name: string;
  84678. shader: string;
  84679. };
  84680. }
  84681. declare module BABYLON {
  84682. /**
  84683. * The grid materials allows you to wrap any shape with a grid.
  84684. * Colors are customizable.
  84685. */
  84686. export class GridMaterial extends BABYLON.PushMaterial {
  84687. /**
  84688. * Main color of the grid (e.g. between lines)
  84689. */
  84690. mainColor: BABYLON.Color3;
  84691. /**
  84692. * Color of the grid lines.
  84693. */
  84694. lineColor: BABYLON.Color3;
  84695. /**
  84696. * The scale of the grid compared to unit.
  84697. */
  84698. gridRatio: number;
  84699. /**
  84700. * Allows setting an offset for the grid lines.
  84701. */
  84702. gridOffset: BABYLON.Vector3;
  84703. /**
  84704. * The frequency of thicker lines.
  84705. */
  84706. majorUnitFrequency: number;
  84707. /**
  84708. * The visibility of minor units in the grid.
  84709. */
  84710. minorUnitVisibility: number;
  84711. /**
  84712. * The grid opacity outside of the lines.
  84713. */
  84714. opacity: number;
  84715. /**
  84716. * Determine RBG output is premultiplied by alpha value.
  84717. */
  84718. preMultiplyAlpha: boolean;
  84719. private _opacityTexture;
  84720. opacityTexture: BABYLON.BaseTexture;
  84721. private _gridControl;
  84722. /**
  84723. * constructor
  84724. * @param name The name given to the material in order to identify it afterwards.
  84725. * @param scene The scene the material is used in.
  84726. */
  84727. constructor(name: string, scene: BABYLON.Scene);
  84728. /**
  84729. * Returns wehter or not the grid requires alpha blending.
  84730. */
  84731. needAlphaBlending(): boolean;
  84732. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  84733. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84734. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84735. /**
  84736. * Dispose the material and its associated resources.
  84737. * @param forceDisposeEffect will also dispose the used effect when true
  84738. */
  84739. dispose(forceDisposeEffect?: boolean): void;
  84740. clone(name: string): GridMaterial;
  84741. serialize(): any;
  84742. getClassName(): string;
  84743. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  84744. }
  84745. }
  84746. declare module BABYLON {
  84747. /** @hidden */
  84748. export var lavaPixelShader: {
  84749. name: string;
  84750. shader: string;
  84751. };
  84752. }
  84753. declare module BABYLON {
  84754. /** @hidden */
  84755. export var lavaVertexShader: {
  84756. name: string;
  84757. shader: string;
  84758. };
  84759. }
  84760. declare module BABYLON {
  84761. export class LavaMaterial extends BABYLON.PushMaterial {
  84762. private _diffuseTexture;
  84763. diffuseTexture: BABYLON.BaseTexture;
  84764. noiseTexture: BABYLON.BaseTexture;
  84765. fogColor: BABYLON.Color3;
  84766. speed: number;
  84767. movingSpeed: number;
  84768. lowFrequencySpeed: number;
  84769. fogDensity: number;
  84770. private _lastTime;
  84771. diffuseColor: BABYLON.Color3;
  84772. private _disableLighting;
  84773. disableLighting: boolean;
  84774. private _unlit;
  84775. unlit: boolean;
  84776. private _maxSimultaneousLights;
  84777. maxSimultaneousLights: number;
  84778. private _scaledDiffuse;
  84779. constructor(name: string, scene: BABYLON.Scene);
  84780. needAlphaBlending(): boolean;
  84781. needAlphaTesting(): boolean;
  84782. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84783. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84784. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84785. getAnimatables(): BABYLON.IAnimatable[];
  84786. getActiveTextures(): BABYLON.BaseTexture[];
  84787. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84788. dispose(forceDisposeEffect?: boolean): void;
  84789. clone(name: string): LavaMaterial;
  84790. serialize(): any;
  84791. getClassName(): string;
  84792. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  84793. }
  84794. }
  84795. declare module BABYLON {
  84796. /** @hidden */
  84797. export var mixPixelShader: {
  84798. name: string;
  84799. shader: string;
  84800. };
  84801. }
  84802. declare module BABYLON {
  84803. /** @hidden */
  84804. export var mixVertexShader: {
  84805. name: string;
  84806. shader: string;
  84807. };
  84808. }
  84809. declare module BABYLON {
  84810. export class MixMaterial extends BABYLON.PushMaterial {
  84811. /**
  84812. * Mix textures
  84813. */
  84814. private _mixTexture1;
  84815. mixTexture1: BABYLON.BaseTexture;
  84816. private _mixTexture2;
  84817. mixTexture2: BABYLON.BaseTexture;
  84818. /**
  84819. * Diffuse textures
  84820. */
  84821. private _diffuseTexture1;
  84822. diffuseTexture1: BABYLON.Texture;
  84823. private _diffuseTexture2;
  84824. diffuseTexture2: BABYLON.Texture;
  84825. private _diffuseTexture3;
  84826. diffuseTexture3: BABYLON.Texture;
  84827. private _diffuseTexture4;
  84828. diffuseTexture4: BABYLON.Texture;
  84829. private _diffuseTexture5;
  84830. diffuseTexture5: BABYLON.Texture;
  84831. private _diffuseTexture6;
  84832. diffuseTexture6: BABYLON.Texture;
  84833. private _diffuseTexture7;
  84834. diffuseTexture7: BABYLON.Texture;
  84835. private _diffuseTexture8;
  84836. diffuseTexture8: BABYLON.Texture;
  84837. /**
  84838. * Uniforms
  84839. */
  84840. diffuseColor: BABYLON.Color3;
  84841. specularColor: BABYLON.Color3;
  84842. specularPower: number;
  84843. private _disableLighting;
  84844. disableLighting: boolean;
  84845. private _maxSimultaneousLights;
  84846. maxSimultaneousLights: number;
  84847. constructor(name: string, scene: BABYLON.Scene);
  84848. needAlphaBlending(): boolean;
  84849. needAlphaTesting(): boolean;
  84850. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84851. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84852. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84853. getAnimatables(): BABYLON.IAnimatable[];
  84854. getActiveTextures(): BABYLON.BaseTexture[];
  84855. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84856. dispose(forceDisposeEffect?: boolean): void;
  84857. clone(name: string): MixMaterial;
  84858. serialize(): any;
  84859. getClassName(): string;
  84860. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  84861. }
  84862. }
  84863. declare module BABYLON {
  84864. /** @hidden */
  84865. export var normalPixelShader: {
  84866. name: string;
  84867. shader: string;
  84868. };
  84869. }
  84870. declare module BABYLON {
  84871. /** @hidden */
  84872. export var normalVertexShader: {
  84873. name: string;
  84874. shader: string;
  84875. };
  84876. }
  84877. declare module BABYLON {
  84878. export class NormalMaterial extends BABYLON.PushMaterial {
  84879. private _diffuseTexture;
  84880. diffuseTexture: BABYLON.BaseTexture;
  84881. diffuseColor: BABYLON.Color3;
  84882. private _disableLighting;
  84883. disableLighting: boolean;
  84884. private _maxSimultaneousLights;
  84885. maxSimultaneousLights: number;
  84886. constructor(name: string, scene: BABYLON.Scene);
  84887. needAlphaBlending(): boolean;
  84888. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  84889. needAlphaTesting(): boolean;
  84890. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84891. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84892. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84893. getAnimatables(): BABYLON.IAnimatable[];
  84894. getActiveTextures(): BABYLON.BaseTexture[];
  84895. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84896. dispose(forceDisposeEffect?: boolean): void;
  84897. clone(name: string): NormalMaterial;
  84898. serialize(): any;
  84899. getClassName(): string;
  84900. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  84901. }
  84902. }
  84903. declare module BABYLON {
  84904. /** @hidden */
  84905. export var shadowOnlyPixelShader: {
  84906. name: string;
  84907. shader: string;
  84908. };
  84909. }
  84910. declare module BABYLON {
  84911. /** @hidden */
  84912. export var shadowOnlyVertexShader: {
  84913. name: string;
  84914. shader: string;
  84915. };
  84916. }
  84917. declare module BABYLON {
  84918. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  84919. private _activeLight;
  84920. private _needAlphaBlending;
  84921. constructor(name: string, scene: BABYLON.Scene);
  84922. shadowColor: BABYLON.Color3;
  84923. needAlphaBlending(): boolean;
  84924. needAlphaTesting(): boolean;
  84925. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84926. get activeLight(): BABYLON.IShadowLight;
  84927. set activeLight(light: BABYLON.IShadowLight);
  84928. private _getFirstShadowLightForMesh;
  84929. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84930. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84931. clone(name: string): ShadowOnlyMaterial;
  84932. serialize(): any;
  84933. getClassName(): string;
  84934. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  84935. }
  84936. }
  84937. declare module BABYLON {
  84938. /** @hidden */
  84939. export var simplePixelShader: {
  84940. name: string;
  84941. shader: string;
  84942. };
  84943. }
  84944. declare module BABYLON {
  84945. /** @hidden */
  84946. export var simpleVertexShader: {
  84947. name: string;
  84948. shader: string;
  84949. };
  84950. }
  84951. declare module BABYLON {
  84952. export class SimpleMaterial extends BABYLON.PushMaterial {
  84953. private _diffuseTexture;
  84954. diffuseTexture: BABYLON.BaseTexture;
  84955. diffuseColor: BABYLON.Color3;
  84956. private _disableLighting;
  84957. disableLighting: boolean;
  84958. private _maxSimultaneousLights;
  84959. maxSimultaneousLights: number;
  84960. constructor(name: string, scene: BABYLON.Scene);
  84961. needAlphaBlending(): boolean;
  84962. needAlphaTesting(): boolean;
  84963. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84964. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84965. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84966. getAnimatables(): BABYLON.IAnimatable[];
  84967. getActiveTextures(): BABYLON.BaseTexture[];
  84968. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84969. dispose(forceDisposeEffect?: boolean): void;
  84970. clone(name: string): SimpleMaterial;
  84971. serialize(): any;
  84972. getClassName(): string;
  84973. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  84974. }
  84975. }
  84976. declare module BABYLON {
  84977. /** @hidden */
  84978. export var skyPixelShader: {
  84979. name: string;
  84980. shader: string;
  84981. };
  84982. }
  84983. declare module BABYLON {
  84984. /** @hidden */
  84985. export var skyVertexShader: {
  84986. name: string;
  84987. shader: string;
  84988. };
  84989. }
  84990. declare module BABYLON {
  84991. /**
  84992. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  84993. * @see https://doc.babylonjs.com/extensions/sky
  84994. */
  84995. export class SkyMaterial extends BABYLON.PushMaterial {
  84996. /**
  84997. * Defines the overall luminance of sky in interval ]0, 1[.
  84998. */
  84999. luminance: number;
  85000. /**
  85001. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  85002. */
  85003. turbidity: number;
  85004. /**
  85005. * Defines the sky appearance (light intensity).
  85006. */
  85007. rayleigh: number;
  85008. /**
  85009. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  85010. */
  85011. mieCoefficient: number;
  85012. /**
  85013. * Defines the amount of haze particles following the Mie scattering theory.
  85014. */
  85015. mieDirectionalG: number;
  85016. /**
  85017. * Defines the distance of the sun according to the active scene camera.
  85018. */
  85019. distance: number;
  85020. /**
  85021. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  85022. * "inclined".
  85023. */
  85024. inclination: number;
  85025. /**
  85026. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  85027. * an object direction and a reference direction.
  85028. */
  85029. azimuth: number;
  85030. /**
  85031. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  85032. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  85033. */
  85034. sunPosition: BABYLON.Vector3;
  85035. /**
  85036. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  85037. * .sunPosition property.
  85038. */
  85039. useSunPosition: boolean;
  85040. /**
  85041. * Defines an offset vector used to get a horizon offset.
  85042. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  85043. */
  85044. cameraOffset: BABYLON.Vector3;
  85045. private _cameraPosition;
  85046. /**
  85047. * Instantiates a new sky material.
  85048. * This material allows to create dynamic and texture free
  85049. * effects for skyboxes by taking care of the atmosphere state.
  85050. * @see https://doc.babylonjs.com/extensions/sky
  85051. * @param name Define the name of the material in the scene
  85052. * @param scene Define the scene the material belong to
  85053. */
  85054. constructor(name: string, scene: BABYLON.Scene);
  85055. /**
  85056. * Specifies if the material will require alpha blending
  85057. * @returns a boolean specifying if alpha blending is needed
  85058. */
  85059. needAlphaBlending(): boolean;
  85060. /**
  85061. * Specifies if this material should be rendered in alpha test mode
  85062. * @returns false as the sky material doesn't need alpha testing.
  85063. */
  85064. needAlphaTesting(): boolean;
  85065. /**
  85066. * Get the texture used for alpha test purpose.
  85067. * @returns null as the sky material has no texture.
  85068. */
  85069. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85070. /**
  85071. * Get if the submesh is ready to be used and all its information available.
  85072. * Child classes can use it to update shaders
  85073. * @param mesh defines the mesh to check
  85074. * @param subMesh defines which submesh to check
  85075. * @param useInstances specifies that instances should be used
  85076. * @returns a boolean indicating that the submesh is ready or not
  85077. */
  85078. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85079. /**
  85080. * Binds the submesh to this material by preparing the effect and shader to draw
  85081. * @param world defines the world transformation matrix
  85082. * @param mesh defines the mesh containing the submesh
  85083. * @param subMesh defines the submesh to bind the material to
  85084. */
  85085. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85086. /**
  85087. * Get the list of animatables in the material.
  85088. * @returns the list of animatables object used in the material
  85089. */
  85090. getAnimatables(): BABYLON.IAnimatable[];
  85091. /**
  85092. * Disposes the material
  85093. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  85094. */
  85095. dispose(forceDisposeEffect?: boolean): void;
  85096. /**
  85097. * Makes a duplicate of the material, and gives it a new name
  85098. * @param name defines the new name for the duplicated material
  85099. * @returns the cloned material
  85100. */
  85101. clone(name: string): SkyMaterial;
  85102. /**
  85103. * Serializes this material in a JSON representation
  85104. * @returns the serialized material object
  85105. */
  85106. serialize(): any;
  85107. /**
  85108. * Gets the current class name of the material e.g. "SkyMaterial"
  85109. * Mainly use in serialization.
  85110. * @returns the class name
  85111. */
  85112. getClassName(): string;
  85113. /**
  85114. * Creates a sky material from parsed material data
  85115. * @param source defines the JSON representation of the material
  85116. * @param scene defines the hosting scene
  85117. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  85118. * @returns a new sky material
  85119. */
  85120. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  85121. }
  85122. }
  85123. declare module BABYLON {
  85124. /** @hidden */
  85125. export var terrainPixelShader: {
  85126. name: string;
  85127. shader: string;
  85128. };
  85129. }
  85130. declare module BABYLON {
  85131. /** @hidden */
  85132. export var terrainVertexShader: {
  85133. name: string;
  85134. shader: string;
  85135. };
  85136. }
  85137. declare module BABYLON {
  85138. export class TerrainMaterial extends BABYLON.PushMaterial {
  85139. private _mixTexture;
  85140. mixTexture: BABYLON.BaseTexture;
  85141. private _diffuseTexture1;
  85142. diffuseTexture1: BABYLON.Texture;
  85143. private _diffuseTexture2;
  85144. diffuseTexture2: BABYLON.Texture;
  85145. private _diffuseTexture3;
  85146. diffuseTexture3: BABYLON.Texture;
  85147. private _bumpTexture1;
  85148. bumpTexture1: BABYLON.Texture;
  85149. private _bumpTexture2;
  85150. bumpTexture2: BABYLON.Texture;
  85151. private _bumpTexture3;
  85152. bumpTexture3: BABYLON.Texture;
  85153. diffuseColor: BABYLON.Color3;
  85154. specularColor: BABYLON.Color3;
  85155. specularPower: number;
  85156. private _disableLighting;
  85157. disableLighting: boolean;
  85158. private _maxSimultaneousLights;
  85159. maxSimultaneousLights: number;
  85160. constructor(name: string, scene: BABYLON.Scene);
  85161. needAlphaBlending(): boolean;
  85162. needAlphaTesting(): boolean;
  85163. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85164. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85165. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85166. getAnimatables(): BABYLON.IAnimatable[];
  85167. getActiveTextures(): BABYLON.BaseTexture[];
  85168. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85169. dispose(forceDisposeEffect?: boolean): void;
  85170. clone(name: string): TerrainMaterial;
  85171. serialize(): any;
  85172. getClassName(): string;
  85173. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  85174. }
  85175. }
  85176. declare module BABYLON {
  85177. /** @hidden */
  85178. export var triplanarPixelShader: {
  85179. name: string;
  85180. shader: string;
  85181. };
  85182. }
  85183. declare module BABYLON {
  85184. /** @hidden */
  85185. export var triplanarVertexShader: {
  85186. name: string;
  85187. shader: string;
  85188. };
  85189. }
  85190. declare module BABYLON {
  85191. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  85192. mixTexture: BABYLON.BaseTexture;
  85193. private _diffuseTextureX;
  85194. diffuseTextureX: BABYLON.BaseTexture;
  85195. private _diffuseTextureY;
  85196. diffuseTextureY: BABYLON.BaseTexture;
  85197. private _diffuseTextureZ;
  85198. diffuseTextureZ: BABYLON.BaseTexture;
  85199. private _normalTextureX;
  85200. normalTextureX: BABYLON.BaseTexture;
  85201. private _normalTextureY;
  85202. normalTextureY: BABYLON.BaseTexture;
  85203. private _normalTextureZ;
  85204. normalTextureZ: BABYLON.BaseTexture;
  85205. tileSize: number;
  85206. diffuseColor: BABYLON.Color3;
  85207. specularColor: BABYLON.Color3;
  85208. specularPower: number;
  85209. private _disableLighting;
  85210. disableLighting: boolean;
  85211. private _maxSimultaneousLights;
  85212. maxSimultaneousLights: number;
  85213. constructor(name: string, scene: BABYLON.Scene);
  85214. needAlphaBlending(): boolean;
  85215. needAlphaTesting(): boolean;
  85216. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85217. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85218. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85219. getAnimatables(): BABYLON.IAnimatable[];
  85220. getActiveTextures(): BABYLON.BaseTexture[];
  85221. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85222. dispose(forceDisposeEffect?: boolean): void;
  85223. clone(name: string): TriPlanarMaterial;
  85224. serialize(): any;
  85225. getClassName(): string;
  85226. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  85227. }
  85228. }
  85229. declare module BABYLON {
  85230. /** @hidden */
  85231. export var waterPixelShader: {
  85232. name: string;
  85233. shader: string;
  85234. };
  85235. }
  85236. declare module BABYLON {
  85237. /** @hidden */
  85238. export var waterVertexShader: {
  85239. name: string;
  85240. shader: string;
  85241. };
  85242. }
  85243. declare module BABYLON {
  85244. export class WaterMaterial extends BABYLON.PushMaterial {
  85245. renderTargetSize: BABYLON.Vector2;
  85246. private _bumpTexture;
  85247. bumpTexture: BABYLON.BaseTexture;
  85248. diffuseColor: BABYLON.Color3;
  85249. specularColor: BABYLON.Color3;
  85250. specularPower: number;
  85251. private _disableLighting;
  85252. disableLighting: boolean;
  85253. private _maxSimultaneousLights;
  85254. maxSimultaneousLights: number;
  85255. /**
  85256. * @param {number}: Represents the wind force
  85257. */
  85258. windForce: number;
  85259. /**
  85260. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  85261. */
  85262. windDirection: BABYLON.Vector2;
  85263. /**
  85264. * @param {number}: Wave height, represents the height of the waves
  85265. */
  85266. waveHeight: number;
  85267. /**
  85268. * @param {number}: Bump height, represents the bump height related to the bump map
  85269. */
  85270. bumpHeight: number;
  85271. /**
  85272. * @param {boolean}: Add a smaller moving bump to less steady waves.
  85273. */
  85274. private _bumpSuperimpose;
  85275. bumpSuperimpose: boolean;
  85276. /**
  85277. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  85278. */
  85279. private _fresnelSeparate;
  85280. fresnelSeparate: boolean;
  85281. /**
  85282. * @param {boolean}: bump Waves modify the reflection.
  85283. */
  85284. private _bumpAffectsReflection;
  85285. bumpAffectsReflection: boolean;
  85286. /**
  85287. * @param {number}: The water color blended with the refraction (near)
  85288. */
  85289. waterColor: BABYLON.Color3;
  85290. /**
  85291. * @param {number}: The blend factor related to the water color
  85292. */
  85293. colorBlendFactor: number;
  85294. /**
  85295. * @param {number}: The water color blended with the reflection (far)
  85296. */
  85297. waterColor2: BABYLON.Color3;
  85298. /**
  85299. * @param {number}: The blend factor related to the water color (reflection, far)
  85300. */
  85301. colorBlendFactor2: number;
  85302. /**
  85303. * @param {number}: Represents the maximum length of a wave
  85304. */
  85305. waveLength: number;
  85306. /**
  85307. * @param {number}: Defines the waves speed
  85308. */
  85309. waveSpeed: number;
  85310. /**
  85311. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  85312. * will avoid calculating useless pixels in the pixel shader of the water material.
  85313. */
  85314. disableClipPlane: boolean;
  85315. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  85316. private _mesh;
  85317. private _refractionRTT;
  85318. private _reflectionRTT;
  85319. private _reflectionTransform;
  85320. private _lastTime;
  85321. private _lastDeltaTime;
  85322. private _useLogarithmicDepth;
  85323. private _waitingRenderList;
  85324. private _imageProcessingConfiguration;
  85325. private _imageProcessingObserver;
  85326. /**
  85327. * Gets a boolean indicating that current material needs to register RTT
  85328. */
  85329. get hasRenderTargetTextures(): boolean;
  85330. /**
  85331. * Constructor
  85332. */
  85333. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  85334. get useLogarithmicDepth(): boolean;
  85335. set useLogarithmicDepth(value: boolean);
  85336. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  85337. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  85338. addToRenderList(node: any): void;
  85339. enableRenderTargets(enable: boolean): void;
  85340. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  85341. get renderTargetsEnabled(): boolean;
  85342. needAlphaBlending(): boolean;
  85343. needAlphaTesting(): boolean;
  85344. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85345. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85346. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85347. private _createRenderTargets;
  85348. getAnimatables(): BABYLON.IAnimatable[];
  85349. getActiveTextures(): BABYLON.BaseTexture[];
  85350. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85351. dispose(forceDisposeEffect?: boolean): void;
  85352. clone(name: string): WaterMaterial;
  85353. serialize(): any;
  85354. getClassName(): string;
  85355. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  85356. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  85357. }
  85358. }
  85359. declare module BABYLON {
  85360. /** @hidden */
  85361. export var asciiartPixelShader: {
  85362. name: string;
  85363. shader: string;
  85364. };
  85365. }
  85366. declare module BABYLON {
  85367. /**
  85368. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  85369. *
  85370. * It basically takes care rendering the font front the given font size to a texture.
  85371. * This is used later on in the postprocess.
  85372. */
  85373. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  85374. private _font;
  85375. private _text;
  85376. private _charSize;
  85377. /**
  85378. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  85379. */
  85380. get charSize(): number;
  85381. /**
  85382. * Create a new instance of the Ascii Art FontTexture class
  85383. * @param name the name of the texture
  85384. * @param font the font to use, use the W3C CSS notation
  85385. * @param text the caracter set to use in the rendering.
  85386. * @param scene the scene that owns the texture
  85387. */
  85388. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  85389. /**
  85390. * Gets the max char width of a font.
  85391. * @param font the font to use, use the W3C CSS notation
  85392. * @return the max char width
  85393. */
  85394. private getFontWidth;
  85395. /**
  85396. * Gets the max char height of a font.
  85397. * @param font the font to use, use the W3C CSS notation
  85398. * @return the max char height
  85399. */
  85400. private getFontHeight;
  85401. /**
  85402. * Clones the current AsciiArtTexture.
  85403. * @return the clone of the texture.
  85404. */
  85405. clone(): AsciiArtFontTexture;
  85406. /**
  85407. * Parses a json object representing the texture and returns an instance of it.
  85408. * @param source the source JSON representation
  85409. * @param scene the scene to create the texture for
  85410. * @return the parsed texture
  85411. */
  85412. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  85413. }
  85414. /**
  85415. * Option available in the Ascii Art Post Process.
  85416. */
  85417. export interface IAsciiArtPostProcessOptions {
  85418. /**
  85419. * The font to use following the w3c font definition.
  85420. */
  85421. font?: string;
  85422. /**
  85423. * The character set to use in the postprocess.
  85424. */
  85425. characterSet?: string;
  85426. /**
  85427. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  85428. * This number is defined between 0 and 1;
  85429. */
  85430. mixToTile?: number;
  85431. /**
  85432. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  85433. * This number is defined between 0 and 1;
  85434. */
  85435. mixToNormal?: number;
  85436. }
  85437. /**
  85438. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  85439. *
  85440. * Simmply add it to your scene and let the nerd that lives in you have fun.
  85441. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  85442. */
  85443. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  85444. /**
  85445. * The font texture used to render the char in the post process.
  85446. */
  85447. private _asciiArtFontTexture;
  85448. /**
  85449. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  85450. * This number is defined between 0 and 1;
  85451. */
  85452. mixToTile: number;
  85453. /**
  85454. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  85455. * This number is defined between 0 and 1;
  85456. */
  85457. mixToNormal: number;
  85458. /**
  85459. * Instantiates a new Ascii Art Post Process.
  85460. * @param name the name to give to the postprocess
  85461. * @camera the camera to apply the post process to.
  85462. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  85463. */
  85464. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  85465. }
  85466. }
  85467. declare module BABYLON {
  85468. /** @hidden */
  85469. export var digitalrainPixelShader: {
  85470. name: string;
  85471. shader: string;
  85472. };
  85473. }
  85474. declare module BABYLON {
  85475. /**
  85476. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  85477. *
  85478. * It basically takes care rendering the font front the given font size to a texture.
  85479. * This is used later on in the postprocess.
  85480. */
  85481. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  85482. private _font;
  85483. private _text;
  85484. private _charSize;
  85485. /**
  85486. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  85487. */
  85488. get charSize(): number;
  85489. /**
  85490. * Create a new instance of the Digital Rain FontTexture class
  85491. * @param name the name of the texture
  85492. * @param font the font to use, use the W3C CSS notation
  85493. * @param text the caracter set to use in the rendering.
  85494. * @param scene the scene that owns the texture
  85495. */
  85496. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  85497. /**
  85498. * Gets the max char width of a font.
  85499. * @param font the font to use, use the W3C CSS notation
  85500. * @return the max char width
  85501. */
  85502. private getFontWidth;
  85503. /**
  85504. * Gets the max char height of a font.
  85505. * @param font the font to use, use the W3C CSS notation
  85506. * @return the max char height
  85507. */
  85508. private getFontHeight;
  85509. /**
  85510. * Clones the current DigitalRainFontTexture.
  85511. * @return the clone of the texture.
  85512. */
  85513. clone(): DigitalRainFontTexture;
  85514. /**
  85515. * Parses a json object representing the texture and returns an instance of it.
  85516. * @param source the source JSON representation
  85517. * @param scene the scene to create the texture for
  85518. * @return the parsed texture
  85519. */
  85520. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  85521. }
  85522. /**
  85523. * Option available in the Digital Rain Post Process.
  85524. */
  85525. export interface IDigitalRainPostProcessOptions {
  85526. /**
  85527. * The font to use following the w3c font definition.
  85528. */
  85529. font?: string;
  85530. /**
  85531. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  85532. * This number is defined between 0 and 1;
  85533. */
  85534. mixToTile?: number;
  85535. /**
  85536. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  85537. * This number is defined between 0 and 1;
  85538. */
  85539. mixToNormal?: number;
  85540. }
  85541. /**
  85542. * DigitalRainPostProcess helps rendering everithing in digital rain.
  85543. *
  85544. * Simmply add it to your scene and let the nerd that lives in you have fun.
  85545. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  85546. */
  85547. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  85548. /**
  85549. * The font texture used to render the char in the post process.
  85550. */
  85551. private _digitalRainFontTexture;
  85552. /**
  85553. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  85554. * This number is defined between 0 and 1;
  85555. */
  85556. mixToTile: number;
  85557. /**
  85558. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  85559. * This number is defined between 0 and 1;
  85560. */
  85561. mixToNormal: number;
  85562. /**
  85563. * Instantiates a new Digital Rain Post Process.
  85564. * @param name the name to give to the postprocess
  85565. * @camera the camera to apply the post process to.
  85566. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  85567. */
  85568. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  85569. }
  85570. }
  85571. declare module BABYLON {
  85572. /** @hidden */
  85573. export var brickProceduralTexturePixelShader: {
  85574. name: string;
  85575. shader: string;
  85576. };
  85577. }
  85578. declare module BABYLON {
  85579. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  85580. private _numberOfBricksHeight;
  85581. private _numberOfBricksWidth;
  85582. private _jointColor;
  85583. private _brickColor;
  85584. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85585. updateShaderUniforms(): void;
  85586. get numberOfBricksHeight(): number;
  85587. set numberOfBricksHeight(value: number);
  85588. get numberOfBricksWidth(): number;
  85589. set numberOfBricksWidth(value: number);
  85590. get jointColor(): BABYLON.Color3;
  85591. set jointColor(value: BABYLON.Color3);
  85592. get brickColor(): BABYLON.Color3;
  85593. set brickColor(value: BABYLON.Color3);
  85594. /**
  85595. * Serializes this brick procedural texture
  85596. * @returns a serialized brick procedural texture object
  85597. */
  85598. serialize(): any;
  85599. /**
  85600. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  85601. * @param parsedTexture defines parsed texture data
  85602. * @param scene defines the current scene
  85603. * @param rootUrl defines the root URL containing brick procedural texture information
  85604. * @returns a parsed Brick Procedural BABYLON.Texture
  85605. */
  85606. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  85607. }
  85608. }
  85609. declare module BABYLON {
  85610. /** @hidden */
  85611. export var cloudProceduralTexturePixelShader: {
  85612. name: string;
  85613. shader: string;
  85614. };
  85615. }
  85616. declare module BABYLON {
  85617. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  85618. private _skyColor;
  85619. private _cloudColor;
  85620. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85621. updateShaderUniforms(): void;
  85622. get skyColor(): BABYLON.Color4;
  85623. set skyColor(value: BABYLON.Color4);
  85624. get cloudColor(): BABYLON.Color4;
  85625. set cloudColor(value: BABYLON.Color4);
  85626. /**
  85627. * Serializes this cloud procedural texture
  85628. * @returns a serialized cloud procedural texture object
  85629. */
  85630. serialize(): any;
  85631. /**
  85632. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  85633. * @param parsedTexture defines parsed texture data
  85634. * @param scene defines the current scene
  85635. * @param rootUrl defines the root URL containing cloud procedural texture information
  85636. * @returns a parsed Cloud Procedural BABYLON.Texture
  85637. */
  85638. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  85639. }
  85640. }
  85641. declare module BABYLON {
  85642. /** @hidden */
  85643. export var fireProceduralTexturePixelShader: {
  85644. name: string;
  85645. shader: string;
  85646. };
  85647. }
  85648. declare module BABYLON {
  85649. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  85650. private _time;
  85651. private _speed;
  85652. private _autoGenerateTime;
  85653. private _fireColors;
  85654. private _alphaThreshold;
  85655. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85656. updateShaderUniforms(): void;
  85657. render(useCameraPostProcess?: boolean): void;
  85658. static get PurpleFireColors(): BABYLON.Color3[];
  85659. static get GreenFireColors(): BABYLON.Color3[];
  85660. static get RedFireColors(): BABYLON.Color3[];
  85661. static get BlueFireColors(): BABYLON.Color3[];
  85662. get autoGenerateTime(): boolean;
  85663. set autoGenerateTime(value: boolean);
  85664. get fireColors(): BABYLON.Color3[];
  85665. set fireColors(value: BABYLON.Color3[]);
  85666. get time(): number;
  85667. set time(value: number);
  85668. get speed(): BABYLON.Vector2;
  85669. set speed(value: BABYLON.Vector2);
  85670. get alphaThreshold(): number;
  85671. set alphaThreshold(value: number);
  85672. /**
  85673. * Serializes this fire procedural texture
  85674. * @returns a serialized fire procedural texture object
  85675. */
  85676. serialize(): any;
  85677. /**
  85678. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  85679. * @param parsedTexture defines parsed texture data
  85680. * @param scene defines the current scene
  85681. * @param rootUrl defines the root URL containing fire procedural texture information
  85682. * @returns a parsed Fire Procedural BABYLON.Texture
  85683. */
  85684. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  85685. }
  85686. }
  85687. declare module BABYLON {
  85688. /** @hidden */
  85689. export var grassProceduralTexturePixelShader: {
  85690. name: string;
  85691. shader: string;
  85692. };
  85693. }
  85694. declare module BABYLON {
  85695. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  85696. private _grassColors;
  85697. private _groundColor;
  85698. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85699. updateShaderUniforms(): void;
  85700. get grassColors(): BABYLON.Color3[];
  85701. set grassColors(value: BABYLON.Color3[]);
  85702. get groundColor(): BABYLON.Color3;
  85703. set groundColor(value: BABYLON.Color3);
  85704. /**
  85705. * Serializes this grass procedural texture
  85706. * @returns a serialized grass procedural texture object
  85707. */
  85708. serialize(): any;
  85709. /**
  85710. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  85711. * @param parsedTexture defines parsed texture data
  85712. * @param scene defines the current scene
  85713. * @param rootUrl defines the root URL containing grass procedural texture information
  85714. * @returns a parsed Grass Procedural BABYLON.Texture
  85715. */
  85716. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  85717. }
  85718. }
  85719. declare module BABYLON {
  85720. /** @hidden */
  85721. export var marbleProceduralTexturePixelShader: {
  85722. name: string;
  85723. shader: string;
  85724. };
  85725. }
  85726. declare module BABYLON {
  85727. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  85728. private _numberOfTilesHeight;
  85729. private _numberOfTilesWidth;
  85730. private _amplitude;
  85731. private _jointColor;
  85732. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85733. updateShaderUniforms(): void;
  85734. get numberOfTilesHeight(): number;
  85735. set numberOfTilesHeight(value: number);
  85736. get amplitude(): number;
  85737. set amplitude(value: number);
  85738. get numberOfTilesWidth(): number;
  85739. set numberOfTilesWidth(value: number);
  85740. get jointColor(): BABYLON.Color3;
  85741. set jointColor(value: BABYLON.Color3);
  85742. /**
  85743. * Serializes this marble procedural texture
  85744. * @returns a serialized marble procedural texture object
  85745. */
  85746. serialize(): any;
  85747. /**
  85748. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  85749. * @param parsedTexture defines parsed texture data
  85750. * @param scene defines the current scene
  85751. * @param rootUrl defines the root URL containing marble procedural texture information
  85752. * @returns a parsed Marble Procedural BABYLON.Texture
  85753. */
  85754. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  85755. }
  85756. }
  85757. declare module BABYLON {
  85758. /** @hidden */
  85759. export var normalMapProceduralTexturePixelShader: {
  85760. name: string;
  85761. shader: string;
  85762. };
  85763. }
  85764. declare module BABYLON {
  85765. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  85766. private _baseTexture;
  85767. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85768. updateShaderUniforms(): void;
  85769. render(useCameraPostProcess?: boolean): void;
  85770. resize(size: any, generateMipMaps: any): void;
  85771. get baseTexture(): BABYLON.Texture;
  85772. set baseTexture(texture: BABYLON.Texture);
  85773. /**
  85774. * Serializes this normal map procedural texture
  85775. * @returns a serialized normal map procedural texture object
  85776. */
  85777. serialize(): any;
  85778. /**
  85779. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  85780. * @param parsedTexture defines parsed texture data
  85781. * @param scene defines the current scene
  85782. * @param rootUrl defines the root URL containing normal map procedural texture information
  85783. * @returns a parsed Normal Map Procedural BABYLON.Texture
  85784. */
  85785. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  85786. }
  85787. }
  85788. declare module BABYLON {
  85789. /** @hidden */
  85790. export var perlinNoiseProceduralTexturePixelShader: {
  85791. name: string;
  85792. shader: string;
  85793. };
  85794. }
  85795. declare module BABYLON {
  85796. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  85797. time: number;
  85798. timeScale: number;
  85799. translationSpeed: number;
  85800. private _currentTranslation;
  85801. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85802. updateShaderUniforms(): void;
  85803. render(useCameraPostProcess?: boolean): void;
  85804. resize(size: any, generateMipMaps: any): void;
  85805. /**
  85806. * Serializes this perlin noise procedural texture
  85807. * @returns a serialized perlin noise procedural texture object
  85808. */
  85809. serialize(): any;
  85810. /**
  85811. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  85812. * @param parsedTexture defines parsed texture data
  85813. * @param scene defines the current scene
  85814. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  85815. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  85816. */
  85817. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  85818. }
  85819. }
  85820. declare module BABYLON {
  85821. /** @hidden */
  85822. export var roadProceduralTexturePixelShader: {
  85823. name: string;
  85824. shader: string;
  85825. };
  85826. }
  85827. declare module BABYLON {
  85828. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  85829. private _roadColor;
  85830. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85831. updateShaderUniforms(): void;
  85832. get roadColor(): BABYLON.Color3;
  85833. set roadColor(value: BABYLON.Color3);
  85834. /**
  85835. * Serializes this road procedural texture
  85836. * @returns a serialized road procedural texture object
  85837. */
  85838. serialize(): any;
  85839. /**
  85840. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  85841. * @param parsedTexture defines parsed texture data
  85842. * @param scene defines the current scene
  85843. * @param rootUrl defines the root URL containing road procedural texture information
  85844. * @returns a parsed Road Procedural BABYLON.Texture
  85845. */
  85846. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  85847. }
  85848. }
  85849. declare module BABYLON {
  85850. /** @hidden */
  85851. export var starfieldProceduralTexturePixelShader: {
  85852. name: string;
  85853. shader: string;
  85854. };
  85855. }
  85856. declare module BABYLON {
  85857. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  85858. private _time;
  85859. private _alpha;
  85860. private _beta;
  85861. private _zoom;
  85862. private _formuparam;
  85863. private _stepsize;
  85864. private _tile;
  85865. private _brightness;
  85866. private _darkmatter;
  85867. private _distfading;
  85868. private _saturation;
  85869. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85870. updateShaderUniforms(): void;
  85871. get time(): number;
  85872. set time(value: number);
  85873. get alpha(): number;
  85874. set alpha(value: number);
  85875. get beta(): number;
  85876. set beta(value: number);
  85877. get formuparam(): number;
  85878. set formuparam(value: number);
  85879. get stepsize(): number;
  85880. set stepsize(value: number);
  85881. get zoom(): number;
  85882. set zoom(value: number);
  85883. get tile(): number;
  85884. set tile(value: number);
  85885. get brightness(): number;
  85886. set brightness(value: number);
  85887. get darkmatter(): number;
  85888. set darkmatter(value: number);
  85889. get distfading(): number;
  85890. set distfading(value: number);
  85891. get saturation(): number;
  85892. set saturation(value: number);
  85893. /**
  85894. * Serializes this starfield procedural texture
  85895. * @returns a serialized starfield procedural texture object
  85896. */
  85897. serialize(): any;
  85898. /**
  85899. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  85900. * @param parsedTexture defines parsed texture data
  85901. * @param scene defines the current scene
  85902. * @param rootUrl defines the root URL containing startfield procedural texture information
  85903. * @returns a parsed Starfield Procedural BABYLON.Texture
  85904. */
  85905. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  85906. }
  85907. }
  85908. declare module BABYLON {
  85909. /** @hidden */
  85910. export var woodProceduralTexturePixelShader: {
  85911. name: string;
  85912. shader: string;
  85913. };
  85914. }
  85915. declare module BABYLON {
  85916. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  85917. private _ampScale;
  85918. private _woodColor;
  85919. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85920. updateShaderUniforms(): void;
  85921. get ampScale(): number;
  85922. set ampScale(value: number);
  85923. get woodColor(): BABYLON.Color3;
  85924. set woodColor(value: BABYLON.Color3);
  85925. /**
  85926. * Serializes this wood procedural texture
  85927. * @returns a serialized wood procedural texture object
  85928. */
  85929. serialize(): any;
  85930. /**
  85931. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  85932. * @param parsedTexture defines parsed texture data
  85933. * @param scene defines the current scene
  85934. * @param rootUrl defines the root URL containing wood procedural texture information
  85935. * @returns a parsed Wood Procedural BABYLON.Texture
  85936. */
  85937. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  85938. }
  85939. }