documentation.d.ts 3.6 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813678146781567816678176781867819678206782167822678236782467825678266782767828678296783067831678326783367834678356783667837678386783967840678416784267843678446784567846678476784867849678506785167852678536785467855678566785767858678596786067861678626786367864678656786667867678686786967870678716787267873678746787567876678776787867879678806788167882678836788467885678866788767888678896789067891678926789367894678956789667897678986789967900679016790267903679046790567906679076790867909679106791167912679136791467915679166791767918679196792067921679226792367924679256792667927679286792967930679316793267933679346793567936679376793867939679406794167942679436794467945679466794767948679496795067951679526795367954679556795667957679586795967960679616796267963679646796567966679676796867969679706797167972679736797467975679766797767978679796798067981679826798367984679856798667987679886798967990679916799267993679946799567996679976799867999680006800168002680036800468005680066800768008680096801068011680126801368014680156801668017680186801968020680216802268023680246802568026680276802868029680306803168032680336803468035680366803768038680396804068041680426804368044680456804668047680486804968050680516805268053680546805568056680576805868059680606806168062680636806468065680666806768068680696807068071680726807368074680756807668077680786807968080680816808268083680846808568086680876808868089680906809168092680936809468095680966809768098680996810068101681026810368104681056810668107681086810968110681116811268113681146811568116681176811868119681206812168122681236812468125681266812768128681296813068131681326813368134681356813668137681386813968140681416814268143681446814568146681476814868149681506815168152681536815468155681566815768158681596816068161681626816368164681656816668167681686816968170681716817268173681746817568176681776817868179681806818168182681836818468185681866818768188681896819068191681926819368194681956819668197681986819968200682016820268203682046820568206682076820868209682106821168212682136821468215682166821768218682196822068221682226822368224682256822668227682286822968230682316823268233682346823568236682376823868239682406824168242682436824468245682466824768248682496825068251682526825368254682556825668257682586825968260682616826268263682646826568266682676826868269682706827168272682736827468275682766827768278682796828068281682826828368284682856828668287682886828968290682916829268293682946829568296682976829868299683006830168302683036830468305683066830768308683096831068311683126831368314683156831668317683186831968320683216832268323683246832568326683276832868329683306833168332683336833468335683366833768338683396834068341683426834368344683456834668347683486834968350683516835268353683546835568356683576835868359683606836168362683636836468365683666836768368683696837068371683726837368374683756837668377683786837968380683816838268383683846838568386683876838868389683906839168392683936839468395683966839768398683996840068401684026840368404684056840668407684086840968410684116841268413684146841568416684176841868419684206842168422684236842468425684266842768428684296843068431684326843368434684356843668437684386843968440684416844268443684446844568446684476844868449684506845168452684536845468455684566845768458684596846068461684626846368464684656846668467684686846968470684716847268473684746847568476684776847868479684806848168482684836848468485684866848768488684896849068491684926849368494684956849668497684986849968500685016850268503685046850568506685076850868509685106851168512685136851468515685166851768518685196852068521685226852368524685256852668527685286852968530685316853268533685346853568536685376853868539685406854168542685436854468545685466854768548685496855068551685526855368554685556855668557685586855968560685616856268563685646856568566685676856868569685706857168572685736857468575685766857768578685796858068581685826858368584685856858668587685886858968590685916859268593685946859568596685976859868599686006860168602686036860468605686066860768608686096861068611686126861368614686156861668617686186861968620686216862268623686246862568626686276862868629686306863168632686336863468635686366863768638686396864068641686426864368644686456864668647686486864968650686516865268653686546865568656686576865868659686606866168662686636866468665686666866768668686696867068671686726867368674686756867668677686786867968680686816868268683686846868568686686876868868689686906869168692686936869468695686966869768698686996870068701687026870368704687056870668707687086870968710687116871268713687146871568716687176871868719687206872168722687236872468725687266872768728687296873068731687326873368734687356873668737687386873968740687416874268743687446874568746687476874868749687506875168752687536875468755687566875768758687596876068761687626876368764687656876668767687686876968770687716877268773687746877568776687776877868779687806878168782687836878468785687866878768788687896879068791687926879368794687956879668797687986879968800688016880268803688046880568806688076880868809688106881168812688136881468815688166881768818688196882068821688226882368824688256882668827688286882968830688316883268833688346883568836688376883868839688406884168842688436884468845688466884768848688496885068851688526885368854688556885668857688586885968860688616886268863688646886568866688676886868869688706887168872688736887468875688766887768878688796888068881688826888368884688856888668887688886888968890688916889268893688946889568896688976889868899689006890168902689036890468905689066890768908689096891068911689126891368914689156891668917689186891968920689216892268923689246892568926689276892868929689306893168932689336893468935689366893768938689396894068941689426894368944689456894668947689486894968950689516895268953689546895568956689576895868959689606896168962689636896468965689666896768968689696897068971689726897368974689756897668977689786897968980689816898268983689846898568986689876898868989689906899168992689936899468995689966899768998689996900069001690026900369004690056900669007690086900969010690116901269013690146901569016690176901869019690206902169022690236902469025690266902769028690296903069031690326903369034690356903669037690386903969040690416904269043690446904569046690476904869049690506905169052690536905469055690566905769058690596906069061690626906369064690656906669067690686906969070690716907269073690746907569076690776907869079690806908169082690836908469085690866908769088690896909069091690926909369094690956909669097690986909969100691016910269103691046910569106691076910869109691106911169112691136911469115691166911769118691196912069121691226912369124691256912669127691286912969130691316913269133691346913569136691376913869139691406914169142691436914469145691466914769148691496915069151691526915369154691556915669157691586915969160691616916269163691646916569166691676916869169691706917169172691736917469175691766917769178691796918069181691826918369184691856918669187691886918969190691916919269193691946919569196691976919869199692006920169202692036920469205692066920769208692096921069211692126921369214692156921669217692186921969220692216922269223692246922569226692276922869229692306923169232692336923469235692366923769238692396924069241692426924369244692456924669247692486924969250692516925269253692546925569256692576925869259692606926169262692636926469265692666926769268692696927069271692726927369274692756927669277692786927969280692816928269283692846928569286692876928869289692906929169292692936929469295692966929769298692996930069301693026930369304693056930669307693086930969310693116931269313693146931569316693176931869319693206932169322693236932469325693266932769328693296933069331693326933369334693356933669337693386933969340693416934269343693446934569346693476934869349693506935169352693536935469355693566935769358693596936069361693626936369364693656936669367693686936969370693716937269373693746937569376693776937869379693806938169382693836938469385693866938769388693896939069391693926939369394693956939669397693986939969400694016940269403694046940569406694076940869409694106941169412694136941469415694166941769418694196942069421694226942369424694256942669427694286942969430694316943269433694346943569436694376943869439694406944169442694436944469445694466944769448694496945069451694526945369454694556945669457694586945969460694616946269463694646946569466694676946869469694706947169472694736947469475694766947769478694796948069481694826948369484694856948669487694886948969490694916949269493694946949569496694976949869499695006950169502695036950469505695066950769508695096951069511695126951369514695156951669517695186951969520695216952269523695246952569526695276952869529695306953169532695336953469535695366953769538695396954069541695426954369544695456954669547695486954969550695516955269553695546955569556695576955869559695606956169562695636956469565695666956769568695696957069571695726957369574695756957669577695786957969580695816958269583695846958569586695876958869589695906959169592695936959469595695966959769598695996960069601696026960369604696056960669607696086960969610696116961269613696146961569616696176961869619696206962169622696236962469625696266962769628696296963069631696326963369634696356963669637696386963969640696416964269643696446964569646696476964869649696506965169652696536965469655696566965769658696596966069661696626966369664696656966669667696686966969670696716967269673696746967569676696776967869679696806968169682696836968469685696866968769688696896969069691696926969369694696956969669697696986969969700697016970269703697046970569706697076970869709697106971169712697136971469715697166971769718697196972069721697226972369724697256972669727697286972969730697316973269733697346973569736697376973869739697406974169742697436974469745697466974769748697496975069751697526975369754697556975669757697586975969760697616976269763697646976569766697676976869769697706977169772697736977469775697766977769778697796978069781697826978369784697856978669787697886978969790697916979269793697946979569796697976979869799698006980169802698036980469805698066980769808698096981069811698126981369814698156981669817698186981969820698216982269823698246982569826698276982869829698306983169832698336983469835698366983769838698396984069841698426984369844698456984669847698486984969850698516985269853698546985569856698576985869859698606986169862698636986469865698666986769868698696987069871698726987369874698756987669877698786987969880698816988269883698846988569886698876988869889698906989169892698936989469895698966989769898698996990069901699026990369904699056990669907699086990969910699116991269913699146991569916699176991869919699206992169922699236992469925699266992769928699296993069931699326993369934699356993669937699386993969940699416994269943699446994569946699476994869949699506995169952699536995469955699566995769958699596996069961699626996369964699656996669967699686996969970699716997269973699746997569976699776997869979699806998169982699836998469985699866998769988699896999069991699926999369994699956999669997699986999970000700017000270003700047000570006700077000870009700107001170012700137001470015700167001770018700197002070021700227002370024700257002670027700287002970030700317003270033700347003570036700377003870039700407004170042700437004470045700467004770048700497005070051700527005370054700557005670057700587005970060700617006270063700647006570066700677006870069700707007170072700737007470075700767007770078700797008070081700827008370084700857008670087700887008970090700917009270093700947009570096700977009870099701007010170102701037010470105701067010770108701097011070111701127011370114701157011670117701187011970120701217012270123701247012570126701277012870129701307013170132701337013470135701367013770138701397014070141701427014370144701457014670147701487014970150701517015270153701547015570156701577015870159701607016170162701637016470165701667016770168701697017070171701727017370174701757017670177701787017970180701817018270183701847018570186701877018870189701907019170192701937019470195701967019770198701997020070201702027020370204702057020670207702087020970210702117021270213702147021570216702177021870219702207022170222702237022470225702267022770228702297023070231702327023370234702357023670237702387023970240702417024270243702447024570246702477024870249702507025170252702537025470255702567025770258702597026070261702627026370264702657026670267702687026970270702717027270273702747027570276702777027870279702807028170282702837028470285702867028770288702897029070291702927029370294702957029670297702987029970300703017030270303703047030570306703077030870309703107031170312703137031470315703167031770318703197032070321703227032370324703257032670327703287032970330703317033270333703347033570336703377033870339703407034170342703437034470345703467034770348703497035070351703527035370354703557035670357703587035970360703617036270363703647036570366703677036870369703707037170372703737037470375703767037770378703797038070381703827038370384703857038670387703887038970390703917039270393703947039570396703977039870399704007040170402704037040470405704067040770408704097041070411704127041370414704157041670417704187041970420704217042270423704247042570426704277042870429704307043170432704337043470435704367043770438704397044070441704427044370444704457044670447704487044970450704517045270453704547045570456704577045870459704607046170462704637046470465704667046770468704697047070471704727047370474704757047670477704787047970480704817048270483704847048570486704877048870489704907049170492704937049470495704967049770498704997050070501705027050370504705057050670507705087050970510705117051270513705147051570516705177051870519705207052170522705237052470525705267052770528705297053070531705327053370534705357053670537705387053970540705417054270543705447054570546705477054870549705507055170552705537055470555705567055770558705597056070561705627056370564705657056670567705687056970570705717057270573705747057570576705777057870579705807058170582705837058470585705867058770588705897059070591705927059370594705957059670597705987059970600706017060270603706047060570606706077060870609706107061170612706137061470615706167061770618706197062070621706227062370624706257062670627706287062970630706317063270633706347063570636706377063870639706407064170642706437064470645706467064770648706497065070651706527065370654706557065670657706587065970660706617066270663706647066570666706677066870669706707067170672706737067470675706767067770678706797068070681706827068370684706857068670687706887068970690706917069270693706947069570696706977069870699707007070170702707037070470705707067070770708707097071070711707127071370714707157071670717707187071970720707217072270723707247072570726707277072870729707307073170732707337073470735707367073770738707397074070741707427074370744707457074670747707487074970750707517075270753707547075570756707577075870759707607076170762707637076470765707667076770768707697077070771707727077370774707757077670777707787077970780707817078270783707847078570786707877078870789707907079170792707937079470795707967079770798707997080070801708027080370804708057080670807708087080970810708117081270813708147081570816708177081870819708207082170822708237082470825708267082770828708297083070831708327083370834708357083670837708387083970840708417084270843708447084570846708477084870849708507085170852708537085470855708567085770858708597086070861708627086370864708657086670867708687086970870708717087270873708747087570876708777087870879708807088170882708837088470885708867088770888708897089070891708927089370894708957089670897708987089970900709017090270903709047090570906709077090870909709107091170912709137091470915709167091770918709197092070921709227092370924709257092670927709287092970930709317093270933709347093570936709377093870939709407094170942709437094470945709467094770948709497095070951709527095370954709557095670957709587095970960709617096270963709647096570966709677096870969709707097170972709737097470975709767097770978709797098070981709827098370984709857098670987709887098970990709917099270993709947099570996709977099870999710007100171002710037100471005710067100771008710097101071011710127101371014710157101671017710187101971020710217102271023710247102571026710277102871029710307103171032710337103471035710367103771038710397104071041710427104371044710457104671047710487104971050710517105271053710547105571056710577105871059710607106171062710637106471065710667106771068710697107071071710727107371074710757107671077710787107971080710817108271083710847108571086710877108871089710907109171092710937109471095710967109771098710997110071101711027110371104711057110671107711087110971110711117111271113711147111571116711177111871119711207112171122711237112471125711267112771128711297113071131711327113371134711357113671137711387113971140711417114271143711447114571146711477114871149711507115171152711537115471155711567115771158711597116071161711627116371164711657116671167711687116971170711717117271173711747117571176711777117871179711807118171182711837118471185711867118771188711897119071191711927119371194711957119671197711987119971200712017120271203712047120571206712077120871209712107121171212712137121471215712167121771218712197122071221712227122371224712257122671227712287122971230712317123271233712347123571236712377123871239712407124171242712437124471245712467124771248712497125071251712527125371254712557125671257712587125971260712617126271263712647126571266712677126871269712707127171272712737127471275712767127771278712797128071281712827128371284712857128671287712887128971290712917129271293712947129571296712977129871299713007130171302713037130471305713067130771308713097131071311713127131371314713157131671317713187131971320713217132271323713247132571326713277132871329713307133171332713337133471335713367133771338713397134071341713427134371344713457134671347713487134971350713517135271353713547135571356713577135871359713607136171362713637136471365713667136771368713697137071371713727137371374713757137671377713787137971380713817138271383713847138571386713877138871389713907139171392713937139471395713967139771398713997140071401714027140371404714057140671407714087140971410714117141271413714147141571416714177141871419714207142171422714237142471425714267142771428714297143071431714327143371434714357143671437714387143971440714417144271443714447144571446714477144871449714507145171452714537145471455714567145771458714597146071461714627146371464714657146671467714687146971470714717147271473714747147571476714777147871479714807148171482714837148471485714867148771488714897149071491714927149371494714957149671497714987149971500715017150271503715047150571506715077150871509715107151171512715137151471515715167151771518715197152071521715227152371524715257152671527715287152971530715317153271533715347153571536715377153871539715407154171542715437154471545715467154771548715497155071551715527155371554715557155671557715587155971560715617156271563715647156571566715677156871569715707157171572715737157471575715767157771578715797158071581715827158371584715857158671587715887158971590715917159271593715947159571596715977159871599716007160171602716037160471605716067160771608716097161071611716127161371614716157161671617716187161971620716217162271623716247162571626716277162871629716307163171632716337163471635716367163771638716397164071641716427164371644716457164671647716487164971650716517165271653716547165571656716577165871659716607166171662716637166471665716667166771668716697167071671716727167371674716757167671677716787167971680716817168271683716847168571686716877168871689716907169171692716937169471695716967169771698716997170071701717027170371704717057170671707717087170971710717117171271713717147171571716717177171871719717207172171722717237172471725717267172771728717297173071731717327173371734717357173671737717387173971740717417174271743717447174571746717477174871749717507175171752717537175471755717567175771758717597176071761717627176371764717657176671767717687176971770717717177271773717747177571776717777177871779717807178171782717837178471785717867178771788717897179071791717927179371794717957179671797717987179971800718017180271803718047180571806718077180871809718107181171812718137181471815718167181771818718197182071821718227182371824718257182671827718287182971830718317183271833718347183571836718377183871839718407184171842718437184471845718467184771848718497185071851718527185371854718557185671857718587185971860718617186271863718647186571866718677186871869718707187171872718737187471875718767187771878718797188071881718827188371884718857188671887718887188971890718917189271893718947189571896718977189871899719007190171902719037190471905719067190771908719097191071911719127191371914719157191671917719187191971920719217192271923719247192571926719277192871929719307193171932719337193471935719367193771938719397194071941719427194371944719457194671947719487194971950719517195271953719547195571956719577195871959719607196171962719637196471965719667196771968719697197071971719727197371974719757197671977719787197971980719817198271983719847198571986719877198871989719907199171992719937199471995719967199771998719997200072001720027200372004720057200672007720087200972010720117201272013720147201572016720177201872019720207202172022720237202472025720267202772028720297203072031720327203372034720357203672037720387203972040720417204272043720447204572046720477204872049720507205172052720537205472055720567205772058720597206072061720627206372064720657206672067720687206972070720717207272073720747207572076720777207872079720807208172082720837208472085720867208772088720897209072091720927209372094720957209672097720987209972100721017210272103721047210572106721077210872109721107211172112721137211472115721167211772118721197212072121721227212372124721257212672127721287212972130721317213272133721347213572136721377213872139721407214172142721437214472145721467214772148721497215072151721527215372154721557215672157721587215972160721617216272163721647216572166721677216872169721707217172172721737217472175721767217772178721797218072181721827218372184721857218672187721887218972190721917219272193721947219572196721977219872199722007220172202722037220472205722067220772208722097221072211722127221372214722157221672217722187221972220722217222272223722247222572226722277222872229722307223172232722337223472235722367223772238722397224072241722427224372244722457224672247722487224972250722517225272253722547225572256722577225872259722607226172262722637226472265722667226772268722697227072271722727227372274722757227672277722787227972280722817228272283722847228572286722877228872289722907229172292722937229472295722967229772298722997230072301723027230372304723057230672307723087230972310723117231272313723147231572316723177231872319723207232172322723237232472325723267232772328723297233072331723327233372334723357233672337723387233972340723417234272343723447234572346723477234872349723507235172352723537235472355723567235772358723597236072361723627236372364723657236672367723687236972370723717237272373723747237572376723777237872379723807238172382723837238472385723867238772388723897239072391723927239372394723957239672397723987239972400724017240272403724047240572406724077240872409724107241172412724137241472415724167241772418724197242072421724227242372424724257242672427724287242972430724317243272433724347243572436724377243872439724407244172442724437244472445724467244772448724497245072451724527245372454724557245672457724587245972460724617246272463724647246572466724677246872469724707247172472724737247472475724767247772478724797248072481724827248372484724857248672487724887248972490724917249272493724947249572496724977249872499725007250172502725037250472505725067250772508725097251072511725127251372514725157251672517725187251972520725217252272523725247252572526725277252872529725307253172532725337253472535725367253772538725397254072541725427254372544725457254672547725487254972550725517255272553725547255572556725577255872559725607256172562725637256472565725667256772568725697257072571725727257372574725757257672577725787257972580725817258272583725847258572586725877258872589725907259172592725937259472595725967259772598725997260072601726027260372604726057260672607726087260972610726117261272613726147261572616726177261872619726207262172622726237262472625726267262772628726297263072631726327263372634726357263672637726387263972640726417264272643726447264572646726477264872649726507265172652726537265472655726567265772658726597266072661726627266372664726657266672667726687266972670726717267272673726747267572676726777267872679726807268172682726837268472685726867268772688726897269072691726927269372694726957269672697726987269972700727017270272703727047270572706727077270872709727107271172712727137271472715727167271772718727197272072721727227272372724727257272672727727287272972730727317273272733727347273572736727377273872739727407274172742727437274472745727467274772748727497275072751727527275372754727557275672757727587275972760727617276272763727647276572766727677276872769727707277172772727737277472775727767277772778727797278072781727827278372784727857278672787727887278972790727917279272793727947279572796727977279872799728007280172802728037280472805728067280772808728097281072811728127281372814728157281672817728187281972820728217282272823728247282572826728277282872829728307283172832728337283472835728367283772838728397284072841728427284372844728457284672847728487284972850728517285272853728547285572856728577285872859728607286172862728637286472865728667286772868728697287072871728727287372874728757287672877728787287972880728817288272883728847288572886728877288872889728907289172892728937289472895728967289772898728997290072901729027290372904729057290672907729087290972910729117291272913729147291572916729177291872919729207292172922729237292472925729267292772928729297293072931729327293372934729357293672937729387293972940729417294272943729447294572946729477294872949729507295172952729537295472955729567295772958729597296072961729627296372964729657296672967729687296972970729717297272973729747297572976729777297872979729807298172982729837298472985729867298772988729897299072991729927299372994729957299672997729987299973000730017300273003730047300573006730077300873009730107301173012730137301473015730167301773018730197302073021730227302373024730257302673027730287302973030730317303273033730347303573036730377303873039730407304173042730437304473045730467304773048730497305073051730527305373054730557305673057730587305973060730617306273063730647306573066730677306873069730707307173072730737307473075730767307773078730797308073081730827308373084730857308673087730887308973090730917309273093730947309573096730977309873099731007310173102731037310473105731067310773108731097311073111731127311373114731157311673117731187311973120731217312273123731247312573126731277312873129731307313173132731337313473135731367313773138731397314073141731427314373144731457314673147731487314973150731517315273153731547315573156731577315873159731607316173162731637316473165731667316773168731697317073171731727317373174731757317673177731787317973180731817318273183731847318573186731877318873189731907319173192731937319473195731967319773198731997320073201732027320373204732057320673207732087320973210732117321273213732147321573216732177321873219732207322173222732237322473225732267322773228732297323073231732327323373234732357323673237732387323973240732417324273243732447324573246732477324873249732507325173252732537325473255732567325773258732597326073261732627326373264732657326673267732687326973270732717327273273732747327573276732777327873279732807328173282732837328473285732867328773288732897329073291732927329373294732957329673297732987329973300733017330273303733047330573306733077330873309733107331173312733137331473315733167331773318733197332073321733227332373324733257332673327733287332973330733317333273333733347333573336733377333873339733407334173342733437334473345733467334773348733497335073351733527335373354733557335673357733587335973360733617336273363733647336573366733677336873369733707337173372733737337473375733767337773378733797338073381733827338373384733857338673387733887338973390733917339273393733947339573396733977339873399734007340173402734037340473405734067340773408734097341073411734127341373414734157341673417734187341973420734217342273423734247342573426734277342873429734307343173432734337343473435734367343773438734397344073441734427344373444734457344673447734487344973450734517345273453734547345573456734577345873459734607346173462734637346473465734667346773468734697347073471734727347373474734757347673477734787347973480734817348273483734847348573486734877348873489734907349173492734937349473495734967349773498734997350073501735027350373504735057350673507735087350973510735117351273513735147351573516735177351873519735207352173522735237352473525735267352773528735297353073531735327353373534735357353673537735387353973540735417354273543735447354573546735477354873549735507355173552735537355473555735567355773558735597356073561735627356373564735657356673567735687356973570735717357273573735747357573576735777357873579735807358173582735837358473585735867358773588735897359073591735927359373594735957359673597735987359973600736017360273603736047360573606736077360873609736107361173612736137361473615736167361773618736197362073621736227362373624736257362673627736287362973630736317363273633736347363573636736377363873639736407364173642736437364473645736467364773648736497365073651736527365373654736557365673657736587365973660736617366273663736647366573666736677366873669736707367173672736737367473675736767367773678736797368073681736827368373684736857368673687736887368973690736917369273693736947369573696736977369873699737007370173702737037370473705737067370773708737097371073711737127371373714737157371673717737187371973720737217372273723737247372573726737277372873729737307373173732737337373473735737367373773738737397374073741737427374373744737457374673747737487374973750737517375273753737547375573756737577375873759737607376173762737637376473765737667376773768737697377073771737727377373774737757377673777737787377973780737817378273783737847378573786737877378873789737907379173792737937379473795737967379773798737997380073801738027380373804738057380673807738087380973810738117381273813738147381573816738177381873819738207382173822738237382473825738267382773828738297383073831738327383373834738357383673837738387383973840738417384273843738447384573846738477384873849738507385173852738537385473855738567385773858738597386073861738627386373864738657386673867738687386973870738717387273873738747387573876738777387873879738807388173882738837388473885738867388773888738897389073891738927389373894738957389673897738987389973900739017390273903739047390573906739077390873909739107391173912739137391473915739167391773918739197392073921739227392373924739257392673927739287392973930739317393273933739347393573936739377393873939739407394173942739437394473945739467394773948739497395073951739527395373954739557395673957739587395973960739617396273963739647396573966739677396873969739707397173972739737397473975739767397773978739797398073981739827398373984739857398673987739887398973990739917399273993739947399573996739977399873999740007400174002740037400474005740067400774008740097401074011740127401374014740157401674017740187401974020740217402274023740247402574026740277402874029740307403174032740337403474035740367403774038740397404074041740427404374044740457404674047740487404974050740517405274053740547405574056740577405874059740607406174062740637406474065740667406774068740697407074071740727407374074740757407674077740787407974080740817408274083740847408574086740877408874089740907409174092740937409474095740967409774098740997410074101741027410374104741057410674107741087410974110741117411274113741147411574116741177411874119741207412174122741237412474125741267412774128741297413074131741327413374134741357413674137741387413974140741417414274143741447414574146741477414874149741507415174152741537415474155741567415774158741597416074161741627416374164741657416674167741687416974170741717417274173741747417574176741777417874179741807418174182741837418474185741867418774188741897419074191741927419374194741957419674197741987419974200742017420274203742047420574206742077420874209742107421174212742137421474215742167421774218742197422074221742227422374224742257422674227742287422974230742317423274233742347423574236742377423874239742407424174242742437424474245742467424774248742497425074251742527425374254742557425674257742587425974260742617426274263742647426574266742677426874269742707427174272742737427474275742767427774278742797428074281742827428374284742857428674287742887428974290742917429274293742947429574296742977429874299743007430174302743037430474305743067430774308743097431074311743127431374314743157431674317743187431974320743217432274323743247432574326743277432874329743307433174332743337433474335743367433774338743397434074341743427434374344743457434674347743487434974350743517435274353743547435574356743577435874359743607436174362743637436474365743667436774368743697437074371743727437374374743757437674377743787437974380743817438274383743847438574386743877438874389743907439174392743937439474395743967439774398743997440074401744027440374404744057440674407744087440974410744117441274413744147441574416744177441874419744207442174422744237442474425744267442774428744297443074431744327443374434744357443674437744387443974440744417444274443744447444574446744477444874449744507445174452744537445474455744567445774458744597446074461744627446374464744657446674467744687446974470744717447274473744747447574476744777447874479744807448174482744837448474485744867448774488744897449074491744927449374494744957449674497744987449974500745017450274503745047450574506745077450874509745107451174512745137451474515745167451774518745197452074521745227452374524745257452674527745287452974530745317453274533745347453574536745377453874539745407454174542745437454474545745467454774548745497455074551745527455374554745557455674557745587455974560745617456274563745647456574566745677456874569745707457174572745737457474575745767457774578745797458074581745827458374584745857458674587745887458974590745917459274593745947459574596745977459874599746007460174602746037460474605746067460774608746097461074611746127461374614746157461674617746187461974620746217462274623746247462574626746277462874629746307463174632746337463474635746367463774638746397464074641746427464374644746457464674647746487464974650746517465274653746547465574656746577465874659746607466174662746637466474665746667466774668746697467074671746727467374674746757467674677746787467974680746817468274683746847468574686746877468874689746907469174692746937469474695746967469774698746997470074701747027470374704747057470674707747087470974710747117471274713747147471574716747177471874719747207472174722747237472474725747267472774728747297473074731747327473374734747357473674737747387473974740747417474274743747447474574746747477474874749747507475174752747537475474755747567475774758747597476074761747627476374764747657476674767747687476974770747717477274773747747477574776747777477874779747807478174782747837478474785747867478774788747897479074791747927479374794747957479674797747987479974800748017480274803748047480574806748077480874809748107481174812748137481474815748167481774818748197482074821748227482374824748257482674827748287482974830748317483274833748347483574836748377483874839748407484174842748437484474845748467484774848748497485074851748527485374854748557485674857748587485974860748617486274863748647486574866748677486874869748707487174872748737487474875748767487774878748797488074881748827488374884748857488674887748887488974890748917489274893748947489574896748977489874899749007490174902749037490474905749067490774908749097491074911749127491374914749157491674917749187491974920749217492274923749247492574926749277492874929749307493174932749337493474935749367493774938749397494074941749427494374944749457494674947749487494974950749517495274953749547495574956749577495874959749607496174962749637496474965749667496774968749697497074971749727497374974749757497674977749787497974980749817498274983749847498574986749877498874989749907499174992749937499474995749967499774998749997500075001750027500375004750057500675007750087500975010750117501275013750147501575016750177501875019750207502175022750237502475025750267502775028750297503075031750327503375034750357503675037750387503975040750417504275043750447504575046750477504875049750507505175052750537505475055750567505775058750597506075061750627506375064750657506675067750687506975070750717507275073750747507575076750777507875079750807508175082750837508475085750867508775088750897509075091750927509375094750957509675097750987509975100751017510275103751047510575106751077510875109751107511175112751137511475115751167511775118751197512075121751227512375124751257512675127751287512975130751317513275133751347513575136751377513875139751407514175142751437514475145751467514775148751497515075151751527515375154751557515675157751587515975160751617516275163751647516575166751677516875169751707517175172751737517475175751767517775178751797518075181751827518375184751857518675187751887518975190751917519275193751947519575196751977519875199752007520175202752037520475205752067520775208752097521075211752127521375214752157521675217752187521975220752217522275223752247522575226752277522875229752307523175232752337523475235752367523775238752397524075241752427524375244752457524675247752487524975250752517525275253752547525575256752577525875259752607526175262752637526475265752667526775268752697527075271752727527375274752757527675277752787527975280752817528275283752847528575286752877528875289752907529175292752937529475295752967529775298752997530075301753027530375304753057530675307753087530975310753117531275313753147531575316753177531875319753207532175322753237532475325753267532775328753297533075331753327533375334753357533675337753387533975340753417534275343753447534575346753477534875349753507535175352753537535475355753567535775358753597536075361753627536375364753657536675367753687536975370753717537275373753747537575376753777537875379753807538175382753837538475385753867538775388753897539075391753927539375394753957539675397753987539975400754017540275403754047540575406754077540875409754107541175412754137541475415754167541775418754197542075421754227542375424754257542675427754287542975430754317543275433754347543575436754377543875439754407544175442754437544475445754467544775448754497545075451754527545375454754557545675457754587545975460754617546275463754647546575466754677546875469754707547175472754737547475475754767547775478754797548075481754827548375484754857548675487754887548975490754917549275493754947549575496754977549875499755007550175502755037550475505755067550775508755097551075511755127551375514755157551675517755187551975520755217552275523755247552575526755277552875529755307553175532755337553475535755367553775538755397554075541755427554375544755457554675547755487554975550755517555275553755547555575556755577555875559755607556175562755637556475565755667556775568755697557075571755727557375574755757557675577755787557975580755817558275583755847558575586755877558875589755907559175592755937559475595755967559775598755997560075601756027560375604756057560675607756087560975610756117561275613756147561575616756177561875619756207562175622756237562475625756267562775628756297563075631756327563375634756357563675637756387563975640756417564275643756447564575646756477564875649756507565175652756537565475655756567565775658756597566075661756627566375664756657566675667756687566975670756717567275673756747567575676756777567875679756807568175682756837568475685756867568775688756897569075691756927569375694756957569675697756987569975700757017570275703757047570575706757077570875709757107571175712757137571475715757167571775718757197572075721757227572375724757257572675727757287572975730757317573275733757347573575736757377573875739757407574175742757437574475745757467574775748757497575075751757527575375754757557575675757757587575975760757617576275763757647576575766757677576875769757707577175772757737577475775757767577775778757797578075781757827578375784757857578675787757887578975790757917579275793757947579575796757977579875799758007580175802758037580475805758067580775808758097581075811758127581375814758157581675817758187581975820758217582275823758247582575826758277582875829758307583175832758337583475835758367583775838758397584075841758427584375844758457584675847758487584975850758517585275853758547585575856758577585875859758607586175862758637586475865758667586775868758697587075871758727587375874758757587675877758787587975880758817588275883758847588575886758877588875889758907589175892758937589475895758967589775898758997590075901759027590375904759057590675907759087590975910759117591275913759147591575916759177591875919759207592175922759237592475925759267592775928759297593075931759327593375934759357593675937759387593975940759417594275943759447594575946759477594875949759507595175952759537595475955759567595775958759597596075961759627596375964759657596675967759687596975970759717597275973759747597575976759777597875979759807598175982759837598475985759867598775988759897599075991759927599375994759957599675997759987599976000760017600276003760047600576006760077600876009760107601176012760137601476015760167601776018760197602076021760227602376024760257602676027760287602976030760317603276033760347603576036760377603876039760407604176042760437604476045760467604776048760497605076051760527605376054760557605676057760587605976060760617606276063760647606576066760677606876069760707607176072760737607476075760767607776078760797608076081760827608376084760857608676087760887608976090760917609276093760947609576096760977609876099761007610176102761037610476105761067610776108761097611076111761127611376114761157611676117761187611976120761217612276123761247612576126761277612876129761307613176132761337613476135761367613776138761397614076141761427614376144761457614676147761487614976150761517615276153761547615576156761577615876159761607616176162761637616476165761667616776168761697617076171761727617376174761757617676177761787617976180761817618276183761847618576186761877618876189761907619176192761937619476195761967619776198761997620076201762027620376204762057620676207762087620976210762117621276213762147621576216762177621876219762207622176222762237622476225762267622776228762297623076231762327623376234762357623676237762387623976240762417624276243762447624576246762477624876249762507625176252762537625476255762567625776258762597626076261762627626376264762657626676267762687626976270762717627276273762747627576276762777627876279762807628176282762837628476285762867628776288762897629076291762927629376294762957629676297762987629976300763017630276303763047630576306763077630876309763107631176312763137631476315763167631776318763197632076321763227632376324763257632676327763287632976330763317633276333763347633576336763377633876339763407634176342763437634476345763467634776348763497635076351763527635376354763557635676357763587635976360763617636276363763647636576366763677636876369763707637176372763737637476375763767637776378763797638076381763827638376384763857638676387763887638976390763917639276393763947639576396763977639876399764007640176402764037640476405764067640776408764097641076411764127641376414764157641676417764187641976420764217642276423764247642576426764277642876429764307643176432764337643476435764367643776438764397644076441764427644376444764457644676447764487644976450764517645276453764547645576456764577645876459764607646176462764637646476465764667646776468764697647076471764727647376474764757647676477764787647976480764817648276483764847648576486764877648876489764907649176492764937649476495764967649776498764997650076501765027650376504765057650676507765087650976510765117651276513765147651576516765177651876519765207652176522765237652476525765267652776528765297653076531765327653376534765357653676537765387653976540765417654276543765447654576546765477654876549765507655176552765537655476555765567655776558765597656076561765627656376564765657656676567765687656976570765717657276573765747657576576765777657876579765807658176582765837658476585765867658776588765897659076591765927659376594765957659676597765987659976600766017660276603766047660576606766077660876609766107661176612766137661476615766167661776618766197662076621766227662376624766257662676627766287662976630766317663276633766347663576636766377663876639766407664176642766437664476645766467664776648766497665076651766527665376654766557665676657766587665976660766617666276663766647666576666766677666876669766707667176672766737667476675766767667776678766797668076681766827668376684766857668676687766887668976690766917669276693766947669576696766977669876699767007670176702767037670476705767067670776708767097671076711767127671376714767157671676717767187671976720767217672276723767247672576726767277672876729767307673176732767337673476735767367673776738767397674076741767427674376744767457674676747767487674976750767517675276753767547675576756767577675876759767607676176762767637676476765767667676776768767697677076771767727677376774767757677676777767787677976780767817678276783767847678576786767877678876789767907679176792767937679476795767967679776798767997680076801768027680376804768057680676807768087680976810768117681276813768147681576816768177681876819768207682176822768237682476825768267682776828768297683076831768327683376834768357683676837768387683976840768417684276843768447684576846768477684876849768507685176852768537685476855768567685776858768597686076861768627686376864768657686676867768687686976870768717687276873768747687576876768777687876879768807688176882768837688476885768867688776888768897689076891768927689376894768957689676897768987689976900769017690276903769047690576906769077690876909769107691176912769137691476915769167691776918769197692076921769227692376924769257692676927769287692976930769317693276933769347693576936769377693876939769407694176942769437694476945769467694776948769497695076951769527695376954769557695676957769587695976960769617696276963769647696576966769677696876969769707697176972769737697476975769767697776978769797698076981769827698376984769857698676987769887698976990769917699276993769947699576996769977699876999770007700177002770037700477005770067700777008770097701077011770127701377014770157701677017770187701977020770217702277023770247702577026770277702877029770307703177032770337703477035770367703777038770397704077041770427704377044770457704677047770487704977050770517705277053770547705577056770577705877059770607706177062770637706477065770667706777068770697707077071770727707377074770757707677077770787707977080770817708277083770847708577086770877708877089770907709177092770937709477095770967709777098770997710077101771027710377104771057710677107771087710977110771117711277113771147711577116771177711877119771207712177122771237712477125771267712777128771297713077131771327713377134771357713677137771387713977140771417714277143771447714577146771477714877149771507715177152771537715477155771567715777158771597716077161771627716377164771657716677167771687716977170771717717277173771747717577176771777717877179771807718177182771837718477185771867718777188771897719077191771927719377194771957719677197771987719977200772017720277203772047720577206772077720877209772107721177212772137721477215772167721777218772197722077221772227722377224772257722677227772287722977230772317723277233772347723577236772377723877239772407724177242772437724477245772467724777248772497725077251772527725377254772557725677257772587725977260772617726277263772647726577266772677726877269772707727177272772737727477275772767727777278772797728077281772827728377284772857728677287772887728977290772917729277293772947729577296772977729877299773007730177302773037730477305773067730777308773097731077311773127731377314773157731677317773187731977320773217732277323773247732577326773277732877329773307733177332773337733477335773367733777338773397734077341773427734377344773457734677347773487734977350773517735277353773547735577356773577735877359773607736177362773637736477365773667736777368773697737077371773727737377374773757737677377773787737977380773817738277383773847738577386773877738877389773907739177392773937739477395773967739777398773997740077401774027740377404774057740677407774087740977410774117741277413774147741577416774177741877419774207742177422774237742477425774267742777428774297743077431774327743377434774357743677437774387743977440774417744277443774447744577446774477744877449774507745177452774537745477455774567745777458774597746077461774627746377464774657746677467774687746977470774717747277473774747747577476774777747877479774807748177482774837748477485774867748777488774897749077491774927749377494774957749677497774987749977500775017750277503775047750577506775077750877509775107751177512775137751477515775167751777518775197752077521775227752377524775257752677527775287752977530775317753277533775347753577536775377753877539775407754177542775437754477545775467754777548775497755077551775527755377554775557755677557775587755977560775617756277563775647756577566775677756877569775707757177572775737757477575775767757777578775797758077581775827758377584775857758677587775887758977590775917759277593775947759577596775977759877599776007760177602776037760477605776067760777608776097761077611776127761377614776157761677617776187761977620776217762277623776247762577626776277762877629776307763177632776337763477635776367763777638776397764077641776427764377644776457764677647776487764977650776517765277653776547765577656776577765877659776607766177662776637766477665776667766777668776697767077671776727767377674776757767677677776787767977680776817768277683776847768577686776877768877689776907769177692776937769477695776967769777698776997770077701777027770377704777057770677707777087770977710777117771277713777147771577716777177771877719777207772177722777237772477725777267772777728777297773077731777327773377734777357773677737777387773977740777417774277743777447774577746777477774877749777507775177752777537775477755777567775777758777597776077761777627776377764777657776677767777687776977770777717777277773777747777577776777777777877779777807778177782777837778477785777867778777788777897779077791777927779377794777957779677797777987779977800778017780277803778047780577806778077780877809778107781177812778137781477815778167781777818778197782077821778227782377824778257782677827778287782977830778317783277833778347783577836778377783877839778407784177842778437784477845778467784777848778497785077851778527785377854778557785677857778587785977860778617786277863778647786577866778677786877869778707787177872778737787477875778767787777878778797788077881778827788377884778857788677887778887788977890778917789277893778947789577896778977789877899779007790177902779037790477905779067790777908779097791077911779127791377914779157791677917779187791977920779217792277923779247792577926779277792877929779307793177932779337793477935779367793777938779397794077941779427794377944779457794677947779487794977950779517795277953779547795577956779577795877959779607796177962779637796477965779667796777968779697797077971779727797377974779757797677977779787797977980779817798277983779847798577986779877798877989779907799177992779937799477995779967799777998779997800078001780027800378004780057800678007780087800978010780117801278013780147801578016780177801878019780207802178022780237802478025780267802778028780297803078031780327803378034780357803678037780387803978040780417804278043780447804578046780477804878049780507805178052780537805478055780567805778058780597806078061780627806378064780657806678067780687806978070780717807278073780747807578076780777807878079780807808178082780837808478085780867808778088780897809078091780927809378094780957809678097780987809978100781017810278103781047810578106781077810878109781107811178112781137811478115781167811778118781197812078121781227812378124781257812678127781287812978130781317813278133781347813578136781377813878139781407814178142781437814478145781467814778148781497815078151781527815378154781557815678157781587815978160781617816278163781647816578166781677816878169781707817178172781737817478175781767817778178781797818078181781827818378184781857818678187781887818978190781917819278193781947819578196781977819878199782007820178202782037820478205782067820778208782097821078211782127821378214782157821678217782187821978220782217822278223782247822578226782277822878229782307823178232782337823478235782367823778238782397824078241782427824378244782457824678247782487824978250782517825278253782547825578256782577825878259782607826178262782637826478265782667826778268782697827078271782727827378274782757827678277782787827978280782817828278283782847828578286782877828878289782907829178292782937829478295782967829778298782997830078301783027830378304783057830678307783087830978310783117831278313783147831578316783177831878319783207832178322783237832478325783267832778328783297833078331783327833378334783357833678337783387833978340783417834278343783447834578346783477834878349783507835178352783537835478355783567835778358783597836078361783627836378364783657836678367783687836978370783717837278373783747837578376783777837878379783807838178382783837838478385783867838778388783897839078391783927839378394783957839678397783987839978400784017840278403784047840578406784077840878409784107841178412784137841478415784167841778418784197842078421784227842378424784257842678427784287842978430784317843278433784347843578436784377843878439784407844178442784437844478445784467844778448784497845078451784527845378454784557845678457784587845978460784617846278463784647846578466784677846878469784707847178472784737847478475784767847778478784797848078481784827848378484784857848678487784887848978490784917849278493784947849578496784977849878499785007850178502785037850478505785067850778508785097851078511785127851378514785157851678517785187851978520785217852278523785247852578526785277852878529785307853178532785337853478535785367853778538785397854078541785427854378544785457854678547785487854978550785517855278553785547855578556785577855878559785607856178562785637856478565785667856778568785697857078571785727857378574785757857678577785787857978580785817858278583785847858578586785877858878589785907859178592785937859478595785967859778598785997860078601786027860378604786057860678607786087860978610786117861278613786147861578616786177861878619786207862178622786237862478625786267862778628786297863078631786327863378634786357863678637786387863978640786417864278643786447864578646786477864878649786507865178652786537865478655786567865778658786597866078661786627866378664786657866678667786687866978670786717867278673786747867578676786777867878679786807868178682786837868478685786867868778688786897869078691786927869378694786957869678697786987869978700787017870278703787047870578706787077870878709787107871178712787137871478715787167871778718787197872078721787227872378724787257872678727787287872978730787317873278733787347873578736787377873878739787407874178742787437874478745787467874778748787497875078751787527875378754787557875678757787587875978760787617876278763787647876578766787677876878769787707877178772787737877478775787767877778778787797878078781787827878378784787857878678787787887878978790787917879278793787947879578796787977879878799788007880178802788037880478805788067880778808788097881078811788127881378814788157881678817788187881978820788217882278823788247882578826788277882878829788307883178832788337883478835788367883778838788397884078841788427884378844788457884678847788487884978850788517885278853788547885578856788577885878859788607886178862788637886478865788667886778868788697887078871788727887378874788757887678877788787887978880788817888278883788847888578886788877888878889788907889178892788937889478895788967889778898788997890078901789027890378904789057890678907789087890978910789117891278913789147891578916789177891878919789207892178922789237892478925789267892778928789297893078931789327893378934789357893678937789387893978940789417894278943789447894578946789477894878949789507895178952789537895478955789567895778958789597896078961789627896378964789657896678967789687896978970789717897278973789747897578976789777897878979789807898178982789837898478985789867898778988789897899078991789927899378994789957899678997789987899979000790017900279003790047900579006790077900879009790107901179012790137901479015790167901779018790197902079021790227902379024790257902679027790287902979030790317903279033790347903579036790377903879039790407904179042790437904479045790467904779048790497905079051790527905379054790557905679057790587905979060790617906279063790647906579066790677906879069790707907179072790737907479075790767907779078790797908079081790827908379084790857908679087790887908979090790917909279093790947909579096790977909879099791007910179102791037910479105791067910779108791097911079111791127911379114791157911679117791187911979120791217912279123791247912579126791277912879129791307913179132791337913479135791367913779138791397914079141791427914379144791457914679147791487914979150791517915279153791547915579156791577915879159791607916179162791637916479165791667916779168791697917079171791727917379174791757917679177791787917979180791817918279183791847918579186791877918879189791907919179192791937919479195791967919779198791997920079201792027920379204792057920679207792087920979210792117921279213792147921579216792177921879219792207922179222792237922479225792267922779228792297923079231792327923379234792357923679237792387923979240792417924279243792447924579246792477924879249792507925179252792537925479255792567925779258792597926079261792627926379264792657926679267792687926979270792717927279273792747927579276792777927879279792807928179282792837928479285792867928779288792897929079291792927929379294792957929679297792987929979300793017930279303793047930579306793077930879309793107931179312793137931479315793167931779318793197932079321793227932379324793257932679327793287932979330793317933279333793347933579336793377933879339793407934179342793437934479345793467934779348793497935079351793527935379354793557935679357793587935979360793617936279363793647936579366793677936879369793707937179372793737937479375793767937779378793797938079381793827938379384793857938679387793887938979390793917939279393793947939579396793977939879399794007940179402794037940479405794067940779408794097941079411794127941379414794157941679417794187941979420794217942279423794247942579426794277942879429794307943179432794337943479435794367943779438794397944079441794427944379444794457944679447794487944979450794517945279453794547945579456794577945879459794607946179462794637946479465794667946779468794697947079471794727947379474794757947679477794787947979480794817948279483794847948579486794877948879489794907949179492794937949479495794967949779498794997950079501795027950379504795057950679507795087950979510795117951279513795147951579516795177951879519795207952179522795237952479525795267952779528795297953079531795327953379534795357953679537795387953979540795417954279543795447954579546795477954879549795507955179552795537955479555795567955779558795597956079561795627956379564795657956679567795687956979570795717957279573795747957579576795777957879579795807958179582795837958479585795867958779588795897959079591795927959379594795957959679597795987959979600796017960279603796047960579606796077960879609796107961179612796137961479615796167961779618796197962079621796227962379624796257962679627796287962979630796317963279633796347963579636796377963879639796407964179642796437964479645796467964779648796497965079651796527965379654796557965679657796587965979660796617966279663796647966579666796677966879669796707967179672796737967479675796767967779678796797968079681796827968379684796857968679687796887968979690796917969279693796947969579696796977969879699797007970179702797037970479705797067970779708797097971079711797127971379714797157971679717797187971979720797217972279723797247972579726797277972879729797307973179732797337973479735797367973779738797397974079741797427974379744797457974679747797487974979750797517975279753797547975579756797577975879759797607976179762797637976479765797667976779768797697977079771797727977379774797757977679777797787977979780797817978279783797847978579786797877978879789797907979179792797937979479795797967979779798797997980079801798027980379804798057980679807798087980979810798117981279813798147981579816798177981879819798207982179822798237982479825798267982779828798297983079831798327983379834798357983679837798387983979840798417984279843798447984579846798477984879849798507985179852798537985479855798567985779858798597986079861798627986379864798657986679867798687986979870798717987279873798747987579876798777987879879798807988179882798837988479885798867988779888798897989079891798927989379894798957989679897798987989979900799017990279903799047990579906799077990879909799107991179912799137991479915799167991779918799197992079921799227992379924799257992679927799287992979930799317993279933799347993579936799377993879939799407994179942799437994479945799467994779948799497995079951799527995379954799557995679957799587995979960799617996279963799647996579966799677996879969799707997179972799737997479975799767997779978799797998079981799827998379984799857998679987799887998979990799917999279993799947999579996799977999879999800008000180002800038000480005800068000780008800098001080011800128001380014800158001680017800188001980020800218002280023800248002580026800278002880029800308003180032800338003480035800368003780038800398004080041800428004380044800458004680047800488004980050800518005280053800548005580056800578005880059800608006180062800638006480065800668006780068800698007080071800728007380074800758007680077800788007980080800818008280083800848008580086800878008880089800908009180092800938009480095800968009780098800998010080101801028010380104801058010680107801088010980110801118011280113801148011580116801178011880119801208012180122801238012480125801268012780128801298013080131801328013380134801358013680137801388013980140801418014280143801448014580146801478014880149801508015180152801538015480155801568015780158801598016080161801628016380164801658016680167801688016980170801718017280173801748017580176801778017880179801808018180182801838018480185801868018780188801898019080191801928019380194801958019680197801988019980200802018020280203802048020580206802078020880209802108021180212802138021480215802168021780218802198022080221802228022380224802258022680227802288022980230802318023280233802348023580236802378023880239802408024180242802438024480245802468024780248802498025080251802528025380254802558025680257802588025980260802618026280263802648026580266802678026880269802708027180272802738027480275802768027780278802798028080281802828028380284802858028680287802888028980290802918029280293802948029580296802978029880299803008030180302803038030480305803068030780308803098031080311803128031380314803158031680317803188031980320803218032280323803248032580326803278032880329803308033180332803338033480335803368033780338803398034080341803428034380344803458034680347803488034980350803518035280353803548035580356803578035880359803608036180362803638036480365803668036780368803698037080371803728037380374803758037680377803788037980380803818038280383803848038580386803878038880389803908039180392803938039480395803968039780398803998040080401804028040380404804058040680407804088040980410804118041280413804148041580416804178041880419804208042180422804238042480425804268042780428804298043080431804328043380434804358043680437804388043980440804418044280443804448044580446804478044880449804508045180452804538045480455804568045780458804598046080461804628046380464804658046680467804688046980470804718047280473804748047580476804778047880479804808048180482804838048480485804868048780488804898049080491804928049380494804958049680497804988049980500805018050280503805048050580506805078050880509805108051180512805138051480515805168051780518805198052080521805228052380524805258052680527805288052980530805318053280533805348053580536805378053880539805408054180542805438054480545805468054780548805498055080551805528055380554805558055680557805588055980560805618056280563805648056580566805678056880569805708057180572805738057480575805768057780578805798058080581805828058380584805858058680587805888058980590805918059280593805948059580596805978059880599806008060180602806038060480605806068060780608806098061080611806128061380614806158061680617806188061980620806218062280623806248062580626806278062880629806308063180632806338063480635806368063780638806398064080641806428064380644806458064680647806488064980650806518065280653806548065580656806578065880659806608066180662806638066480665806668066780668806698067080671806728067380674806758067680677806788067980680806818068280683806848068580686806878068880689806908069180692806938069480695806968069780698806998070080701807028070380704807058070680707807088070980710807118071280713807148071580716807178071880719807208072180722807238072480725807268072780728807298073080731807328073380734807358073680737807388073980740807418074280743807448074580746807478074880749807508075180752807538075480755807568075780758807598076080761807628076380764807658076680767807688076980770807718077280773807748077580776807778077880779807808078180782807838078480785807868078780788807898079080791807928079380794807958079680797807988079980800808018080280803808048080580806808078080880809808108081180812808138081480815808168081780818808198082080821808228082380824808258082680827808288082980830808318083280833808348083580836808378083880839808408084180842808438084480845808468084780848808498085080851808528085380854808558085680857808588085980860808618086280863808648086580866808678086880869808708087180872808738087480875808768087780878808798088080881808828088380884808858088680887808888088980890808918089280893808948089580896808978089880899809008090180902809038090480905809068090780908809098091080911809128091380914809158091680917809188091980920809218092280923809248092580926809278092880929809308093180932809338093480935809368093780938809398094080941809428094380944809458094680947809488094980950809518095280953809548095580956809578095880959809608096180962809638096480965809668096780968809698097080971809728097380974809758097680977809788097980980809818098280983809848098580986809878098880989809908099180992809938099480995809968099780998809998100081001810028100381004810058100681007810088100981010810118101281013810148101581016810178101881019810208102181022810238102481025810268102781028810298103081031810328103381034810358103681037810388103981040810418104281043810448104581046810478104881049810508105181052810538105481055810568105781058810598106081061810628106381064810658106681067810688106981070810718107281073810748107581076810778107881079810808108181082810838108481085810868108781088810898109081091810928109381094810958109681097810988109981100811018110281103811048110581106811078110881109811108111181112811138111481115811168111781118811198112081121811228112381124811258112681127811288112981130811318113281133811348113581136811378113881139811408114181142811438114481145811468114781148811498115081151811528115381154811558115681157811588115981160811618116281163811648116581166811678116881169811708117181172811738117481175811768117781178811798118081181811828118381184811858118681187811888118981190811918119281193811948119581196811978119881199812008120181202812038120481205812068120781208812098121081211812128121381214812158121681217812188121981220812218122281223812248122581226812278122881229812308123181232812338123481235812368123781238812398124081241812428124381244812458124681247812488124981250812518125281253812548125581256812578125881259812608126181262812638126481265812668126781268812698127081271812728127381274812758127681277812788127981280812818128281283812848128581286812878128881289812908129181292812938129481295812968129781298812998130081301813028130381304813058130681307813088130981310813118131281313813148131581316813178131881319813208132181322813238132481325813268132781328813298133081331813328133381334813358133681337813388133981340813418134281343813448134581346813478134881349813508135181352813538135481355813568135781358813598136081361813628136381364813658136681367813688136981370813718137281373813748137581376813778137881379813808138181382813838138481385813868138781388813898139081391813928139381394813958139681397813988139981400814018140281403814048140581406814078140881409814108141181412814138141481415814168141781418814198142081421814228142381424814258142681427814288142981430814318143281433814348143581436814378143881439814408144181442814438144481445814468144781448814498145081451814528145381454814558145681457814588145981460814618146281463814648146581466814678146881469814708147181472814738147481475814768147781478814798148081481814828148381484814858148681487814888148981490814918149281493814948149581496814978149881499815008150181502815038150481505815068150781508815098151081511815128151381514815158151681517815188151981520815218152281523815248152581526815278152881529815308153181532815338153481535815368153781538815398154081541815428154381544815458154681547815488154981550815518155281553815548155581556815578155881559815608156181562815638156481565815668156781568815698157081571815728157381574815758157681577815788157981580815818158281583815848158581586815878158881589815908159181592815938159481595815968159781598815998160081601816028160381604816058160681607816088160981610816118161281613816148161581616816178161881619816208162181622816238162481625816268162781628816298163081631816328163381634816358163681637816388163981640816418164281643816448164581646816478164881649816508165181652816538165481655816568165781658816598166081661816628166381664816658166681667816688166981670816718167281673816748167581676816778167881679816808168181682816838168481685816868168781688816898169081691816928169381694816958169681697816988169981700817018170281703817048170581706817078170881709817108171181712817138171481715817168171781718817198172081721817228172381724817258172681727817288172981730817318173281733817348173581736817378173881739817408174181742817438174481745817468174781748817498175081751817528175381754817558175681757817588175981760817618176281763817648176581766817678176881769817708177181772817738177481775817768177781778817798178081781817828178381784817858178681787817888178981790817918179281793817948179581796817978179881799818008180181802818038180481805818068180781808818098181081811818128181381814818158181681817818188181981820818218182281823818248182581826818278182881829818308183181832818338183481835818368183781838818398184081841818428184381844818458184681847818488184981850818518185281853818548185581856818578185881859818608186181862818638186481865818668186781868818698187081871818728187381874818758187681877818788187981880818818188281883818848188581886818878188881889818908189181892818938189481895818968189781898818998190081901819028190381904819058190681907819088190981910819118191281913819148191581916819178191881919819208192181922819238192481925819268192781928819298193081931819328193381934819358193681937819388193981940819418194281943819448194581946819478194881949819508195181952819538195481955819568195781958819598196081961819628196381964819658196681967819688196981970819718197281973819748197581976819778197881979819808198181982819838198481985819868198781988819898199081991819928199381994819958199681997819988199982000820018200282003820048200582006820078200882009820108201182012820138201482015820168201782018820198202082021820228202382024820258202682027820288202982030820318203282033820348203582036820378203882039820408204182042820438204482045820468204782048820498205082051820528205382054820558205682057820588205982060820618206282063820648206582066820678206882069820708207182072820738207482075820768207782078820798208082081820828208382084820858208682087820888208982090820918209282093820948209582096820978209882099821008210182102821038210482105821068210782108821098211082111821128211382114821158211682117821188211982120821218212282123821248212582126821278212882129821308213182132821338213482135821368213782138821398214082141821428214382144821458214682147821488214982150821518215282153821548215582156821578215882159821608216182162821638216482165821668216782168821698217082171821728217382174821758217682177821788217982180821818218282183821848218582186821878218882189821908219182192821938219482195821968219782198821998220082201822028220382204822058220682207822088220982210822118221282213822148221582216822178221882219822208222182222822238222482225822268222782228822298223082231822328223382234822358223682237822388223982240822418224282243822448224582246822478224882249822508225182252822538225482255822568225782258822598226082261822628226382264822658226682267822688226982270822718227282273822748227582276822778227882279822808228182282822838228482285822868228782288822898229082291822928229382294822958229682297822988229982300823018230282303823048230582306823078230882309823108231182312823138231482315823168231782318823198232082321823228232382324823258232682327823288232982330823318233282333823348233582336823378233882339823408234182342823438234482345823468234782348823498235082351823528235382354823558235682357823588235982360823618236282363823648236582366823678236882369823708237182372823738237482375823768237782378823798238082381823828238382384823858238682387823888238982390823918239282393823948239582396823978239882399824008240182402824038240482405824068240782408824098241082411824128241382414824158241682417824188241982420824218242282423824248242582426824278242882429824308243182432824338243482435824368243782438824398244082441824428244382444824458244682447824488244982450824518245282453824548245582456824578245882459824608246182462824638246482465824668246782468824698247082471824728247382474824758247682477824788247982480824818248282483824848248582486824878248882489824908249182492824938249482495824968249782498824998250082501825028250382504825058250682507825088250982510825118251282513825148251582516825178251882519825208252182522825238252482525825268252782528825298253082531825328253382534825358253682537825388253982540825418254282543825448254582546825478254882549825508255182552825538255482555825568255782558825598256082561825628256382564825658256682567825688256982570825718257282573825748257582576825778257882579825808258182582825838258482585825868258782588825898259082591825928259382594825958259682597825988259982600826018260282603826048260582606826078260882609826108261182612826138261482615826168261782618826198262082621826228262382624826258262682627826288262982630826318263282633826348263582636826378263882639826408264182642826438264482645826468264782648826498265082651826528265382654826558265682657826588265982660826618266282663826648266582666826678266882669826708267182672826738267482675826768267782678826798268082681826828268382684826858268682687826888268982690826918269282693826948269582696826978269882699827008270182702827038270482705827068270782708827098271082711827128271382714827158271682717827188271982720827218272282723827248272582726827278272882729827308273182732827338273482735827368273782738827398274082741827428274382744827458274682747827488274982750827518275282753827548275582756827578275882759827608276182762827638276482765827668276782768827698277082771827728277382774827758277682777827788277982780827818278282783827848278582786827878278882789827908279182792827938279482795827968279782798827998280082801828028280382804828058280682807828088280982810828118281282813828148281582816828178281882819828208282182822828238282482825828268282782828828298283082831828328283382834828358283682837828388283982840828418284282843828448284582846828478284882849828508285182852828538285482855828568285782858828598286082861828628286382864828658286682867828688286982870828718287282873828748287582876828778287882879828808288182882828838288482885828868288782888828898289082891828928289382894828958289682897828988289982900829018290282903829048290582906829078290882909829108291182912829138291482915829168291782918829198292082921829228292382924829258292682927829288292982930829318293282933829348293582936829378293882939829408294182942829438294482945829468294782948829498295082951829528295382954829558295682957829588295982960829618296282963829648296582966829678296882969829708297182972829738297482975829768297782978829798298082981829828298382984829858298682987829888298982990829918299282993829948299582996829978299882999830008300183002830038300483005830068300783008830098301083011830128301383014830158301683017830188301983020830218302283023830248302583026830278302883029830308303183032830338303483035830368303783038830398304083041830428304383044830458304683047830488304983050830518305283053830548305583056830578305883059830608306183062830638306483065830668306783068830698307083071830728307383074830758307683077830788307983080830818308283083830848308583086830878308883089830908309183092830938309483095830968309783098830998310083101831028310383104831058310683107831088310983110831118311283113831148311583116831178311883119831208312183122831238312483125831268312783128831298313083131831328313383134831358313683137831388313983140831418314283143831448314583146831478314883149831508315183152831538315483155831568315783158831598316083161831628316383164831658316683167831688316983170831718317283173831748317583176831778317883179831808318183182831838318483185831868318783188831898319083191831928319383194831958319683197831988319983200832018320283203832048320583206832078320883209832108321183212832138321483215832168321783218832198322083221832228322383224832258322683227832288322983230832318323283233832348323583236832378323883239832408324183242832438324483245832468324783248832498325083251832528325383254832558325683257832588325983260832618326283263832648326583266832678326883269832708327183272832738327483275832768327783278832798328083281832828328383284832858328683287832888328983290832918329283293832948329583296832978329883299833008330183302833038330483305833068330783308833098331083311833128331383314833158331683317833188331983320833218332283323833248332583326833278332883329833308333183332833338333483335833368333783338833398334083341833428334383344833458334683347833488334983350833518335283353833548335583356833578335883359833608336183362833638336483365833668336783368833698337083371833728337383374833758337683377833788337983380833818338283383833848338583386833878338883389833908339183392833938339483395833968339783398833998340083401834028340383404834058340683407834088340983410834118341283413834148341583416834178341883419834208342183422834238342483425834268342783428834298343083431834328343383434834358343683437834388343983440834418344283443834448344583446834478344883449834508345183452834538345483455834568345783458834598346083461834628346383464834658346683467834688346983470834718347283473834748347583476834778347883479834808348183482834838348483485834868348783488834898349083491834928349383494834958349683497834988349983500835018350283503835048350583506835078350883509835108351183512835138351483515835168351783518835198352083521835228352383524835258352683527835288352983530835318353283533835348353583536835378353883539835408354183542835438354483545835468354783548835498355083551835528355383554835558355683557835588355983560835618356283563835648356583566835678356883569835708357183572835738357483575835768357783578835798358083581835828358383584835858358683587835888358983590835918359283593835948359583596835978359883599836008360183602836038360483605836068360783608836098361083611836128361383614836158361683617836188361983620836218362283623836248362583626836278362883629836308363183632836338363483635836368363783638836398364083641836428364383644836458364683647836488364983650836518365283653836548365583656836578365883659836608366183662836638366483665836668366783668836698367083671836728367383674836758367683677836788367983680836818368283683836848368583686836878368883689836908369183692836938369483695836968369783698836998370083701837028370383704837058370683707837088370983710837118371283713837148371583716837178371883719837208372183722837238372483725837268372783728837298373083731837328373383734837358373683737837388373983740837418374283743837448374583746837478374883749837508375183752837538375483755837568375783758837598376083761837628376383764837658376683767837688376983770837718377283773837748377583776837778377883779837808378183782837838378483785837868378783788837898379083791837928379383794837958379683797837988379983800838018380283803838048380583806838078380883809838108381183812838138381483815838168381783818838198382083821838228382383824838258382683827838288382983830838318383283833838348383583836838378383883839838408384183842838438384483845838468384783848838498385083851838528385383854838558385683857838588385983860838618386283863838648386583866838678386883869838708387183872838738387483875838768387783878838798388083881838828388383884838858388683887838888388983890838918389283893838948389583896838978389883899839008390183902839038390483905839068390783908839098391083911839128391383914839158391683917839188391983920839218392283923839248392583926839278392883929839308393183932839338393483935839368393783938839398394083941839428394383944839458394683947839488394983950839518395283953839548395583956839578395883959839608396183962839638396483965839668396783968839698397083971839728397383974839758397683977839788397983980839818398283983839848398583986839878398883989839908399183992839938399483995839968399783998839998400084001840028400384004840058400684007840088400984010840118401284013840148401584016840178401884019840208402184022840238402484025840268402784028840298403084031840328403384034840358403684037840388403984040840418404284043840448404584046840478404884049840508405184052840538405484055840568405784058840598406084061840628406384064840658406684067840688406984070840718407284073840748407584076840778407884079840808408184082840838408484085840868408784088840898409084091840928409384094840958409684097840988409984100841018410284103841048410584106841078410884109841108411184112841138411484115841168411784118841198412084121841228412384124841258412684127841288412984130841318413284133841348413584136841378413884139841408414184142841438414484145841468414784148841498415084151841528415384154841558415684157841588415984160841618416284163841648416584166841678416884169841708417184172841738417484175841768417784178841798418084181841828418384184841858418684187841888418984190841918419284193841948419584196841978419884199842008420184202842038420484205842068420784208842098421084211842128421384214842158421684217842188421984220842218422284223842248422584226842278422884229842308423184232842338423484235842368423784238842398424084241842428424384244842458424684247842488424984250842518425284253842548425584256842578425884259842608426184262842638426484265842668426784268842698427084271842728427384274842758427684277842788427984280842818428284283842848428584286842878428884289842908429184292842938429484295842968429784298842998430084301843028430384304843058430684307843088430984310843118431284313843148431584316843178431884319843208432184322843238432484325843268432784328843298433084331843328433384334843358433684337843388433984340843418434284343843448434584346843478434884349843508435184352843538435484355843568435784358843598436084361843628436384364843658436684367843688436984370843718437284373843748437584376843778437884379843808438184382843838438484385843868438784388843898439084391843928439384394843958439684397843988439984400844018440284403844048440584406844078440884409844108441184412844138441484415844168441784418844198442084421844228442384424844258442684427844288442984430844318443284433844348443584436844378443884439844408444184442844438444484445844468444784448844498445084451844528445384454844558445684457844588445984460844618446284463844648446584466844678446884469844708447184472844738447484475844768447784478844798448084481844828448384484844858448684487844888448984490844918449284493844948449584496844978449884499845008450184502845038450484505845068450784508845098451084511845128451384514845158451684517845188451984520845218452284523845248452584526845278452884529845308453184532845338453484535845368453784538845398454084541845428454384544845458454684547845488454984550845518455284553845548455584556845578455884559845608456184562845638456484565845668456784568845698457084571845728457384574845758457684577845788457984580845818458284583845848458584586845878458884589845908459184592845938459484595845968459784598845998460084601846028460384604846058460684607846088460984610846118461284613846148461584616846178461884619846208462184622846238462484625846268462784628846298463084631846328463384634846358463684637846388463984640846418464284643846448464584646846478464884649846508465184652846538465484655846568465784658846598466084661846628466384664846658466684667846688466984670846718467284673846748467584676846778467884679846808468184682846838468484685846868468784688846898469084691846928469384694846958469684697846988469984700847018470284703847048470584706847078470884709847108471184712847138471484715847168471784718847198472084721847228472384724847258472684727847288472984730847318473284733847348473584736847378473884739847408474184742847438474484745847468474784748847498475084751847528475384754847558475684757847588475984760847618476284763847648476584766847678476884769847708477184772847738477484775847768477784778847798478084781847828478384784847858478684787847888478984790847918479284793847948479584796847978479884799848008480184802848038480484805848068480784808848098481084811848128481384814848158481684817848188481984820848218482284823848248482584826848278482884829848308483184832848338483484835848368483784838848398484084841848428484384844848458484684847848488484984850848518485284853848548485584856848578485884859848608486184862848638486484865848668486784868848698487084871848728487384874848758487684877848788487984880848818488284883848848488584886848878488884889848908489184892848938489484895848968489784898848998490084901849028490384904849058490684907849088490984910849118491284913849148491584916849178491884919849208492184922849238492484925849268492784928849298493084931849328493384934849358493684937849388493984940849418494284943849448494584946849478494884949849508495184952849538495484955849568495784958849598496084961849628496384964849658496684967849688496984970849718497284973849748497584976849778497884979849808498184982849838498484985849868498784988849898499084991849928499384994849958499684997849988499985000850018500285003850048500585006850078500885009850108501185012850138501485015850168501785018850198502085021850228502385024850258502685027850288502985030850318503285033850348503585036850378503885039850408504185042850438504485045850468504785048850498505085051850528505385054850558505685057850588505985060850618506285063850648506585066850678506885069850708507185072850738507485075850768507785078850798508085081850828508385084850858508685087850888508985090850918509285093850948509585096850978509885099851008510185102851038510485105851068510785108851098511085111851128511385114851158511685117851188511985120851218512285123851248512585126851278512885129851308513185132851338513485135851368513785138851398514085141851428514385144851458514685147851488514985150851518515285153851548515585156851578515885159851608516185162851638516485165851668516785168851698517085171851728517385174851758517685177851788517985180851818518285183851848518585186851878518885189851908519185192851938519485195851968519785198851998520085201852028520385204852058520685207852088520985210852118521285213852148521585216852178521885219852208522185222852238522485225852268522785228852298523085231852328523385234852358523685237852388523985240852418524285243852448524585246852478524885249852508525185252852538525485255852568525785258852598526085261852628526385264852658526685267852688526985270852718527285273852748527585276852778527885279852808528185282852838528485285852868528785288852898529085291852928529385294852958529685297852988529985300853018530285303853048530585306853078530885309853108531185312853138531485315853168531785318853198532085321853228532385324853258532685327853288532985330853318533285333853348533585336853378533885339853408534185342853438534485345853468534785348853498535085351853528535385354853558535685357853588535985360853618536285363853648536585366853678536885369853708537185372853738537485375853768537785378853798538085381853828538385384853858538685387853888538985390853918539285393853948539585396853978539885399854008540185402854038540485405854068540785408854098541085411854128541385414854158541685417854188541985420854218542285423854248542585426854278542885429854308543185432854338543485435854368543785438854398544085441854428544385444854458544685447854488544985450854518545285453854548545585456854578545885459854608546185462854638546485465854668546785468854698547085471854728547385474854758547685477854788547985480854818548285483854848548585486854878548885489854908549185492854938549485495854968549785498854998550085501855028550385504855058550685507855088550985510855118551285513855148551585516855178551885519855208552185522855238552485525855268552785528855298553085531855328553385534855358553685537855388553985540855418554285543855448554585546855478554885549855508555185552855538555485555855568555785558855598556085561855628556385564855658556685567855688556985570855718557285573855748557585576855778557885579855808558185582855838558485585855868558785588855898559085591855928559385594855958559685597855988559985600856018560285603856048560585606856078560885609856108561185612856138561485615856168561785618856198562085621856228562385624856258562685627856288562985630856318563285633856348563585636856378563885639856408564185642856438564485645856468564785648856498565085651856528565385654856558565685657856588565985660856618566285663856648566585666856678566885669856708567185672856738567485675856768567785678856798568085681856828568385684856858568685687856888568985690856918569285693856948569585696856978569885699857008570185702857038570485705857068570785708857098571085711857128571385714857158571685717857188571985720857218572285723857248572585726857278572885729857308573185732857338573485735857368573785738857398574085741857428574385744857458574685747857488574985750857518575285753857548575585756857578575885759857608576185762857638576485765857668576785768857698577085771857728577385774857758577685777857788577985780857818578285783857848578585786857878578885789857908579185792857938579485795857968579785798857998580085801858028580385804858058580685807858088580985810858118581285813858148581585816858178581885819858208582185822858238582485825
  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. /**
  10397. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10398. */
  10399. originMesh: Nullable<AbstractMesh>;
  10400. /**
  10401. * The ray that was used to perform the picking.
  10402. */
  10403. ray: Nullable<Ray>;
  10404. /**
  10405. * Gets the normal correspodning to the face the pick collided with
  10406. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10407. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10408. * @returns The normal correspodning to the face the pick collided with
  10409. */
  10410. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10411. /**
  10412. * Gets the texture coordinates of where the pick occured
  10413. * @returns the vector containing the coordnates of the texture
  10414. */
  10415. getTextureCoordinates(): Nullable<Vector2>;
  10416. }
  10417. }
  10418. declare module BABYLON {
  10419. /**
  10420. * Class representing a ray with position and direction
  10421. */
  10422. export class Ray {
  10423. /** origin point */
  10424. origin: Vector3;
  10425. /** direction */
  10426. direction: Vector3;
  10427. /** length of the ray */
  10428. length: number;
  10429. private static readonly TmpVector3;
  10430. private _tmpRay;
  10431. /**
  10432. * Creates a new ray
  10433. * @param origin origin point
  10434. * @param direction direction
  10435. * @param length length of the ray
  10436. */
  10437. constructor(
  10438. /** origin point */
  10439. origin: Vector3,
  10440. /** direction */
  10441. direction: Vector3,
  10442. /** length of the ray */
  10443. length?: number);
  10444. /**
  10445. * Checks if the ray intersects a box
  10446. * This does not account for the ray lenght by design to improve perfs.
  10447. * @param minimum bound of the box
  10448. * @param maximum bound of the box
  10449. * @param intersectionTreshold extra extend to be added to the box in all direction
  10450. * @returns if the box was hit
  10451. */
  10452. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10453. /**
  10454. * Checks if the ray intersects a box
  10455. * This does not account for the ray lenght by design to improve perfs.
  10456. * @param box the bounding box to check
  10457. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10458. * @returns if the box was hit
  10459. */
  10460. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10461. /**
  10462. * If the ray hits a sphere
  10463. * @param sphere the bounding sphere to check
  10464. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10465. * @returns true if it hits the sphere
  10466. */
  10467. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10468. /**
  10469. * If the ray hits a triange
  10470. * @param vertex0 triangle vertex
  10471. * @param vertex1 triangle vertex
  10472. * @param vertex2 triangle vertex
  10473. * @returns intersection information if hit
  10474. */
  10475. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10476. /**
  10477. * Checks if ray intersects a plane
  10478. * @param plane the plane to check
  10479. * @returns the distance away it was hit
  10480. */
  10481. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10482. /**
  10483. * Calculate the intercept of a ray on a given axis
  10484. * @param axis to check 'x' | 'y' | 'z'
  10485. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10486. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10487. */
  10488. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10489. /**
  10490. * Checks if ray intersects a mesh
  10491. * @param mesh the mesh to check
  10492. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10493. * @returns picking info of the intersecton
  10494. */
  10495. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10496. /**
  10497. * Checks if ray intersects a mesh
  10498. * @param meshes the meshes to check
  10499. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10500. * @param results array to store result in
  10501. * @returns Array of picking infos
  10502. */
  10503. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10504. private _comparePickingInfo;
  10505. private static smallnum;
  10506. private static rayl;
  10507. /**
  10508. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10509. * @param sega the first point of the segment to test the intersection against
  10510. * @param segb the second point of the segment to test the intersection against
  10511. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10512. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10513. */
  10514. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10515. /**
  10516. * Update the ray from viewport position
  10517. * @param x position
  10518. * @param y y position
  10519. * @param viewportWidth viewport width
  10520. * @param viewportHeight viewport height
  10521. * @param world world matrix
  10522. * @param view view matrix
  10523. * @param projection projection matrix
  10524. * @returns this ray updated
  10525. */
  10526. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10527. /**
  10528. * Creates a ray with origin and direction of 0,0,0
  10529. * @returns the new ray
  10530. */
  10531. static Zero(): Ray;
  10532. /**
  10533. * Creates a new ray from screen space and viewport
  10534. * @param x position
  10535. * @param y y position
  10536. * @param viewportWidth viewport width
  10537. * @param viewportHeight viewport height
  10538. * @param world world matrix
  10539. * @param view view matrix
  10540. * @param projection projection matrix
  10541. * @returns new ray
  10542. */
  10543. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10544. /**
  10545. * 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
  10546. * transformed to the given world matrix.
  10547. * @param origin The origin point
  10548. * @param end The end point
  10549. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10550. * @returns the new ray
  10551. */
  10552. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10553. /**
  10554. * Transforms a ray by a matrix
  10555. * @param ray ray to transform
  10556. * @param matrix matrix to apply
  10557. * @returns the resulting new ray
  10558. */
  10559. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10560. /**
  10561. * Transforms a ray by a matrix
  10562. * @param ray ray to transform
  10563. * @param matrix matrix to apply
  10564. * @param result ray to store result in
  10565. */
  10566. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10567. /**
  10568. * Unproject a ray from screen space to object space
  10569. * @param sourceX defines the screen space x coordinate to use
  10570. * @param sourceY defines the screen space y coordinate to use
  10571. * @param viewportWidth defines the current width of the viewport
  10572. * @param viewportHeight defines the current height of the viewport
  10573. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10574. * @param view defines the view matrix to use
  10575. * @param projection defines the projection matrix to use
  10576. */
  10577. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10578. }
  10579. /**
  10580. * Type used to define predicate used to select faces when a mesh intersection is detected
  10581. */
  10582. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10583. interface Scene {
  10584. /** @hidden */
  10585. _tempPickingRay: Nullable<Ray>;
  10586. /** @hidden */
  10587. _cachedRayForTransform: Ray;
  10588. /** @hidden */
  10589. _pickWithRayInverseMatrix: Matrix;
  10590. /** @hidden */
  10591. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10592. /** @hidden */
  10593. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10594. }
  10595. }
  10596. declare module BABYLON {
  10597. /**
  10598. * Groups all the scene component constants in one place to ease maintenance.
  10599. * @hidden
  10600. */
  10601. export class SceneComponentConstants {
  10602. static readonly NAME_EFFECTLAYER: string;
  10603. static readonly NAME_LAYER: string;
  10604. static readonly NAME_LENSFLARESYSTEM: string;
  10605. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10606. static readonly NAME_PARTICLESYSTEM: string;
  10607. static readonly NAME_GAMEPAD: string;
  10608. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10609. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10610. static readonly NAME_PREPASSRENDERER: string;
  10611. static readonly NAME_DEPTHRENDERER: string;
  10612. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10613. static readonly NAME_SPRITE: string;
  10614. static readonly NAME_OUTLINERENDERER: string;
  10615. static readonly NAME_PROCEDURALTEXTURE: string;
  10616. static readonly NAME_SHADOWGENERATOR: string;
  10617. static readonly NAME_OCTREE: string;
  10618. static readonly NAME_PHYSICSENGINE: string;
  10619. static readonly NAME_AUDIO: string;
  10620. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10621. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10622. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10623. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10624. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10625. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10626. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10627. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10628. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10629. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10630. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10631. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10632. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10633. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10634. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10635. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10636. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10637. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10638. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10639. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10640. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10641. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10642. static readonly STEP_AFTERRENDER_AUDIO: number;
  10643. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10644. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10645. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10646. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10647. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10648. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10649. static readonly STEP_POINTERMOVE_SPRITE: number;
  10650. static readonly STEP_POINTERDOWN_SPRITE: number;
  10651. static readonly STEP_POINTERUP_SPRITE: number;
  10652. }
  10653. /**
  10654. * This represents a scene component.
  10655. *
  10656. * This is used to decouple the dependency the scene is having on the different workloads like
  10657. * layers, post processes...
  10658. */
  10659. export interface ISceneComponent {
  10660. /**
  10661. * The name of the component. Each component must have a unique name.
  10662. */
  10663. name: string;
  10664. /**
  10665. * The scene the component belongs to.
  10666. */
  10667. scene: Scene;
  10668. /**
  10669. * Register the component to one instance of a scene.
  10670. */
  10671. register(): void;
  10672. /**
  10673. * Rebuilds the elements related to this component in case of
  10674. * context lost for instance.
  10675. */
  10676. rebuild(): void;
  10677. /**
  10678. * Disposes the component and the associated ressources.
  10679. */
  10680. dispose(): void;
  10681. }
  10682. /**
  10683. * This represents a SERIALIZABLE scene component.
  10684. *
  10685. * This extends Scene Component to add Serialization methods on top.
  10686. */
  10687. export interface ISceneSerializableComponent extends ISceneComponent {
  10688. /**
  10689. * Adds all the elements from the container to the scene
  10690. * @param container the container holding the elements
  10691. */
  10692. addFromContainer(container: AbstractScene): void;
  10693. /**
  10694. * Removes all the elements in the container from the scene
  10695. * @param container contains the elements to remove
  10696. * @param dispose if the removed element should be disposed (default: false)
  10697. */
  10698. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10699. /**
  10700. * Serializes the component data to the specified json object
  10701. * @param serializationObject The object to serialize to
  10702. */
  10703. serialize(serializationObject: any): void;
  10704. }
  10705. /**
  10706. * Strong typing of a Mesh related stage step action
  10707. */
  10708. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10709. /**
  10710. * Strong typing of a Evaluate Sub Mesh related stage step action
  10711. */
  10712. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10713. /**
  10714. * Strong typing of a Active Mesh related stage step action
  10715. */
  10716. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10717. /**
  10718. * Strong typing of a Camera related stage step action
  10719. */
  10720. export type CameraStageAction = (camera: Camera) => void;
  10721. /**
  10722. * Strong typing of a Camera Frame buffer related stage step action
  10723. */
  10724. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10725. /**
  10726. * Strong typing of a Render Target related stage step action
  10727. */
  10728. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10729. /**
  10730. * Strong typing of a RenderingGroup related stage step action
  10731. */
  10732. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10733. /**
  10734. * Strong typing of a Mesh Render related stage step action
  10735. */
  10736. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10737. /**
  10738. * Strong typing of a simple stage step action
  10739. */
  10740. export type SimpleStageAction = () => void;
  10741. /**
  10742. * Strong typing of a render target action.
  10743. */
  10744. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10745. /**
  10746. * Strong typing of a pointer move action.
  10747. */
  10748. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10749. /**
  10750. * Strong typing of a pointer up/down action.
  10751. */
  10752. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10753. /**
  10754. * Representation of a stage in the scene (Basically a list of ordered steps)
  10755. * @hidden
  10756. */
  10757. export class Stage<T extends Function> extends Array<{
  10758. index: number;
  10759. component: ISceneComponent;
  10760. action: T;
  10761. }> {
  10762. /**
  10763. * Hide ctor from the rest of the world.
  10764. * @param items The items to add.
  10765. */
  10766. private constructor();
  10767. /**
  10768. * Creates a new Stage.
  10769. * @returns A new instance of a Stage
  10770. */
  10771. static Create<T extends Function>(): Stage<T>;
  10772. /**
  10773. * Registers a step in an ordered way in the targeted stage.
  10774. * @param index Defines the position to register the step in
  10775. * @param component Defines the component attached to the step
  10776. * @param action Defines the action to launch during the step
  10777. */
  10778. registerStep(index: number, component: ISceneComponent, action: T): void;
  10779. /**
  10780. * Clears all the steps from the stage.
  10781. */
  10782. clear(): void;
  10783. }
  10784. }
  10785. declare module BABYLON {
  10786. interface Scene {
  10787. /** @hidden */
  10788. _pointerOverSprite: Nullable<Sprite>;
  10789. /** @hidden */
  10790. _pickedDownSprite: Nullable<Sprite>;
  10791. /** @hidden */
  10792. _tempSpritePickingRay: Nullable<Ray>;
  10793. /**
  10794. * All of the sprite managers added to this scene
  10795. * @see https://doc.babylonjs.com/babylon101/sprites
  10796. */
  10797. spriteManagers: Array<ISpriteManager>;
  10798. /**
  10799. * An event triggered when sprites rendering is about to start
  10800. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10801. */
  10802. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10803. /**
  10804. * An event triggered when sprites rendering is done
  10805. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10806. */
  10807. onAfterSpritesRenderingObservable: Observable<Scene>;
  10808. /** @hidden */
  10809. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10810. /** Launch a ray to try to pick a sprite in the scene
  10811. * @param x position on screen
  10812. * @param y position on screen
  10813. * @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
  10814. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10815. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10816. * @returns a PickingInfo
  10817. */
  10818. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10819. /** Use the given ray to pick a sprite in the scene
  10820. * @param ray The ray (in world space) to use to pick meshes
  10821. * @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
  10822. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10823. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10824. * @returns a PickingInfo
  10825. */
  10826. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10827. /** @hidden */
  10828. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10829. /** Launch a ray to try to pick sprites in the scene
  10830. * @param x position on screen
  10831. * @param y position on screen
  10832. * @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
  10833. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10834. * @returns a PickingInfo array
  10835. */
  10836. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10837. /** Use the given ray to pick sprites in the scene
  10838. * @param ray The ray (in world space) to use to pick meshes
  10839. * @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
  10840. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10841. * @returns a PickingInfo array
  10842. */
  10843. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10844. /**
  10845. * Force the sprite under the pointer
  10846. * @param sprite defines the sprite to use
  10847. */
  10848. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10849. /**
  10850. * Gets the sprite under the pointer
  10851. * @returns a Sprite or null if no sprite is under the pointer
  10852. */
  10853. getPointerOverSprite(): Nullable<Sprite>;
  10854. }
  10855. /**
  10856. * Defines the sprite scene component responsible to manage sprites
  10857. * in a given scene.
  10858. */
  10859. export class SpriteSceneComponent implements ISceneComponent {
  10860. /**
  10861. * The component name helpfull to identify the component in the list of scene components.
  10862. */
  10863. readonly name: string;
  10864. /**
  10865. * The scene the component belongs to.
  10866. */
  10867. scene: Scene;
  10868. /** @hidden */
  10869. private _spritePredicate;
  10870. /**
  10871. * Creates a new instance of the component for the given scene
  10872. * @param scene Defines the scene to register the component in
  10873. */
  10874. constructor(scene: Scene);
  10875. /**
  10876. * Registers the component in a given scene
  10877. */
  10878. register(): void;
  10879. /**
  10880. * Rebuilds the elements related to this component in case of
  10881. * context lost for instance.
  10882. */
  10883. rebuild(): void;
  10884. /**
  10885. * Disposes the component and the associated ressources.
  10886. */
  10887. dispose(): void;
  10888. private _pickSpriteButKeepRay;
  10889. private _pointerMove;
  10890. private _pointerDown;
  10891. private _pointerUp;
  10892. }
  10893. }
  10894. declare module BABYLON {
  10895. /** @hidden */
  10896. export var fogFragmentDeclaration: {
  10897. name: string;
  10898. shader: string;
  10899. };
  10900. }
  10901. declare module BABYLON {
  10902. /** @hidden */
  10903. export var fogFragment: {
  10904. name: string;
  10905. shader: string;
  10906. };
  10907. }
  10908. declare module BABYLON {
  10909. /** @hidden */
  10910. export var spritesPixelShader: {
  10911. name: string;
  10912. shader: string;
  10913. };
  10914. }
  10915. declare module BABYLON {
  10916. /** @hidden */
  10917. export var fogVertexDeclaration: {
  10918. name: string;
  10919. shader: string;
  10920. };
  10921. }
  10922. declare module BABYLON {
  10923. /** @hidden */
  10924. export var spritesVertexShader: {
  10925. name: string;
  10926. shader: string;
  10927. };
  10928. }
  10929. declare module BABYLON {
  10930. /**
  10931. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10932. */
  10933. export interface ISpriteManager extends IDisposable {
  10934. /**
  10935. * Gets manager's name
  10936. */
  10937. name: string;
  10938. /**
  10939. * Restricts the camera to viewing objects with the same layerMask.
  10940. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10941. */
  10942. layerMask: number;
  10943. /**
  10944. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10945. */
  10946. isPickable: boolean;
  10947. /**
  10948. * Gets the hosting scene
  10949. */
  10950. scene: Scene;
  10951. /**
  10952. * Specifies the rendering group id for this mesh (0 by default)
  10953. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10954. */
  10955. renderingGroupId: number;
  10956. /**
  10957. * Defines the list of sprites managed by the manager.
  10958. */
  10959. sprites: Array<Sprite>;
  10960. /**
  10961. * Gets or sets the spritesheet texture
  10962. */
  10963. texture: Texture;
  10964. /** Defines the default width of a cell in the spritesheet */
  10965. cellWidth: number;
  10966. /** Defines the default height of a cell in the spritesheet */
  10967. cellHeight: number;
  10968. /**
  10969. * Tests the intersection of a sprite with a specific ray.
  10970. * @param ray The ray we are sending to test the collision
  10971. * @param camera The camera space we are sending rays in
  10972. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10973. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10974. * @returns picking info or null.
  10975. */
  10976. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10977. /**
  10978. * Intersects the sprites with a ray
  10979. * @param ray defines the ray to intersect with
  10980. * @param camera defines the current active camera
  10981. * @param predicate defines a predicate used to select candidate sprites
  10982. * @returns null if no hit or a PickingInfo array
  10983. */
  10984. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10985. /**
  10986. * Renders the list of sprites on screen.
  10987. */
  10988. render(): void;
  10989. }
  10990. /**
  10991. * Class used to manage multiple sprites on the same spritesheet
  10992. * @see https://doc.babylonjs.com/babylon101/sprites
  10993. */
  10994. export class SpriteManager implements ISpriteManager {
  10995. /** defines the manager's name */
  10996. name: string;
  10997. /** Define the Url to load snippets */
  10998. static SnippetUrl: string;
  10999. /** Snippet ID if the manager was created from the snippet server */
  11000. snippetId: string;
  11001. /** Gets the list of sprites */
  11002. sprites: Sprite[];
  11003. /** Gets or sets the rendering group id (0 by default) */
  11004. renderingGroupId: number;
  11005. /** Gets or sets camera layer mask */
  11006. layerMask: number;
  11007. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11008. fogEnabled: boolean;
  11009. /** Gets or sets a boolean indicating if the sprites are pickable */
  11010. isPickable: boolean;
  11011. /** Defines the default width of a cell in the spritesheet */
  11012. cellWidth: number;
  11013. /** Defines the default height of a cell in the spritesheet */
  11014. cellHeight: number;
  11015. /** Associative array from JSON sprite data file */
  11016. private _cellData;
  11017. /** Array of sprite names from JSON sprite data file */
  11018. private _spriteMap;
  11019. /** True when packed cell data from JSON file is ready*/
  11020. private _packedAndReady;
  11021. private _textureContent;
  11022. /**
  11023. * An event triggered when the manager is disposed.
  11024. */
  11025. onDisposeObservable: Observable<SpriteManager>;
  11026. private _onDisposeObserver;
  11027. /**
  11028. * Callback called when the manager is disposed
  11029. */
  11030. set onDispose(callback: () => void);
  11031. private _capacity;
  11032. private _fromPacked;
  11033. private _spriteTexture;
  11034. private _epsilon;
  11035. private _scene;
  11036. private _vertexData;
  11037. private _buffer;
  11038. private _vertexBuffers;
  11039. private _indexBuffer;
  11040. private _effectBase;
  11041. private _effectFog;
  11042. /**
  11043. * Gets or sets the unique id of the sprite
  11044. */
  11045. uniqueId: number;
  11046. /**
  11047. * Gets the array of sprites
  11048. */
  11049. get children(): Sprite[];
  11050. /**
  11051. * Gets the hosting scene
  11052. */
  11053. get scene(): Scene;
  11054. /**
  11055. * Gets the capacity of the manager
  11056. */
  11057. get capacity(): number;
  11058. /**
  11059. * Gets or sets the spritesheet texture
  11060. */
  11061. get texture(): Texture;
  11062. set texture(value: Texture);
  11063. private _blendMode;
  11064. /**
  11065. * Blend mode use to render the particle, it can be any of
  11066. * the static Constants.ALPHA_x properties provided in this class.
  11067. * Default value is Constants.ALPHA_COMBINE
  11068. */
  11069. get blendMode(): number;
  11070. set blendMode(blendMode: number);
  11071. /** Disables writing to the depth buffer when rendering the sprites.
  11072. * It can be handy to disable depth writing when using textures without alpha channel
  11073. * and setting some specific blend modes.
  11074. */
  11075. disableDepthWrite: boolean;
  11076. /**
  11077. * Creates a new sprite manager
  11078. * @param name defines the manager's name
  11079. * @param imgUrl defines the sprite sheet url
  11080. * @param capacity defines the maximum allowed number of sprites
  11081. * @param cellSize defines the size of a sprite cell
  11082. * @param scene defines the hosting scene
  11083. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11084. * @param samplingMode defines the smapling mode to use with spritesheet
  11085. * @param fromPacked set to false; do not alter
  11086. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11087. */
  11088. constructor(
  11089. /** defines the manager's name */
  11090. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11091. /**
  11092. * Returns the string "SpriteManager"
  11093. * @returns "SpriteManager"
  11094. */
  11095. getClassName(): string;
  11096. private _makePacked;
  11097. private _appendSpriteVertex;
  11098. private _checkTextureAlpha;
  11099. /**
  11100. * Intersects the sprites with a ray
  11101. * @param ray defines the ray to intersect with
  11102. * @param camera defines the current active camera
  11103. * @param predicate defines a predicate used to select candidate sprites
  11104. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11105. * @returns null if no hit or a PickingInfo
  11106. */
  11107. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11108. /**
  11109. * Intersects the sprites with a ray
  11110. * @param ray defines the ray to intersect with
  11111. * @param camera defines the current active camera
  11112. * @param predicate defines a predicate used to select candidate sprites
  11113. * @returns null if no hit or a PickingInfo array
  11114. */
  11115. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11116. /**
  11117. * Render all child sprites
  11118. */
  11119. render(): void;
  11120. /**
  11121. * Release associated resources
  11122. */
  11123. dispose(): void;
  11124. /**
  11125. * Serializes the sprite manager to a JSON object
  11126. * @param serializeTexture defines if the texture must be serialized as well
  11127. * @returns the JSON object
  11128. */
  11129. serialize(serializeTexture?: boolean): any;
  11130. /**
  11131. * Parses a JSON object to create a new sprite manager.
  11132. * @param parsedManager The JSON object to parse
  11133. * @param scene The scene to create the sprite managerin
  11134. * @param rootUrl The root url to use to load external dependencies like texture
  11135. * @returns the new sprite manager
  11136. */
  11137. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11138. /**
  11139. * Creates a sprite manager from a snippet saved in a remote file
  11140. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11141. * @param url defines the url to load from
  11142. * @param scene defines the hosting scene
  11143. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11144. * @returns a promise that will resolve to the new sprite manager
  11145. */
  11146. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11147. /**
  11148. * Creates a sprite manager from a snippet saved by the sprite editor
  11149. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11150. * @param scene defines the hosting scene
  11151. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11152. * @returns a promise that will resolve to the new sprite manager
  11153. */
  11154. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11155. }
  11156. }
  11157. declare module BABYLON {
  11158. /** Interface used by value gradients (color, factor, ...) */
  11159. export interface IValueGradient {
  11160. /**
  11161. * Gets or sets the gradient value (between 0 and 1)
  11162. */
  11163. gradient: number;
  11164. }
  11165. /** Class used to store color4 gradient */
  11166. export class ColorGradient implements IValueGradient {
  11167. /**
  11168. * Gets or sets the gradient value (between 0 and 1)
  11169. */
  11170. gradient: number;
  11171. /**
  11172. * Gets or sets first associated color
  11173. */
  11174. color1: Color4;
  11175. /**
  11176. * Gets or sets second associated color
  11177. */
  11178. color2?: Color4 | undefined;
  11179. /**
  11180. * Creates a new color4 gradient
  11181. * @param gradient gets or sets the gradient value (between 0 and 1)
  11182. * @param color1 gets or sets first associated color
  11183. * @param color2 gets or sets first second color
  11184. */
  11185. constructor(
  11186. /**
  11187. * Gets or sets the gradient value (between 0 and 1)
  11188. */
  11189. gradient: number,
  11190. /**
  11191. * Gets or sets first associated color
  11192. */
  11193. color1: Color4,
  11194. /**
  11195. * Gets or sets second associated color
  11196. */
  11197. color2?: Color4 | undefined);
  11198. /**
  11199. * Will get a color picked randomly between color1 and color2.
  11200. * If color2 is undefined then color1 will be used
  11201. * @param result defines the target Color4 to store the result in
  11202. */
  11203. getColorToRef(result: Color4): void;
  11204. }
  11205. /** Class used to store color 3 gradient */
  11206. export class Color3Gradient implements IValueGradient {
  11207. /**
  11208. * Gets or sets the gradient value (between 0 and 1)
  11209. */
  11210. gradient: number;
  11211. /**
  11212. * Gets or sets the associated color
  11213. */
  11214. color: Color3;
  11215. /**
  11216. * Creates a new color3 gradient
  11217. * @param gradient gets or sets the gradient value (between 0 and 1)
  11218. * @param color gets or sets associated color
  11219. */
  11220. constructor(
  11221. /**
  11222. * Gets or sets the gradient value (between 0 and 1)
  11223. */
  11224. gradient: number,
  11225. /**
  11226. * Gets or sets the associated color
  11227. */
  11228. color: Color3);
  11229. }
  11230. /** Class used to store factor gradient */
  11231. export class FactorGradient implements IValueGradient {
  11232. /**
  11233. * Gets or sets the gradient value (between 0 and 1)
  11234. */
  11235. gradient: number;
  11236. /**
  11237. * Gets or sets first associated factor
  11238. */
  11239. factor1: number;
  11240. /**
  11241. * Gets or sets second associated factor
  11242. */
  11243. factor2?: number | undefined;
  11244. /**
  11245. * Creates a new factor gradient
  11246. * @param gradient gets or sets the gradient value (between 0 and 1)
  11247. * @param factor1 gets or sets first associated factor
  11248. * @param factor2 gets or sets second associated factor
  11249. */
  11250. constructor(
  11251. /**
  11252. * Gets or sets the gradient value (between 0 and 1)
  11253. */
  11254. gradient: number,
  11255. /**
  11256. * Gets or sets first associated factor
  11257. */
  11258. factor1: number,
  11259. /**
  11260. * Gets or sets second associated factor
  11261. */
  11262. factor2?: number | undefined);
  11263. /**
  11264. * Will get a number picked randomly between factor1 and factor2.
  11265. * If factor2 is undefined then factor1 will be used
  11266. * @returns the picked number
  11267. */
  11268. getFactor(): number;
  11269. }
  11270. /**
  11271. * Helper used to simplify some generic gradient tasks
  11272. */
  11273. export class GradientHelper {
  11274. /**
  11275. * Gets the current gradient from an array of IValueGradient
  11276. * @param ratio defines the current ratio to get
  11277. * @param gradients defines the array of IValueGradient
  11278. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11279. */
  11280. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11281. }
  11282. }
  11283. declare module BABYLON {
  11284. interface ThinEngine {
  11285. /**
  11286. * Creates a raw texture
  11287. * @param data defines the data to store in the texture
  11288. * @param width defines the width of the texture
  11289. * @param height defines the height of the texture
  11290. * @param format defines the format of the data
  11291. * @param generateMipMaps defines if the engine should generate the mip levels
  11292. * @param invertY defines if data must be stored with Y axis inverted
  11293. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11294. * @param compression defines the compression used (null by default)
  11295. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11296. * @returns the raw texture inside an InternalTexture
  11297. */
  11298. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11299. /**
  11300. * Update a raw texture
  11301. * @param texture defines the texture to update
  11302. * @param data defines the data to store in the texture
  11303. * @param format defines the format of the data
  11304. * @param invertY defines if data must be stored with Y axis inverted
  11305. */
  11306. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11307. /**
  11308. * Update a raw texture
  11309. * @param texture defines the texture to update
  11310. * @param data defines the data to store in the texture
  11311. * @param format defines the format of the data
  11312. * @param invertY defines if data must be stored with Y axis inverted
  11313. * @param compression defines the compression used (null by default)
  11314. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11315. */
  11316. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11317. /**
  11318. * Creates a new raw cube texture
  11319. * @param data defines the array of data to use to create each face
  11320. * @param size defines the size of the textures
  11321. * @param format defines the format of the data
  11322. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11323. * @param generateMipMaps defines if the engine should generate the mip levels
  11324. * @param invertY defines if data must be stored with Y axis inverted
  11325. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11326. * @param compression defines the compression used (null by default)
  11327. * @returns the cube texture as an InternalTexture
  11328. */
  11329. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11330. /**
  11331. * Update a raw cube texture
  11332. * @param texture defines the texture to udpdate
  11333. * @param data defines the data to store
  11334. * @param format defines the data format
  11335. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11336. * @param invertY defines if data must be stored with Y axis inverted
  11337. */
  11338. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11339. /**
  11340. * Update a raw cube texture
  11341. * @param texture defines the texture to udpdate
  11342. * @param data defines the data to store
  11343. * @param format defines the data format
  11344. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11345. * @param invertY defines if data must be stored with Y axis inverted
  11346. * @param compression defines the compression used (null by default)
  11347. */
  11348. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11349. /**
  11350. * Update a raw cube texture
  11351. * @param texture defines the texture to udpdate
  11352. * @param data defines the data to store
  11353. * @param format defines the data format
  11354. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11355. * @param invertY defines if data must be stored with Y axis inverted
  11356. * @param compression defines the compression used (null by default)
  11357. * @param level defines which level of the texture to update
  11358. */
  11359. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11360. /**
  11361. * Creates a new raw cube texture from a specified url
  11362. * @param url defines the url where the data is located
  11363. * @param scene defines the current scene
  11364. * @param size defines the size of the textures
  11365. * @param format defines the format of the data
  11366. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11367. * @param noMipmap defines if the engine should avoid generating the mip levels
  11368. * @param callback defines a callback used to extract texture data from loaded data
  11369. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11370. * @param onLoad defines a callback called when texture is loaded
  11371. * @param onError defines a callback called if there is an error
  11372. * @returns the cube texture as an InternalTexture
  11373. */
  11374. 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;
  11375. /**
  11376. * Creates a new raw cube texture from a specified url
  11377. * @param url defines the url where the data is located
  11378. * @param scene defines the current scene
  11379. * @param size defines the size of the textures
  11380. * @param format defines the format of the data
  11381. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11382. * @param noMipmap defines if the engine should avoid generating the mip levels
  11383. * @param callback defines a callback used to extract texture data from loaded data
  11384. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11385. * @param onLoad defines a callback called when texture is loaded
  11386. * @param onError defines a callback called if there is an error
  11387. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11388. * @param invertY defines if data must be stored with Y axis inverted
  11389. * @returns the cube texture as an InternalTexture
  11390. */
  11391. 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;
  11392. /**
  11393. * Creates a new raw 3D texture
  11394. * @param data defines the data used to create the texture
  11395. * @param width defines the width of the texture
  11396. * @param height defines the height of the texture
  11397. * @param depth defines the depth of the texture
  11398. * @param format defines the format of the texture
  11399. * @param generateMipMaps defines if the engine must generate mip levels
  11400. * @param invertY defines if data must be stored with Y axis inverted
  11401. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11402. * @param compression defines the compressed used (can be null)
  11403. * @param textureType defines the compressed used (can be null)
  11404. * @returns a new raw 3D texture (stored in an InternalTexture)
  11405. */
  11406. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11407. /**
  11408. * Update a raw 3D texture
  11409. * @param texture defines the texture to update
  11410. * @param data defines the data to store
  11411. * @param format defines the data format
  11412. * @param invertY defines if data must be stored with Y axis inverted
  11413. */
  11414. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11415. /**
  11416. * Update a raw 3D texture
  11417. * @param texture defines the texture to update
  11418. * @param data defines the data to store
  11419. * @param format defines the data format
  11420. * @param invertY defines if data must be stored with Y axis inverted
  11421. * @param compression defines the used compression (can be null)
  11422. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11423. */
  11424. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11425. /**
  11426. * Creates a new raw 2D array texture
  11427. * @param data defines the data used to create the texture
  11428. * @param width defines the width of the texture
  11429. * @param height defines the height of the texture
  11430. * @param depth defines the number of layers of the texture
  11431. * @param format defines the format of the texture
  11432. * @param generateMipMaps defines if the engine must generate mip levels
  11433. * @param invertY defines if data must be stored with Y axis inverted
  11434. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11435. * @param compression defines the compressed used (can be null)
  11436. * @param textureType defines the compressed used (can be null)
  11437. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11438. */
  11439. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11440. /**
  11441. * Update a raw 2D array texture
  11442. * @param texture defines the texture to update
  11443. * @param data defines the data to store
  11444. * @param format defines the data format
  11445. * @param invertY defines if data must be stored with Y axis inverted
  11446. */
  11447. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11448. /**
  11449. * Update a raw 2D array texture
  11450. * @param texture defines the texture to update
  11451. * @param data defines the data to store
  11452. * @param format defines the data format
  11453. * @param invertY defines if data must be stored with Y axis inverted
  11454. * @param compression defines the used compression (can be null)
  11455. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11456. */
  11457. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11458. }
  11459. }
  11460. declare module BABYLON {
  11461. /**
  11462. * Raw texture can help creating a texture directly from an array of data.
  11463. * This can be super useful if you either get the data from an uncompressed source or
  11464. * if you wish to create your texture pixel by pixel.
  11465. */
  11466. export class RawTexture extends Texture {
  11467. /**
  11468. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11469. */
  11470. format: number;
  11471. /**
  11472. * Instantiates a new RawTexture.
  11473. * Raw texture can help creating a texture directly from an array of data.
  11474. * This can be super useful if you either get the data from an uncompressed source or
  11475. * if you wish to create your texture pixel by pixel.
  11476. * @param data define the array of data to use to create the texture
  11477. * @param width define the width of the texture
  11478. * @param height define the height of the texture
  11479. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11480. * @param scene define the scene the texture belongs to
  11481. * @param generateMipMaps define whether mip maps should be generated or not
  11482. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11483. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11484. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11485. */
  11486. constructor(data: ArrayBufferView, width: number, height: number,
  11487. /**
  11488. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11489. */
  11490. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11491. /**
  11492. * Updates the texture underlying data.
  11493. * @param data Define the new data of the texture
  11494. */
  11495. update(data: ArrayBufferView): void;
  11496. /**
  11497. * Creates a luminance texture from some data.
  11498. * @param data Define the texture data
  11499. * @param width Define the width of the texture
  11500. * @param height Define the height of the texture
  11501. * @param scene Define the scene the texture belongs to
  11502. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11503. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11504. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11505. * @returns the luminance texture
  11506. */
  11507. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11508. /**
  11509. * Creates a luminance alpha texture from some data.
  11510. * @param data Define the texture data
  11511. * @param width Define the width of the texture
  11512. * @param height Define the height of the texture
  11513. * @param scene Define the scene the texture belongs to
  11514. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11515. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11516. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11517. * @returns the luminance alpha texture
  11518. */
  11519. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11520. /**
  11521. * Creates an alpha texture from some data.
  11522. * @param data Define the texture data
  11523. * @param width Define the width of the texture
  11524. * @param height Define the height of the texture
  11525. * @param scene Define the scene the texture belongs to
  11526. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11527. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11528. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11529. * @returns the alpha texture
  11530. */
  11531. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11532. /**
  11533. * Creates a RGB texture from some data.
  11534. * @param data Define the texture data
  11535. * @param width Define the width of the texture
  11536. * @param height Define the height of the texture
  11537. * @param scene Define the scene the texture belongs to
  11538. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11539. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11540. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11541. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11542. * @returns the RGB alpha texture
  11543. */
  11544. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11545. /**
  11546. * Creates a RGBA texture from some data.
  11547. * @param data Define the texture data
  11548. * @param width Define the width of the texture
  11549. * @param height Define the height of the texture
  11550. * @param scene Define the scene the texture belongs to
  11551. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11552. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11553. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11554. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11555. * @returns the RGBA texture
  11556. */
  11557. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11558. /**
  11559. * Creates a R texture from some data.
  11560. * @param data Define the texture data
  11561. * @param width Define the width of the texture
  11562. * @param height Define the height of the texture
  11563. * @param scene Define the scene the texture belongs to
  11564. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11565. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11566. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11567. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11568. * @returns the R texture
  11569. */
  11570. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11571. }
  11572. }
  11573. declare module BABYLON {
  11574. interface AbstractScene {
  11575. /**
  11576. * The list of procedural textures added to the scene
  11577. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11578. */
  11579. proceduralTextures: Array<ProceduralTexture>;
  11580. }
  11581. /**
  11582. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11583. * in a given scene.
  11584. */
  11585. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11586. /**
  11587. * The component name helpfull to identify the component in the list of scene components.
  11588. */
  11589. readonly name: string;
  11590. /**
  11591. * The scene the component belongs to.
  11592. */
  11593. scene: Scene;
  11594. /**
  11595. * Creates a new instance of the component for the given scene
  11596. * @param scene Defines the scene to register the component in
  11597. */
  11598. constructor(scene: Scene);
  11599. /**
  11600. * Registers the component in a given scene
  11601. */
  11602. register(): void;
  11603. /**
  11604. * Rebuilds the elements related to this component in case of
  11605. * context lost for instance.
  11606. */
  11607. rebuild(): void;
  11608. /**
  11609. * Disposes the component and the associated ressources.
  11610. */
  11611. dispose(): void;
  11612. private _beforeClear;
  11613. }
  11614. }
  11615. declare module BABYLON {
  11616. interface ThinEngine {
  11617. /**
  11618. * Creates a new render target cube texture
  11619. * @param size defines the size of the texture
  11620. * @param options defines the options used to create the texture
  11621. * @returns a new render target cube texture stored in an InternalTexture
  11622. */
  11623. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11624. }
  11625. }
  11626. declare module BABYLON {
  11627. /** @hidden */
  11628. export var proceduralVertexShader: {
  11629. name: string;
  11630. shader: string;
  11631. };
  11632. }
  11633. declare module BABYLON {
  11634. /**
  11635. * 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.
  11636. * This is the base class of any Procedural texture and contains most of the shareable code.
  11637. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11638. */
  11639. export class ProceduralTexture extends Texture {
  11640. isCube: boolean;
  11641. /**
  11642. * Define if the texture is enabled or not (disabled texture will not render)
  11643. */
  11644. isEnabled: boolean;
  11645. /**
  11646. * Define if the texture must be cleared before rendering (default is true)
  11647. */
  11648. autoClear: boolean;
  11649. /**
  11650. * Callback called when the texture is generated
  11651. */
  11652. onGenerated: () => void;
  11653. /**
  11654. * Event raised when the texture is generated
  11655. */
  11656. onGeneratedObservable: Observable<ProceduralTexture>;
  11657. /** @hidden */
  11658. _generateMipMaps: boolean;
  11659. /** @hidden **/
  11660. _effect: Effect;
  11661. /** @hidden */
  11662. _textures: {
  11663. [key: string]: Texture;
  11664. };
  11665. /** @hidden */
  11666. protected _fallbackTexture: Nullable<Texture>;
  11667. private _size;
  11668. private _currentRefreshId;
  11669. private _frameId;
  11670. private _refreshRate;
  11671. private _vertexBuffers;
  11672. private _indexBuffer;
  11673. private _uniforms;
  11674. private _samplers;
  11675. private _fragment;
  11676. private _floats;
  11677. private _ints;
  11678. private _floatsArrays;
  11679. private _colors3;
  11680. private _colors4;
  11681. private _vectors2;
  11682. private _vectors3;
  11683. private _matrices;
  11684. private _fallbackTextureUsed;
  11685. private _fullEngine;
  11686. private _cachedDefines;
  11687. private _contentUpdateId;
  11688. private _contentData;
  11689. /**
  11690. * Instantiates a new procedural texture.
  11691. * 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.
  11692. * This is the base class of any Procedural texture and contains most of the shareable code.
  11693. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11694. * @param name Define the name of the texture
  11695. * @param size Define the size of the texture to create
  11696. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11697. * @param scene Define the scene the texture belongs to
  11698. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11699. * @param generateMipMaps Define if the texture should creates mip maps or not
  11700. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11701. */
  11702. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11703. /**
  11704. * The effect that is created when initializing the post process.
  11705. * @returns The created effect corresponding the the postprocess.
  11706. */
  11707. getEffect(): Effect;
  11708. /**
  11709. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11710. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11711. */
  11712. getContent(): Nullable<ArrayBufferView>;
  11713. private _createIndexBuffer;
  11714. /** @hidden */
  11715. _rebuild(): void;
  11716. /**
  11717. * Resets the texture in order to recreate its associated resources.
  11718. * This can be called in case of context loss
  11719. */
  11720. reset(): void;
  11721. protected _getDefines(): string;
  11722. /**
  11723. * Is the texture ready to be used ? (rendered at least once)
  11724. * @returns true if ready, otherwise, false.
  11725. */
  11726. isReady(): boolean;
  11727. /**
  11728. * Resets the refresh counter of the texture and start bak from scratch.
  11729. * Could be useful to regenerate the texture if it is setup to render only once.
  11730. */
  11731. resetRefreshCounter(): void;
  11732. /**
  11733. * Set the fragment shader to use in order to render the texture.
  11734. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11735. */
  11736. setFragment(fragment: any): void;
  11737. /**
  11738. * Define the refresh rate of the texture or the rendering frequency.
  11739. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11740. */
  11741. get refreshRate(): number;
  11742. set refreshRate(value: number);
  11743. /** @hidden */
  11744. _shouldRender(): boolean;
  11745. /**
  11746. * Get the size the texture is rendering at.
  11747. * @returns the size (texture is always squared)
  11748. */
  11749. getRenderSize(): number;
  11750. /**
  11751. * Resize the texture to new value.
  11752. * @param size Define the new size the texture should have
  11753. * @param generateMipMaps Define whether the new texture should create mip maps
  11754. */
  11755. resize(size: number, generateMipMaps: boolean): void;
  11756. private _checkUniform;
  11757. /**
  11758. * Set a texture in the shader program used to render.
  11759. * @param name Define the name of the uniform samplers as defined in the shader
  11760. * @param texture Define the texture to bind to this sampler
  11761. * @return the texture itself allowing "fluent" like uniform updates
  11762. */
  11763. setTexture(name: string, texture: Texture): ProceduralTexture;
  11764. /**
  11765. * Set a float in the shader.
  11766. * @param name Define the name of the uniform as defined in the shader
  11767. * @param value Define the value to give to the uniform
  11768. * @return the texture itself allowing "fluent" like uniform updates
  11769. */
  11770. setFloat(name: string, value: number): ProceduralTexture;
  11771. /**
  11772. * Set a int in the shader.
  11773. * @param name Define the name of the uniform as defined in the shader
  11774. * @param value Define the value to give to the uniform
  11775. * @return the texture itself allowing "fluent" like uniform updates
  11776. */
  11777. setInt(name: string, value: number): ProceduralTexture;
  11778. /**
  11779. * Set an array of floats in the shader.
  11780. * @param name Define the name of the uniform as defined in the shader
  11781. * @param value Define the value to give to the uniform
  11782. * @return the texture itself allowing "fluent" like uniform updates
  11783. */
  11784. setFloats(name: string, value: number[]): ProceduralTexture;
  11785. /**
  11786. * Set a vec3 in the shader from a Color3.
  11787. * @param name Define the name of the uniform as defined in the shader
  11788. * @param value Define the value to give to the uniform
  11789. * @return the texture itself allowing "fluent" like uniform updates
  11790. */
  11791. setColor3(name: string, value: Color3): ProceduralTexture;
  11792. /**
  11793. * Set a vec4 in the shader from a Color4.
  11794. * @param name Define the name of the uniform as defined in the shader
  11795. * @param value Define the value to give to the uniform
  11796. * @return the texture itself allowing "fluent" like uniform updates
  11797. */
  11798. setColor4(name: string, value: Color4): ProceduralTexture;
  11799. /**
  11800. * Set a vec2 in the shader from a Vector2.
  11801. * @param name Define the name of the uniform as defined in the shader
  11802. * @param value Define the value to give to the uniform
  11803. * @return the texture itself allowing "fluent" like uniform updates
  11804. */
  11805. setVector2(name: string, value: Vector2): ProceduralTexture;
  11806. /**
  11807. * Set a vec3 in the shader from a Vector3.
  11808. * @param name Define the name of the uniform as defined in the shader
  11809. * @param value Define the value to give to the uniform
  11810. * @return the texture itself allowing "fluent" like uniform updates
  11811. */
  11812. setVector3(name: string, value: Vector3): ProceduralTexture;
  11813. /**
  11814. * Set a mat4 in the shader from a MAtrix.
  11815. * @param name Define the name of the uniform as defined in the shader
  11816. * @param value Define the value to give to the uniform
  11817. * @return the texture itself allowing "fluent" like uniform updates
  11818. */
  11819. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11820. /**
  11821. * Render the texture to its associated render target.
  11822. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11823. */
  11824. render(useCameraPostProcess?: boolean): void;
  11825. /**
  11826. * Clone the texture.
  11827. * @returns the cloned texture
  11828. */
  11829. clone(): ProceduralTexture;
  11830. /**
  11831. * Dispose the texture and release its asoociated resources.
  11832. */
  11833. dispose(): void;
  11834. }
  11835. }
  11836. declare module BABYLON {
  11837. /**
  11838. * This represents the base class for particle system in Babylon.
  11839. * 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.
  11840. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11841. * @example https://doc.babylonjs.com/babylon101/particles
  11842. */
  11843. export class BaseParticleSystem {
  11844. /**
  11845. * Source color is added to the destination color without alpha affecting the result
  11846. */
  11847. static BLENDMODE_ONEONE: number;
  11848. /**
  11849. * Blend current color and particle color using particle’s alpha
  11850. */
  11851. static BLENDMODE_STANDARD: number;
  11852. /**
  11853. * Add current color and particle color multiplied by particle’s alpha
  11854. */
  11855. static BLENDMODE_ADD: number;
  11856. /**
  11857. * Multiply current color with particle color
  11858. */
  11859. static BLENDMODE_MULTIPLY: number;
  11860. /**
  11861. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11862. */
  11863. static BLENDMODE_MULTIPLYADD: number;
  11864. /**
  11865. * List of animations used by the particle system.
  11866. */
  11867. animations: Animation[];
  11868. /**
  11869. * Gets or sets the unique id of the particle system
  11870. */
  11871. uniqueId: number;
  11872. /**
  11873. * The id of the Particle system.
  11874. */
  11875. id: string;
  11876. /**
  11877. * The friendly name of the Particle system.
  11878. */
  11879. name: string;
  11880. /**
  11881. * Snippet ID if the particle system was created from the snippet server
  11882. */
  11883. snippetId: string;
  11884. /**
  11885. * The rendering group used by the Particle system to chose when to render.
  11886. */
  11887. renderingGroupId: number;
  11888. /**
  11889. * The emitter represents the Mesh or position we are attaching the particle system to.
  11890. */
  11891. emitter: Nullable<AbstractMesh | Vector3>;
  11892. /**
  11893. * The maximum number of particles to emit per frame
  11894. */
  11895. emitRate: number;
  11896. /**
  11897. * If you want to launch only a few particles at once, that can be done, as well.
  11898. */
  11899. manualEmitCount: number;
  11900. /**
  11901. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11902. */
  11903. updateSpeed: number;
  11904. /**
  11905. * The amount of time the particle system is running (depends of the overall update speed).
  11906. */
  11907. targetStopDuration: number;
  11908. /**
  11909. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11910. */
  11911. disposeOnStop: boolean;
  11912. /**
  11913. * Minimum power of emitting particles.
  11914. */
  11915. minEmitPower: number;
  11916. /**
  11917. * Maximum power of emitting particles.
  11918. */
  11919. maxEmitPower: number;
  11920. /**
  11921. * Minimum life time of emitting particles.
  11922. */
  11923. minLifeTime: number;
  11924. /**
  11925. * Maximum life time of emitting particles.
  11926. */
  11927. maxLifeTime: number;
  11928. /**
  11929. * Minimum Size of emitting particles.
  11930. */
  11931. minSize: number;
  11932. /**
  11933. * Maximum Size of emitting particles.
  11934. */
  11935. maxSize: number;
  11936. /**
  11937. * Minimum scale of emitting particles on X axis.
  11938. */
  11939. minScaleX: number;
  11940. /**
  11941. * Maximum scale of emitting particles on X axis.
  11942. */
  11943. maxScaleX: number;
  11944. /**
  11945. * Minimum scale of emitting particles on Y axis.
  11946. */
  11947. minScaleY: number;
  11948. /**
  11949. * Maximum scale of emitting particles on Y axis.
  11950. */
  11951. maxScaleY: number;
  11952. /**
  11953. * Gets or sets the minimal initial rotation in radians.
  11954. */
  11955. minInitialRotation: number;
  11956. /**
  11957. * Gets or sets the maximal initial rotation in radians.
  11958. */
  11959. maxInitialRotation: number;
  11960. /**
  11961. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11962. */
  11963. minAngularSpeed: number;
  11964. /**
  11965. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11966. */
  11967. maxAngularSpeed: number;
  11968. /**
  11969. * The texture used to render each particle. (this can be a spritesheet)
  11970. */
  11971. particleTexture: Nullable<Texture>;
  11972. /**
  11973. * The layer mask we are rendering the particles through.
  11974. */
  11975. layerMask: number;
  11976. /**
  11977. * This can help using your own shader to render the particle system.
  11978. * The according effect will be created
  11979. */
  11980. customShader: any;
  11981. /**
  11982. * By default particle system starts as soon as they are created. This prevents the
  11983. * automatic start to happen and let you decide when to start emitting particles.
  11984. */
  11985. preventAutoStart: boolean;
  11986. private _noiseTexture;
  11987. /**
  11988. * Gets or sets a texture used to add random noise to particle positions
  11989. */
  11990. get noiseTexture(): Nullable<ProceduralTexture>;
  11991. set noiseTexture(value: Nullable<ProceduralTexture>);
  11992. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11993. noiseStrength: Vector3;
  11994. /**
  11995. * Callback triggered when the particle animation is ending.
  11996. */
  11997. onAnimationEnd: Nullable<() => void>;
  11998. /**
  11999. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12000. */
  12001. blendMode: number;
  12002. /**
  12003. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12004. * to override the particles.
  12005. */
  12006. forceDepthWrite: boolean;
  12007. /** 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 */
  12008. preWarmCycles: number;
  12009. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12010. preWarmStepOffset: number;
  12011. /**
  12012. * 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)
  12013. */
  12014. spriteCellChangeSpeed: number;
  12015. /**
  12016. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12017. */
  12018. startSpriteCellID: number;
  12019. /**
  12020. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12021. */
  12022. endSpriteCellID: number;
  12023. /**
  12024. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12025. */
  12026. spriteCellWidth: number;
  12027. /**
  12028. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12029. */
  12030. spriteCellHeight: number;
  12031. /**
  12032. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12033. */
  12034. spriteRandomStartCell: boolean;
  12035. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12036. translationPivot: Vector2;
  12037. /** @hidden */
  12038. protected _isAnimationSheetEnabled: boolean;
  12039. /**
  12040. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12041. */
  12042. beginAnimationOnStart: boolean;
  12043. /**
  12044. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12045. */
  12046. beginAnimationFrom: number;
  12047. /**
  12048. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12049. */
  12050. beginAnimationTo: number;
  12051. /**
  12052. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12053. */
  12054. beginAnimationLoop: boolean;
  12055. /**
  12056. * Gets or sets a world offset applied to all particles
  12057. */
  12058. worldOffset: Vector3;
  12059. /**
  12060. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12061. */
  12062. get isAnimationSheetEnabled(): boolean;
  12063. set isAnimationSheetEnabled(value: boolean);
  12064. /**
  12065. * Get hosting scene
  12066. * @returns the scene
  12067. */
  12068. getScene(): Scene;
  12069. /**
  12070. * You can use gravity if you want to give an orientation to your particles.
  12071. */
  12072. gravity: Vector3;
  12073. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12074. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12075. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12076. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12077. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12078. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12079. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12080. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12081. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12082. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12083. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12084. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12085. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12086. /**
  12087. * Defines the delay in milliseconds before starting the system (0 by default)
  12088. */
  12089. startDelay: number;
  12090. /**
  12091. * Gets the current list of drag gradients.
  12092. * You must use addDragGradient and removeDragGradient to udpate this list
  12093. * @returns the list of drag gradients
  12094. */
  12095. getDragGradients(): Nullable<Array<FactorGradient>>;
  12096. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12097. limitVelocityDamping: number;
  12098. /**
  12099. * Gets the current list of limit velocity gradients.
  12100. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12101. * @returns the list of limit velocity gradients
  12102. */
  12103. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12104. /**
  12105. * Gets the current list of color gradients.
  12106. * You must use addColorGradient and removeColorGradient to udpate this list
  12107. * @returns the list of color gradients
  12108. */
  12109. getColorGradients(): Nullable<Array<ColorGradient>>;
  12110. /**
  12111. * Gets the current list of size gradients.
  12112. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12113. * @returns the list of size gradients
  12114. */
  12115. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12116. /**
  12117. * Gets the current list of color remap gradients.
  12118. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12119. * @returns the list of color remap gradients
  12120. */
  12121. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12122. /**
  12123. * Gets the current list of alpha remap gradients.
  12124. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12125. * @returns the list of alpha remap gradients
  12126. */
  12127. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12128. /**
  12129. * Gets the current list of life time gradients.
  12130. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12131. * @returns the list of life time gradients
  12132. */
  12133. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12134. /**
  12135. * Gets the current list of angular speed gradients.
  12136. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12137. * @returns the list of angular speed gradients
  12138. */
  12139. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12140. /**
  12141. * Gets the current list of velocity gradients.
  12142. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12143. * @returns the list of velocity gradients
  12144. */
  12145. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12146. /**
  12147. * Gets the current list of start size gradients.
  12148. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12149. * @returns the list of start size gradients
  12150. */
  12151. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12152. /**
  12153. * Gets the current list of emit rate gradients.
  12154. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12155. * @returns the list of emit rate gradients
  12156. */
  12157. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12158. /**
  12159. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12160. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12161. */
  12162. get direction1(): Vector3;
  12163. set direction1(value: Vector3);
  12164. /**
  12165. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12166. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12167. */
  12168. get direction2(): Vector3;
  12169. set direction2(value: Vector3);
  12170. /**
  12171. * 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.
  12172. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12173. */
  12174. get minEmitBox(): Vector3;
  12175. set minEmitBox(value: Vector3);
  12176. /**
  12177. * 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.
  12178. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12179. */
  12180. get maxEmitBox(): Vector3;
  12181. set maxEmitBox(value: Vector3);
  12182. /**
  12183. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12184. */
  12185. color1: Color4;
  12186. /**
  12187. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12188. */
  12189. color2: Color4;
  12190. /**
  12191. * Color the particle will have at the end of its lifetime
  12192. */
  12193. colorDead: Color4;
  12194. /**
  12195. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12196. */
  12197. textureMask: Color4;
  12198. /**
  12199. * The particle emitter type defines the emitter used by the particle system.
  12200. * It can be for example box, sphere, or cone...
  12201. */
  12202. particleEmitterType: IParticleEmitterType;
  12203. /** @hidden */
  12204. _isSubEmitter: boolean;
  12205. /**
  12206. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12207. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12208. */
  12209. billboardMode: number;
  12210. protected _isBillboardBased: boolean;
  12211. /**
  12212. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12213. */
  12214. get isBillboardBased(): boolean;
  12215. set isBillboardBased(value: boolean);
  12216. /**
  12217. * The scene the particle system belongs to.
  12218. */
  12219. protected _scene: Scene;
  12220. /**
  12221. * Local cache of defines for image processing.
  12222. */
  12223. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12224. /**
  12225. * Default configuration related to image processing available in the standard Material.
  12226. */
  12227. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  12228. /**
  12229. * Gets the image processing configuration used either in this material.
  12230. */
  12231. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  12232. /**
  12233. * Sets the Default image processing configuration used either in the this material.
  12234. *
  12235. * If sets to null, the scene one is in use.
  12236. */
  12237. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  12238. /**
  12239. * Attaches a new image processing configuration to the Standard Material.
  12240. * @param configuration
  12241. */
  12242. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12243. /** @hidden */
  12244. protected _reset(): void;
  12245. /** @hidden */
  12246. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12247. /**
  12248. * Instantiates a particle system.
  12249. * 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.
  12250. * @param name The name of the particle system
  12251. */
  12252. constructor(name: string);
  12253. /**
  12254. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12255. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12256. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12257. * @returns the emitter
  12258. */
  12259. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12260. /**
  12261. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12262. * @param radius The radius of the hemisphere to emit from
  12263. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12264. * @returns the emitter
  12265. */
  12266. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12267. /**
  12268. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12269. * @param radius The radius of the sphere to emit from
  12270. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12271. * @returns the emitter
  12272. */
  12273. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12274. /**
  12275. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12276. * @param radius The radius of the sphere to emit from
  12277. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12278. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12279. * @returns the emitter
  12280. */
  12281. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12282. /**
  12283. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12284. * @param radius The radius of the emission cylinder
  12285. * @param height The height of the emission cylinder
  12286. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12287. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12288. * @returns the emitter
  12289. */
  12290. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12291. /**
  12292. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12293. * @param radius The radius of the cylinder to emit from
  12294. * @param height The height of the emission cylinder
  12295. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12296. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12297. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12298. * @returns the emitter
  12299. */
  12300. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12301. /**
  12302. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12303. * @param radius The radius of the cone to emit from
  12304. * @param angle The base angle of the cone
  12305. * @returns the emitter
  12306. */
  12307. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12308. /**
  12309. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12310. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12311. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12312. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12313. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12314. * @returns the emitter
  12315. */
  12316. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12317. }
  12318. }
  12319. declare module BABYLON {
  12320. /**
  12321. * Type of sub emitter
  12322. */
  12323. export enum SubEmitterType {
  12324. /**
  12325. * Attached to the particle over it's lifetime
  12326. */
  12327. ATTACHED = 0,
  12328. /**
  12329. * Created when the particle dies
  12330. */
  12331. END = 1
  12332. }
  12333. /**
  12334. * Sub emitter class used to emit particles from an existing particle
  12335. */
  12336. export class SubEmitter {
  12337. /**
  12338. * the particle system to be used by the sub emitter
  12339. */
  12340. particleSystem: ParticleSystem;
  12341. /**
  12342. * Type of the submitter (Default: END)
  12343. */
  12344. type: SubEmitterType;
  12345. /**
  12346. * 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)
  12347. * Note: This only is supported when using an emitter of type Mesh
  12348. */
  12349. inheritDirection: boolean;
  12350. /**
  12351. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12352. */
  12353. inheritedVelocityAmount: number;
  12354. /**
  12355. * Creates a sub emitter
  12356. * @param particleSystem the particle system to be used by the sub emitter
  12357. */
  12358. constructor(
  12359. /**
  12360. * the particle system to be used by the sub emitter
  12361. */
  12362. particleSystem: ParticleSystem);
  12363. /**
  12364. * Clones the sub emitter
  12365. * @returns the cloned sub emitter
  12366. */
  12367. clone(): SubEmitter;
  12368. /**
  12369. * Serialize current object to a JSON object
  12370. * @returns the serialized object
  12371. */
  12372. serialize(): any;
  12373. /** @hidden */
  12374. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  12375. /**
  12376. * Creates a new SubEmitter from a serialized JSON version
  12377. * @param serializationObject defines the JSON object to read from
  12378. * @param scene defines the hosting scene
  12379. * @param rootUrl defines the rootUrl for data loading
  12380. * @returns a new SubEmitter
  12381. */
  12382. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  12383. /** Release associated resources */
  12384. dispose(): void;
  12385. }
  12386. }
  12387. declare module BABYLON {
  12388. /** @hidden */
  12389. export var imageProcessingDeclaration: {
  12390. name: string;
  12391. shader: string;
  12392. };
  12393. }
  12394. declare module BABYLON {
  12395. /** @hidden */
  12396. export var imageProcessingFunctions: {
  12397. name: string;
  12398. shader: string;
  12399. };
  12400. }
  12401. declare module BABYLON {
  12402. /** @hidden */
  12403. export var particlesPixelShader: {
  12404. name: string;
  12405. shader: string;
  12406. };
  12407. }
  12408. declare module BABYLON {
  12409. /** @hidden */
  12410. export var particlesVertexShader: {
  12411. name: string;
  12412. shader: string;
  12413. };
  12414. }
  12415. declare module BABYLON {
  12416. /**
  12417. * This represents a particle system in Babylon.
  12418. * 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.
  12419. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12420. * @example https://doc.babylonjs.com/babylon101/particles
  12421. */
  12422. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12423. /**
  12424. * Billboard mode will only apply to Y axis
  12425. */
  12426. static readonly BILLBOARDMODE_Y: number;
  12427. /**
  12428. * Billboard mode will apply to all axes
  12429. */
  12430. static readonly BILLBOARDMODE_ALL: number;
  12431. /**
  12432. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12433. */
  12434. static readonly BILLBOARDMODE_STRETCHED: number;
  12435. /**
  12436. * This function can be defined to provide custom update for active particles.
  12437. * This function will be called instead of regular update (age, position, color, etc.).
  12438. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12439. */
  12440. updateFunction: (particles: Particle[]) => void;
  12441. private _emitterWorldMatrix;
  12442. /**
  12443. * This function can be defined to specify initial direction for every new particle.
  12444. * It by default use the emitterType defined function
  12445. */
  12446. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12447. /**
  12448. * This function can be defined to specify initial position for every new particle.
  12449. * It by default use the emitterType defined function
  12450. */
  12451. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12452. /**
  12453. * @hidden
  12454. */
  12455. _inheritedVelocityOffset: Vector3;
  12456. /**
  12457. * An event triggered when the system is disposed
  12458. */
  12459. onDisposeObservable: Observable<IParticleSystem>;
  12460. private _onDisposeObserver;
  12461. /**
  12462. * Sets a callback that will be triggered when the system is disposed
  12463. */
  12464. set onDispose(callback: () => void);
  12465. private _particles;
  12466. private _epsilon;
  12467. private _capacity;
  12468. private _stockParticles;
  12469. private _newPartsExcess;
  12470. private _vertexData;
  12471. private _vertexBuffer;
  12472. private _vertexBuffers;
  12473. private _spriteBuffer;
  12474. private _indexBuffer;
  12475. private _effect;
  12476. private _customEffect;
  12477. private _cachedDefines;
  12478. private _scaledColorStep;
  12479. private _colorDiff;
  12480. private _scaledDirection;
  12481. private _scaledGravity;
  12482. private _currentRenderId;
  12483. private _alive;
  12484. private _useInstancing;
  12485. private _started;
  12486. private _stopped;
  12487. private _actualFrame;
  12488. private _scaledUpdateSpeed;
  12489. private _vertexBufferSize;
  12490. /** @hidden */
  12491. _currentEmitRateGradient: Nullable<FactorGradient>;
  12492. /** @hidden */
  12493. _currentEmitRate1: number;
  12494. /** @hidden */
  12495. _currentEmitRate2: number;
  12496. /** @hidden */
  12497. _currentStartSizeGradient: Nullable<FactorGradient>;
  12498. /** @hidden */
  12499. _currentStartSize1: number;
  12500. /** @hidden */
  12501. _currentStartSize2: number;
  12502. private readonly _rawTextureWidth;
  12503. private _rampGradientsTexture;
  12504. private _useRampGradients;
  12505. /** Gets or sets a boolean indicating that ramp gradients must be used
  12506. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12507. */
  12508. get useRampGradients(): boolean;
  12509. set useRampGradients(value: boolean);
  12510. /**
  12511. * 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.
  12512. * 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: [])
  12513. */
  12514. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12515. private _subEmitters;
  12516. /**
  12517. * @hidden
  12518. * If the particle systems emitter should be disposed when the particle system is disposed
  12519. */
  12520. _disposeEmitterOnDispose: boolean;
  12521. /**
  12522. * The current active Sub-systems, this property is used by the root particle system only.
  12523. */
  12524. activeSubSystems: Array<ParticleSystem>;
  12525. /**
  12526. * Specifies if the particles are updated in emitter local space or world space
  12527. */
  12528. isLocal: boolean;
  12529. private _rootParticleSystem;
  12530. /**
  12531. * Gets the current list of active particles
  12532. */
  12533. get particles(): Particle[];
  12534. /**
  12535. * Gets the number of particles active at the same time.
  12536. * @returns The number of active particles.
  12537. */
  12538. getActiveCount(): number;
  12539. /**
  12540. * Returns the string "ParticleSystem"
  12541. * @returns a string containing the class name
  12542. */
  12543. getClassName(): string;
  12544. /**
  12545. * Gets a boolean indicating that the system is stopping
  12546. * @returns true if the system is currently stopping
  12547. */
  12548. isStopping(): boolean;
  12549. /**
  12550. * Gets the custom effect used to render the particles
  12551. * @param blendMode Blend mode for which the effect should be retrieved
  12552. * @returns The effect
  12553. */
  12554. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12555. /**
  12556. * Sets the custom effect used to render the particles
  12557. * @param effect The effect to set
  12558. * @param blendMode Blend mode for which the effect should be set
  12559. */
  12560. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12561. /** @hidden */
  12562. private _onBeforeDrawParticlesObservable;
  12563. /**
  12564. * Observable that will be called just before the particles are drawn
  12565. */
  12566. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12567. /**
  12568. * Gets the name of the particle vertex shader
  12569. */
  12570. get vertexShaderName(): string;
  12571. /**
  12572. * Instantiates a particle system.
  12573. * 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.
  12574. * @param name The name of the particle system
  12575. * @param capacity The max number of particles alive at the same time
  12576. * @param scene The scene the particle system belongs to
  12577. * @param customEffect a custom effect used to change the way particles are rendered by default
  12578. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12579. * @param epsilon Offset used to render the particles
  12580. */
  12581. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12582. private _addFactorGradient;
  12583. private _removeFactorGradient;
  12584. /**
  12585. * Adds a new life time gradient
  12586. * @param gradient defines the gradient to use (between 0 and 1)
  12587. * @param factor defines the life time factor to affect to the specified gradient
  12588. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12589. * @returns the current particle system
  12590. */
  12591. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12592. /**
  12593. * Remove a specific life time gradient
  12594. * @param gradient defines the gradient to remove
  12595. * @returns the current particle system
  12596. */
  12597. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12598. /**
  12599. * Adds a new size gradient
  12600. * @param gradient defines the gradient to use (between 0 and 1)
  12601. * @param factor defines the size factor to affect to the specified gradient
  12602. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12603. * @returns the current particle system
  12604. */
  12605. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12606. /**
  12607. * Remove a specific size gradient
  12608. * @param gradient defines the gradient to remove
  12609. * @returns the current particle system
  12610. */
  12611. removeSizeGradient(gradient: number): IParticleSystem;
  12612. /**
  12613. * Adds a new color remap gradient
  12614. * @param gradient defines the gradient to use (between 0 and 1)
  12615. * @param min defines the color remap minimal range
  12616. * @param max defines the color remap maximal range
  12617. * @returns the current particle system
  12618. */
  12619. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12620. /**
  12621. * Remove a specific color remap gradient
  12622. * @param gradient defines the gradient to remove
  12623. * @returns the current particle system
  12624. */
  12625. removeColorRemapGradient(gradient: number): IParticleSystem;
  12626. /**
  12627. * Adds a new alpha remap gradient
  12628. * @param gradient defines the gradient to use (between 0 and 1)
  12629. * @param min defines the alpha remap minimal range
  12630. * @param max defines the alpha remap maximal range
  12631. * @returns the current particle system
  12632. */
  12633. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12634. /**
  12635. * Remove a specific alpha remap gradient
  12636. * @param gradient defines the gradient to remove
  12637. * @returns the current particle system
  12638. */
  12639. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12640. /**
  12641. * Adds a new angular speed gradient
  12642. * @param gradient defines the gradient to use (between 0 and 1)
  12643. * @param factor defines the angular speed to affect to the specified gradient
  12644. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12645. * @returns the current particle system
  12646. */
  12647. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12648. /**
  12649. * Remove a specific angular speed gradient
  12650. * @param gradient defines the gradient to remove
  12651. * @returns the current particle system
  12652. */
  12653. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12654. /**
  12655. * Adds a new velocity gradient
  12656. * @param gradient defines the gradient to use (between 0 and 1)
  12657. * @param factor defines the velocity to affect to the specified gradient
  12658. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12659. * @returns the current particle system
  12660. */
  12661. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12662. /**
  12663. * Remove a specific velocity gradient
  12664. * @param gradient defines the gradient to remove
  12665. * @returns the current particle system
  12666. */
  12667. removeVelocityGradient(gradient: number): IParticleSystem;
  12668. /**
  12669. * Adds a new limit velocity gradient
  12670. * @param gradient defines the gradient to use (between 0 and 1)
  12671. * @param factor defines the limit velocity value to affect to the specified gradient
  12672. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12673. * @returns the current particle system
  12674. */
  12675. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12676. /**
  12677. * Remove a specific limit velocity gradient
  12678. * @param gradient defines the gradient to remove
  12679. * @returns the current particle system
  12680. */
  12681. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12682. /**
  12683. * Adds a new drag gradient
  12684. * @param gradient defines the gradient to use (between 0 and 1)
  12685. * @param factor defines the drag value to affect to the specified gradient
  12686. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12687. * @returns the current particle system
  12688. */
  12689. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12690. /**
  12691. * Remove a specific drag gradient
  12692. * @param gradient defines the gradient to remove
  12693. * @returns the current particle system
  12694. */
  12695. removeDragGradient(gradient: number): IParticleSystem;
  12696. /**
  12697. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12698. * @param gradient defines the gradient to use (between 0 and 1)
  12699. * @param factor defines the emit rate value to affect to the specified gradient
  12700. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12701. * @returns the current particle system
  12702. */
  12703. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12704. /**
  12705. * Remove a specific emit rate gradient
  12706. * @param gradient defines the gradient to remove
  12707. * @returns the current particle system
  12708. */
  12709. removeEmitRateGradient(gradient: number): IParticleSystem;
  12710. /**
  12711. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12712. * @param gradient defines the gradient to use (between 0 and 1)
  12713. * @param factor defines the start size value to affect to the specified gradient
  12714. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12715. * @returns the current particle system
  12716. */
  12717. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12718. /**
  12719. * Remove a specific start size gradient
  12720. * @param gradient defines the gradient to remove
  12721. * @returns the current particle system
  12722. */
  12723. removeStartSizeGradient(gradient: number): IParticleSystem;
  12724. private _createRampGradientTexture;
  12725. /**
  12726. * Gets the current list of ramp gradients.
  12727. * You must use addRampGradient and removeRampGradient to udpate this list
  12728. * @returns the list of ramp gradients
  12729. */
  12730. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12731. /** Force the system to rebuild all gradients that need to be resync */
  12732. forceRefreshGradients(): void;
  12733. private _syncRampGradientTexture;
  12734. /**
  12735. * Adds a new ramp gradient used to remap particle colors
  12736. * @param gradient defines the gradient to use (between 0 and 1)
  12737. * @param color defines the color to affect to the specified gradient
  12738. * @returns the current particle system
  12739. */
  12740. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12741. /**
  12742. * Remove a specific ramp gradient
  12743. * @param gradient defines the gradient to remove
  12744. * @returns the current particle system
  12745. */
  12746. removeRampGradient(gradient: number): ParticleSystem;
  12747. /**
  12748. * Adds a new color gradient
  12749. * @param gradient defines the gradient to use (between 0 and 1)
  12750. * @param color1 defines the color to affect to the specified gradient
  12751. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12752. * @returns this particle system
  12753. */
  12754. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12755. /**
  12756. * Remove a specific color gradient
  12757. * @param gradient defines the gradient to remove
  12758. * @returns this particle system
  12759. */
  12760. removeColorGradient(gradient: number): IParticleSystem;
  12761. private _fetchR;
  12762. protected _reset(): void;
  12763. private _resetEffect;
  12764. private _createVertexBuffers;
  12765. private _createIndexBuffer;
  12766. /**
  12767. * Gets the maximum number of particles active at the same time.
  12768. * @returns The max number of active particles.
  12769. */
  12770. getCapacity(): number;
  12771. /**
  12772. * Gets whether there are still active particles in the system.
  12773. * @returns True if it is alive, otherwise false.
  12774. */
  12775. isAlive(): boolean;
  12776. /**
  12777. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12778. * @returns True if it has been started, otherwise false.
  12779. */
  12780. isStarted(): boolean;
  12781. private _prepareSubEmitterInternalArray;
  12782. /**
  12783. * Starts the particle system and begins to emit
  12784. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12785. */
  12786. start(delay?: number): void;
  12787. /**
  12788. * Stops the particle system.
  12789. * @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.
  12790. */
  12791. stop(stopSubEmitters?: boolean): void;
  12792. /**
  12793. * Remove all active particles
  12794. */
  12795. reset(): void;
  12796. /**
  12797. * @hidden (for internal use only)
  12798. */
  12799. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12800. /**
  12801. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12802. * Its lifetime will start back at 0.
  12803. */
  12804. recycleParticle: (particle: Particle) => void;
  12805. private _stopSubEmitters;
  12806. private _createParticle;
  12807. private _removeFromRoot;
  12808. private _emitFromParticle;
  12809. private _update;
  12810. /** @hidden */
  12811. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12812. /** @hidden */
  12813. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12814. /**
  12815. * Fill the defines array according to the current settings of the particle system
  12816. * @param defines Array to be updated
  12817. * @param blendMode blend mode to take into account when updating the array
  12818. */
  12819. fillDefines(defines: Array<string>, blendMode: number): void;
  12820. /**
  12821. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  12822. * @param uniforms Uniforms array to fill
  12823. * @param attributes Attributes array to fill
  12824. * @param samplers Samplers array to fill
  12825. */
  12826. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  12827. /** @hidden */
  12828. private _getEffect;
  12829. /**
  12830. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12831. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12832. */
  12833. animate(preWarmOnly?: boolean): void;
  12834. private _appendParticleVertices;
  12835. /**
  12836. * Rebuilds the particle system.
  12837. */
  12838. rebuild(): void;
  12839. /**
  12840. * Is this system ready to be used/rendered
  12841. * @return true if the system is ready
  12842. */
  12843. isReady(): boolean;
  12844. private _render;
  12845. /**
  12846. * Renders the particle system in its current state.
  12847. * @returns the current number of particles
  12848. */
  12849. render(): number;
  12850. /**
  12851. * Disposes the particle system and free the associated resources
  12852. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12853. */
  12854. dispose(disposeTexture?: boolean): void;
  12855. /**
  12856. * Clones the particle system.
  12857. * @param name The name of the cloned object
  12858. * @param newEmitter The new emitter to use
  12859. * @returns the cloned particle system
  12860. */
  12861. clone(name: string, newEmitter: any): ParticleSystem;
  12862. /**
  12863. * Serializes the particle system to a JSON object
  12864. * @param serializeTexture defines if the texture must be serialized as well
  12865. * @returns the JSON object
  12866. */
  12867. serialize(serializeTexture?: boolean): any;
  12868. /** @hidden */
  12869. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  12870. /** @hidden */
  12871. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12872. /**
  12873. * Parses a JSON object to create a particle system.
  12874. * @param parsedParticleSystem The JSON object to parse
  12875. * @param scene The scene to create the particle system in
  12876. * @param rootUrl The root url to use to load external dependencies like texture
  12877. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12878. * @returns the Parsed particle system
  12879. */
  12880. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12881. }
  12882. }
  12883. declare module BABYLON {
  12884. /**
  12885. * A particle represents one of the element emitted by a particle system.
  12886. * This is mainly define by its coordinates, direction, velocity and age.
  12887. */
  12888. export class Particle {
  12889. /**
  12890. * The particle system the particle belongs to.
  12891. */
  12892. particleSystem: ParticleSystem;
  12893. private static _Count;
  12894. /**
  12895. * Unique ID of the particle
  12896. */
  12897. id: number;
  12898. /**
  12899. * The world position of the particle in the scene.
  12900. */
  12901. position: Vector3;
  12902. /**
  12903. * The world direction of the particle in the scene.
  12904. */
  12905. direction: Vector3;
  12906. /**
  12907. * The color of the particle.
  12908. */
  12909. color: Color4;
  12910. /**
  12911. * The color change of the particle per step.
  12912. */
  12913. colorStep: Color4;
  12914. /**
  12915. * Defines how long will the life of the particle be.
  12916. */
  12917. lifeTime: number;
  12918. /**
  12919. * The current age of the particle.
  12920. */
  12921. age: number;
  12922. /**
  12923. * The current size of the particle.
  12924. */
  12925. size: number;
  12926. /**
  12927. * The current scale of the particle.
  12928. */
  12929. scale: Vector2;
  12930. /**
  12931. * The current angle of the particle.
  12932. */
  12933. angle: number;
  12934. /**
  12935. * Defines how fast is the angle changing.
  12936. */
  12937. angularSpeed: number;
  12938. /**
  12939. * Defines the cell index used by the particle to be rendered from a sprite.
  12940. */
  12941. cellIndex: number;
  12942. /**
  12943. * The information required to support color remapping
  12944. */
  12945. remapData: Vector4;
  12946. /** @hidden */
  12947. _randomCellOffset?: number;
  12948. /** @hidden */
  12949. _initialDirection: Nullable<Vector3>;
  12950. /** @hidden */
  12951. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12952. /** @hidden */
  12953. _initialStartSpriteCellID: number;
  12954. /** @hidden */
  12955. _initialEndSpriteCellID: number;
  12956. /** @hidden */
  12957. _currentColorGradient: Nullable<ColorGradient>;
  12958. /** @hidden */
  12959. _currentColor1: Color4;
  12960. /** @hidden */
  12961. _currentColor2: Color4;
  12962. /** @hidden */
  12963. _currentSizeGradient: Nullable<FactorGradient>;
  12964. /** @hidden */
  12965. _currentSize1: number;
  12966. /** @hidden */
  12967. _currentSize2: number;
  12968. /** @hidden */
  12969. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12970. /** @hidden */
  12971. _currentAngularSpeed1: number;
  12972. /** @hidden */
  12973. _currentAngularSpeed2: number;
  12974. /** @hidden */
  12975. _currentVelocityGradient: Nullable<FactorGradient>;
  12976. /** @hidden */
  12977. _currentVelocity1: number;
  12978. /** @hidden */
  12979. _currentVelocity2: number;
  12980. /** @hidden */
  12981. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12982. /** @hidden */
  12983. _currentLimitVelocity1: number;
  12984. /** @hidden */
  12985. _currentLimitVelocity2: number;
  12986. /** @hidden */
  12987. _currentDragGradient: Nullable<FactorGradient>;
  12988. /** @hidden */
  12989. _currentDrag1: number;
  12990. /** @hidden */
  12991. _currentDrag2: number;
  12992. /** @hidden */
  12993. _randomNoiseCoordinates1: Vector3;
  12994. /** @hidden */
  12995. _randomNoiseCoordinates2: Vector3;
  12996. /** @hidden */
  12997. _localPosition?: Vector3;
  12998. /**
  12999. * Creates a new instance Particle
  13000. * @param particleSystem the particle system the particle belongs to
  13001. */
  13002. constructor(
  13003. /**
  13004. * The particle system the particle belongs to.
  13005. */
  13006. particleSystem: ParticleSystem);
  13007. private updateCellInfoFromSystem;
  13008. /**
  13009. * Defines how the sprite cell index is updated for the particle
  13010. */
  13011. updateCellIndex(): void;
  13012. /** @hidden */
  13013. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13014. /** @hidden */
  13015. _inheritParticleInfoToSubEmitters(): void;
  13016. /** @hidden */
  13017. _reset(): void;
  13018. /**
  13019. * Copy the properties of particle to another one.
  13020. * @param other the particle to copy the information to.
  13021. */
  13022. copyTo(other: Particle): void;
  13023. }
  13024. }
  13025. declare module BABYLON {
  13026. /**
  13027. * Particle emitter represents a volume emitting particles.
  13028. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13029. */
  13030. export interface IParticleEmitterType {
  13031. /**
  13032. * Called by the particle System when the direction is computed for the created particle.
  13033. * @param worldMatrix is the world matrix of the particle system
  13034. * @param directionToUpdate is the direction vector to update with the result
  13035. * @param particle is the particle we are computed the direction for
  13036. * @param isLocal defines if the direction should be set in local space
  13037. */
  13038. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13039. /**
  13040. * Called by the particle System when the position is computed for the created particle.
  13041. * @param worldMatrix is the world matrix of the particle system
  13042. * @param positionToUpdate is the position vector to update with the result
  13043. * @param particle is the particle we are computed the position for
  13044. * @param isLocal defines if the position should be set in local space
  13045. */
  13046. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13047. /**
  13048. * Clones the current emitter and returns a copy of it
  13049. * @returns the new emitter
  13050. */
  13051. clone(): IParticleEmitterType;
  13052. /**
  13053. * Called by the GPUParticleSystem to setup the update shader
  13054. * @param effect defines the update shader
  13055. */
  13056. applyToShader(effect: Effect): void;
  13057. /**
  13058. * Returns a string to use to update the GPU particles update shader
  13059. * @returns the effect defines string
  13060. */
  13061. getEffectDefines(): string;
  13062. /**
  13063. * Returns a string representing the class name
  13064. * @returns a string containing the class name
  13065. */
  13066. getClassName(): string;
  13067. /**
  13068. * Serializes the particle system to a JSON object.
  13069. * @returns the JSON object
  13070. */
  13071. serialize(): any;
  13072. /**
  13073. * Parse properties from a JSON object
  13074. * @param serializationObject defines the JSON object
  13075. * @param scene defines the hosting scene
  13076. */
  13077. parse(serializationObject: any, scene: Scene): void;
  13078. }
  13079. }
  13080. declare module BABYLON {
  13081. /**
  13082. * Particle emitter emitting particles from the inside of a box.
  13083. * It emits the particles randomly between 2 given directions.
  13084. */
  13085. export class BoxParticleEmitter implements IParticleEmitterType {
  13086. /**
  13087. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13088. */
  13089. direction1: Vector3;
  13090. /**
  13091. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13092. */
  13093. direction2: Vector3;
  13094. /**
  13095. * 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.
  13096. */
  13097. minEmitBox: Vector3;
  13098. /**
  13099. * 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.
  13100. */
  13101. maxEmitBox: Vector3;
  13102. /**
  13103. * Creates a new instance BoxParticleEmitter
  13104. */
  13105. constructor();
  13106. /**
  13107. * Called by the particle System when the direction is computed for the created particle.
  13108. * @param worldMatrix is the world matrix of the particle system
  13109. * @param directionToUpdate is the direction vector to update with the result
  13110. * @param particle is the particle we are computed the direction for
  13111. * @param isLocal defines if the direction should be set in local space
  13112. */
  13113. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13114. /**
  13115. * Called by the particle System when the position is computed for the created particle.
  13116. * @param worldMatrix is the world matrix of the particle system
  13117. * @param positionToUpdate is the position vector to update with the result
  13118. * @param particle is the particle we are computed the position for
  13119. * @param isLocal defines if the position should be set in local space
  13120. */
  13121. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13122. /**
  13123. * Clones the current emitter and returns a copy of it
  13124. * @returns the new emitter
  13125. */
  13126. clone(): BoxParticleEmitter;
  13127. /**
  13128. * Called by the GPUParticleSystem to setup the update shader
  13129. * @param effect defines the update shader
  13130. */
  13131. applyToShader(effect: Effect): void;
  13132. /**
  13133. * Returns a string to use to update the GPU particles update shader
  13134. * @returns a string containng the defines string
  13135. */
  13136. getEffectDefines(): string;
  13137. /**
  13138. * Returns the string "BoxParticleEmitter"
  13139. * @returns a string containing the class name
  13140. */
  13141. getClassName(): string;
  13142. /**
  13143. * Serializes the particle system to a JSON object.
  13144. * @returns the JSON object
  13145. */
  13146. serialize(): any;
  13147. /**
  13148. * Parse properties from a JSON object
  13149. * @param serializationObject defines the JSON object
  13150. */
  13151. parse(serializationObject: any): void;
  13152. }
  13153. }
  13154. declare module BABYLON {
  13155. /**
  13156. * Particle emitter emitting particles from the inside of a cone.
  13157. * It emits the particles alongside the cone volume from the base to the particle.
  13158. * The emission direction might be randomized.
  13159. */
  13160. export class ConeParticleEmitter implements IParticleEmitterType {
  13161. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13162. directionRandomizer: number;
  13163. private _radius;
  13164. private _angle;
  13165. private _height;
  13166. /**
  13167. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13168. */
  13169. radiusRange: number;
  13170. /**
  13171. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13172. */
  13173. heightRange: number;
  13174. /**
  13175. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13176. */
  13177. emitFromSpawnPointOnly: boolean;
  13178. /**
  13179. * Gets or sets the radius of the emission cone
  13180. */
  13181. get radius(): number;
  13182. set radius(value: number);
  13183. /**
  13184. * Gets or sets the angle of the emission cone
  13185. */
  13186. get angle(): number;
  13187. set angle(value: number);
  13188. private _buildHeight;
  13189. /**
  13190. * Creates a new instance ConeParticleEmitter
  13191. * @param radius the radius of the emission cone (1 by default)
  13192. * @param angle the cone base angle (PI by default)
  13193. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13194. */
  13195. constructor(radius?: number, angle?: number,
  13196. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13197. directionRandomizer?: number);
  13198. /**
  13199. * Called by the particle System when the direction is computed for the created particle.
  13200. * @param worldMatrix is the world matrix of the particle system
  13201. * @param directionToUpdate is the direction vector to update with the result
  13202. * @param particle is the particle we are computed the direction for
  13203. * @param isLocal defines if the direction should be set in local space
  13204. */
  13205. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13206. /**
  13207. * Called by the particle System when the position is computed for the created particle.
  13208. * @param worldMatrix is the world matrix of the particle system
  13209. * @param positionToUpdate is the position vector to update with the result
  13210. * @param particle is the particle we are computed the position for
  13211. * @param isLocal defines if the position should be set in local space
  13212. */
  13213. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13214. /**
  13215. * Clones the current emitter and returns a copy of it
  13216. * @returns the new emitter
  13217. */
  13218. clone(): ConeParticleEmitter;
  13219. /**
  13220. * Called by the GPUParticleSystem to setup the update shader
  13221. * @param effect defines the update shader
  13222. */
  13223. applyToShader(effect: Effect): void;
  13224. /**
  13225. * Returns a string to use to update the GPU particles update shader
  13226. * @returns a string containng the defines string
  13227. */
  13228. getEffectDefines(): string;
  13229. /**
  13230. * Returns the string "ConeParticleEmitter"
  13231. * @returns a string containing the class name
  13232. */
  13233. getClassName(): string;
  13234. /**
  13235. * Serializes the particle system to a JSON object.
  13236. * @returns the JSON object
  13237. */
  13238. serialize(): any;
  13239. /**
  13240. * Parse properties from a JSON object
  13241. * @param serializationObject defines the JSON object
  13242. */
  13243. parse(serializationObject: any): void;
  13244. }
  13245. }
  13246. declare module BABYLON {
  13247. /**
  13248. * Particle emitter emitting particles from the inside of a cylinder.
  13249. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13250. */
  13251. export class CylinderParticleEmitter implements IParticleEmitterType {
  13252. /**
  13253. * The radius of the emission cylinder.
  13254. */
  13255. radius: number;
  13256. /**
  13257. * The height of the emission cylinder.
  13258. */
  13259. height: number;
  13260. /**
  13261. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13262. */
  13263. radiusRange: number;
  13264. /**
  13265. * How much to randomize the particle direction [0-1].
  13266. */
  13267. directionRandomizer: number;
  13268. /**
  13269. * Creates a new instance CylinderParticleEmitter
  13270. * @param radius the radius of the emission cylinder (1 by default)
  13271. * @param height the height of the emission cylinder (1 by default)
  13272. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13273. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13274. */
  13275. constructor(
  13276. /**
  13277. * The radius of the emission cylinder.
  13278. */
  13279. radius?: number,
  13280. /**
  13281. * The height of the emission cylinder.
  13282. */
  13283. height?: number,
  13284. /**
  13285. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13286. */
  13287. radiusRange?: number,
  13288. /**
  13289. * How much to randomize the particle direction [0-1].
  13290. */
  13291. directionRandomizer?: number);
  13292. /**
  13293. * Called by the particle System when the direction is computed for the created particle.
  13294. * @param worldMatrix is the world matrix of the particle system
  13295. * @param directionToUpdate is the direction vector to update with the result
  13296. * @param particle is the particle we are computed the direction for
  13297. * @param isLocal defines if the direction should be set in local space
  13298. */
  13299. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13300. /**
  13301. * Called by the particle System when the position is computed for the created particle.
  13302. * @param worldMatrix is the world matrix of the particle system
  13303. * @param positionToUpdate is the position vector to update with the result
  13304. * @param particle is the particle we are computed the position for
  13305. * @param isLocal defines if the position should be set in local space
  13306. */
  13307. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13308. /**
  13309. * Clones the current emitter and returns a copy of it
  13310. * @returns the new emitter
  13311. */
  13312. clone(): CylinderParticleEmitter;
  13313. /**
  13314. * Called by the GPUParticleSystem to setup the update shader
  13315. * @param effect defines the update shader
  13316. */
  13317. applyToShader(effect: Effect): void;
  13318. /**
  13319. * Returns a string to use to update the GPU particles update shader
  13320. * @returns a string containng the defines string
  13321. */
  13322. getEffectDefines(): string;
  13323. /**
  13324. * Returns the string "CylinderParticleEmitter"
  13325. * @returns a string containing the class name
  13326. */
  13327. getClassName(): string;
  13328. /**
  13329. * Serializes the particle system to a JSON object.
  13330. * @returns the JSON object
  13331. */
  13332. serialize(): any;
  13333. /**
  13334. * Parse properties from a JSON object
  13335. * @param serializationObject defines the JSON object
  13336. */
  13337. parse(serializationObject: any): void;
  13338. }
  13339. /**
  13340. * Particle emitter emitting particles from the inside of a cylinder.
  13341. * It emits the particles randomly between two vectors.
  13342. */
  13343. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13344. /**
  13345. * The min limit of the emission direction.
  13346. */
  13347. direction1: Vector3;
  13348. /**
  13349. * The max limit of the emission direction.
  13350. */
  13351. direction2: Vector3;
  13352. /**
  13353. * Creates a new instance CylinderDirectedParticleEmitter
  13354. * @param radius the radius of the emission cylinder (1 by default)
  13355. * @param height the height of the emission cylinder (1 by default)
  13356. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13357. * @param direction1 the min limit of the emission direction (up vector by default)
  13358. * @param direction2 the max limit of the emission direction (up vector by default)
  13359. */
  13360. constructor(radius?: number, height?: number, radiusRange?: number,
  13361. /**
  13362. * The min limit of the emission direction.
  13363. */
  13364. direction1?: Vector3,
  13365. /**
  13366. * The max limit of the emission direction.
  13367. */
  13368. direction2?: Vector3);
  13369. /**
  13370. * Called by the particle System when the direction is computed for the created particle.
  13371. * @param worldMatrix is the world matrix of the particle system
  13372. * @param directionToUpdate is the direction vector to update with the result
  13373. * @param particle is the particle we are computed the direction for
  13374. */
  13375. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13376. /**
  13377. * Clones the current emitter and returns a copy of it
  13378. * @returns the new emitter
  13379. */
  13380. clone(): CylinderDirectedParticleEmitter;
  13381. /**
  13382. * Called by the GPUParticleSystem to setup the update shader
  13383. * @param effect defines the update shader
  13384. */
  13385. applyToShader(effect: Effect): void;
  13386. /**
  13387. * Returns a string to use to update the GPU particles update shader
  13388. * @returns a string containng the defines string
  13389. */
  13390. getEffectDefines(): string;
  13391. /**
  13392. * Returns the string "CylinderDirectedParticleEmitter"
  13393. * @returns a string containing the class name
  13394. */
  13395. getClassName(): string;
  13396. /**
  13397. * Serializes the particle system to a JSON object.
  13398. * @returns the JSON object
  13399. */
  13400. serialize(): any;
  13401. /**
  13402. * Parse properties from a JSON object
  13403. * @param serializationObject defines the JSON object
  13404. */
  13405. parse(serializationObject: any): void;
  13406. }
  13407. }
  13408. declare module BABYLON {
  13409. /**
  13410. * Particle emitter emitting particles from the inside of a hemisphere.
  13411. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13412. */
  13413. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13414. /**
  13415. * The radius of the emission hemisphere.
  13416. */
  13417. radius: number;
  13418. /**
  13419. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13420. */
  13421. radiusRange: number;
  13422. /**
  13423. * How much to randomize the particle direction [0-1].
  13424. */
  13425. directionRandomizer: number;
  13426. /**
  13427. * Creates a new instance HemisphericParticleEmitter
  13428. * @param radius the radius of the emission hemisphere (1 by default)
  13429. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13430. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13431. */
  13432. constructor(
  13433. /**
  13434. * The radius of the emission hemisphere.
  13435. */
  13436. radius?: number,
  13437. /**
  13438. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13439. */
  13440. radiusRange?: number,
  13441. /**
  13442. * How much to randomize the particle direction [0-1].
  13443. */
  13444. directionRandomizer?: number);
  13445. /**
  13446. * Called by the particle System when the direction is computed for the created particle.
  13447. * @param worldMatrix is the world matrix of the particle system
  13448. * @param directionToUpdate is the direction vector to update with the result
  13449. * @param particle is the particle we are computed the direction for
  13450. * @param isLocal defines if the direction should be set in local space
  13451. */
  13452. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13453. /**
  13454. * Called by the particle System when the position is computed for the created particle.
  13455. * @param worldMatrix is the world matrix of the particle system
  13456. * @param positionToUpdate is the position vector to update with the result
  13457. * @param particle is the particle we are computed the position for
  13458. * @param isLocal defines if the position should be set in local space
  13459. */
  13460. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13461. /**
  13462. * Clones the current emitter and returns a copy of it
  13463. * @returns the new emitter
  13464. */
  13465. clone(): HemisphericParticleEmitter;
  13466. /**
  13467. * Called by the GPUParticleSystem to setup the update shader
  13468. * @param effect defines the update shader
  13469. */
  13470. applyToShader(effect: Effect): void;
  13471. /**
  13472. * Returns a string to use to update the GPU particles update shader
  13473. * @returns a string containng the defines string
  13474. */
  13475. getEffectDefines(): string;
  13476. /**
  13477. * Returns the string "HemisphericParticleEmitter"
  13478. * @returns a string containing the class name
  13479. */
  13480. getClassName(): string;
  13481. /**
  13482. * Serializes the particle system to a JSON object.
  13483. * @returns the JSON object
  13484. */
  13485. serialize(): any;
  13486. /**
  13487. * Parse properties from a JSON object
  13488. * @param serializationObject defines the JSON object
  13489. */
  13490. parse(serializationObject: any): void;
  13491. }
  13492. }
  13493. declare module BABYLON {
  13494. /**
  13495. * Particle emitter emitting particles from a point.
  13496. * It emits the particles randomly between 2 given directions.
  13497. */
  13498. export class PointParticleEmitter implements IParticleEmitterType {
  13499. /**
  13500. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13501. */
  13502. direction1: Vector3;
  13503. /**
  13504. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13505. */
  13506. direction2: Vector3;
  13507. /**
  13508. * Creates a new instance PointParticleEmitter
  13509. */
  13510. constructor();
  13511. /**
  13512. * Called by the particle System when the direction is computed for the created particle.
  13513. * @param worldMatrix is the world matrix of the particle system
  13514. * @param directionToUpdate is the direction vector to update with the result
  13515. * @param particle is the particle we are computed the direction for
  13516. * @param isLocal defines if the direction should be set in local space
  13517. */
  13518. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13519. /**
  13520. * Called by the particle System when the position is computed for the created particle.
  13521. * @param worldMatrix is the world matrix of the particle system
  13522. * @param positionToUpdate is the position vector to update with the result
  13523. * @param particle is the particle we are computed the position for
  13524. * @param isLocal defines if the position should be set in local space
  13525. */
  13526. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13527. /**
  13528. * Clones the current emitter and returns a copy of it
  13529. * @returns the new emitter
  13530. */
  13531. clone(): PointParticleEmitter;
  13532. /**
  13533. * Called by the GPUParticleSystem to setup the update shader
  13534. * @param effect defines the update shader
  13535. */
  13536. applyToShader(effect: Effect): void;
  13537. /**
  13538. * Returns a string to use to update the GPU particles update shader
  13539. * @returns a string containng the defines string
  13540. */
  13541. getEffectDefines(): string;
  13542. /**
  13543. * Returns the string "PointParticleEmitter"
  13544. * @returns a string containing the class name
  13545. */
  13546. getClassName(): string;
  13547. /**
  13548. * Serializes the particle system to a JSON object.
  13549. * @returns the JSON object
  13550. */
  13551. serialize(): any;
  13552. /**
  13553. * Parse properties from a JSON object
  13554. * @param serializationObject defines the JSON object
  13555. */
  13556. parse(serializationObject: any): void;
  13557. }
  13558. }
  13559. declare module BABYLON {
  13560. /**
  13561. * Particle emitter emitting particles from the inside of a sphere.
  13562. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13563. */
  13564. export class SphereParticleEmitter implements IParticleEmitterType {
  13565. /**
  13566. * The radius of the emission sphere.
  13567. */
  13568. radius: number;
  13569. /**
  13570. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13571. */
  13572. radiusRange: number;
  13573. /**
  13574. * How much to randomize the particle direction [0-1].
  13575. */
  13576. directionRandomizer: number;
  13577. /**
  13578. * Creates a new instance SphereParticleEmitter
  13579. * @param radius the radius of the emission sphere (1 by default)
  13580. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13581. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13582. */
  13583. constructor(
  13584. /**
  13585. * The radius of the emission sphere.
  13586. */
  13587. radius?: number,
  13588. /**
  13589. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13590. */
  13591. radiusRange?: number,
  13592. /**
  13593. * How much to randomize the particle direction [0-1].
  13594. */
  13595. directionRandomizer?: number);
  13596. /**
  13597. * Called by the particle System when the direction is computed for the created particle.
  13598. * @param worldMatrix is the world matrix of the particle system
  13599. * @param directionToUpdate is the direction vector to update with the result
  13600. * @param particle is the particle we are computed the direction for
  13601. * @param isLocal defines if the direction should be set in local space
  13602. */
  13603. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13604. /**
  13605. * Called by the particle System when the position is computed for the created particle.
  13606. * @param worldMatrix is the world matrix of the particle system
  13607. * @param positionToUpdate is the position vector to update with the result
  13608. * @param particle is the particle we are computed the position for
  13609. * @param isLocal defines if the position should be set in local space
  13610. */
  13611. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13612. /**
  13613. * Clones the current emitter and returns a copy of it
  13614. * @returns the new emitter
  13615. */
  13616. clone(): SphereParticleEmitter;
  13617. /**
  13618. * Called by the GPUParticleSystem to setup the update shader
  13619. * @param effect defines the update shader
  13620. */
  13621. applyToShader(effect: Effect): void;
  13622. /**
  13623. * Returns a string to use to update the GPU particles update shader
  13624. * @returns a string containng the defines string
  13625. */
  13626. getEffectDefines(): string;
  13627. /**
  13628. * Returns the string "SphereParticleEmitter"
  13629. * @returns a string containing the class name
  13630. */
  13631. getClassName(): string;
  13632. /**
  13633. * Serializes the particle system to a JSON object.
  13634. * @returns the JSON object
  13635. */
  13636. serialize(): any;
  13637. /**
  13638. * Parse properties from a JSON object
  13639. * @param serializationObject defines the JSON object
  13640. */
  13641. parse(serializationObject: any): void;
  13642. }
  13643. /**
  13644. * Particle emitter emitting particles from the inside of a sphere.
  13645. * It emits the particles randomly between two vectors.
  13646. */
  13647. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13648. /**
  13649. * The min limit of the emission direction.
  13650. */
  13651. direction1: Vector3;
  13652. /**
  13653. * The max limit of the emission direction.
  13654. */
  13655. direction2: Vector3;
  13656. /**
  13657. * Creates a new instance SphereDirectedParticleEmitter
  13658. * @param radius the radius of the emission sphere (1 by default)
  13659. * @param direction1 the min limit of the emission direction (up vector by default)
  13660. * @param direction2 the max limit of the emission direction (up vector by default)
  13661. */
  13662. constructor(radius?: number,
  13663. /**
  13664. * The min limit of the emission direction.
  13665. */
  13666. direction1?: Vector3,
  13667. /**
  13668. * The max limit of the emission direction.
  13669. */
  13670. direction2?: Vector3);
  13671. /**
  13672. * Called by the particle System when the direction is computed for the created particle.
  13673. * @param worldMatrix is the world matrix of the particle system
  13674. * @param directionToUpdate is the direction vector to update with the result
  13675. * @param particle is the particle we are computed the direction for
  13676. */
  13677. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13678. /**
  13679. * Clones the current emitter and returns a copy of it
  13680. * @returns the new emitter
  13681. */
  13682. clone(): SphereDirectedParticleEmitter;
  13683. /**
  13684. * Called by the GPUParticleSystem to setup the update shader
  13685. * @param effect defines the update shader
  13686. */
  13687. applyToShader(effect: Effect): void;
  13688. /**
  13689. * Returns a string to use to update the GPU particles update shader
  13690. * @returns a string containng the defines string
  13691. */
  13692. getEffectDefines(): string;
  13693. /**
  13694. * Returns the string "SphereDirectedParticleEmitter"
  13695. * @returns a string containing the class name
  13696. */
  13697. getClassName(): string;
  13698. /**
  13699. * Serializes the particle system to a JSON object.
  13700. * @returns the JSON object
  13701. */
  13702. serialize(): any;
  13703. /**
  13704. * Parse properties from a JSON object
  13705. * @param serializationObject defines the JSON object
  13706. */
  13707. parse(serializationObject: any): void;
  13708. }
  13709. }
  13710. declare module BABYLON {
  13711. /**
  13712. * Particle emitter emitting particles from a custom list of positions.
  13713. */
  13714. export class CustomParticleEmitter implements IParticleEmitterType {
  13715. /**
  13716. * Gets or sets the position generator that will create the inital position of each particle.
  13717. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13718. */
  13719. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13720. /**
  13721. * Gets or sets the destination generator that will create the final destination of each particle.
  13722. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13723. */
  13724. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13725. /**
  13726. * Creates a new instance CustomParticleEmitter
  13727. */
  13728. constructor();
  13729. /**
  13730. * Called by the particle System when the direction is computed for the created particle.
  13731. * @param worldMatrix is the world matrix of the particle system
  13732. * @param directionToUpdate is the direction vector to update with the result
  13733. * @param particle is the particle we are computed the direction for
  13734. * @param isLocal defines if the direction should be set in local space
  13735. */
  13736. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13737. /**
  13738. * Called by the particle System when the position is computed for the created particle.
  13739. * @param worldMatrix is the world matrix of the particle system
  13740. * @param positionToUpdate is the position vector to update with the result
  13741. * @param particle is the particle we are computed the position for
  13742. * @param isLocal defines if the position should be set in local space
  13743. */
  13744. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13745. /**
  13746. * Clones the current emitter and returns a copy of it
  13747. * @returns the new emitter
  13748. */
  13749. clone(): CustomParticleEmitter;
  13750. /**
  13751. * Called by the GPUParticleSystem to setup the update shader
  13752. * @param effect defines the update shader
  13753. */
  13754. applyToShader(effect: Effect): void;
  13755. /**
  13756. * Returns a string to use to update the GPU particles update shader
  13757. * @returns a string containng the defines string
  13758. */
  13759. getEffectDefines(): string;
  13760. /**
  13761. * Returns the string "PointParticleEmitter"
  13762. * @returns a string containing the class name
  13763. */
  13764. getClassName(): string;
  13765. /**
  13766. * Serializes the particle system to a JSON object.
  13767. * @returns the JSON object
  13768. */
  13769. serialize(): any;
  13770. /**
  13771. * Parse properties from a JSON object
  13772. * @param serializationObject defines the JSON object
  13773. */
  13774. parse(serializationObject: any): void;
  13775. }
  13776. }
  13777. declare module BABYLON {
  13778. /**
  13779. * Particle emitter emitting particles from the inside of a box.
  13780. * It emits the particles randomly between 2 given directions.
  13781. */
  13782. export class MeshParticleEmitter implements IParticleEmitterType {
  13783. private _indices;
  13784. private _positions;
  13785. private _normals;
  13786. private _storedNormal;
  13787. private _mesh;
  13788. /**
  13789. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13790. */
  13791. direction1: Vector3;
  13792. /**
  13793. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13794. */
  13795. direction2: Vector3;
  13796. /**
  13797. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13798. */
  13799. useMeshNormalsForDirection: boolean;
  13800. /** Defines the mesh to use as source */
  13801. get mesh(): Nullable<AbstractMesh>;
  13802. set mesh(value: Nullable<AbstractMesh>);
  13803. /**
  13804. * Creates a new instance MeshParticleEmitter
  13805. * @param mesh defines the mesh to use as source
  13806. */
  13807. constructor(mesh?: Nullable<AbstractMesh>);
  13808. /**
  13809. * Called by the particle System when the direction is computed for the created particle.
  13810. * @param worldMatrix is the world matrix of the particle system
  13811. * @param directionToUpdate is the direction vector to update with the result
  13812. * @param particle is the particle we are computed the direction for
  13813. * @param isLocal defines if the direction should be set in local space
  13814. */
  13815. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13816. /**
  13817. * Called by the particle System when the position is computed for the created particle.
  13818. * @param worldMatrix is the world matrix of the particle system
  13819. * @param positionToUpdate is the position vector to update with the result
  13820. * @param particle is the particle we are computed the position for
  13821. * @param isLocal defines if the position should be set in local space
  13822. */
  13823. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13824. /**
  13825. * Clones the current emitter and returns a copy of it
  13826. * @returns the new emitter
  13827. */
  13828. clone(): MeshParticleEmitter;
  13829. /**
  13830. * Called by the GPUParticleSystem to setup the update shader
  13831. * @param effect defines the update shader
  13832. */
  13833. applyToShader(effect: Effect): void;
  13834. /**
  13835. * Returns a string to use to update the GPU particles update shader
  13836. * @returns a string containng the defines string
  13837. */
  13838. getEffectDefines(): string;
  13839. /**
  13840. * Returns the string "BoxParticleEmitter"
  13841. * @returns a string containing the class name
  13842. */
  13843. getClassName(): string;
  13844. /**
  13845. * Serializes the particle system to a JSON object.
  13846. * @returns the JSON object
  13847. */
  13848. serialize(): any;
  13849. /**
  13850. * Parse properties from a JSON object
  13851. * @param serializationObject defines the JSON object
  13852. * @param scene defines the hosting scene
  13853. */
  13854. parse(serializationObject: any, scene: Scene): void;
  13855. }
  13856. }
  13857. declare module BABYLON {
  13858. /**
  13859. * Interface representing a particle system in Babylon.js.
  13860. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13861. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13862. */
  13863. export interface IParticleSystem {
  13864. /**
  13865. * List of animations used by the particle system.
  13866. */
  13867. animations: Animation[];
  13868. /**
  13869. * The id of the Particle system.
  13870. */
  13871. id: string;
  13872. /**
  13873. * The name of the Particle system.
  13874. */
  13875. name: string;
  13876. /**
  13877. * The emitter represents the Mesh or position we are attaching the particle system to.
  13878. */
  13879. emitter: Nullable<AbstractMesh | Vector3>;
  13880. /**
  13881. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13882. */
  13883. isBillboardBased: boolean;
  13884. /**
  13885. * The rendering group used by the Particle system to chose when to render.
  13886. */
  13887. renderingGroupId: number;
  13888. /**
  13889. * The layer mask we are rendering the particles through.
  13890. */
  13891. layerMask: number;
  13892. /**
  13893. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13894. */
  13895. updateSpeed: number;
  13896. /**
  13897. * The amount of time the particle system is running (depends of the overall update speed).
  13898. */
  13899. targetStopDuration: number;
  13900. /**
  13901. * The texture used to render each particle. (this can be a spritesheet)
  13902. */
  13903. particleTexture: Nullable<Texture>;
  13904. /**
  13905. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13906. */
  13907. blendMode: number;
  13908. /**
  13909. * Minimum life time of emitting particles.
  13910. */
  13911. minLifeTime: number;
  13912. /**
  13913. * Maximum life time of emitting particles.
  13914. */
  13915. maxLifeTime: number;
  13916. /**
  13917. * Minimum Size of emitting particles.
  13918. */
  13919. minSize: number;
  13920. /**
  13921. * Maximum Size of emitting particles.
  13922. */
  13923. maxSize: number;
  13924. /**
  13925. * Minimum scale of emitting particles on X axis.
  13926. */
  13927. minScaleX: number;
  13928. /**
  13929. * Maximum scale of emitting particles on X axis.
  13930. */
  13931. maxScaleX: number;
  13932. /**
  13933. * Minimum scale of emitting particles on Y axis.
  13934. */
  13935. minScaleY: number;
  13936. /**
  13937. * Maximum scale of emitting particles on Y axis.
  13938. */
  13939. maxScaleY: number;
  13940. /**
  13941. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13942. */
  13943. color1: Color4;
  13944. /**
  13945. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13946. */
  13947. color2: Color4;
  13948. /**
  13949. * Color the particle will have at the end of its lifetime.
  13950. */
  13951. colorDead: Color4;
  13952. /**
  13953. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13954. */
  13955. emitRate: number;
  13956. /**
  13957. * You can use gravity if you want to give an orientation to your particles.
  13958. */
  13959. gravity: Vector3;
  13960. /**
  13961. * Minimum power of emitting particles.
  13962. */
  13963. minEmitPower: number;
  13964. /**
  13965. * Maximum power of emitting particles.
  13966. */
  13967. maxEmitPower: number;
  13968. /**
  13969. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13970. */
  13971. minAngularSpeed: number;
  13972. /**
  13973. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13974. */
  13975. maxAngularSpeed: number;
  13976. /**
  13977. * Gets or sets the minimal initial rotation in radians.
  13978. */
  13979. minInitialRotation: number;
  13980. /**
  13981. * Gets or sets the maximal initial rotation in radians.
  13982. */
  13983. maxInitialRotation: number;
  13984. /**
  13985. * The particle emitter type defines the emitter used by the particle system.
  13986. * It can be for example box, sphere, or cone...
  13987. */
  13988. particleEmitterType: Nullable<IParticleEmitterType>;
  13989. /**
  13990. * Defines the delay in milliseconds before starting the system (0 by default)
  13991. */
  13992. startDelay: number;
  13993. /**
  13994. * 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
  13995. */
  13996. preWarmCycles: number;
  13997. /**
  13998. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13999. */
  14000. preWarmStepOffset: number;
  14001. /**
  14002. * 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)
  14003. */
  14004. spriteCellChangeSpeed: number;
  14005. /**
  14006. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14007. */
  14008. startSpriteCellID: number;
  14009. /**
  14010. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14011. */
  14012. endSpriteCellID: number;
  14013. /**
  14014. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14015. */
  14016. spriteCellWidth: number;
  14017. /**
  14018. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14019. */
  14020. spriteCellHeight: number;
  14021. /**
  14022. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14023. */
  14024. spriteRandomStartCell: boolean;
  14025. /**
  14026. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14027. */
  14028. isAnimationSheetEnabled: boolean;
  14029. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14030. translationPivot: Vector2;
  14031. /**
  14032. * Gets or sets a texture used to add random noise to particle positions
  14033. */
  14034. noiseTexture: Nullable<BaseTexture>;
  14035. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14036. noiseStrength: Vector3;
  14037. /**
  14038. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14039. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14040. */
  14041. billboardMode: number;
  14042. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14043. limitVelocityDamping: number;
  14044. /**
  14045. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14046. */
  14047. beginAnimationOnStart: boolean;
  14048. /**
  14049. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14050. */
  14051. beginAnimationFrom: number;
  14052. /**
  14053. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14054. */
  14055. beginAnimationTo: number;
  14056. /**
  14057. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14058. */
  14059. beginAnimationLoop: boolean;
  14060. /**
  14061. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14062. */
  14063. disposeOnStop: boolean;
  14064. /**
  14065. * Specifies if the particles are updated in emitter local space or world space
  14066. */
  14067. isLocal: boolean;
  14068. /** Snippet ID if the particle system was created from the snippet server */
  14069. snippetId: string;
  14070. /**
  14071. * Gets the maximum number of particles active at the same time.
  14072. * @returns The max number of active particles.
  14073. */
  14074. getCapacity(): number;
  14075. /**
  14076. * Gets the number of particles active at the same time.
  14077. * @returns The number of active particles.
  14078. */
  14079. getActiveCount(): number;
  14080. /**
  14081. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14082. * @returns True if it has been started, otherwise false.
  14083. */
  14084. isStarted(): boolean;
  14085. /**
  14086. * Animates the particle system for this frame.
  14087. */
  14088. animate(): void;
  14089. /**
  14090. * Renders the particle system in its current state.
  14091. * @returns the current number of particles
  14092. */
  14093. render(): number;
  14094. /**
  14095. * Dispose the particle system and frees its associated resources.
  14096. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14097. */
  14098. dispose(disposeTexture?: boolean): void;
  14099. /**
  14100. * An event triggered when the system is disposed
  14101. */
  14102. onDisposeObservable: Observable<IParticleSystem>;
  14103. /**
  14104. * Clones the particle system.
  14105. * @param name The name of the cloned object
  14106. * @param newEmitter The new emitter to use
  14107. * @returns the cloned particle system
  14108. */
  14109. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14110. /**
  14111. * Serializes the particle system to a JSON object
  14112. * @param serializeTexture defines if the texture must be serialized as well
  14113. * @returns the JSON object
  14114. */
  14115. serialize(serializeTexture: boolean): any;
  14116. /**
  14117. * Rebuild the particle system
  14118. */
  14119. rebuild(): void;
  14120. /** Force the system to rebuild all gradients that need to be resync */
  14121. forceRefreshGradients(): void;
  14122. /**
  14123. * Starts the particle system and begins to emit
  14124. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14125. */
  14126. start(delay?: number): void;
  14127. /**
  14128. * Stops the particle system.
  14129. */
  14130. stop(): void;
  14131. /**
  14132. * Remove all active particles
  14133. */
  14134. reset(): void;
  14135. /**
  14136. * Gets a boolean indicating that the system is stopping
  14137. * @returns true if the system is currently stopping
  14138. */
  14139. isStopping(): boolean;
  14140. /**
  14141. * Is this system ready to be used/rendered
  14142. * @return true if the system is ready
  14143. */
  14144. isReady(): boolean;
  14145. /**
  14146. * Returns the string "ParticleSystem"
  14147. * @returns a string containing the class name
  14148. */
  14149. getClassName(): string;
  14150. /**
  14151. * Gets the custom effect used to render the particles
  14152. * @param blendMode Blend mode for which the effect should be retrieved
  14153. * @returns The effect
  14154. */
  14155. getCustomEffect(blendMode: number): Nullable<Effect>;
  14156. /**
  14157. * Sets the custom effect used to render the particles
  14158. * @param effect The effect to set
  14159. * @param blendMode Blend mode for which the effect should be set
  14160. */
  14161. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14162. /**
  14163. * Fill the defines array according to the current settings of the particle system
  14164. * @param defines Array to be updated
  14165. * @param blendMode blend mode to take into account when updating the array
  14166. */
  14167. fillDefines(defines: Array<string>, blendMode: number): void;
  14168. /**
  14169. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14170. * @param uniforms Uniforms array to fill
  14171. * @param attributes Attributes array to fill
  14172. * @param samplers Samplers array to fill
  14173. */
  14174. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14175. /**
  14176. * Observable that will be called just before the particles are drawn
  14177. */
  14178. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14179. /**
  14180. * Gets the name of the particle vertex shader
  14181. */
  14182. vertexShaderName: string;
  14183. /**
  14184. * Adds a new color gradient
  14185. * @param gradient defines the gradient to use (between 0 and 1)
  14186. * @param color1 defines the color to affect to the specified gradient
  14187. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14188. * @returns the current particle system
  14189. */
  14190. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14191. /**
  14192. * Remove a specific color gradient
  14193. * @param gradient defines the gradient to remove
  14194. * @returns the current particle system
  14195. */
  14196. removeColorGradient(gradient: number): IParticleSystem;
  14197. /**
  14198. * Adds a new size gradient
  14199. * @param gradient defines the gradient to use (between 0 and 1)
  14200. * @param factor defines the size factor to affect to the specified gradient
  14201. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14202. * @returns the current particle system
  14203. */
  14204. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14205. /**
  14206. * Remove a specific size gradient
  14207. * @param gradient defines the gradient to remove
  14208. * @returns the current particle system
  14209. */
  14210. removeSizeGradient(gradient: number): IParticleSystem;
  14211. /**
  14212. * Gets the current list of color gradients.
  14213. * You must use addColorGradient and removeColorGradient to udpate this list
  14214. * @returns the list of color gradients
  14215. */
  14216. getColorGradients(): Nullable<Array<ColorGradient>>;
  14217. /**
  14218. * Gets the current list of size gradients.
  14219. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14220. * @returns the list of size gradients
  14221. */
  14222. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14223. /**
  14224. * Gets the current list of angular speed gradients.
  14225. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14226. * @returns the list of angular speed gradients
  14227. */
  14228. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14229. /**
  14230. * Adds a new angular speed gradient
  14231. * @param gradient defines the gradient to use (between 0 and 1)
  14232. * @param factor defines the angular speed to affect to the specified gradient
  14233. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14234. * @returns the current particle system
  14235. */
  14236. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14237. /**
  14238. * Remove a specific angular speed gradient
  14239. * @param gradient defines the gradient to remove
  14240. * @returns the current particle system
  14241. */
  14242. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14243. /**
  14244. * Gets the current list of velocity gradients.
  14245. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14246. * @returns the list of velocity gradients
  14247. */
  14248. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14249. /**
  14250. * Adds a new velocity gradient
  14251. * @param gradient defines the gradient to use (between 0 and 1)
  14252. * @param factor defines the velocity to affect to the specified gradient
  14253. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14254. * @returns the current particle system
  14255. */
  14256. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14257. /**
  14258. * Remove a specific velocity gradient
  14259. * @param gradient defines the gradient to remove
  14260. * @returns the current particle system
  14261. */
  14262. removeVelocityGradient(gradient: number): IParticleSystem;
  14263. /**
  14264. * Gets the current list of limit velocity gradients.
  14265. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14266. * @returns the list of limit velocity gradients
  14267. */
  14268. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14269. /**
  14270. * Adds a new limit velocity gradient
  14271. * @param gradient defines the gradient to use (between 0 and 1)
  14272. * @param factor defines the limit velocity to affect to the specified gradient
  14273. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14274. * @returns the current particle system
  14275. */
  14276. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14277. /**
  14278. * Remove a specific limit velocity gradient
  14279. * @param gradient defines the gradient to remove
  14280. * @returns the current particle system
  14281. */
  14282. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14283. /**
  14284. * Adds a new drag gradient
  14285. * @param gradient defines the gradient to use (between 0 and 1)
  14286. * @param factor defines the drag to affect to the specified gradient
  14287. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14288. * @returns the current particle system
  14289. */
  14290. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14291. /**
  14292. * Remove a specific drag gradient
  14293. * @param gradient defines the gradient to remove
  14294. * @returns the current particle system
  14295. */
  14296. removeDragGradient(gradient: number): IParticleSystem;
  14297. /**
  14298. * Gets the current list of drag gradients.
  14299. * You must use addDragGradient and removeDragGradient to udpate this list
  14300. * @returns the list of drag gradients
  14301. */
  14302. getDragGradients(): Nullable<Array<FactorGradient>>;
  14303. /**
  14304. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14305. * @param gradient defines the gradient to use (between 0 and 1)
  14306. * @param factor defines the emit rate to affect to the specified gradient
  14307. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14308. * @returns the current particle system
  14309. */
  14310. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14311. /**
  14312. * Remove a specific emit rate gradient
  14313. * @param gradient defines the gradient to remove
  14314. * @returns the current particle system
  14315. */
  14316. removeEmitRateGradient(gradient: number): IParticleSystem;
  14317. /**
  14318. * Gets the current list of emit rate gradients.
  14319. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14320. * @returns the list of emit rate gradients
  14321. */
  14322. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14323. /**
  14324. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14325. * @param gradient defines the gradient to use (between 0 and 1)
  14326. * @param factor defines the start size to affect to the specified gradient
  14327. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14328. * @returns the current particle system
  14329. */
  14330. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14331. /**
  14332. * Remove a specific start size gradient
  14333. * @param gradient defines the gradient to remove
  14334. * @returns the current particle system
  14335. */
  14336. removeStartSizeGradient(gradient: number): IParticleSystem;
  14337. /**
  14338. * Gets the current list of start size gradients.
  14339. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14340. * @returns the list of start size gradients
  14341. */
  14342. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14343. /**
  14344. * Adds a new life time gradient
  14345. * @param gradient defines the gradient to use (between 0 and 1)
  14346. * @param factor defines the life time factor to affect to the specified gradient
  14347. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14348. * @returns the current particle system
  14349. */
  14350. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14351. /**
  14352. * Remove a specific life time gradient
  14353. * @param gradient defines the gradient to remove
  14354. * @returns the current particle system
  14355. */
  14356. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14357. /**
  14358. * Gets the current list of life time gradients.
  14359. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14360. * @returns the list of life time gradients
  14361. */
  14362. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14363. /**
  14364. * Gets the current list of color gradients.
  14365. * You must use addColorGradient and removeColorGradient to udpate this list
  14366. * @returns the list of color gradients
  14367. */
  14368. getColorGradients(): Nullable<Array<ColorGradient>>;
  14369. /**
  14370. * Adds a new ramp gradient used to remap particle colors
  14371. * @param gradient defines the gradient to use (between 0 and 1)
  14372. * @param color defines the color to affect to the specified gradient
  14373. * @returns the current particle system
  14374. */
  14375. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14376. /**
  14377. * Gets the current list of ramp gradients.
  14378. * You must use addRampGradient and removeRampGradient to udpate this list
  14379. * @returns the list of ramp gradients
  14380. */
  14381. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14382. /** Gets or sets a boolean indicating that ramp gradients must be used
  14383. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14384. */
  14385. useRampGradients: boolean;
  14386. /**
  14387. * Adds a new color remap gradient
  14388. * @param gradient defines the gradient to use (between 0 and 1)
  14389. * @param min defines the color remap minimal range
  14390. * @param max defines the color remap maximal range
  14391. * @returns the current particle system
  14392. */
  14393. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14394. /**
  14395. * Gets the current list of color remap gradients.
  14396. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14397. * @returns the list of color remap gradients
  14398. */
  14399. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14400. /**
  14401. * Adds a new alpha remap gradient
  14402. * @param gradient defines the gradient to use (between 0 and 1)
  14403. * @param min defines the alpha remap minimal range
  14404. * @param max defines the alpha remap maximal range
  14405. * @returns the current particle system
  14406. */
  14407. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14408. /**
  14409. * Gets the current list of alpha remap gradients.
  14410. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14411. * @returns the list of alpha remap gradients
  14412. */
  14413. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14414. /**
  14415. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14416. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14417. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14418. * @returns the emitter
  14419. */
  14420. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14421. /**
  14422. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14423. * @param radius The radius of the hemisphere to emit from
  14424. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14425. * @returns the emitter
  14426. */
  14427. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14428. /**
  14429. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14430. * @param radius The radius of the sphere to emit from
  14431. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14432. * @returns the emitter
  14433. */
  14434. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14435. /**
  14436. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14437. * @param radius The radius of the sphere to emit from
  14438. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14439. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14440. * @returns the emitter
  14441. */
  14442. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14443. /**
  14444. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14445. * @param radius The radius of the emission cylinder
  14446. * @param height The height of the emission cylinder
  14447. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14448. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14449. * @returns the emitter
  14450. */
  14451. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14452. /**
  14453. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14454. * @param radius The radius of the cylinder to emit from
  14455. * @param height The height of the emission cylinder
  14456. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14457. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14458. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14459. * @returns the emitter
  14460. */
  14461. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14462. /**
  14463. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14464. * @param radius The radius of the cone to emit from
  14465. * @param angle The base angle of the cone
  14466. * @returns the emitter
  14467. */
  14468. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14469. /**
  14470. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14471. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14472. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14473. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14474. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14475. * @returns the emitter
  14476. */
  14477. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14478. /**
  14479. * Get hosting scene
  14480. * @returns the scene
  14481. */
  14482. getScene(): Scene;
  14483. }
  14484. }
  14485. declare module BABYLON {
  14486. /**
  14487. * 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.
  14488. * @see https://doc.babylonjs.com/how_to/transformnode
  14489. */
  14490. export class TransformNode extends Node {
  14491. /**
  14492. * Object will not rotate to face the camera
  14493. */
  14494. static BILLBOARDMODE_NONE: number;
  14495. /**
  14496. * Object will rotate to face the camera but only on the x axis
  14497. */
  14498. static BILLBOARDMODE_X: number;
  14499. /**
  14500. * Object will rotate to face the camera but only on the y axis
  14501. */
  14502. static BILLBOARDMODE_Y: number;
  14503. /**
  14504. * Object will rotate to face the camera but only on the z axis
  14505. */
  14506. static BILLBOARDMODE_Z: number;
  14507. /**
  14508. * Object will rotate to face the camera
  14509. */
  14510. static BILLBOARDMODE_ALL: number;
  14511. /**
  14512. * Object will rotate to face the camera's position instead of orientation
  14513. */
  14514. static BILLBOARDMODE_USE_POSITION: number;
  14515. private static _TmpRotation;
  14516. private static _TmpScaling;
  14517. private static _TmpTranslation;
  14518. private _forward;
  14519. private _forwardInverted;
  14520. private _up;
  14521. private _right;
  14522. private _rightInverted;
  14523. private _position;
  14524. private _rotation;
  14525. private _rotationQuaternion;
  14526. protected _scaling: Vector3;
  14527. protected _isDirty: boolean;
  14528. private _transformToBoneReferal;
  14529. private _isAbsoluteSynced;
  14530. private _billboardMode;
  14531. /**
  14532. * Gets or sets the billboard mode. Default is 0.
  14533. *
  14534. * | Value | Type | Description |
  14535. * | --- | --- | --- |
  14536. * | 0 | BILLBOARDMODE_NONE | |
  14537. * | 1 | BILLBOARDMODE_X | |
  14538. * | 2 | BILLBOARDMODE_Y | |
  14539. * | 4 | BILLBOARDMODE_Z | |
  14540. * | 7 | BILLBOARDMODE_ALL | |
  14541. *
  14542. */
  14543. get billboardMode(): number;
  14544. set billboardMode(value: number);
  14545. private _preserveParentRotationForBillboard;
  14546. /**
  14547. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14548. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14549. */
  14550. get preserveParentRotationForBillboard(): boolean;
  14551. set preserveParentRotationForBillboard(value: boolean);
  14552. /**
  14553. * 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
  14554. */
  14555. scalingDeterminant: number;
  14556. private _infiniteDistance;
  14557. /**
  14558. * Gets or sets the distance of the object to max, often used by skybox
  14559. */
  14560. get infiniteDistance(): boolean;
  14561. set infiniteDistance(value: boolean);
  14562. /**
  14563. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14564. * By default the system will update normals to compensate
  14565. */
  14566. ignoreNonUniformScaling: boolean;
  14567. /**
  14568. * 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
  14569. */
  14570. reIntegrateRotationIntoRotationQuaternion: boolean;
  14571. /** @hidden */
  14572. _poseMatrix: Nullable<Matrix>;
  14573. /** @hidden */
  14574. _localMatrix: Matrix;
  14575. private _usePivotMatrix;
  14576. private _absolutePosition;
  14577. private _absoluteScaling;
  14578. private _absoluteRotationQuaternion;
  14579. private _pivotMatrix;
  14580. private _pivotMatrixInverse;
  14581. protected _postMultiplyPivotMatrix: boolean;
  14582. protected _isWorldMatrixFrozen: boolean;
  14583. /** @hidden */
  14584. _indexInSceneTransformNodesArray: number;
  14585. /**
  14586. * An event triggered after the world matrix is updated
  14587. */
  14588. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14589. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14590. /**
  14591. * Gets a string identifying the name of the class
  14592. * @returns "TransformNode" string
  14593. */
  14594. getClassName(): string;
  14595. /**
  14596. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14597. */
  14598. get position(): Vector3;
  14599. set position(newPosition: Vector3);
  14600. /**
  14601. * 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)).
  14602. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14603. */
  14604. get rotation(): Vector3;
  14605. set rotation(newRotation: Vector3);
  14606. /**
  14607. * 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)).
  14608. */
  14609. get scaling(): Vector3;
  14610. set scaling(newScaling: Vector3);
  14611. /**
  14612. * 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).
  14613. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14614. */
  14615. get rotationQuaternion(): Nullable<Quaternion>;
  14616. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14617. /**
  14618. * The forward direction of that transform in world space.
  14619. */
  14620. get forward(): Vector3;
  14621. /**
  14622. * The up direction of that transform in world space.
  14623. */
  14624. get up(): Vector3;
  14625. /**
  14626. * The right direction of that transform in world space.
  14627. */
  14628. get right(): Vector3;
  14629. /**
  14630. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14631. * @param matrix the matrix to copy the pose from
  14632. * @returns this TransformNode.
  14633. */
  14634. updatePoseMatrix(matrix: Matrix): TransformNode;
  14635. /**
  14636. * Returns the mesh Pose matrix.
  14637. * @returns the pose matrix
  14638. */
  14639. getPoseMatrix(): Matrix;
  14640. /** @hidden */
  14641. _isSynchronized(): boolean;
  14642. /** @hidden */
  14643. _initCache(): void;
  14644. /**
  14645. * Flag the transform node as dirty (Forcing it to update everything)
  14646. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14647. * @returns this transform node
  14648. */
  14649. markAsDirty(property: string): TransformNode;
  14650. /**
  14651. * Returns the current mesh absolute position.
  14652. * Returns a Vector3.
  14653. */
  14654. get absolutePosition(): Vector3;
  14655. /**
  14656. * Returns the current mesh absolute scaling.
  14657. * Returns a Vector3.
  14658. */
  14659. get absoluteScaling(): Vector3;
  14660. /**
  14661. * Returns the current mesh absolute rotation.
  14662. * Returns a Quaternion.
  14663. */
  14664. get absoluteRotationQuaternion(): Quaternion;
  14665. /**
  14666. * Sets a new matrix to apply before all other transformation
  14667. * @param matrix defines the transform matrix
  14668. * @returns the current TransformNode
  14669. */
  14670. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14671. /**
  14672. * Sets a new pivot matrix to the current node
  14673. * @param matrix defines the new pivot matrix to use
  14674. * @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
  14675. * @returns the current TransformNode
  14676. */
  14677. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14678. /**
  14679. * Returns the mesh pivot matrix.
  14680. * Default : Identity.
  14681. * @returns the matrix
  14682. */
  14683. getPivotMatrix(): Matrix;
  14684. /**
  14685. * Instantiate (when possible) or clone that node with its hierarchy
  14686. * @param newParent defines the new parent to use for the instance (or clone)
  14687. * @param options defines options to configure how copy is done
  14688. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14689. * @returns an instance (or a clone) of the current node with its hiearchy
  14690. */
  14691. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14692. doNotInstantiate: boolean;
  14693. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14694. /**
  14695. * Prevents the World matrix to be computed any longer
  14696. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14697. * @returns the TransformNode.
  14698. */
  14699. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14700. /**
  14701. * Allows back the World matrix computation.
  14702. * @returns the TransformNode.
  14703. */
  14704. unfreezeWorldMatrix(): this;
  14705. /**
  14706. * True if the World matrix has been frozen.
  14707. */
  14708. get isWorldMatrixFrozen(): boolean;
  14709. /**
  14710. * Retuns the mesh absolute position in the World.
  14711. * @returns a Vector3.
  14712. */
  14713. getAbsolutePosition(): Vector3;
  14714. /**
  14715. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14716. * @param absolutePosition the absolute position to set
  14717. * @returns the TransformNode.
  14718. */
  14719. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14720. /**
  14721. * Sets the mesh position in its local space.
  14722. * @param vector3 the position to set in localspace
  14723. * @returns the TransformNode.
  14724. */
  14725. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14726. /**
  14727. * Returns the mesh position in the local space from the current World matrix values.
  14728. * @returns a new Vector3.
  14729. */
  14730. getPositionExpressedInLocalSpace(): Vector3;
  14731. /**
  14732. * Translates the mesh along the passed Vector3 in its local space.
  14733. * @param vector3 the distance to translate in localspace
  14734. * @returns the TransformNode.
  14735. */
  14736. locallyTranslate(vector3: Vector3): TransformNode;
  14737. private static _lookAtVectorCache;
  14738. /**
  14739. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14740. * @param targetPoint the position (must be in same space as current mesh) to look at
  14741. * @param yawCor optional yaw (y-axis) correction in radians
  14742. * @param pitchCor optional pitch (x-axis) correction in radians
  14743. * @param rollCor optional roll (z-axis) correction in radians
  14744. * @param space the choosen space of the target
  14745. * @returns the TransformNode.
  14746. */
  14747. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14748. /**
  14749. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14750. * This Vector3 is expressed in the World space.
  14751. * @param localAxis axis to rotate
  14752. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14753. */
  14754. getDirection(localAxis: Vector3): Vector3;
  14755. /**
  14756. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14757. * localAxis is expressed in the mesh local space.
  14758. * result is computed in the Wordl space from the mesh World matrix.
  14759. * @param localAxis axis to rotate
  14760. * @param result the resulting transformnode
  14761. * @returns this TransformNode.
  14762. */
  14763. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14764. /**
  14765. * Sets this transform node rotation to the given local axis.
  14766. * @param localAxis the axis in local space
  14767. * @param yawCor optional yaw (y-axis) correction in radians
  14768. * @param pitchCor optional pitch (x-axis) correction in radians
  14769. * @param rollCor optional roll (z-axis) correction in radians
  14770. * @returns this TransformNode
  14771. */
  14772. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14773. /**
  14774. * Sets a new pivot point to the current node
  14775. * @param point defines the new pivot point to use
  14776. * @param space defines if the point is in world or local space (local by default)
  14777. * @returns the current TransformNode
  14778. */
  14779. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14780. /**
  14781. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14782. * @returns the pivot point
  14783. */
  14784. getPivotPoint(): Vector3;
  14785. /**
  14786. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14787. * @param result the vector3 to store the result
  14788. * @returns this TransformNode.
  14789. */
  14790. getPivotPointToRef(result: Vector3): TransformNode;
  14791. /**
  14792. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14793. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14794. */
  14795. getAbsolutePivotPoint(): Vector3;
  14796. /**
  14797. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14798. * @param result vector3 to store the result
  14799. * @returns this TransformNode.
  14800. */
  14801. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14802. /**
  14803. * Defines the passed node as the parent of the current node.
  14804. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14805. * @see https://doc.babylonjs.com/how_to/parenting
  14806. * @param node the node ot set as the parent
  14807. * @returns this TransformNode.
  14808. */
  14809. setParent(node: Nullable<Node>): TransformNode;
  14810. private _nonUniformScaling;
  14811. /**
  14812. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14813. */
  14814. get nonUniformScaling(): boolean;
  14815. /** @hidden */
  14816. _updateNonUniformScalingState(value: boolean): boolean;
  14817. /**
  14818. * Attach the current TransformNode to another TransformNode associated with a bone
  14819. * @param bone Bone affecting the TransformNode
  14820. * @param affectedTransformNode TransformNode associated with the bone
  14821. * @returns this object
  14822. */
  14823. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14824. /**
  14825. * Detach the transform node if its associated with a bone
  14826. * @returns this object
  14827. */
  14828. detachFromBone(): TransformNode;
  14829. private static _rotationAxisCache;
  14830. /**
  14831. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14832. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14833. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14834. * The passed axis is also normalized.
  14835. * @param axis the axis to rotate around
  14836. * @param amount the amount to rotate in radians
  14837. * @param space Space to rotate in (Default: local)
  14838. * @returns the TransformNode.
  14839. */
  14840. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14841. /**
  14842. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14843. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14844. * The passed axis is also normalized. .
  14845. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14846. * @param point the point to rotate around
  14847. * @param axis the axis to rotate around
  14848. * @param amount the amount to rotate in radians
  14849. * @returns the TransformNode
  14850. */
  14851. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14852. /**
  14853. * Translates the mesh along the axis vector for the passed distance in the given space.
  14854. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14855. * @param axis the axis to translate in
  14856. * @param distance the distance to translate
  14857. * @param space Space to rotate in (Default: local)
  14858. * @returns the TransformNode.
  14859. */
  14860. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14861. /**
  14862. * Adds a rotation step to the mesh current rotation.
  14863. * x, y, z are Euler angles expressed in radians.
  14864. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14865. * This means this rotation is made in the mesh local space only.
  14866. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14867. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14868. * ```javascript
  14869. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14870. * ```
  14871. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14872. * 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.
  14873. * @param x Rotation to add
  14874. * @param y Rotation to add
  14875. * @param z Rotation to add
  14876. * @returns the TransformNode.
  14877. */
  14878. addRotation(x: number, y: number, z: number): TransformNode;
  14879. /**
  14880. * @hidden
  14881. */
  14882. protected _getEffectiveParent(): Nullable<Node>;
  14883. /**
  14884. * Computes the world matrix of the node
  14885. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14886. * @returns the world matrix
  14887. */
  14888. computeWorldMatrix(force?: boolean): Matrix;
  14889. /**
  14890. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14891. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14892. */
  14893. resetLocalMatrix(independentOfChildren?: boolean): void;
  14894. protected _afterComputeWorldMatrix(): void;
  14895. /**
  14896. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14897. * @param func callback function to add
  14898. *
  14899. * @returns the TransformNode.
  14900. */
  14901. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14902. /**
  14903. * Removes a registered callback function.
  14904. * @param func callback function to remove
  14905. * @returns the TransformNode.
  14906. */
  14907. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14908. /**
  14909. * Gets the position of the current mesh in camera space
  14910. * @param camera defines the camera to use
  14911. * @returns a position
  14912. */
  14913. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14914. /**
  14915. * Returns the distance from the mesh to the active camera
  14916. * @param camera defines the camera to use
  14917. * @returns the distance
  14918. */
  14919. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14920. /**
  14921. * Clone the current transform node
  14922. * @param name Name of the new clone
  14923. * @param newParent New parent for the clone
  14924. * @param doNotCloneChildren Do not clone children hierarchy
  14925. * @returns the new transform node
  14926. */
  14927. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14928. /**
  14929. * Serializes the objects information.
  14930. * @param currentSerializationObject defines the object to serialize in
  14931. * @returns the serialized object
  14932. */
  14933. serialize(currentSerializationObject?: any): any;
  14934. /**
  14935. * Returns a new TransformNode object parsed from the source provided.
  14936. * @param parsedTransformNode is the source.
  14937. * @param scene the scne the object belongs to
  14938. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14939. * @returns a new TransformNode object parsed from the source provided.
  14940. */
  14941. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14942. /**
  14943. * Get all child-transformNodes of this node
  14944. * @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
  14945. * @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
  14946. * @returns an array of TransformNode
  14947. */
  14948. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14949. /**
  14950. * Releases resources associated with this transform node.
  14951. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14952. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14953. */
  14954. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14955. /**
  14956. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14957. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14958. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14959. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14960. * @returns the current mesh
  14961. */
  14962. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14963. private _syncAbsoluteScalingAndRotation;
  14964. }
  14965. }
  14966. declare module BABYLON {
  14967. /**
  14968. * Class used to override all child animations of a given target
  14969. */
  14970. export class AnimationPropertiesOverride {
  14971. /**
  14972. * Gets or sets a value indicating if animation blending must be used
  14973. */
  14974. enableBlending: boolean;
  14975. /**
  14976. * Gets or sets the blending speed to use when enableBlending is true
  14977. */
  14978. blendingSpeed: number;
  14979. /**
  14980. * Gets or sets the default loop mode to use
  14981. */
  14982. loopMode: number;
  14983. }
  14984. }
  14985. declare module BABYLON {
  14986. /**
  14987. * Class used to store bone information
  14988. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14989. */
  14990. export class Bone extends Node {
  14991. /**
  14992. * defines the bone name
  14993. */
  14994. name: string;
  14995. private static _tmpVecs;
  14996. private static _tmpQuat;
  14997. private static _tmpMats;
  14998. /**
  14999. * Gets the list of child bones
  15000. */
  15001. children: Bone[];
  15002. /** Gets the animations associated with this bone */
  15003. animations: Animation[];
  15004. /**
  15005. * Gets or sets bone length
  15006. */
  15007. length: number;
  15008. /**
  15009. * @hidden Internal only
  15010. * Set this value to map this bone to a different index in the transform matrices
  15011. * Set this value to -1 to exclude the bone from the transform matrices
  15012. */
  15013. _index: Nullable<number>;
  15014. private _skeleton;
  15015. private _localMatrix;
  15016. private _restPose;
  15017. private _baseMatrix;
  15018. private _absoluteTransform;
  15019. private _invertedAbsoluteTransform;
  15020. private _parent;
  15021. private _scalingDeterminant;
  15022. private _worldTransform;
  15023. private _localScaling;
  15024. private _localRotation;
  15025. private _localPosition;
  15026. private _needToDecompose;
  15027. private _needToCompose;
  15028. /** @hidden */
  15029. _linkedTransformNode: Nullable<TransformNode>;
  15030. /** @hidden */
  15031. _waitingTransformNodeId: Nullable<string>;
  15032. /** @hidden */
  15033. get _matrix(): Matrix;
  15034. /** @hidden */
  15035. set _matrix(value: Matrix);
  15036. /**
  15037. * Create a new bone
  15038. * @param name defines the bone name
  15039. * @param skeleton defines the parent skeleton
  15040. * @param parentBone defines the parent (can be null if the bone is the root)
  15041. * @param localMatrix defines the local matrix
  15042. * @param restPose defines the rest pose matrix
  15043. * @param baseMatrix defines the base matrix
  15044. * @param index defines index of the bone in the hiearchy
  15045. */
  15046. constructor(
  15047. /**
  15048. * defines the bone name
  15049. */
  15050. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15051. /**
  15052. * Gets the current object class name.
  15053. * @return the class name
  15054. */
  15055. getClassName(): string;
  15056. /**
  15057. * Gets the parent skeleton
  15058. * @returns a skeleton
  15059. */
  15060. getSkeleton(): Skeleton;
  15061. /**
  15062. * Gets parent bone
  15063. * @returns a bone or null if the bone is the root of the bone hierarchy
  15064. */
  15065. getParent(): Nullable<Bone>;
  15066. /**
  15067. * Returns an array containing the root bones
  15068. * @returns an array containing the root bones
  15069. */
  15070. getChildren(): Array<Bone>;
  15071. /**
  15072. * Gets the node index in matrix array generated for rendering
  15073. * @returns the node index
  15074. */
  15075. getIndex(): number;
  15076. /**
  15077. * Sets the parent bone
  15078. * @param parent defines the parent (can be null if the bone is the root)
  15079. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15080. */
  15081. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15082. /**
  15083. * Gets the local matrix
  15084. * @returns a matrix
  15085. */
  15086. getLocalMatrix(): Matrix;
  15087. /**
  15088. * Gets the base matrix (initial matrix which remains unchanged)
  15089. * @returns a matrix
  15090. */
  15091. getBaseMatrix(): Matrix;
  15092. /**
  15093. * Gets the rest pose matrix
  15094. * @returns a matrix
  15095. */
  15096. getRestPose(): Matrix;
  15097. /**
  15098. * Sets the rest pose matrix
  15099. * @param matrix the local-space rest pose to set for this bone
  15100. */
  15101. setRestPose(matrix: Matrix): void;
  15102. /**
  15103. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15104. */
  15105. getWorldMatrix(): Matrix;
  15106. /**
  15107. * Sets the local matrix to rest pose matrix
  15108. */
  15109. returnToRest(): void;
  15110. /**
  15111. * Gets the inverse of the absolute transform matrix.
  15112. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15113. * @returns a matrix
  15114. */
  15115. getInvertedAbsoluteTransform(): Matrix;
  15116. /**
  15117. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15118. * @returns a matrix
  15119. */
  15120. getAbsoluteTransform(): Matrix;
  15121. /**
  15122. * Links with the given transform node.
  15123. * The local matrix of this bone is copied from the transform node every frame.
  15124. * @param transformNode defines the transform node to link to
  15125. */
  15126. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15127. /**
  15128. * Gets the node used to drive the bone's transformation
  15129. * @returns a transform node or null
  15130. */
  15131. getTransformNode(): Nullable<TransformNode>;
  15132. /** Gets or sets current position (in local space) */
  15133. get position(): Vector3;
  15134. set position(newPosition: Vector3);
  15135. /** Gets or sets current rotation (in local space) */
  15136. get rotation(): Vector3;
  15137. set rotation(newRotation: Vector3);
  15138. /** Gets or sets current rotation quaternion (in local space) */
  15139. get rotationQuaternion(): Quaternion;
  15140. set rotationQuaternion(newRotation: Quaternion);
  15141. /** Gets or sets current scaling (in local space) */
  15142. get scaling(): Vector3;
  15143. set scaling(newScaling: Vector3);
  15144. /**
  15145. * Gets the animation properties override
  15146. */
  15147. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15148. private _decompose;
  15149. private _compose;
  15150. /**
  15151. * Update the base and local matrices
  15152. * @param matrix defines the new base or local matrix
  15153. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15154. * @param updateLocalMatrix defines if the local matrix should be updated
  15155. */
  15156. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15157. /** @hidden */
  15158. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15159. /**
  15160. * Flag the bone as dirty (Forcing it to update everything)
  15161. */
  15162. markAsDirty(): void;
  15163. /** @hidden */
  15164. _markAsDirtyAndCompose(): void;
  15165. private _markAsDirtyAndDecompose;
  15166. /**
  15167. * Translate the bone in local or world space
  15168. * @param vec The amount to translate the bone
  15169. * @param space The space that the translation is in
  15170. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15171. */
  15172. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15173. /**
  15174. * Set the postion of the bone in local or world space
  15175. * @param position The position to set the bone
  15176. * @param space The space that the position is in
  15177. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15178. */
  15179. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15180. /**
  15181. * Set the absolute position of the bone (world space)
  15182. * @param position The position to set the bone
  15183. * @param mesh The mesh that this bone is attached to
  15184. */
  15185. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15186. /**
  15187. * Scale the bone on the x, y and z axes (in local space)
  15188. * @param x The amount to scale the bone on the x axis
  15189. * @param y The amount to scale the bone on the y axis
  15190. * @param z The amount to scale the bone on the z axis
  15191. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15192. */
  15193. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15194. /**
  15195. * Set the bone scaling in local space
  15196. * @param scale defines the scaling vector
  15197. */
  15198. setScale(scale: Vector3): void;
  15199. /**
  15200. * Gets the current scaling in local space
  15201. * @returns the current scaling vector
  15202. */
  15203. getScale(): Vector3;
  15204. /**
  15205. * Gets the current scaling in local space and stores it in a target vector
  15206. * @param result defines the target vector
  15207. */
  15208. getScaleToRef(result: Vector3): void;
  15209. /**
  15210. * Set the yaw, pitch, and roll of the bone in local or world space
  15211. * @param yaw The rotation of the bone on the y axis
  15212. * @param pitch The rotation of the bone on the x axis
  15213. * @param roll The rotation of the bone on the z axis
  15214. * @param space The space that the axes of rotation are in
  15215. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15216. */
  15217. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15218. /**
  15219. * Add a rotation to the bone on an axis in local or world space
  15220. * @param axis The axis to rotate the bone on
  15221. * @param amount The amount to rotate the bone
  15222. * @param space The space that the axis is in
  15223. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15224. */
  15225. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15226. /**
  15227. * Set the rotation of the bone to a particular axis angle in local or world space
  15228. * @param axis The axis to rotate the bone on
  15229. * @param angle The angle that the bone should be rotated to
  15230. * @param space The space that the axis is in
  15231. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15232. */
  15233. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15234. /**
  15235. * Set the euler rotation of the bone in local of world space
  15236. * @param rotation The euler rotation that the bone should be set to
  15237. * @param space The space that the rotation is in
  15238. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15239. */
  15240. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15241. /**
  15242. * Set the quaternion rotation of the bone in local of world space
  15243. * @param quat The quaternion rotation that the bone should be set to
  15244. * @param space The space that the rotation is in
  15245. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15246. */
  15247. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15248. /**
  15249. * Set the rotation matrix of the bone in local of world space
  15250. * @param rotMat The rotation matrix that the bone should be set to
  15251. * @param space The space that the rotation is in
  15252. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15253. */
  15254. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15255. private _rotateWithMatrix;
  15256. private _getNegativeRotationToRef;
  15257. /**
  15258. * Get the position of the bone in local or world space
  15259. * @param space The space that the returned position is in
  15260. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15261. * @returns The position of the bone
  15262. */
  15263. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15264. /**
  15265. * Copy the position of the bone to a vector3 in local or world space
  15266. * @param space The space that the returned position is in
  15267. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15268. * @param result The vector3 to copy the position to
  15269. */
  15270. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15271. /**
  15272. * Get the absolute position of the bone (world space)
  15273. * @param mesh The mesh that this bone is attached to
  15274. * @returns The absolute position of the bone
  15275. */
  15276. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15277. /**
  15278. * Copy the absolute position of the bone (world space) to the result param
  15279. * @param mesh The mesh that this bone is attached to
  15280. * @param result The vector3 to copy the absolute position to
  15281. */
  15282. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15283. /**
  15284. * Compute the absolute transforms of this bone and its children
  15285. */
  15286. computeAbsoluteTransforms(): void;
  15287. /**
  15288. * Get the world direction from an axis that is in the local space of the bone
  15289. * @param localAxis The local direction that is used to compute the world direction
  15290. * @param mesh The mesh that this bone is attached to
  15291. * @returns The world direction
  15292. */
  15293. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15294. /**
  15295. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15296. * @param localAxis The local direction that is used to compute the world direction
  15297. * @param mesh The mesh that this bone is attached to
  15298. * @param result The vector3 that the world direction will be copied to
  15299. */
  15300. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15301. /**
  15302. * Get the euler rotation of the bone in local or world space
  15303. * @param space The space that the rotation should be in
  15304. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15305. * @returns The euler rotation
  15306. */
  15307. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15308. /**
  15309. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15310. * @param space The space that the rotation should be in
  15311. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15312. * @param result The vector3 that the rotation should be copied to
  15313. */
  15314. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15315. /**
  15316. * Get the quaternion rotation of the bone in either local or world space
  15317. * @param space The space that the rotation should be in
  15318. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15319. * @returns The quaternion rotation
  15320. */
  15321. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15322. /**
  15323. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15324. * @param space The space that the rotation should be in
  15325. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15326. * @param result The quaternion that the rotation should be copied to
  15327. */
  15328. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15329. /**
  15330. * Get the rotation matrix of the bone in local or world space
  15331. * @param space The space that the rotation should be in
  15332. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15333. * @returns The rotation matrix
  15334. */
  15335. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15336. /**
  15337. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15338. * @param space The space that the rotation should be in
  15339. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15340. * @param result The quaternion that the rotation should be copied to
  15341. */
  15342. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15343. /**
  15344. * Get the world position of a point that is in the local space of the bone
  15345. * @param position The local position
  15346. * @param mesh The mesh that this bone is attached to
  15347. * @returns The world position
  15348. */
  15349. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15350. /**
  15351. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15352. * @param position The local position
  15353. * @param mesh The mesh that this bone is attached to
  15354. * @param result The vector3 that the world position should be copied to
  15355. */
  15356. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15357. /**
  15358. * Get the local position of a point that is in world space
  15359. * @param position The world position
  15360. * @param mesh The mesh that this bone is attached to
  15361. * @returns The local position
  15362. */
  15363. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15364. /**
  15365. * Get the local position of a point that is in world space and copy it to the result param
  15366. * @param position The world position
  15367. * @param mesh The mesh that this bone is attached to
  15368. * @param result The vector3 that the local position should be copied to
  15369. */
  15370. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15371. }
  15372. }
  15373. declare module BABYLON {
  15374. /**
  15375. * Defines a runtime animation
  15376. */
  15377. export class RuntimeAnimation {
  15378. private _events;
  15379. /**
  15380. * The current frame of the runtime animation
  15381. */
  15382. private _currentFrame;
  15383. /**
  15384. * The animation used by the runtime animation
  15385. */
  15386. private _animation;
  15387. /**
  15388. * The target of the runtime animation
  15389. */
  15390. private _target;
  15391. /**
  15392. * The initiating animatable
  15393. */
  15394. private _host;
  15395. /**
  15396. * The original value of the runtime animation
  15397. */
  15398. private _originalValue;
  15399. /**
  15400. * The original blend value of the runtime animation
  15401. */
  15402. private _originalBlendValue;
  15403. /**
  15404. * The offsets cache of the runtime animation
  15405. */
  15406. private _offsetsCache;
  15407. /**
  15408. * The high limits cache of the runtime animation
  15409. */
  15410. private _highLimitsCache;
  15411. /**
  15412. * Specifies if the runtime animation has been stopped
  15413. */
  15414. private _stopped;
  15415. /**
  15416. * The blending factor of the runtime animation
  15417. */
  15418. private _blendingFactor;
  15419. /**
  15420. * The BabylonJS scene
  15421. */
  15422. private _scene;
  15423. /**
  15424. * The current value of the runtime animation
  15425. */
  15426. private _currentValue;
  15427. /** @hidden */
  15428. _animationState: _IAnimationState;
  15429. /**
  15430. * The active target of the runtime animation
  15431. */
  15432. private _activeTargets;
  15433. private _currentActiveTarget;
  15434. private _directTarget;
  15435. /**
  15436. * The target path of the runtime animation
  15437. */
  15438. private _targetPath;
  15439. /**
  15440. * The weight of the runtime animation
  15441. */
  15442. private _weight;
  15443. /**
  15444. * The ratio offset of the runtime animation
  15445. */
  15446. private _ratioOffset;
  15447. /**
  15448. * The previous delay of the runtime animation
  15449. */
  15450. private _previousDelay;
  15451. /**
  15452. * The previous ratio of the runtime animation
  15453. */
  15454. private _previousRatio;
  15455. private _enableBlending;
  15456. private _keys;
  15457. private _minFrame;
  15458. private _maxFrame;
  15459. private _minValue;
  15460. private _maxValue;
  15461. private _targetIsArray;
  15462. /**
  15463. * Gets the current frame of the runtime animation
  15464. */
  15465. get currentFrame(): number;
  15466. /**
  15467. * Gets the weight of the runtime animation
  15468. */
  15469. get weight(): number;
  15470. /**
  15471. * Gets the current value of the runtime animation
  15472. */
  15473. get currentValue(): any;
  15474. /**
  15475. * Gets the target path of the runtime animation
  15476. */
  15477. get targetPath(): string;
  15478. /**
  15479. * Gets the actual target of the runtime animation
  15480. */
  15481. get target(): any;
  15482. /**
  15483. * Gets the additive state of the runtime animation
  15484. */
  15485. get isAdditive(): boolean;
  15486. /** @hidden */
  15487. _onLoop: () => void;
  15488. /**
  15489. * Create a new RuntimeAnimation object
  15490. * @param target defines the target of the animation
  15491. * @param animation defines the source animation object
  15492. * @param scene defines the hosting scene
  15493. * @param host defines the initiating Animatable
  15494. */
  15495. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15496. private _preparePath;
  15497. /**
  15498. * Gets the animation from the runtime animation
  15499. */
  15500. get animation(): Animation;
  15501. /**
  15502. * Resets the runtime animation to the beginning
  15503. * @param restoreOriginal defines whether to restore the target property to the original value
  15504. */
  15505. reset(restoreOriginal?: boolean): void;
  15506. /**
  15507. * Specifies if the runtime animation is stopped
  15508. * @returns Boolean specifying if the runtime animation is stopped
  15509. */
  15510. isStopped(): boolean;
  15511. /**
  15512. * Disposes of the runtime animation
  15513. */
  15514. dispose(): void;
  15515. /**
  15516. * Apply the interpolated value to the target
  15517. * @param currentValue defines the value computed by the animation
  15518. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15519. */
  15520. setValue(currentValue: any, weight: number): void;
  15521. private _getOriginalValues;
  15522. private _setValue;
  15523. /**
  15524. * Gets the loop pmode of the runtime animation
  15525. * @returns Loop Mode
  15526. */
  15527. private _getCorrectLoopMode;
  15528. /**
  15529. * Move the current animation to a given frame
  15530. * @param frame defines the frame to move to
  15531. */
  15532. goToFrame(frame: number): void;
  15533. /**
  15534. * @hidden Internal use only
  15535. */
  15536. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15537. /**
  15538. * Execute the current animation
  15539. * @param delay defines the delay to add to the current frame
  15540. * @param from defines the lower bound of the animation range
  15541. * @param to defines the upper bound of the animation range
  15542. * @param loop defines if the current animation must loop
  15543. * @param speedRatio defines the current speed ratio
  15544. * @param weight defines the weight of the animation (default is -1 so no weight)
  15545. * @param onLoop optional callback called when animation loops
  15546. * @returns a boolean indicating if the animation is running
  15547. */
  15548. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15549. }
  15550. }
  15551. declare module BABYLON {
  15552. /**
  15553. * Class used to store an actual running animation
  15554. */
  15555. export class Animatable {
  15556. /** defines the target object */
  15557. target: any;
  15558. /** defines the starting frame number (default is 0) */
  15559. fromFrame: number;
  15560. /** defines the ending frame number (default is 100) */
  15561. toFrame: number;
  15562. /** defines if the animation must loop (default is false) */
  15563. loopAnimation: boolean;
  15564. /** defines a callback to call when animation ends if it is not looping */
  15565. onAnimationEnd?: (() => void) | null | undefined;
  15566. /** defines a callback to call when animation loops */
  15567. onAnimationLoop?: (() => void) | null | undefined;
  15568. /** defines whether the animation should be evaluated additively */
  15569. isAdditive: boolean;
  15570. private _localDelayOffset;
  15571. private _pausedDelay;
  15572. private _runtimeAnimations;
  15573. private _paused;
  15574. private _scene;
  15575. private _speedRatio;
  15576. private _weight;
  15577. private _syncRoot;
  15578. /**
  15579. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15580. * This will only apply for non looping animation (default is true)
  15581. */
  15582. disposeOnEnd: boolean;
  15583. /**
  15584. * Gets a boolean indicating if the animation has started
  15585. */
  15586. animationStarted: boolean;
  15587. /**
  15588. * Observer raised when the animation ends
  15589. */
  15590. onAnimationEndObservable: Observable<Animatable>;
  15591. /**
  15592. * Observer raised when the animation loops
  15593. */
  15594. onAnimationLoopObservable: Observable<Animatable>;
  15595. /**
  15596. * Gets the root Animatable used to synchronize and normalize animations
  15597. */
  15598. get syncRoot(): Nullable<Animatable>;
  15599. /**
  15600. * Gets the current frame of the first RuntimeAnimation
  15601. * Used to synchronize Animatables
  15602. */
  15603. get masterFrame(): number;
  15604. /**
  15605. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15606. */
  15607. get weight(): number;
  15608. set weight(value: number);
  15609. /**
  15610. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15611. */
  15612. get speedRatio(): number;
  15613. set speedRatio(value: number);
  15614. /**
  15615. * Creates a new Animatable
  15616. * @param scene defines the hosting scene
  15617. * @param target defines the target object
  15618. * @param fromFrame defines the starting frame number (default is 0)
  15619. * @param toFrame defines the ending frame number (default is 100)
  15620. * @param loopAnimation defines if the animation must loop (default is false)
  15621. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15622. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15623. * @param animations defines a group of animation to add to the new Animatable
  15624. * @param onAnimationLoop defines a callback to call when animation loops
  15625. * @param isAdditive defines whether the animation should be evaluated additively
  15626. */
  15627. constructor(scene: Scene,
  15628. /** defines the target object */
  15629. target: any,
  15630. /** defines the starting frame number (default is 0) */
  15631. fromFrame?: number,
  15632. /** defines the ending frame number (default is 100) */
  15633. toFrame?: number,
  15634. /** defines if the animation must loop (default is false) */
  15635. loopAnimation?: boolean, speedRatio?: number,
  15636. /** defines a callback to call when animation ends if it is not looping */
  15637. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15638. /** defines a callback to call when animation loops */
  15639. onAnimationLoop?: (() => void) | null | undefined,
  15640. /** defines whether the animation should be evaluated additively */
  15641. isAdditive?: boolean);
  15642. /**
  15643. * Synchronize and normalize current Animatable with a source Animatable
  15644. * This is useful when using animation weights and when animations are not of the same length
  15645. * @param root defines the root Animatable to synchronize with
  15646. * @returns the current Animatable
  15647. */
  15648. syncWith(root: Animatable): Animatable;
  15649. /**
  15650. * Gets the list of runtime animations
  15651. * @returns an array of RuntimeAnimation
  15652. */
  15653. getAnimations(): RuntimeAnimation[];
  15654. /**
  15655. * Adds more animations to the current animatable
  15656. * @param target defines the target of the animations
  15657. * @param animations defines the new animations to add
  15658. */
  15659. appendAnimations(target: any, animations: Animation[]): void;
  15660. /**
  15661. * Gets the source animation for a specific property
  15662. * @param property defines the propertyu to look for
  15663. * @returns null or the source animation for the given property
  15664. */
  15665. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15666. /**
  15667. * Gets the runtime animation for a specific property
  15668. * @param property defines the propertyu to look for
  15669. * @returns null or the runtime animation for the given property
  15670. */
  15671. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15672. /**
  15673. * Resets the animatable to its original state
  15674. */
  15675. reset(): void;
  15676. /**
  15677. * Allows the animatable to blend with current running animations
  15678. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15679. * @param blendingSpeed defines the blending speed to use
  15680. */
  15681. enableBlending(blendingSpeed: number): void;
  15682. /**
  15683. * Disable animation blending
  15684. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15685. */
  15686. disableBlending(): void;
  15687. /**
  15688. * Jump directly to a given frame
  15689. * @param frame defines the frame to jump to
  15690. */
  15691. goToFrame(frame: number): void;
  15692. /**
  15693. * Pause the animation
  15694. */
  15695. pause(): void;
  15696. /**
  15697. * Restart the animation
  15698. */
  15699. restart(): void;
  15700. private _raiseOnAnimationEnd;
  15701. /**
  15702. * Stop and delete the current animation
  15703. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15704. * @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)
  15705. */
  15706. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15707. /**
  15708. * Wait asynchronously for the animation to end
  15709. * @returns a promise which will be fullfilled when the animation ends
  15710. */
  15711. waitAsync(): Promise<Animatable>;
  15712. /** @hidden */
  15713. _animate(delay: number): boolean;
  15714. }
  15715. interface Scene {
  15716. /** @hidden */
  15717. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15718. /** @hidden */
  15719. _processLateAnimationBindingsForMatrices(holder: {
  15720. totalWeight: number;
  15721. totalAdditiveWeight: number;
  15722. animations: RuntimeAnimation[];
  15723. additiveAnimations: RuntimeAnimation[];
  15724. originalValue: Matrix;
  15725. }): any;
  15726. /** @hidden */
  15727. _processLateAnimationBindingsForQuaternions(holder: {
  15728. totalWeight: number;
  15729. totalAdditiveWeight: number;
  15730. animations: RuntimeAnimation[];
  15731. additiveAnimations: RuntimeAnimation[];
  15732. originalValue: Quaternion;
  15733. }, refQuaternion: Quaternion): Quaternion;
  15734. /** @hidden */
  15735. _processLateAnimationBindings(): void;
  15736. /**
  15737. * Will start the animation sequence of a given target
  15738. * @param target defines the target
  15739. * @param from defines from which frame should animation start
  15740. * @param to defines until which frame should animation run.
  15741. * @param weight defines the weight to apply to the animation (1.0 by default)
  15742. * @param loop defines if the animation loops
  15743. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15744. * @param onAnimationEnd defines the function to be executed when the animation ends
  15745. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15746. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15747. * @param onAnimationLoop defines the callback to call when an animation loops
  15748. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15749. * @returns the animatable object created for this animation
  15750. */
  15751. 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;
  15752. /**
  15753. * Will start the animation sequence of a given target
  15754. * @param target defines the target
  15755. * @param from defines from which frame should animation start
  15756. * @param to defines until which frame should animation run.
  15757. * @param loop defines if the animation loops
  15758. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15759. * @param onAnimationEnd defines the function to be executed when the animation ends
  15760. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15761. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15762. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15763. * @param onAnimationLoop defines the callback to call when an animation loops
  15764. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15765. * @returns the animatable object created for this animation
  15766. */
  15767. 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;
  15768. /**
  15769. * Will start the animation sequence of a given target and its hierarchy
  15770. * @param target defines the target
  15771. * @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.
  15772. * @param from defines from which frame should animation start
  15773. * @param to defines until which frame should animation run.
  15774. * @param loop defines if the animation loops
  15775. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15776. * @param onAnimationEnd defines the function to be executed when the animation ends
  15777. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15778. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15779. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15780. * @param onAnimationLoop defines the callback to call when an animation loops
  15781. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15782. * @returns the list of created animatables
  15783. */
  15784. 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[];
  15785. /**
  15786. * Begin a new animation on a given node
  15787. * @param target defines the target where the animation will take place
  15788. * @param animations defines the list of animations to start
  15789. * @param from defines the initial value
  15790. * @param to defines the final value
  15791. * @param loop defines if you want animation to loop (off by default)
  15792. * @param speedRatio defines the speed ratio to apply to all animations
  15793. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15794. * @param onAnimationLoop defines the callback to call when an animation loops
  15795. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15796. * @returns the list of created animatables
  15797. */
  15798. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  15799. /**
  15800. * Begin a new animation on a given node and its hierarchy
  15801. * @param target defines the root node where the animation will take place
  15802. * @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.
  15803. * @param animations defines the list of animations to start
  15804. * @param from defines the initial value
  15805. * @param to defines the final value
  15806. * @param loop defines if you want animation to loop (off by default)
  15807. * @param speedRatio defines the speed ratio to apply to all animations
  15808. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15809. * @param onAnimationLoop defines the callback to call when an animation loops
  15810. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15811. * @returns the list of animatables created for all nodes
  15812. */
  15813. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  15814. /**
  15815. * Gets the animatable associated with a specific target
  15816. * @param target defines the target of the animatable
  15817. * @returns the required animatable if found
  15818. */
  15819. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15820. /**
  15821. * Gets all animatables associated with a given target
  15822. * @param target defines the target to look animatables for
  15823. * @returns an array of Animatables
  15824. */
  15825. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15826. /**
  15827. * Stops and removes all animations that have been applied to the scene
  15828. */
  15829. stopAllAnimations(): void;
  15830. /**
  15831. * Gets the current delta time used by animation engine
  15832. */
  15833. deltaTime: number;
  15834. }
  15835. interface Bone {
  15836. /**
  15837. * Copy an animation range from another bone
  15838. * @param source defines the source bone
  15839. * @param rangeName defines the range name to copy
  15840. * @param frameOffset defines the frame offset
  15841. * @param rescaleAsRequired defines if rescaling must be applied if required
  15842. * @param skelDimensionsRatio defines the scaling ratio
  15843. * @returns true if operation was successful
  15844. */
  15845. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15846. }
  15847. }
  15848. declare module BABYLON {
  15849. /**
  15850. * Class used to handle skinning animations
  15851. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15852. */
  15853. export class Skeleton implements IAnimatable {
  15854. /** defines the skeleton name */
  15855. name: string;
  15856. /** defines the skeleton Id */
  15857. id: string;
  15858. /**
  15859. * Defines the list of child bones
  15860. */
  15861. bones: Bone[];
  15862. /**
  15863. * Defines an estimate of the dimension of the skeleton at rest
  15864. */
  15865. dimensionsAtRest: Vector3;
  15866. /**
  15867. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15868. */
  15869. needInitialSkinMatrix: boolean;
  15870. /**
  15871. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15872. */
  15873. overrideMesh: Nullable<AbstractMesh>;
  15874. /**
  15875. * Gets the list of animations attached to this skeleton
  15876. */
  15877. animations: Array<Animation>;
  15878. private _scene;
  15879. private _isDirty;
  15880. private _transformMatrices;
  15881. private _transformMatrixTexture;
  15882. private _meshesWithPoseMatrix;
  15883. private _animatables;
  15884. private _identity;
  15885. private _synchronizedWithMesh;
  15886. private _ranges;
  15887. private _lastAbsoluteTransformsUpdateId;
  15888. private _canUseTextureForBones;
  15889. private _uniqueId;
  15890. /** @hidden */
  15891. _numBonesWithLinkedTransformNode: number;
  15892. /** @hidden */
  15893. _hasWaitingData: Nullable<boolean>;
  15894. /**
  15895. * Specifies if the skeleton should be serialized
  15896. */
  15897. doNotSerialize: boolean;
  15898. private _useTextureToStoreBoneMatrices;
  15899. /**
  15900. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15901. * Please note that this option is not available if the hardware does not support it
  15902. */
  15903. get useTextureToStoreBoneMatrices(): boolean;
  15904. set useTextureToStoreBoneMatrices(value: boolean);
  15905. private _animationPropertiesOverride;
  15906. /**
  15907. * Gets or sets the animation properties override
  15908. */
  15909. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15910. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15911. /**
  15912. * List of inspectable custom properties (used by the Inspector)
  15913. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15914. */
  15915. inspectableCustomProperties: IInspectable[];
  15916. /**
  15917. * An observable triggered before computing the skeleton's matrices
  15918. */
  15919. onBeforeComputeObservable: Observable<Skeleton>;
  15920. /**
  15921. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15922. */
  15923. get isUsingTextureForMatrices(): boolean;
  15924. /**
  15925. * Gets the unique ID of this skeleton
  15926. */
  15927. get uniqueId(): number;
  15928. /**
  15929. * Creates a new skeleton
  15930. * @param name defines the skeleton name
  15931. * @param id defines the skeleton Id
  15932. * @param scene defines the hosting scene
  15933. */
  15934. constructor(
  15935. /** defines the skeleton name */
  15936. name: string,
  15937. /** defines the skeleton Id */
  15938. id: string, scene: Scene);
  15939. /**
  15940. * Gets the current object class name.
  15941. * @return the class name
  15942. */
  15943. getClassName(): string;
  15944. /**
  15945. * Returns an array containing the root bones
  15946. * @returns an array containing the root bones
  15947. */
  15948. getChildren(): Array<Bone>;
  15949. /**
  15950. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15951. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15952. * @returns a Float32Array containing matrices data
  15953. */
  15954. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15955. /**
  15956. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15957. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15958. * @returns a raw texture containing the data
  15959. */
  15960. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15961. /**
  15962. * Gets the current hosting scene
  15963. * @returns a scene object
  15964. */
  15965. getScene(): Scene;
  15966. /**
  15967. * Gets a string representing the current skeleton data
  15968. * @param fullDetails defines a boolean indicating if we want a verbose version
  15969. * @returns a string representing the current skeleton data
  15970. */
  15971. toString(fullDetails?: boolean): string;
  15972. /**
  15973. * Get bone's index searching by name
  15974. * @param name defines bone's name to search for
  15975. * @return the indice of the bone. Returns -1 if not found
  15976. */
  15977. getBoneIndexByName(name: string): number;
  15978. /**
  15979. * Creater a new animation range
  15980. * @param name defines the name of the range
  15981. * @param from defines the start key
  15982. * @param to defines the end key
  15983. */
  15984. createAnimationRange(name: string, from: number, to: number): void;
  15985. /**
  15986. * Delete a specific animation range
  15987. * @param name defines the name of the range
  15988. * @param deleteFrames defines if frames must be removed as well
  15989. */
  15990. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15991. /**
  15992. * Gets a specific animation range
  15993. * @param name defines the name of the range to look for
  15994. * @returns the requested animation range or null if not found
  15995. */
  15996. getAnimationRange(name: string): Nullable<AnimationRange>;
  15997. /**
  15998. * Gets the list of all animation ranges defined on this skeleton
  15999. * @returns an array
  16000. */
  16001. getAnimationRanges(): Nullable<AnimationRange>[];
  16002. /**
  16003. * Copy animation range from a source skeleton.
  16004. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16005. * @param source defines the source skeleton
  16006. * @param name defines the name of the range to copy
  16007. * @param rescaleAsRequired defines if rescaling must be applied if required
  16008. * @returns true if operation was successful
  16009. */
  16010. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16011. /**
  16012. * Forces the skeleton to go to rest pose
  16013. */
  16014. returnToRest(): void;
  16015. private _getHighestAnimationFrame;
  16016. /**
  16017. * Begin a specific animation range
  16018. * @param name defines the name of the range to start
  16019. * @param loop defines if looping must be turned on (false by default)
  16020. * @param speedRatio defines the speed ratio to apply (1 by default)
  16021. * @param onAnimationEnd defines a callback which will be called when animation will end
  16022. * @returns a new animatable
  16023. */
  16024. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16025. /**
  16026. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16027. * @param skeleton defines the Skeleton containing the animation range to convert
  16028. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16029. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16030. * @returns the original skeleton
  16031. */
  16032. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16033. /** @hidden */
  16034. _markAsDirty(): void;
  16035. /** @hidden */
  16036. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16037. /** @hidden */
  16038. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16039. private _computeTransformMatrices;
  16040. /**
  16041. * Build all resources required to render a skeleton
  16042. */
  16043. prepare(): void;
  16044. /**
  16045. * Gets the list of animatables currently running for this skeleton
  16046. * @returns an array of animatables
  16047. */
  16048. getAnimatables(): IAnimatable[];
  16049. /**
  16050. * Clone the current skeleton
  16051. * @param name defines the name of the new skeleton
  16052. * @param id defines the id of the new skeleton
  16053. * @returns the new skeleton
  16054. */
  16055. clone(name: string, id?: string): Skeleton;
  16056. /**
  16057. * Enable animation blending for this skeleton
  16058. * @param blendingSpeed defines the blending speed to apply
  16059. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16060. */
  16061. enableBlending(blendingSpeed?: number): void;
  16062. /**
  16063. * Releases all resources associated with the current skeleton
  16064. */
  16065. dispose(): void;
  16066. /**
  16067. * Serialize the skeleton in a JSON object
  16068. * @returns a JSON object
  16069. */
  16070. serialize(): any;
  16071. /**
  16072. * Creates a new skeleton from serialized data
  16073. * @param parsedSkeleton defines the serialized data
  16074. * @param scene defines the hosting scene
  16075. * @returns a new skeleton
  16076. */
  16077. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16078. /**
  16079. * Compute all node absolute transforms
  16080. * @param forceUpdate defines if computation must be done even if cache is up to date
  16081. */
  16082. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16083. /**
  16084. * Gets the root pose matrix
  16085. * @returns a matrix
  16086. */
  16087. getPoseMatrix(): Nullable<Matrix>;
  16088. /**
  16089. * Sorts bones per internal index
  16090. */
  16091. sortBones(): void;
  16092. private _sortBones;
  16093. }
  16094. }
  16095. declare module BABYLON {
  16096. /**
  16097. * Creates an instance based on a source mesh.
  16098. */
  16099. export class InstancedMesh extends AbstractMesh {
  16100. private _sourceMesh;
  16101. private _currentLOD;
  16102. /** @hidden */
  16103. _indexInSourceMeshInstanceArray: number;
  16104. constructor(name: string, source: Mesh);
  16105. /**
  16106. * Returns the string "InstancedMesh".
  16107. */
  16108. getClassName(): string;
  16109. /** Gets the list of lights affecting that mesh */
  16110. get lightSources(): Light[];
  16111. _resyncLightSources(): void;
  16112. _resyncLightSource(light: Light): void;
  16113. _removeLightSource(light: Light, dispose: boolean): void;
  16114. /**
  16115. * If the source mesh receives shadows
  16116. */
  16117. get receiveShadows(): boolean;
  16118. /**
  16119. * The material of the source mesh
  16120. */
  16121. get material(): Nullable<Material>;
  16122. /**
  16123. * Visibility of the source mesh
  16124. */
  16125. get visibility(): number;
  16126. /**
  16127. * Skeleton of the source mesh
  16128. */
  16129. get skeleton(): Nullable<Skeleton>;
  16130. /**
  16131. * Rendering ground id of the source mesh
  16132. */
  16133. get renderingGroupId(): number;
  16134. set renderingGroupId(value: number);
  16135. /**
  16136. * Returns the total number of vertices (integer).
  16137. */
  16138. getTotalVertices(): number;
  16139. /**
  16140. * Returns a positive integer : the total number of indices in this mesh geometry.
  16141. * @returns the numner of indices or zero if the mesh has no geometry.
  16142. */
  16143. getTotalIndices(): number;
  16144. /**
  16145. * The source mesh of the instance
  16146. */
  16147. get sourceMesh(): Mesh;
  16148. /**
  16149. * Creates a new InstancedMesh object from the mesh model.
  16150. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16151. * @param name defines the name of the new instance
  16152. * @returns a new InstancedMesh
  16153. */
  16154. createInstance(name: string): InstancedMesh;
  16155. /**
  16156. * Is this node ready to be used/rendered
  16157. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16158. * @return {boolean} is it ready
  16159. */
  16160. isReady(completeCheck?: boolean): boolean;
  16161. /**
  16162. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16163. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16164. * @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.
  16165. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16166. */
  16167. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16168. /**
  16169. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16170. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16171. * The `data` are either a numeric array either a Float32Array.
  16172. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16173. * 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).
  16174. * Note that a new underlying VertexBuffer object is created each call.
  16175. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16176. *
  16177. * Possible `kind` values :
  16178. * - VertexBuffer.PositionKind
  16179. * - VertexBuffer.UVKind
  16180. * - VertexBuffer.UV2Kind
  16181. * - VertexBuffer.UV3Kind
  16182. * - VertexBuffer.UV4Kind
  16183. * - VertexBuffer.UV5Kind
  16184. * - VertexBuffer.UV6Kind
  16185. * - VertexBuffer.ColorKind
  16186. * - VertexBuffer.MatricesIndicesKind
  16187. * - VertexBuffer.MatricesIndicesExtraKind
  16188. * - VertexBuffer.MatricesWeightsKind
  16189. * - VertexBuffer.MatricesWeightsExtraKind
  16190. *
  16191. * Returns the Mesh.
  16192. */
  16193. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16194. /**
  16195. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16196. * If the mesh has no geometry, it is simply returned as it is.
  16197. * The `data` are either a numeric array either a Float32Array.
  16198. * No new underlying VertexBuffer object is created.
  16199. * 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.
  16200. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16201. *
  16202. * Possible `kind` values :
  16203. * - VertexBuffer.PositionKind
  16204. * - VertexBuffer.UVKind
  16205. * - VertexBuffer.UV2Kind
  16206. * - VertexBuffer.UV3Kind
  16207. * - VertexBuffer.UV4Kind
  16208. * - VertexBuffer.UV5Kind
  16209. * - VertexBuffer.UV6Kind
  16210. * - VertexBuffer.ColorKind
  16211. * - VertexBuffer.MatricesIndicesKind
  16212. * - VertexBuffer.MatricesIndicesExtraKind
  16213. * - VertexBuffer.MatricesWeightsKind
  16214. * - VertexBuffer.MatricesWeightsExtraKind
  16215. *
  16216. * Returns the Mesh.
  16217. */
  16218. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16219. /**
  16220. * Sets the mesh indices.
  16221. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16222. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16223. * This method creates a new index buffer each call.
  16224. * Returns the Mesh.
  16225. */
  16226. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16227. /**
  16228. * Boolean : True if the mesh owns the requested kind of data.
  16229. */
  16230. isVerticesDataPresent(kind: string): boolean;
  16231. /**
  16232. * Returns an array of indices (IndicesArray).
  16233. */
  16234. getIndices(): Nullable<IndicesArray>;
  16235. get _positions(): Nullable<Vector3[]>;
  16236. /**
  16237. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16238. * This means the mesh underlying bounding box and sphere are recomputed.
  16239. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16240. * @returns the current mesh
  16241. */
  16242. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16243. /** @hidden */
  16244. _preActivate(): InstancedMesh;
  16245. /** @hidden */
  16246. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16247. /** @hidden */
  16248. _postActivate(): void;
  16249. getWorldMatrix(): Matrix;
  16250. get isAnInstance(): boolean;
  16251. /**
  16252. * Returns the current associated LOD AbstractMesh.
  16253. */
  16254. getLOD(camera: Camera): AbstractMesh;
  16255. /** @hidden */
  16256. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16257. /** @hidden */
  16258. _syncSubMeshes(): InstancedMesh;
  16259. /** @hidden */
  16260. _generatePointsArray(): boolean;
  16261. /**
  16262. * Creates a new InstancedMesh from the current mesh.
  16263. * - name (string) : the cloned mesh name
  16264. * - newParent (optional Node) : the optional Node to parent the clone to.
  16265. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16266. *
  16267. * Returns the clone.
  16268. */
  16269. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16270. /**
  16271. * Disposes the InstancedMesh.
  16272. * Returns nothing.
  16273. */
  16274. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16275. }
  16276. interface Mesh {
  16277. /**
  16278. * Register a custom buffer that will be instanced
  16279. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16280. * @param kind defines the buffer kind
  16281. * @param stride defines the stride in floats
  16282. */
  16283. registerInstancedBuffer(kind: string, stride: number): void;
  16284. /**
  16285. * true to use the edge renderer for all instances of this mesh
  16286. */
  16287. edgesShareWithInstances: boolean;
  16288. /** @hidden */
  16289. _userInstancedBuffersStorage: {
  16290. data: {
  16291. [key: string]: Float32Array;
  16292. };
  16293. sizes: {
  16294. [key: string]: number;
  16295. };
  16296. vertexBuffers: {
  16297. [key: string]: Nullable<VertexBuffer>;
  16298. };
  16299. strides: {
  16300. [key: string]: number;
  16301. };
  16302. };
  16303. }
  16304. interface AbstractMesh {
  16305. /**
  16306. * Object used to store instanced buffers defined by user
  16307. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16308. */
  16309. instancedBuffers: {
  16310. [key: string]: any;
  16311. };
  16312. }
  16313. }
  16314. declare module BABYLON {
  16315. /**
  16316. * Defines the options associated with the creation of a shader material.
  16317. */
  16318. export interface IShaderMaterialOptions {
  16319. /**
  16320. * Does the material work in alpha blend mode
  16321. */
  16322. needAlphaBlending: boolean;
  16323. /**
  16324. * Does the material work in alpha test mode
  16325. */
  16326. needAlphaTesting: boolean;
  16327. /**
  16328. * The list of attribute names used in the shader
  16329. */
  16330. attributes: string[];
  16331. /**
  16332. * The list of unifrom names used in the shader
  16333. */
  16334. uniforms: string[];
  16335. /**
  16336. * The list of UBO names used in the shader
  16337. */
  16338. uniformBuffers: string[];
  16339. /**
  16340. * The list of sampler names used in the shader
  16341. */
  16342. samplers: string[];
  16343. /**
  16344. * The list of defines used in the shader
  16345. */
  16346. defines: string[];
  16347. }
  16348. /**
  16349. * 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.
  16350. *
  16351. * This returned material effects how the mesh will look based on the code in the shaders.
  16352. *
  16353. * @see https://doc.babylonjs.com/how_to/shader_material
  16354. */
  16355. export class ShaderMaterial extends Material {
  16356. private _shaderPath;
  16357. private _options;
  16358. private _textures;
  16359. private _textureArrays;
  16360. private _floats;
  16361. private _ints;
  16362. private _floatsArrays;
  16363. private _colors3;
  16364. private _colors3Arrays;
  16365. private _colors4;
  16366. private _colors4Arrays;
  16367. private _vectors2;
  16368. private _vectors3;
  16369. private _vectors4;
  16370. private _matrices;
  16371. private _matrixArrays;
  16372. private _matrices3x3;
  16373. private _matrices2x2;
  16374. private _vectors2Arrays;
  16375. private _vectors3Arrays;
  16376. private _vectors4Arrays;
  16377. private _cachedWorldViewMatrix;
  16378. private _cachedWorldViewProjectionMatrix;
  16379. private _renderId;
  16380. private _multiview;
  16381. private _cachedDefines;
  16382. /** Define the Url to load snippets */
  16383. static SnippetUrl: string;
  16384. /** Snippet ID if the material was created from the snippet server */
  16385. snippetId: string;
  16386. /**
  16387. * Instantiate a new shader material.
  16388. * 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.
  16389. * This returned material effects how the mesh will look based on the code in the shaders.
  16390. * @see https://doc.babylonjs.com/how_to/shader_material
  16391. * @param name Define the name of the material in the scene
  16392. * @param scene Define the scene the material belongs to
  16393. * @param shaderPath Defines the route to the shader code in one of three ways:
  16394. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16395. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16396. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16397. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16398. * @param options Define the options used to create the shader
  16399. */
  16400. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16401. /**
  16402. * Gets the shader path used to define the shader code
  16403. * It can be modified to trigger a new compilation
  16404. */
  16405. get shaderPath(): any;
  16406. /**
  16407. * Sets the shader path used to define the shader code
  16408. * It can be modified to trigger a new compilation
  16409. */
  16410. set shaderPath(shaderPath: any);
  16411. /**
  16412. * Gets the options used to compile the shader.
  16413. * They can be modified to trigger a new compilation
  16414. */
  16415. get options(): IShaderMaterialOptions;
  16416. /**
  16417. * Gets the current class name of the material e.g. "ShaderMaterial"
  16418. * Mainly use in serialization.
  16419. * @returns the class name
  16420. */
  16421. getClassName(): string;
  16422. /**
  16423. * Specifies if the material will require alpha blending
  16424. * @returns a boolean specifying if alpha blending is needed
  16425. */
  16426. needAlphaBlending(): boolean;
  16427. /**
  16428. * Specifies if this material should be rendered in alpha test mode
  16429. * @returns a boolean specifying if an alpha test is needed.
  16430. */
  16431. needAlphaTesting(): boolean;
  16432. private _checkUniform;
  16433. /**
  16434. * Set a texture in the shader.
  16435. * @param name Define the name of the uniform samplers as defined in the shader
  16436. * @param texture Define the texture to bind to this sampler
  16437. * @return the material itself allowing "fluent" like uniform updates
  16438. */
  16439. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16440. /**
  16441. * Set a texture array in the shader.
  16442. * @param name Define the name of the uniform sampler array as defined in the shader
  16443. * @param textures Define the list of textures to bind to this sampler
  16444. * @return the material itself allowing "fluent" like uniform updates
  16445. */
  16446. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16447. /**
  16448. * Set a float in the shader.
  16449. * @param name Define the name of the uniform as defined in the shader
  16450. * @param value Define the value to give to the uniform
  16451. * @return the material itself allowing "fluent" like uniform updates
  16452. */
  16453. setFloat(name: string, value: number): ShaderMaterial;
  16454. /**
  16455. * Set a int in the shader.
  16456. * @param name Define the name of the uniform as defined in the shader
  16457. * @param value Define the value to give to the uniform
  16458. * @return the material itself allowing "fluent" like uniform updates
  16459. */
  16460. setInt(name: string, value: number): ShaderMaterial;
  16461. /**
  16462. * Set an array of floats in the shader.
  16463. * @param name Define the name of the uniform as defined in the shader
  16464. * @param value Define the value to give to the uniform
  16465. * @return the material itself allowing "fluent" like uniform updates
  16466. */
  16467. setFloats(name: string, value: number[]): ShaderMaterial;
  16468. /**
  16469. * Set a vec3 in the shader from a Color3.
  16470. * @param name Define the name of the uniform as defined in the shader
  16471. * @param value Define the value to give to the uniform
  16472. * @return the material itself allowing "fluent" like uniform updates
  16473. */
  16474. setColor3(name: string, value: Color3): ShaderMaterial;
  16475. /**
  16476. * Set a vec3 array in the shader from a Color3 array.
  16477. * @param name Define the name of the uniform as defined in the shader
  16478. * @param value Define the value to give to the uniform
  16479. * @return the material itself allowing "fluent" like uniform updates
  16480. */
  16481. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16482. /**
  16483. * Set a vec4 in the shader from a Color4.
  16484. * @param name Define the name of the uniform as defined in the shader
  16485. * @param value Define the value to give to the uniform
  16486. * @return the material itself allowing "fluent" like uniform updates
  16487. */
  16488. setColor4(name: string, value: Color4): ShaderMaterial;
  16489. /**
  16490. * Set a vec4 array in the shader from a Color4 array.
  16491. * @param name Define the name of the uniform as defined in the shader
  16492. * @param value Define the value to give to the uniform
  16493. * @return the material itself allowing "fluent" like uniform updates
  16494. */
  16495. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16496. /**
  16497. * Set a vec2 in the shader from a Vector2.
  16498. * @param name Define the name of the uniform as defined in the shader
  16499. * @param value Define the value to give to the uniform
  16500. * @return the material itself allowing "fluent" like uniform updates
  16501. */
  16502. setVector2(name: string, value: Vector2): ShaderMaterial;
  16503. /**
  16504. * Set a vec3 in the shader from a Vector3.
  16505. * @param name Define the name of the uniform as defined in the shader
  16506. * @param value Define the value to give to the uniform
  16507. * @return the material itself allowing "fluent" like uniform updates
  16508. */
  16509. setVector3(name: string, value: Vector3): ShaderMaterial;
  16510. /**
  16511. * Set a vec4 in the shader from a Vector4.
  16512. * @param name Define the name of the uniform as defined in the shader
  16513. * @param value Define the value to give to the uniform
  16514. * @return the material itself allowing "fluent" like uniform updates
  16515. */
  16516. setVector4(name: string, value: Vector4): ShaderMaterial;
  16517. /**
  16518. * Set a mat4 in the shader from a Matrix.
  16519. * @param name Define the name of the uniform as defined in the shader
  16520. * @param value Define the value to give to the uniform
  16521. * @return the material itself allowing "fluent" like uniform updates
  16522. */
  16523. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16524. /**
  16525. * Set a float32Array in the shader from a matrix array.
  16526. * @param name Define the name of the uniform as defined in the shader
  16527. * @param value Define the value to give to the uniform
  16528. * @return the material itself allowing "fluent" like uniform updates
  16529. */
  16530. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16531. /**
  16532. * Set a mat3 in the shader from a Float32Array.
  16533. * @param name Define the name of the uniform as defined in the shader
  16534. * @param value Define the value to give to the uniform
  16535. * @return the material itself allowing "fluent" like uniform updates
  16536. */
  16537. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16538. /**
  16539. * Set a mat2 in the shader from a Float32Array.
  16540. * @param name Define the name of the uniform as defined in the shader
  16541. * @param value Define the value to give to the uniform
  16542. * @return the material itself allowing "fluent" like uniform updates
  16543. */
  16544. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16545. /**
  16546. * Set a vec2 array in the shader from a number array.
  16547. * @param name Define the name of the uniform as defined in the shader
  16548. * @param value Define the value to give to the uniform
  16549. * @return the material itself allowing "fluent" like uniform updates
  16550. */
  16551. setArray2(name: string, value: number[]): ShaderMaterial;
  16552. /**
  16553. * Set a vec3 array in the shader from a number array.
  16554. * @param name Define the name of the uniform as defined in the shader
  16555. * @param value Define the value to give to the uniform
  16556. * @return the material itself allowing "fluent" like uniform updates
  16557. */
  16558. setArray3(name: string, value: number[]): ShaderMaterial;
  16559. /**
  16560. * Set a vec4 array in the shader from a number array.
  16561. * @param name Define the name of the uniform as defined in the shader
  16562. * @param value Define the value to give to the uniform
  16563. * @return the material itself allowing "fluent" like uniform updates
  16564. */
  16565. setArray4(name: string, value: number[]): ShaderMaterial;
  16566. private _checkCache;
  16567. /**
  16568. * Specifies that the submesh is ready to be used
  16569. * @param mesh defines the mesh to check
  16570. * @param subMesh defines which submesh to check
  16571. * @param useInstances specifies that instances should be used
  16572. * @returns a boolean indicating that the submesh is ready or not
  16573. */
  16574. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16575. /**
  16576. * Checks if the material is ready to render the requested mesh
  16577. * @param mesh Define the mesh to render
  16578. * @param useInstances Define whether or not the material is used with instances
  16579. * @returns true if ready, otherwise false
  16580. */
  16581. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16582. /**
  16583. * Binds the world matrix to the material
  16584. * @param world defines the world transformation matrix
  16585. * @param effectOverride - If provided, use this effect instead of internal effect
  16586. */
  16587. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16588. /**
  16589. * Binds the submesh to this material by preparing the effect and shader to draw
  16590. * @param world defines the world transformation matrix
  16591. * @param mesh defines the mesh containing the submesh
  16592. * @param subMesh defines the submesh to bind the material to
  16593. */
  16594. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16595. /**
  16596. * Binds the material to the mesh
  16597. * @param world defines the world transformation matrix
  16598. * @param mesh defines the mesh to bind the material to
  16599. * @param effectOverride - If provided, use this effect instead of internal effect
  16600. */
  16601. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16602. protected _afterBind(mesh?: Mesh): void;
  16603. /**
  16604. * Gets the active textures from the material
  16605. * @returns an array of textures
  16606. */
  16607. getActiveTextures(): BaseTexture[];
  16608. /**
  16609. * Specifies if the material uses a texture
  16610. * @param texture defines the texture to check against the material
  16611. * @returns a boolean specifying if the material uses the texture
  16612. */
  16613. hasTexture(texture: BaseTexture): boolean;
  16614. /**
  16615. * Makes a duplicate of the material, and gives it a new name
  16616. * @param name defines the new name for the duplicated material
  16617. * @returns the cloned material
  16618. */
  16619. clone(name: string): ShaderMaterial;
  16620. /**
  16621. * Disposes the material
  16622. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16623. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16624. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16625. */
  16626. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16627. /**
  16628. * Serializes this material in a JSON representation
  16629. * @returns the serialized material object
  16630. */
  16631. serialize(): any;
  16632. /**
  16633. * Creates a shader material from parsed shader material data
  16634. * @param source defines the JSON represnetation of the material
  16635. * @param scene defines the hosting scene
  16636. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16637. * @returns a new material
  16638. */
  16639. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16640. /**
  16641. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16642. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16643. * @param url defines the url to load from
  16644. * @param scene defines the hosting scene
  16645. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16646. * @returns a promise that will resolve to the new ShaderMaterial
  16647. */
  16648. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16649. /**
  16650. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16651. * @param snippetId defines the snippet to load
  16652. * @param scene defines the hosting scene
  16653. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16654. * @returns a promise that will resolve to the new ShaderMaterial
  16655. */
  16656. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16657. }
  16658. }
  16659. declare module BABYLON {
  16660. /** @hidden */
  16661. export var colorPixelShader: {
  16662. name: string;
  16663. shader: string;
  16664. };
  16665. }
  16666. declare module BABYLON {
  16667. /** @hidden */
  16668. export var colorVertexShader: {
  16669. name: string;
  16670. shader: string;
  16671. };
  16672. }
  16673. declare module BABYLON {
  16674. /**
  16675. * Line mesh
  16676. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16677. */
  16678. export class LinesMesh extends Mesh {
  16679. /**
  16680. * If vertex color should be applied to the mesh
  16681. */
  16682. readonly useVertexColor?: boolean | undefined;
  16683. /**
  16684. * If vertex alpha should be applied to the mesh
  16685. */
  16686. readonly useVertexAlpha?: boolean | undefined;
  16687. /**
  16688. * Color of the line (Default: White)
  16689. */
  16690. color: Color3;
  16691. /**
  16692. * Alpha of the line (Default: 1)
  16693. */
  16694. alpha: number;
  16695. /**
  16696. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16697. * This margin is expressed in world space coordinates, so its value may vary.
  16698. * Default value is 0.1
  16699. */
  16700. intersectionThreshold: number;
  16701. private _colorShader;
  16702. private color4;
  16703. /**
  16704. * Creates a new LinesMesh
  16705. * @param name defines the name
  16706. * @param scene defines the hosting scene
  16707. * @param parent defines the parent mesh if any
  16708. * @param source defines the optional source LinesMesh used to clone data from
  16709. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16710. * When false, achieved by calling a clone(), also passing False.
  16711. * This will make creation of children, recursive.
  16712. * @param useVertexColor defines if this LinesMesh supports vertex color
  16713. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16714. */
  16715. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16716. /**
  16717. * If vertex color should be applied to the mesh
  16718. */
  16719. useVertexColor?: boolean | undefined,
  16720. /**
  16721. * If vertex alpha should be applied to the mesh
  16722. */
  16723. useVertexAlpha?: boolean | undefined);
  16724. private _addClipPlaneDefine;
  16725. private _removeClipPlaneDefine;
  16726. isReady(): boolean;
  16727. /**
  16728. * Returns the string "LineMesh"
  16729. */
  16730. getClassName(): string;
  16731. /**
  16732. * @hidden
  16733. */
  16734. get material(): Material;
  16735. /**
  16736. * @hidden
  16737. */
  16738. set material(value: Material);
  16739. /**
  16740. * @hidden
  16741. */
  16742. get checkCollisions(): boolean;
  16743. /** @hidden */
  16744. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16745. /** @hidden */
  16746. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16747. /**
  16748. * Disposes of the line mesh
  16749. * @param doNotRecurse If children should be disposed
  16750. */
  16751. dispose(doNotRecurse?: boolean): void;
  16752. /**
  16753. * Returns a new LineMesh object cloned from the current one.
  16754. */
  16755. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16756. /**
  16757. * Creates a new InstancedLinesMesh object from the mesh model.
  16758. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16759. * @param name defines the name of the new instance
  16760. * @returns a new InstancedLinesMesh
  16761. */
  16762. createInstance(name: string): InstancedLinesMesh;
  16763. }
  16764. /**
  16765. * Creates an instance based on a source LinesMesh
  16766. */
  16767. export class InstancedLinesMesh extends InstancedMesh {
  16768. /**
  16769. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16770. * This margin is expressed in world space coordinates, so its value may vary.
  16771. * Initilized with the intersectionThreshold value of the source LinesMesh
  16772. */
  16773. intersectionThreshold: number;
  16774. constructor(name: string, source: LinesMesh);
  16775. /**
  16776. * Returns the string "InstancedLinesMesh".
  16777. */
  16778. getClassName(): string;
  16779. }
  16780. }
  16781. declare module BABYLON {
  16782. /** @hidden */
  16783. export var linePixelShader: {
  16784. name: string;
  16785. shader: string;
  16786. };
  16787. }
  16788. declare module BABYLON {
  16789. /** @hidden */
  16790. export var lineVertexShader: {
  16791. name: string;
  16792. shader: string;
  16793. };
  16794. }
  16795. declare module BABYLON {
  16796. interface Scene {
  16797. /** @hidden */
  16798. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  16799. }
  16800. interface AbstractMesh {
  16801. /**
  16802. * Gets the edgesRenderer associated with the mesh
  16803. */
  16804. edgesRenderer: Nullable<EdgesRenderer>;
  16805. }
  16806. interface LinesMesh {
  16807. /**
  16808. * Enables the edge rendering mode on the mesh.
  16809. * This mode makes the mesh edges visible
  16810. * @param epsilon defines the maximal distance between two angles to detect a face
  16811. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16812. * @returns the currentAbstractMesh
  16813. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16814. */
  16815. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16816. }
  16817. interface InstancedLinesMesh {
  16818. /**
  16819. * Enables the edge rendering mode on the mesh.
  16820. * This mode makes the mesh edges visible
  16821. * @param epsilon defines the maximal distance between two angles to detect a face
  16822. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16823. * @returns the current InstancedLinesMesh
  16824. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16825. */
  16826. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16827. }
  16828. /**
  16829. * Defines the minimum contract an Edges renderer should follow.
  16830. */
  16831. export interface IEdgesRenderer extends IDisposable {
  16832. /**
  16833. * Gets or sets a boolean indicating if the edgesRenderer is active
  16834. */
  16835. isEnabled: boolean;
  16836. /**
  16837. * Renders the edges of the attached mesh,
  16838. */
  16839. render(): void;
  16840. /**
  16841. * Checks wether or not the edges renderer is ready to render.
  16842. * @return true if ready, otherwise false.
  16843. */
  16844. isReady(): boolean;
  16845. /**
  16846. * List of instances to render in case the source mesh has instances
  16847. */
  16848. customInstances: SmartArray<Matrix>;
  16849. }
  16850. /**
  16851. * Defines the additional options of the edges renderer
  16852. */
  16853. export interface IEdgesRendererOptions {
  16854. /**
  16855. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  16856. * If not defined, the default value is true
  16857. */
  16858. useAlternateEdgeFinder?: boolean;
  16859. /**
  16860. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  16861. * If not defined, the default value is true.
  16862. * 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)
  16863. * This option is used only if useAlternateEdgeFinder = true
  16864. */
  16865. useFastVertexMerger?: boolean;
  16866. /**
  16867. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  16868. * The default value is 1e-6
  16869. * This option is used only if useAlternateEdgeFinder = true
  16870. */
  16871. epsilonVertexMerge?: number;
  16872. /**
  16873. * 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
  16874. * 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.
  16875. * This option is used only if useAlternateEdgeFinder = true
  16876. */
  16877. applyTessellation?: boolean;
  16878. /**
  16879. * 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
  16880. * The default value is 1e-6
  16881. * This option is used only if useAlternateEdgeFinder = true
  16882. */
  16883. epsilonVertexAligned?: number;
  16884. }
  16885. /**
  16886. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16887. */
  16888. export class EdgesRenderer implements IEdgesRenderer {
  16889. /**
  16890. * Define the size of the edges with an orthographic camera
  16891. */
  16892. edgesWidthScalerForOrthographic: number;
  16893. /**
  16894. * Define the size of the edges with a perspective camera
  16895. */
  16896. edgesWidthScalerForPerspective: number;
  16897. protected _source: AbstractMesh;
  16898. protected _linesPositions: number[];
  16899. protected _linesNormals: number[];
  16900. protected _linesIndices: number[];
  16901. protected _epsilon: number;
  16902. protected _indicesCount: number;
  16903. protected _lineShader: ShaderMaterial;
  16904. protected _ib: DataBuffer;
  16905. protected _buffers: {
  16906. [key: string]: Nullable<VertexBuffer>;
  16907. };
  16908. protected _buffersForInstances: {
  16909. [key: string]: Nullable<VertexBuffer>;
  16910. };
  16911. protected _checkVerticesInsteadOfIndices: boolean;
  16912. protected _options: Nullable<IEdgesRendererOptions>;
  16913. private _meshRebuildObserver;
  16914. private _meshDisposeObserver;
  16915. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16916. isEnabled: boolean;
  16917. /**
  16918. * List of instances to render in case the source mesh has instances
  16919. */
  16920. customInstances: SmartArray<Matrix>;
  16921. private static GetShader;
  16922. /**
  16923. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16924. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16925. * @param source Mesh used to create edges
  16926. * @param epsilon sum of angles in adjacency to check for edge
  16927. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  16928. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16929. * @param options The options to apply when generating the edges
  16930. */
  16931. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  16932. protected _prepareRessources(): void;
  16933. /** @hidden */
  16934. _rebuild(): void;
  16935. /**
  16936. * Releases the required resources for the edges renderer
  16937. */
  16938. dispose(): void;
  16939. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16940. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16941. /**
  16942. * Checks if the pair of p0 and p1 is en edge
  16943. * @param faceIndex
  16944. * @param edge
  16945. * @param faceNormals
  16946. * @param p0
  16947. * @param p1
  16948. * @private
  16949. */
  16950. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16951. /**
  16952. * push line into the position, normal and index buffer
  16953. * @protected
  16954. */
  16955. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16956. /**
  16957. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  16958. */
  16959. private _tessellateTriangle;
  16960. private _generateEdgesLinesAlternate;
  16961. /**
  16962. * Generates lines edges from adjacencjes
  16963. * @private
  16964. */
  16965. _generateEdgesLines(): void;
  16966. /**
  16967. * Checks wether or not the edges renderer is ready to render.
  16968. * @return true if ready, otherwise false.
  16969. */
  16970. isReady(): boolean;
  16971. /**
  16972. * Renders the edges of the attached mesh,
  16973. */
  16974. render(): void;
  16975. }
  16976. /**
  16977. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16978. */
  16979. export class LineEdgesRenderer extends EdgesRenderer {
  16980. /**
  16981. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16982. * @param source LineMesh used to generate edges
  16983. * @param epsilon not important (specified angle for edge detection)
  16984. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16985. */
  16986. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16987. /**
  16988. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16989. */
  16990. _generateEdgesLines(): void;
  16991. }
  16992. }
  16993. declare module BABYLON {
  16994. /**
  16995. * This represents the object necessary to create a rendering group.
  16996. * This is exclusively used and created by the rendering manager.
  16997. * To modify the behavior, you use the available helpers in your scene or meshes.
  16998. * @hidden
  16999. */
  17000. export class RenderingGroup {
  17001. index: number;
  17002. private static _zeroVector;
  17003. private _scene;
  17004. private _opaqueSubMeshes;
  17005. private _transparentSubMeshes;
  17006. private _alphaTestSubMeshes;
  17007. private _depthOnlySubMeshes;
  17008. private _particleSystems;
  17009. private _spriteManagers;
  17010. private _opaqueSortCompareFn;
  17011. private _alphaTestSortCompareFn;
  17012. private _transparentSortCompareFn;
  17013. private _renderOpaque;
  17014. private _renderAlphaTest;
  17015. private _renderTransparent;
  17016. /** @hidden */
  17017. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17018. onBeforeTransparentRendering: () => void;
  17019. /**
  17020. * Set the opaque sort comparison function.
  17021. * If null the sub meshes will be render in the order they were created
  17022. */
  17023. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17024. /**
  17025. * Set the alpha test sort comparison function.
  17026. * If null the sub meshes will be render in the order they were created
  17027. */
  17028. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17029. /**
  17030. * Set the transparent sort comparison function.
  17031. * If null the sub meshes will be render in the order they were created
  17032. */
  17033. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17034. /**
  17035. * Creates a new rendering group.
  17036. * @param index The rendering group index
  17037. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17038. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17039. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17040. */
  17041. 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>);
  17042. /**
  17043. * Render all the sub meshes contained in the group.
  17044. * @param customRenderFunction Used to override the default render behaviour of the group.
  17045. * @returns true if rendered some submeshes.
  17046. */
  17047. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17048. /**
  17049. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17050. * @param subMeshes The submeshes to render
  17051. */
  17052. private renderOpaqueSorted;
  17053. /**
  17054. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17055. * @param subMeshes The submeshes to render
  17056. */
  17057. private renderAlphaTestSorted;
  17058. /**
  17059. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17060. * @param subMeshes The submeshes to render
  17061. */
  17062. private renderTransparentSorted;
  17063. /**
  17064. * Renders the submeshes in a specified order.
  17065. * @param subMeshes The submeshes to sort before render
  17066. * @param sortCompareFn The comparison function use to sort
  17067. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17068. * @param transparent Specifies to activate blending if true
  17069. */
  17070. private static renderSorted;
  17071. /**
  17072. * Renders the submeshes in the order they were dispatched (no sort applied).
  17073. * @param subMeshes The submeshes to render
  17074. */
  17075. private static renderUnsorted;
  17076. /**
  17077. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17078. * are rendered back to front if in the same alpha index.
  17079. *
  17080. * @param a The first submesh
  17081. * @param b The second submesh
  17082. * @returns The result of the comparison
  17083. */
  17084. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17085. /**
  17086. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17087. * are rendered back to front.
  17088. *
  17089. * @param a The first submesh
  17090. * @param b The second submesh
  17091. * @returns The result of the comparison
  17092. */
  17093. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17094. /**
  17095. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17096. * are rendered front to back (prevent overdraw).
  17097. *
  17098. * @param a The first submesh
  17099. * @param b The second submesh
  17100. * @returns The result of the comparison
  17101. */
  17102. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17103. /**
  17104. * Resets the different lists of submeshes to prepare a new frame.
  17105. */
  17106. prepare(): void;
  17107. dispose(): void;
  17108. /**
  17109. * Inserts the submesh in its correct queue depending on its material.
  17110. * @param subMesh The submesh to dispatch
  17111. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17112. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17113. */
  17114. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17115. dispatchSprites(spriteManager: ISpriteManager): void;
  17116. dispatchParticles(particleSystem: IParticleSystem): void;
  17117. private _renderParticles;
  17118. private _renderSprites;
  17119. }
  17120. }
  17121. declare module BABYLON {
  17122. /**
  17123. * Interface describing the different options available in the rendering manager
  17124. * regarding Auto Clear between groups.
  17125. */
  17126. export interface IRenderingManagerAutoClearSetup {
  17127. /**
  17128. * Defines whether or not autoclear is enable.
  17129. */
  17130. autoClear: boolean;
  17131. /**
  17132. * Defines whether or not to autoclear the depth buffer.
  17133. */
  17134. depth: boolean;
  17135. /**
  17136. * Defines whether or not to autoclear the stencil buffer.
  17137. */
  17138. stencil: boolean;
  17139. }
  17140. /**
  17141. * This class is used by the onRenderingGroupObservable
  17142. */
  17143. export class RenderingGroupInfo {
  17144. /**
  17145. * The Scene that being rendered
  17146. */
  17147. scene: Scene;
  17148. /**
  17149. * The camera currently used for the rendering pass
  17150. */
  17151. camera: Nullable<Camera>;
  17152. /**
  17153. * The ID of the renderingGroup being processed
  17154. */
  17155. renderingGroupId: number;
  17156. }
  17157. /**
  17158. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17159. * It is enable to manage the different groups as well as the different necessary sort functions.
  17160. * This should not be used directly aside of the few static configurations
  17161. */
  17162. export class RenderingManager {
  17163. /**
  17164. * The max id used for rendering groups (not included)
  17165. */
  17166. static MAX_RENDERINGGROUPS: number;
  17167. /**
  17168. * The min id used for rendering groups (included)
  17169. */
  17170. static MIN_RENDERINGGROUPS: number;
  17171. /**
  17172. * Used to globally prevent autoclearing scenes.
  17173. */
  17174. static AUTOCLEAR: boolean;
  17175. /**
  17176. * @hidden
  17177. */
  17178. _useSceneAutoClearSetup: boolean;
  17179. private _scene;
  17180. private _renderingGroups;
  17181. private _depthStencilBufferAlreadyCleaned;
  17182. private _autoClearDepthStencil;
  17183. private _customOpaqueSortCompareFn;
  17184. private _customAlphaTestSortCompareFn;
  17185. private _customTransparentSortCompareFn;
  17186. private _renderingGroupInfo;
  17187. /**
  17188. * Instantiates a new rendering group for a particular scene
  17189. * @param scene Defines the scene the groups belongs to
  17190. */
  17191. constructor(scene: Scene);
  17192. private _clearDepthStencilBuffer;
  17193. /**
  17194. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17195. * @hidden
  17196. */
  17197. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17198. /**
  17199. * Resets the different information of the group to prepare a new frame
  17200. * @hidden
  17201. */
  17202. reset(): void;
  17203. /**
  17204. * Dispose and release the group and its associated resources.
  17205. * @hidden
  17206. */
  17207. dispose(): void;
  17208. /**
  17209. * Clear the info related to rendering groups preventing retention points during dispose.
  17210. */
  17211. freeRenderingGroups(): void;
  17212. private _prepareRenderingGroup;
  17213. /**
  17214. * Add a sprite manager to the rendering manager in order to render it this frame.
  17215. * @param spriteManager Define the sprite manager to render
  17216. */
  17217. dispatchSprites(spriteManager: ISpriteManager): void;
  17218. /**
  17219. * Add a particle system to the rendering manager in order to render it this frame.
  17220. * @param particleSystem Define the particle system to render
  17221. */
  17222. dispatchParticles(particleSystem: IParticleSystem): void;
  17223. /**
  17224. * Add a submesh to the manager in order to render it this frame
  17225. * @param subMesh The submesh to dispatch
  17226. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17227. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17228. */
  17229. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17230. /**
  17231. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17232. * This allowed control for front to back rendering or reversly depending of the special needs.
  17233. *
  17234. * @param renderingGroupId The rendering group id corresponding to its index
  17235. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17236. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17237. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17238. */
  17239. 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;
  17240. /**
  17241. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17242. *
  17243. * @param renderingGroupId The rendering group id corresponding to its index
  17244. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17245. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17246. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17247. */
  17248. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17249. /**
  17250. * Gets the current auto clear configuration for one rendering group of the rendering
  17251. * manager.
  17252. * @param index the rendering group index to get the information for
  17253. * @returns The auto clear setup for the requested rendering group
  17254. */
  17255. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17256. }
  17257. }
  17258. declare module BABYLON {
  17259. /**
  17260. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17261. */
  17262. export interface ICustomShaderOptions {
  17263. /**
  17264. * Gets or sets the custom shader name to use
  17265. */
  17266. shaderName: string;
  17267. /**
  17268. * The list of attribute names used in the shader
  17269. */
  17270. attributes?: string[];
  17271. /**
  17272. * The list of unifrom names used in the shader
  17273. */
  17274. uniforms?: string[];
  17275. /**
  17276. * The list of sampler names used in the shader
  17277. */
  17278. samplers?: string[];
  17279. /**
  17280. * The list of defines used in the shader
  17281. */
  17282. defines?: string[];
  17283. }
  17284. /**
  17285. * Interface to implement to create a shadow generator compatible with BJS.
  17286. */
  17287. export interface IShadowGenerator {
  17288. /**
  17289. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17290. * @returns The render target texture if present otherwise, null
  17291. */
  17292. getShadowMap(): Nullable<RenderTargetTexture>;
  17293. /**
  17294. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17295. * @param subMesh The submesh we want to render in the shadow map
  17296. * @param useInstances Defines wether will draw in the map using instances
  17297. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17298. * @returns true if ready otherwise, false
  17299. */
  17300. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17301. /**
  17302. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17303. * @param defines Defines of the material we want to update
  17304. * @param lightIndex Index of the light in the enabled light list of the material
  17305. */
  17306. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17307. /**
  17308. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17309. * defined in the generator but impacting the effect).
  17310. * It implies the unifroms available on the materials are the standard BJS ones.
  17311. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17312. * @param effect The effect we are binfing the information for
  17313. */
  17314. bindShadowLight(lightIndex: string, effect: Effect): void;
  17315. /**
  17316. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17317. * (eq to shadow prjection matrix * light transform matrix)
  17318. * @returns The transform matrix used to create the shadow map
  17319. */
  17320. getTransformMatrix(): Matrix;
  17321. /**
  17322. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17323. * Cube and 2D textures for instance.
  17324. */
  17325. recreateShadowMap(): void;
  17326. /**
  17327. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17328. * @param onCompiled Callback triggered at the and of the effects compilation
  17329. * @param options Sets of optional options forcing the compilation with different modes
  17330. */
  17331. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17332. useInstances: boolean;
  17333. }>): void;
  17334. /**
  17335. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17336. * @param options Sets of optional options forcing the compilation with different modes
  17337. * @returns A promise that resolves when the compilation completes
  17338. */
  17339. forceCompilationAsync(options?: Partial<{
  17340. useInstances: boolean;
  17341. }>): Promise<void>;
  17342. /**
  17343. * Serializes the shadow generator setup to a json object.
  17344. * @returns The serialized JSON object
  17345. */
  17346. serialize(): any;
  17347. /**
  17348. * Disposes the Shadow map and related Textures and effects.
  17349. */
  17350. dispose(): void;
  17351. }
  17352. /**
  17353. * Default implementation IShadowGenerator.
  17354. * This is the main object responsible of generating shadows in the framework.
  17355. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17356. */
  17357. export class ShadowGenerator implements IShadowGenerator {
  17358. /**
  17359. * Name of the shadow generator class
  17360. */
  17361. static CLASSNAME: string;
  17362. /**
  17363. * Shadow generator mode None: no filtering applied.
  17364. */
  17365. static readonly FILTER_NONE: number;
  17366. /**
  17367. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17368. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17369. */
  17370. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17371. /**
  17372. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17373. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17374. */
  17375. static readonly FILTER_POISSONSAMPLING: number;
  17376. /**
  17377. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17378. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17379. */
  17380. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17381. /**
  17382. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17383. * edge artifacts on steep falloff.
  17384. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17385. */
  17386. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17387. /**
  17388. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17389. * edge artifacts on steep falloff.
  17390. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17391. */
  17392. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17393. /**
  17394. * Shadow generator mode PCF: Percentage Closer Filtering
  17395. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17396. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17397. */
  17398. static readonly FILTER_PCF: number;
  17399. /**
  17400. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17401. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17402. * Contact Hardening
  17403. */
  17404. static readonly FILTER_PCSS: number;
  17405. /**
  17406. * Reserved for PCF and PCSS
  17407. * Highest Quality.
  17408. *
  17409. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17410. *
  17411. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17412. */
  17413. static readonly QUALITY_HIGH: number;
  17414. /**
  17415. * Reserved for PCF and PCSS
  17416. * Good tradeoff for quality/perf cross devices
  17417. *
  17418. * Execute PCF on a 3*3 kernel.
  17419. *
  17420. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17421. */
  17422. static readonly QUALITY_MEDIUM: number;
  17423. /**
  17424. * Reserved for PCF and PCSS
  17425. * The lowest quality but the fastest.
  17426. *
  17427. * Execute PCF on a 1*1 kernel.
  17428. *
  17429. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17430. */
  17431. static readonly QUALITY_LOW: number;
  17432. /** Gets or sets the custom shader name to use */
  17433. customShaderOptions: ICustomShaderOptions;
  17434. /**
  17435. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17436. */
  17437. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17438. /**
  17439. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17440. */
  17441. onAfterShadowMapRenderObservable: Observable<Effect>;
  17442. /**
  17443. * Observable triggered before a mesh is rendered in the shadow map.
  17444. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17445. */
  17446. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17447. /**
  17448. * Observable triggered after a mesh is rendered in the shadow map.
  17449. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17450. */
  17451. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17452. protected _bias: number;
  17453. /**
  17454. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17455. */
  17456. get bias(): number;
  17457. /**
  17458. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17459. */
  17460. set bias(bias: number);
  17461. protected _normalBias: number;
  17462. /**
  17463. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17464. */
  17465. get normalBias(): number;
  17466. /**
  17467. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17468. */
  17469. set normalBias(normalBias: number);
  17470. protected _blurBoxOffset: number;
  17471. /**
  17472. * Gets the blur box offset: offset applied during the blur pass.
  17473. * Only useful if useKernelBlur = false
  17474. */
  17475. get blurBoxOffset(): number;
  17476. /**
  17477. * Sets the blur box offset: offset applied during the blur pass.
  17478. * Only useful if useKernelBlur = false
  17479. */
  17480. set blurBoxOffset(value: number);
  17481. protected _blurScale: number;
  17482. /**
  17483. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17484. * 2 means half of the size.
  17485. */
  17486. get blurScale(): number;
  17487. /**
  17488. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17489. * 2 means half of the size.
  17490. */
  17491. set blurScale(value: number);
  17492. protected _blurKernel: number;
  17493. /**
  17494. * Gets the blur kernel: kernel size of the blur pass.
  17495. * Only useful if useKernelBlur = true
  17496. */
  17497. get blurKernel(): number;
  17498. /**
  17499. * Sets the blur kernel: kernel size of the blur pass.
  17500. * Only useful if useKernelBlur = true
  17501. */
  17502. set blurKernel(value: number);
  17503. protected _useKernelBlur: boolean;
  17504. /**
  17505. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17506. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17507. */
  17508. get useKernelBlur(): boolean;
  17509. /**
  17510. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17511. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17512. */
  17513. set useKernelBlur(value: boolean);
  17514. protected _depthScale: number;
  17515. /**
  17516. * Gets the depth scale used in ESM mode.
  17517. */
  17518. get depthScale(): number;
  17519. /**
  17520. * Sets the depth scale used in ESM mode.
  17521. * This can override the scale stored on the light.
  17522. */
  17523. set depthScale(value: number);
  17524. protected _validateFilter(filter: number): number;
  17525. protected _filter: number;
  17526. /**
  17527. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17528. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17529. */
  17530. get filter(): number;
  17531. /**
  17532. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17533. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17534. */
  17535. set filter(value: number);
  17536. /**
  17537. * Gets if the current filter is set to Poisson Sampling.
  17538. */
  17539. get usePoissonSampling(): boolean;
  17540. /**
  17541. * Sets the current filter to Poisson Sampling.
  17542. */
  17543. set usePoissonSampling(value: boolean);
  17544. /**
  17545. * Gets if the current filter is set to ESM.
  17546. */
  17547. get useExponentialShadowMap(): boolean;
  17548. /**
  17549. * Sets the current filter is to ESM.
  17550. */
  17551. set useExponentialShadowMap(value: boolean);
  17552. /**
  17553. * Gets if the current filter is set to filtered ESM.
  17554. */
  17555. get useBlurExponentialShadowMap(): boolean;
  17556. /**
  17557. * Gets if the current filter is set to filtered ESM.
  17558. */
  17559. set useBlurExponentialShadowMap(value: boolean);
  17560. /**
  17561. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17562. * exponential to prevent steep falloff artifacts).
  17563. */
  17564. get useCloseExponentialShadowMap(): boolean;
  17565. /**
  17566. * Sets the current filter to "close ESM" (using the inverse of the
  17567. * exponential to prevent steep falloff artifacts).
  17568. */
  17569. set useCloseExponentialShadowMap(value: boolean);
  17570. /**
  17571. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17572. * exponential to prevent steep falloff artifacts).
  17573. */
  17574. get useBlurCloseExponentialShadowMap(): boolean;
  17575. /**
  17576. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17577. * exponential to prevent steep falloff artifacts).
  17578. */
  17579. set useBlurCloseExponentialShadowMap(value: boolean);
  17580. /**
  17581. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17582. */
  17583. get usePercentageCloserFiltering(): boolean;
  17584. /**
  17585. * Sets the current filter to "PCF" (percentage closer filtering).
  17586. */
  17587. set usePercentageCloserFiltering(value: boolean);
  17588. protected _filteringQuality: number;
  17589. /**
  17590. * Gets the PCF or PCSS Quality.
  17591. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17592. */
  17593. get filteringQuality(): number;
  17594. /**
  17595. * Sets the PCF or PCSS Quality.
  17596. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17597. */
  17598. set filteringQuality(filteringQuality: number);
  17599. /**
  17600. * Gets if the current filter is set to "PCSS" (contact hardening).
  17601. */
  17602. get useContactHardeningShadow(): boolean;
  17603. /**
  17604. * Sets the current filter to "PCSS" (contact hardening).
  17605. */
  17606. set useContactHardeningShadow(value: boolean);
  17607. protected _contactHardeningLightSizeUVRatio: number;
  17608. /**
  17609. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17610. * Using a ratio helps keeping shape stability independently of the map size.
  17611. *
  17612. * It does not account for the light projection as it was having too much
  17613. * instability during the light setup or during light position changes.
  17614. *
  17615. * Only valid if useContactHardeningShadow is true.
  17616. */
  17617. get contactHardeningLightSizeUVRatio(): number;
  17618. /**
  17619. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17620. * Using a ratio helps keeping shape stability independently of the map size.
  17621. *
  17622. * It does not account for the light projection as it was having too much
  17623. * instability during the light setup or during light position changes.
  17624. *
  17625. * Only valid if useContactHardeningShadow is true.
  17626. */
  17627. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17628. protected _darkness: number;
  17629. /** Gets or sets the actual darkness of a shadow */
  17630. get darkness(): number;
  17631. set darkness(value: number);
  17632. /**
  17633. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17634. * 0 means strongest and 1 would means no shadow.
  17635. * @returns the darkness.
  17636. */
  17637. getDarkness(): number;
  17638. /**
  17639. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17640. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17641. * @returns the shadow generator allowing fluent coding.
  17642. */
  17643. setDarkness(darkness: number): ShadowGenerator;
  17644. protected _transparencyShadow: boolean;
  17645. /** Gets or sets the ability to have transparent shadow */
  17646. get transparencyShadow(): boolean;
  17647. set transparencyShadow(value: boolean);
  17648. /**
  17649. * Sets the ability to have transparent shadow (boolean).
  17650. * @param transparent True if transparent else False
  17651. * @returns the shadow generator allowing fluent coding
  17652. */
  17653. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17654. /**
  17655. * Enables or disables shadows with varying strength based on the transparency
  17656. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17657. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17658. * mesh.visibility * alphaTexture.a
  17659. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17660. */
  17661. enableSoftTransparentShadow: boolean;
  17662. protected _shadowMap: Nullable<RenderTargetTexture>;
  17663. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17664. /**
  17665. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17666. * @returns The render target texture if present otherwise, null
  17667. */
  17668. getShadowMap(): Nullable<RenderTargetTexture>;
  17669. /**
  17670. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17671. * @returns The render target texture if the shadow map is present otherwise, null
  17672. */
  17673. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17674. /**
  17675. * Gets the class name of that object
  17676. * @returns "ShadowGenerator"
  17677. */
  17678. getClassName(): string;
  17679. /**
  17680. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17681. * @param mesh Mesh to add
  17682. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17683. * @returns the Shadow Generator itself
  17684. */
  17685. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17686. /**
  17687. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17688. * @param mesh Mesh to remove
  17689. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17690. * @returns the Shadow Generator itself
  17691. */
  17692. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17693. /**
  17694. * Controls the extent to which the shadows fade out at the edge of the frustum
  17695. */
  17696. frustumEdgeFalloff: number;
  17697. protected _light: IShadowLight;
  17698. /**
  17699. * Returns the associated light object.
  17700. * @returns the light generating the shadow
  17701. */
  17702. getLight(): IShadowLight;
  17703. /**
  17704. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17705. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17706. * It might on the other hand introduce peter panning.
  17707. */
  17708. forceBackFacesOnly: boolean;
  17709. protected _scene: Scene;
  17710. protected _lightDirection: Vector3;
  17711. protected _effect: Effect;
  17712. protected _viewMatrix: Matrix;
  17713. protected _projectionMatrix: Matrix;
  17714. protected _transformMatrix: Matrix;
  17715. protected _cachedPosition: Vector3;
  17716. protected _cachedDirection: Vector3;
  17717. protected _cachedDefines: string;
  17718. protected _currentRenderID: number;
  17719. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17720. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17721. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17722. protected _blurPostProcesses: PostProcess[];
  17723. protected _mapSize: number;
  17724. protected _currentFaceIndex: number;
  17725. protected _currentFaceIndexCache: number;
  17726. protected _textureType: number;
  17727. protected _defaultTextureMatrix: Matrix;
  17728. protected _storedUniqueId: Nullable<number>;
  17729. /** @hidden */
  17730. static _SceneComponentInitialization: (scene: Scene) => void;
  17731. /**
  17732. * Creates a ShadowGenerator object.
  17733. * A ShadowGenerator is the required tool to use the shadows.
  17734. * Each light casting shadows needs to use its own ShadowGenerator.
  17735. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17736. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17737. * @param light The light object generating the shadows.
  17738. * @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.
  17739. */
  17740. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17741. protected _initializeGenerator(): void;
  17742. protected _createTargetRenderTexture(): void;
  17743. protected _initializeShadowMap(): void;
  17744. protected _initializeBlurRTTAndPostProcesses(): void;
  17745. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17746. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17747. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  17748. protected _applyFilterValues(): void;
  17749. /**
  17750. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17751. * @param onCompiled Callback triggered at the and of the effects compilation
  17752. * @param options Sets of optional options forcing the compilation with different modes
  17753. */
  17754. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17755. useInstances: boolean;
  17756. }>): void;
  17757. /**
  17758. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17759. * @param options Sets of optional options forcing the compilation with different modes
  17760. * @returns A promise that resolves when the compilation completes
  17761. */
  17762. forceCompilationAsync(options?: Partial<{
  17763. useInstances: boolean;
  17764. }>): Promise<void>;
  17765. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17766. private _prepareShadowDefines;
  17767. /**
  17768. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17769. * @param subMesh The submesh we want to render in the shadow map
  17770. * @param useInstances Defines wether will draw in the map using instances
  17771. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17772. * @returns true if ready otherwise, false
  17773. */
  17774. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17775. /**
  17776. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17777. * @param defines Defines of the material we want to update
  17778. * @param lightIndex Index of the light in the enabled light list of the material
  17779. */
  17780. prepareDefines(defines: any, lightIndex: number): void;
  17781. /**
  17782. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17783. * defined in the generator but impacting the effect).
  17784. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17785. * @param effect The effect we are binfing the information for
  17786. */
  17787. bindShadowLight(lightIndex: string, effect: Effect): void;
  17788. /**
  17789. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17790. * (eq to shadow prjection matrix * light transform matrix)
  17791. * @returns The transform matrix used to create the shadow map
  17792. */
  17793. getTransformMatrix(): Matrix;
  17794. /**
  17795. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17796. * Cube and 2D textures for instance.
  17797. */
  17798. recreateShadowMap(): void;
  17799. protected _disposeBlurPostProcesses(): void;
  17800. protected _disposeRTTandPostProcesses(): void;
  17801. /**
  17802. * Disposes the ShadowGenerator.
  17803. * Returns nothing.
  17804. */
  17805. dispose(): void;
  17806. /**
  17807. * Serializes the shadow generator setup to a json object.
  17808. * @returns The serialized JSON object
  17809. */
  17810. serialize(): any;
  17811. /**
  17812. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17813. * @param parsedShadowGenerator The JSON object to parse
  17814. * @param scene The scene to create the shadow map for
  17815. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17816. * @returns The parsed shadow generator
  17817. */
  17818. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17819. }
  17820. }
  17821. declare module BABYLON {
  17822. /**
  17823. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17824. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17825. * 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.
  17826. */
  17827. export abstract class Light extends Node {
  17828. /**
  17829. * Falloff Default: light is falling off following the material specification:
  17830. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17831. */
  17832. static readonly FALLOFF_DEFAULT: number;
  17833. /**
  17834. * Falloff Physical: light is falling off following the inverse squared distance law.
  17835. */
  17836. static readonly FALLOFF_PHYSICAL: number;
  17837. /**
  17838. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17839. * to enhance interoperability with other engines.
  17840. */
  17841. static readonly FALLOFF_GLTF: number;
  17842. /**
  17843. * Falloff Standard: light is falling off like in the standard material
  17844. * to enhance interoperability with other materials.
  17845. */
  17846. static readonly FALLOFF_STANDARD: number;
  17847. /**
  17848. * If every light affecting the material is in this lightmapMode,
  17849. * material.lightmapTexture adds or multiplies
  17850. * (depends on material.useLightmapAsShadowmap)
  17851. * after every other light calculations.
  17852. */
  17853. static readonly LIGHTMAP_DEFAULT: number;
  17854. /**
  17855. * material.lightmapTexture as only diffuse lighting from this light
  17856. * adds only specular lighting from this light
  17857. * adds dynamic shadows
  17858. */
  17859. static readonly LIGHTMAP_SPECULAR: number;
  17860. /**
  17861. * material.lightmapTexture as only lighting
  17862. * no light calculation from this light
  17863. * only adds dynamic shadows from this light
  17864. */
  17865. static readonly LIGHTMAP_SHADOWSONLY: number;
  17866. /**
  17867. * Each light type uses the default quantity according to its type:
  17868. * point/spot lights use luminous intensity
  17869. * directional lights use illuminance
  17870. */
  17871. static readonly INTENSITYMODE_AUTOMATIC: number;
  17872. /**
  17873. * lumen (lm)
  17874. */
  17875. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17876. /**
  17877. * candela (lm/sr)
  17878. */
  17879. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17880. /**
  17881. * lux (lm/m^2)
  17882. */
  17883. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17884. /**
  17885. * nit (cd/m^2)
  17886. */
  17887. static readonly INTENSITYMODE_LUMINANCE: number;
  17888. /**
  17889. * Light type const id of the point light.
  17890. */
  17891. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17892. /**
  17893. * Light type const id of the directional light.
  17894. */
  17895. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17896. /**
  17897. * Light type const id of the spot light.
  17898. */
  17899. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17900. /**
  17901. * Light type const id of the hemispheric light.
  17902. */
  17903. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17904. /**
  17905. * Diffuse gives the basic color to an object.
  17906. */
  17907. diffuse: Color3;
  17908. /**
  17909. * Specular produces a highlight color on an object.
  17910. * Note: This is note affecting PBR materials.
  17911. */
  17912. specular: Color3;
  17913. /**
  17914. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17915. * falling off base on range or angle.
  17916. * This can be set to any values in Light.FALLOFF_x.
  17917. *
  17918. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17919. * other types of materials.
  17920. */
  17921. falloffType: number;
  17922. /**
  17923. * Strength of the light.
  17924. * Note: By default it is define in the framework own unit.
  17925. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17926. */
  17927. intensity: number;
  17928. private _range;
  17929. protected _inverseSquaredRange: number;
  17930. /**
  17931. * Defines how far from the source the light is impacting in scene units.
  17932. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17933. */
  17934. get range(): number;
  17935. /**
  17936. * Defines how far from the source the light is impacting in scene units.
  17937. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17938. */
  17939. set range(value: number);
  17940. /**
  17941. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17942. * of light.
  17943. */
  17944. private _photometricScale;
  17945. private _intensityMode;
  17946. /**
  17947. * Gets the photometric scale used to interpret the intensity.
  17948. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17949. */
  17950. get intensityMode(): number;
  17951. /**
  17952. * Sets the photometric scale used to interpret the intensity.
  17953. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17954. */
  17955. set intensityMode(value: number);
  17956. private _radius;
  17957. /**
  17958. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17959. */
  17960. get radius(): number;
  17961. /**
  17962. * sets the light radius used by PBR Materials to simulate soft area lights.
  17963. */
  17964. set radius(value: number);
  17965. private _renderPriority;
  17966. /**
  17967. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17968. * exceeding the number allowed of the materials.
  17969. */
  17970. renderPriority: number;
  17971. private _shadowEnabled;
  17972. /**
  17973. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17974. * the current shadow generator.
  17975. */
  17976. get shadowEnabled(): boolean;
  17977. /**
  17978. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17979. * the current shadow generator.
  17980. */
  17981. set shadowEnabled(value: boolean);
  17982. private _includedOnlyMeshes;
  17983. /**
  17984. * Gets the only meshes impacted by this light.
  17985. */
  17986. get includedOnlyMeshes(): AbstractMesh[];
  17987. /**
  17988. * Sets the only meshes impacted by this light.
  17989. */
  17990. set includedOnlyMeshes(value: AbstractMesh[]);
  17991. private _excludedMeshes;
  17992. /**
  17993. * Gets the meshes not impacted by this light.
  17994. */
  17995. get excludedMeshes(): AbstractMesh[];
  17996. /**
  17997. * Sets the meshes not impacted by this light.
  17998. */
  17999. set excludedMeshes(value: AbstractMesh[]);
  18000. private _excludeWithLayerMask;
  18001. /**
  18002. * Gets the layer id use to find what meshes are not impacted by the light.
  18003. * Inactive if 0
  18004. */
  18005. get excludeWithLayerMask(): number;
  18006. /**
  18007. * Sets the layer id use to find what meshes are not impacted by the light.
  18008. * Inactive if 0
  18009. */
  18010. set excludeWithLayerMask(value: number);
  18011. private _includeOnlyWithLayerMask;
  18012. /**
  18013. * Gets the layer id use to find what meshes are impacted by the light.
  18014. * Inactive if 0
  18015. */
  18016. get includeOnlyWithLayerMask(): number;
  18017. /**
  18018. * Sets the layer id use to find what meshes are impacted by the light.
  18019. * Inactive if 0
  18020. */
  18021. set includeOnlyWithLayerMask(value: number);
  18022. private _lightmapMode;
  18023. /**
  18024. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18025. */
  18026. get lightmapMode(): number;
  18027. /**
  18028. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18029. */
  18030. set lightmapMode(value: number);
  18031. /**
  18032. * Shadow generator associted to the light.
  18033. * @hidden Internal use only.
  18034. */
  18035. _shadowGenerator: Nullable<IShadowGenerator>;
  18036. /**
  18037. * @hidden Internal use only.
  18038. */
  18039. _excludedMeshesIds: string[];
  18040. /**
  18041. * @hidden Internal use only.
  18042. */
  18043. _includedOnlyMeshesIds: string[];
  18044. /**
  18045. * The current light unifom buffer.
  18046. * @hidden Internal use only.
  18047. */
  18048. _uniformBuffer: UniformBuffer;
  18049. /** @hidden */
  18050. _renderId: number;
  18051. /**
  18052. * Creates a Light object in the scene.
  18053. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18054. * @param name The firendly name of the light
  18055. * @param scene The scene the light belongs too
  18056. */
  18057. constructor(name: string, scene: Scene);
  18058. protected abstract _buildUniformLayout(): void;
  18059. /**
  18060. * Sets the passed Effect "effect" with the Light information.
  18061. * @param effect The effect to update
  18062. * @param lightIndex The index of the light in the effect to update
  18063. * @returns The light
  18064. */
  18065. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18066. /**
  18067. * Sets the passed Effect "effect" with the Light textures.
  18068. * @param effect The effect to update
  18069. * @param lightIndex The index of the light in the effect to update
  18070. * @returns The light
  18071. */
  18072. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18073. /**
  18074. * Binds the lights information from the scene to the effect for the given mesh.
  18075. * @param lightIndex Light index
  18076. * @param scene The scene where the light belongs to
  18077. * @param effect The effect we are binding the data to
  18078. * @param useSpecular Defines if specular is supported
  18079. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18080. */
  18081. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18082. /**
  18083. * Sets the passed Effect "effect" with the Light information.
  18084. * @param effect The effect to update
  18085. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18086. * @returns The light
  18087. */
  18088. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18089. /**
  18090. * Returns the string "Light".
  18091. * @returns the class name
  18092. */
  18093. getClassName(): string;
  18094. /** @hidden */
  18095. readonly _isLight: boolean;
  18096. /**
  18097. * Converts the light information to a readable string for debug purpose.
  18098. * @param fullDetails Supports for multiple levels of logging within scene loading
  18099. * @returns the human readable light info
  18100. */
  18101. toString(fullDetails?: boolean): string;
  18102. /** @hidden */
  18103. protected _syncParentEnabledState(): void;
  18104. /**
  18105. * Set the enabled state of this node.
  18106. * @param value - the new enabled state
  18107. */
  18108. setEnabled(value: boolean): void;
  18109. /**
  18110. * Returns the Light associated shadow generator if any.
  18111. * @return the associated shadow generator.
  18112. */
  18113. getShadowGenerator(): Nullable<IShadowGenerator>;
  18114. /**
  18115. * Returns a Vector3, the absolute light position in the World.
  18116. * @returns the world space position of the light
  18117. */
  18118. getAbsolutePosition(): Vector3;
  18119. /**
  18120. * Specifies if the light will affect the passed mesh.
  18121. * @param mesh The mesh to test against the light
  18122. * @return true the mesh is affected otherwise, false.
  18123. */
  18124. canAffectMesh(mesh: AbstractMesh): boolean;
  18125. /**
  18126. * Sort function to order lights for rendering.
  18127. * @param a First Light object to compare to second.
  18128. * @param b Second Light object to compare first.
  18129. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18130. */
  18131. static CompareLightsPriority(a: Light, b: Light): number;
  18132. /**
  18133. * Releases resources associated with this node.
  18134. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18135. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18136. */
  18137. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18138. /**
  18139. * Returns the light type ID (integer).
  18140. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18141. */
  18142. getTypeID(): number;
  18143. /**
  18144. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18145. * @returns the scaled intensity in intensity mode unit
  18146. */
  18147. getScaledIntensity(): number;
  18148. /**
  18149. * Returns a new Light object, named "name", from the current one.
  18150. * @param name The name of the cloned light
  18151. * @param newParent The parent of this light, if it has one
  18152. * @returns the new created light
  18153. */
  18154. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18155. /**
  18156. * Serializes the current light into a Serialization object.
  18157. * @returns the serialized object.
  18158. */
  18159. serialize(): any;
  18160. /**
  18161. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18162. * This new light is named "name" and added to the passed scene.
  18163. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18164. * @param name The friendly name of the light
  18165. * @param scene The scene the new light will belong to
  18166. * @returns the constructor function
  18167. */
  18168. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18169. /**
  18170. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18171. * @param parsedLight The JSON representation of the light
  18172. * @param scene The scene to create the parsed light in
  18173. * @returns the created light after parsing
  18174. */
  18175. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18176. private _hookArrayForExcluded;
  18177. private _hookArrayForIncludedOnly;
  18178. private _resyncMeshes;
  18179. /**
  18180. * Forces the meshes to update their light related information in their rendering used effects
  18181. * @hidden Internal Use Only
  18182. */
  18183. _markMeshesAsLightDirty(): void;
  18184. /**
  18185. * Recomputes the cached photometric scale if needed.
  18186. */
  18187. private _computePhotometricScale;
  18188. /**
  18189. * Returns the Photometric Scale according to the light type and intensity mode.
  18190. */
  18191. private _getPhotometricScale;
  18192. /**
  18193. * Reorder the light in the scene according to their defined priority.
  18194. * @hidden Internal Use Only
  18195. */
  18196. _reorderLightsInScene(): void;
  18197. /**
  18198. * Prepares the list of defines specific to the light type.
  18199. * @param defines the list of defines
  18200. * @param lightIndex defines the index of the light for the effect
  18201. */
  18202. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18203. }
  18204. }
  18205. declare module BABYLON {
  18206. /**
  18207. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18208. * This is the base of the follow, arc rotate cameras and Free camera
  18209. * @see https://doc.babylonjs.com/features/cameras
  18210. */
  18211. export class TargetCamera extends Camera {
  18212. private static _RigCamTransformMatrix;
  18213. private static _TargetTransformMatrix;
  18214. private static _TargetFocalPoint;
  18215. private _tmpUpVector;
  18216. private _tmpTargetVector;
  18217. /**
  18218. * Define the current direction the camera is moving to
  18219. */
  18220. cameraDirection: Vector3;
  18221. /**
  18222. * Define the current rotation the camera is rotating to
  18223. */
  18224. cameraRotation: Vector2;
  18225. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18226. ignoreParentScaling: boolean;
  18227. /**
  18228. * When set, the up vector of the camera will be updated by the rotation of the camera
  18229. */
  18230. updateUpVectorFromRotation: boolean;
  18231. private _tmpQuaternion;
  18232. /**
  18233. * Define the current rotation of the camera
  18234. */
  18235. rotation: Vector3;
  18236. /**
  18237. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18238. */
  18239. rotationQuaternion: Quaternion;
  18240. /**
  18241. * Define the current speed of the camera
  18242. */
  18243. speed: number;
  18244. /**
  18245. * Add constraint to the camera to prevent it to move freely in all directions and
  18246. * around all axis.
  18247. */
  18248. noRotationConstraint: boolean;
  18249. /**
  18250. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18251. * panning
  18252. */
  18253. invertRotation: boolean;
  18254. /**
  18255. * Speed multiplier for inverse camera panning
  18256. */
  18257. inverseRotationSpeed: number;
  18258. /**
  18259. * Define the current target of the camera as an object or a position.
  18260. */
  18261. lockedTarget: any;
  18262. /** @hidden */
  18263. _currentTarget: Vector3;
  18264. /** @hidden */
  18265. _initialFocalDistance: number;
  18266. /** @hidden */
  18267. _viewMatrix: Matrix;
  18268. /** @hidden */
  18269. _camMatrix: Matrix;
  18270. /** @hidden */
  18271. _cameraTransformMatrix: Matrix;
  18272. /** @hidden */
  18273. _cameraRotationMatrix: Matrix;
  18274. /** @hidden */
  18275. _referencePoint: Vector3;
  18276. /** @hidden */
  18277. _transformedReferencePoint: Vector3;
  18278. /** @hidden */
  18279. _reset: () => void;
  18280. private _defaultUp;
  18281. /**
  18282. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18283. * This is the base of the follow, arc rotate cameras and Free camera
  18284. * @see https://doc.babylonjs.com/features/cameras
  18285. * @param name Defines the name of the camera in the scene
  18286. * @param position Defines the start position of the camera in the scene
  18287. * @param scene Defines the scene the camera belongs to
  18288. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18289. */
  18290. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18291. /**
  18292. * Gets the position in front of the camera at a given distance.
  18293. * @param distance The distance from the camera we want the position to be
  18294. * @returns the position
  18295. */
  18296. getFrontPosition(distance: number): Vector3;
  18297. /** @hidden */
  18298. _getLockedTargetPosition(): Nullable<Vector3>;
  18299. private _storedPosition;
  18300. private _storedRotation;
  18301. private _storedRotationQuaternion;
  18302. /**
  18303. * Store current camera state of the camera (fov, position, rotation, etc..)
  18304. * @returns the camera
  18305. */
  18306. storeState(): Camera;
  18307. /**
  18308. * Restored camera state. You must call storeState() first
  18309. * @returns whether it was successful or not
  18310. * @hidden
  18311. */
  18312. _restoreStateValues(): boolean;
  18313. /** @hidden */
  18314. _initCache(): void;
  18315. /** @hidden */
  18316. _updateCache(ignoreParentClass?: boolean): void;
  18317. /** @hidden */
  18318. _isSynchronizedViewMatrix(): boolean;
  18319. /** @hidden */
  18320. _computeLocalCameraSpeed(): number;
  18321. /**
  18322. * Defines the target the camera should look at.
  18323. * @param target Defines the new target as a Vector or a mesh
  18324. */
  18325. setTarget(target: Vector3): void;
  18326. /**
  18327. * Return the current target position of the camera. This value is expressed in local space.
  18328. * @returns the target position
  18329. */
  18330. getTarget(): Vector3;
  18331. /** @hidden */
  18332. _decideIfNeedsToMove(): boolean;
  18333. /** @hidden */
  18334. _updatePosition(): void;
  18335. /** @hidden */
  18336. _checkInputs(): void;
  18337. protected _updateCameraRotationMatrix(): void;
  18338. /**
  18339. * 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)
  18340. * @returns the current camera
  18341. */
  18342. private _rotateUpVectorWithCameraRotationMatrix;
  18343. private _cachedRotationZ;
  18344. private _cachedQuaternionRotationZ;
  18345. /** @hidden */
  18346. _getViewMatrix(): Matrix;
  18347. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18348. /**
  18349. * @hidden
  18350. */
  18351. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18352. /**
  18353. * @hidden
  18354. */
  18355. _updateRigCameras(): void;
  18356. private _getRigCamPositionAndTarget;
  18357. /**
  18358. * Gets the current object class name.
  18359. * @return the class name
  18360. */
  18361. getClassName(): string;
  18362. }
  18363. }
  18364. declare module BABYLON {
  18365. /**
  18366. * Gather the list of keyboard event types as constants.
  18367. */
  18368. export class KeyboardEventTypes {
  18369. /**
  18370. * The keydown event is fired when a key becomes active (pressed).
  18371. */
  18372. static readonly KEYDOWN: number;
  18373. /**
  18374. * The keyup event is fired when a key has been released.
  18375. */
  18376. static readonly KEYUP: number;
  18377. }
  18378. /**
  18379. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18380. */
  18381. export class KeyboardInfo {
  18382. /**
  18383. * Defines the type of event (KeyboardEventTypes)
  18384. */
  18385. type: number;
  18386. /**
  18387. * Defines the related dom event
  18388. */
  18389. event: KeyboardEvent;
  18390. /**
  18391. * Instantiates a new keyboard info.
  18392. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18393. * @param type Defines the type of event (KeyboardEventTypes)
  18394. * @param event Defines the related dom event
  18395. */
  18396. constructor(
  18397. /**
  18398. * Defines the type of event (KeyboardEventTypes)
  18399. */
  18400. type: number,
  18401. /**
  18402. * Defines the related dom event
  18403. */
  18404. event: KeyboardEvent);
  18405. }
  18406. /**
  18407. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18408. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18409. */
  18410. export class KeyboardInfoPre extends KeyboardInfo {
  18411. /**
  18412. * Defines the type of event (KeyboardEventTypes)
  18413. */
  18414. type: number;
  18415. /**
  18416. * Defines the related dom event
  18417. */
  18418. event: KeyboardEvent;
  18419. /**
  18420. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18421. */
  18422. skipOnPointerObservable: boolean;
  18423. /**
  18424. * Instantiates a new keyboard pre info.
  18425. * This class is used to store keyboard related info for the onPreKeyboardObservable 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. declare module BABYLON {
  18441. /**
  18442. * Manage the keyboard inputs to control the movement of a free camera.
  18443. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18444. */
  18445. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18446. /**
  18447. * Defines the camera the input is attached to.
  18448. */
  18449. camera: FreeCamera;
  18450. /**
  18451. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18452. */
  18453. keysUp: number[];
  18454. /**
  18455. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18456. */
  18457. keysUpward: number[];
  18458. /**
  18459. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18460. */
  18461. keysDown: number[];
  18462. /**
  18463. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18464. */
  18465. keysDownward: number[];
  18466. /**
  18467. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18468. */
  18469. keysLeft: number[];
  18470. /**
  18471. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18472. */
  18473. keysRight: number[];
  18474. private _keys;
  18475. private _onCanvasBlurObserver;
  18476. private _onKeyboardObserver;
  18477. private _engine;
  18478. private _scene;
  18479. /**
  18480. * Attach the input controls to a specific dom element to get the input from.
  18481. * @param element Defines the element the controls should be listened from
  18482. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18483. */
  18484. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18485. /**
  18486. * Detach the current controls from the specified dom element.
  18487. * @param element Defines the element to stop listening the inputs from
  18488. */
  18489. detachControl(element: Nullable<HTMLElement>): void;
  18490. /**
  18491. * Update the current camera state depending on the inputs that have been used this frame.
  18492. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18493. */
  18494. checkInputs(): void;
  18495. /**
  18496. * Gets the class name of the current intput.
  18497. * @returns the class name
  18498. */
  18499. getClassName(): string;
  18500. /** @hidden */
  18501. _onLostFocus(): void;
  18502. /**
  18503. * Get the friendly name associated with the input class.
  18504. * @returns the input friendly name
  18505. */
  18506. getSimpleName(): string;
  18507. }
  18508. }
  18509. declare module BABYLON {
  18510. /**
  18511. * Gather the list of pointer event types as constants.
  18512. */
  18513. export class PointerEventTypes {
  18514. /**
  18515. * 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.
  18516. */
  18517. static readonly POINTERDOWN: number;
  18518. /**
  18519. * The pointerup event is fired when a pointer is no longer active.
  18520. */
  18521. static readonly POINTERUP: number;
  18522. /**
  18523. * The pointermove event is fired when a pointer changes coordinates.
  18524. */
  18525. static readonly POINTERMOVE: number;
  18526. /**
  18527. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18528. */
  18529. static readonly POINTERWHEEL: number;
  18530. /**
  18531. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18532. */
  18533. static readonly POINTERPICK: number;
  18534. /**
  18535. * The pointertap event is fired when a the object has been touched and released without drag.
  18536. */
  18537. static readonly POINTERTAP: number;
  18538. /**
  18539. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18540. */
  18541. static readonly POINTERDOUBLETAP: number;
  18542. }
  18543. /**
  18544. * Base class of pointer info types.
  18545. */
  18546. export class PointerInfoBase {
  18547. /**
  18548. * Defines the type of event (PointerEventTypes)
  18549. */
  18550. type: number;
  18551. /**
  18552. * Defines the related dom event
  18553. */
  18554. event: PointerEvent | MouseWheelEvent;
  18555. /**
  18556. * Instantiates the base class of pointers info.
  18557. * @param type Defines the type of event (PointerEventTypes)
  18558. * @param event Defines the related dom event
  18559. */
  18560. constructor(
  18561. /**
  18562. * Defines the type of event (PointerEventTypes)
  18563. */
  18564. type: number,
  18565. /**
  18566. * Defines the related dom event
  18567. */
  18568. event: PointerEvent | MouseWheelEvent);
  18569. }
  18570. /**
  18571. * This class is used to store pointer related info for the onPrePointerObservable event.
  18572. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18573. */
  18574. export class PointerInfoPre extends PointerInfoBase {
  18575. /**
  18576. * Ray from a pointer if availible (eg. 6dof controller)
  18577. */
  18578. ray: Nullable<Ray>;
  18579. /**
  18580. * Defines the local position of the pointer on the canvas.
  18581. */
  18582. localPosition: Vector2;
  18583. /**
  18584. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18585. */
  18586. skipOnPointerObservable: boolean;
  18587. /**
  18588. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18589. * @param type Defines the type of event (PointerEventTypes)
  18590. * @param event Defines the related dom event
  18591. * @param localX Defines the local x coordinates of the pointer when the event occured
  18592. * @param localY Defines the local y coordinates of the pointer when the event occured
  18593. */
  18594. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18595. }
  18596. /**
  18597. * This type contains all the data related to a pointer event in Babylon.js.
  18598. * 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.
  18599. */
  18600. export class PointerInfo extends PointerInfoBase {
  18601. /**
  18602. * Defines the picking info associated to the info (if any)\
  18603. */
  18604. pickInfo: Nullable<PickingInfo>;
  18605. /**
  18606. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18607. * @param type Defines the type of event (PointerEventTypes)
  18608. * @param event Defines the related dom event
  18609. * @param pickInfo Defines the picking info associated to the info (if any)\
  18610. */
  18611. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18612. /**
  18613. * Defines the picking info associated to the info (if any)\
  18614. */
  18615. pickInfo: Nullable<PickingInfo>);
  18616. }
  18617. /**
  18618. * Data relating to a touch event on the screen.
  18619. */
  18620. export interface PointerTouch {
  18621. /**
  18622. * X coordinate of touch.
  18623. */
  18624. x: number;
  18625. /**
  18626. * Y coordinate of touch.
  18627. */
  18628. y: number;
  18629. /**
  18630. * Id of touch. Unique for each finger.
  18631. */
  18632. pointerId: number;
  18633. /**
  18634. * Event type passed from DOM.
  18635. */
  18636. type: any;
  18637. }
  18638. }
  18639. declare module BABYLON {
  18640. /**
  18641. * Manage the mouse inputs to control the movement of a free camera.
  18642. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18643. */
  18644. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18645. /**
  18646. * Define if touch is enabled in the mouse input
  18647. */
  18648. touchEnabled: boolean;
  18649. /**
  18650. * Defines the camera the input is attached to.
  18651. */
  18652. camera: FreeCamera;
  18653. /**
  18654. * Defines the buttons associated with the input to handle camera move.
  18655. */
  18656. buttons: number[];
  18657. /**
  18658. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18659. */
  18660. angularSensibility: number;
  18661. private _pointerInput;
  18662. private _onMouseMove;
  18663. private _observer;
  18664. private previousPosition;
  18665. /**
  18666. * Observable for when a pointer move event occurs containing the move offset
  18667. */
  18668. onPointerMovedObservable: Observable<{
  18669. offsetX: number;
  18670. offsetY: number;
  18671. }>;
  18672. /**
  18673. * @hidden
  18674. * If the camera should be rotated automatically based on pointer movement
  18675. */
  18676. _allowCameraRotation: boolean;
  18677. /**
  18678. * Manage the mouse inputs to control the movement of a free camera.
  18679. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18680. * @param touchEnabled Defines if touch is enabled or not
  18681. */
  18682. constructor(
  18683. /**
  18684. * Define if touch is enabled in the mouse input
  18685. */
  18686. touchEnabled?: boolean);
  18687. /**
  18688. * Attach the input controls to a specific dom element to get the input from.
  18689. * @param element Defines the element the controls should be listened from
  18690. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18691. */
  18692. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18693. /**
  18694. * Called on JS contextmenu event.
  18695. * Override this method to provide functionality.
  18696. */
  18697. protected onContextMenu(evt: PointerEvent): void;
  18698. /**
  18699. * Detach the current controls from the specified dom element.
  18700. * @param element Defines the element to stop listening the inputs from
  18701. */
  18702. detachControl(element: Nullable<HTMLElement>): void;
  18703. /**
  18704. * Gets the class name of the current intput.
  18705. * @returns the class name
  18706. */
  18707. getClassName(): string;
  18708. /**
  18709. * Get the friendly name associated with the input class.
  18710. * @returns the input friendly name
  18711. */
  18712. getSimpleName(): string;
  18713. }
  18714. }
  18715. declare module BABYLON {
  18716. /**
  18717. * Manage the touch inputs to control the movement of a free camera.
  18718. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18719. */
  18720. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18721. /**
  18722. * Defines the camera the input is attached to.
  18723. */
  18724. camera: FreeCamera;
  18725. /**
  18726. * Defines the touch sensibility for rotation.
  18727. * The higher the faster.
  18728. */
  18729. touchAngularSensibility: number;
  18730. /**
  18731. * Defines the touch sensibility for move.
  18732. * The higher the faster.
  18733. */
  18734. touchMoveSensibility: number;
  18735. private _offsetX;
  18736. private _offsetY;
  18737. private _pointerPressed;
  18738. private _pointerInput;
  18739. private _observer;
  18740. private _onLostFocus;
  18741. /**
  18742. * Attach the input controls to a specific dom element to get the input from.
  18743. * @param element Defines the element the controls should be listened from
  18744. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18745. */
  18746. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18747. /**
  18748. * Detach the current controls from the specified dom element.
  18749. * @param element Defines the element to stop listening the inputs from
  18750. */
  18751. detachControl(element: Nullable<HTMLElement>): void;
  18752. /**
  18753. * Update the current camera state depending on the inputs that have been used this frame.
  18754. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18755. */
  18756. checkInputs(): void;
  18757. /**
  18758. * Gets the class name of the current intput.
  18759. * @returns the class name
  18760. */
  18761. getClassName(): string;
  18762. /**
  18763. * Get the friendly name associated with the input class.
  18764. * @returns the input friendly name
  18765. */
  18766. getSimpleName(): string;
  18767. }
  18768. }
  18769. declare module BABYLON {
  18770. /**
  18771. * Default Inputs manager for the FreeCamera.
  18772. * It groups all the default supported inputs for ease of use.
  18773. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18774. */
  18775. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18776. /**
  18777. * @hidden
  18778. */
  18779. _mouseInput: Nullable<FreeCameraMouseInput>;
  18780. /**
  18781. * Instantiates a new FreeCameraInputsManager.
  18782. * @param camera Defines the camera the inputs belong to
  18783. */
  18784. constructor(camera: FreeCamera);
  18785. /**
  18786. * Add keyboard input support to the input manager.
  18787. * @returns the current input manager
  18788. */
  18789. addKeyboard(): FreeCameraInputsManager;
  18790. /**
  18791. * Add mouse input support to the input manager.
  18792. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18793. * @returns the current input manager
  18794. */
  18795. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18796. /**
  18797. * Removes the mouse input support from the manager
  18798. * @returns the current input manager
  18799. */
  18800. removeMouse(): FreeCameraInputsManager;
  18801. /**
  18802. * Add touch input support to the input manager.
  18803. * @returns the current input manager
  18804. */
  18805. addTouch(): FreeCameraInputsManager;
  18806. /**
  18807. * Remove all attached input methods from a camera
  18808. */
  18809. clear(): void;
  18810. }
  18811. }
  18812. declare module BABYLON {
  18813. /**
  18814. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18815. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18816. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  18817. */
  18818. export class FreeCamera extends TargetCamera {
  18819. /**
  18820. * Define the collision ellipsoid of the camera.
  18821. * This is helpful to simulate a camera body like the player body around the camera
  18822. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18823. */
  18824. ellipsoid: Vector3;
  18825. /**
  18826. * Define an offset for the position of the ellipsoid around the camera.
  18827. * This can be helpful to determine the center of the body near the gravity center of the body
  18828. * instead of its head.
  18829. */
  18830. ellipsoidOffset: Vector3;
  18831. /**
  18832. * Enable or disable collisions of the camera with the rest of the scene objects.
  18833. */
  18834. checkCollisions: boolean;
  18835. /**
  18836. * Enable or disable gravity on the camera.
  18837. */
  18838. applyGravity: boolean;
  18839. /**
  18840. * Define the input manager associated to the camera.
  18841. */
  18842. inputs: FreeCameraInputsManager;
  18843. /**
  18844. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18845. * Higher values reduce sensitivity.
  18846. */
  18847. get angularSensibility(): number;
  18848. /**
  18849. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18850. * Higher values reduce sensitivity.
  18851. */
  18852. set angularSensibility(value: number);
  18853. /**
  18854. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18855. */
  18856. get keysUp(): number[];
  18857. set keysUp(value: number[]);
  18858. /**
  18859. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18860. */
  18861. get keysUpward(): number[];
  18862. set keysUpward(value: number[]);
  18863. /**
  18864. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18865. */
  18866. get keysDown(): number[];
  18867. set keysDown(value: number[]);
  18868. /**
  18869. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18870. */
  18871. get keysDownward(): number[];
  18872. set keysDownward(value: number[]);
  18873. /**
  18874. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18875. */
  18876. get keysLeft(): number[];
  18877. set keysLeft(value: number[]);
  18878. /**
  18879. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18880. */
  18881. get keysRight(): number[];
  18882. set keysRight(value: number[]);
  18883. /**
  18884. * Event raised when the camera collide with a mesh in the scene.
  18885. */
  18886. onCollide: (collidedMesh: AbstractMesh) => void;
  18887. private _collider;
  18888. private _needMoveForGravity;
  18889. private _oldPosition;
  18890. private _diffPosition;
  18891. private _newPosition;
  18892. /** @hidden */
  18893. _localDirection: Vector3;
  18894. /** @hidden */
  18895. _transformedDirection: Vector3;
  18896. /**
  18897. * Instantiates a Free Camera.
  18898. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18899. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18900. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  18901. * @param name Define the name of the camera in the scene
  18902. * @param position Define the start position of the camera in the scene
  18903. * @param scene Define the scene the camera belongs to
  18904. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18905. */
  18906. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18907. /**
  18908. * Attached controls to the current camera.
  18909. * @param element Defines the element the controls should be listened from
  18910. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18911. */
  18912. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18913. /**
  18914. * Detach the current controls from the camera.
  18915. * The camera will stop reacting to inputs.
  18916. * @param element Defines the element to stop listening the inputs from
  18917. */
  18918. detachControl(element: HTMLElement): void;
  18919. private _collisionMask;
  18920. /**
  18921. * Define a collision mask to limit the list of object the camera can collide with
  18922. */
  18923. get collisionMask(): number;
  18924. set collisionMask(mask: number);
  18925. /** @hidden */
  18926. _collideWithWorld(displacement: Vector3): void;
  18927. private _onCollisionPositionChange;
  18928. /** @hidden */
  18929. _checkInputs(): void;
  18930. /** @hidden */
  18931. _decideIfNeedsToMove(): boolean;
  18932. /** @hidden */
  18933. _updatePosition(): void;
  18934. /**
  18935. * Destroy the camera and release the current resources hold by it.
  18936. */
  18937. dispose(): void;
  18938. /**
  18939. * Gets the current object class name.
  18940. * @return the class name
  18941. */
  18942. getClassName(): string;
  18943. }
  18944. }
  18945. declare module BABYLON {
  18946. /**
  18947. * Represents a gamepad control stick position
  18948. */
  18949. export class StickValues {
  18950. /**
  18951. * The x component of the control stick
  18952. */
  18953. x: number;
  18954. /**
  18955. * The y component of the control stick
  18956. */
  18957. y: number;
  18958. /**
  18959. * Initializes the gamepad x and y control stick values
  18960. * @param x The x component of the gamepad control stick value
  18961. * @param y The y component of the gamepad control stick value
  18962. */
  18963. constructor(
  18964. /**
  18965. * The x component of the control stick
  18966. */
  18967. x: number,
  18968. /**
  18969. * The y component of the control stick
  18970. */
  18971. y: number);
  18972. }
  18973. /**
  18974. * An interface which manages callbacks for gamepad button changes
  18975. */
  18976. export interface GamepadButtonChanges {
  18977. /**
  18978. * Called when a gamepad has been changed
  18979. */
  18980. changed: boolean;
  18981. /**
  18982. * Called when a gamepad press event has been triggered
  18983. */
  18984. pressChanged: boolean;
  18985. /**
  18986. * Called when a touch event has been triggered
  18987. */
  18988. touchChanged: boolean;
  18989. /**
  18990. * Called when a value has changed
  18991. */
  18992. valueChanged: boolean;
  18993. }
  18994. /**
  18995. * Represents a gamepad
  18996. */
  18997. export class Gamepad {
  18998. /**
  18999. * The id of the gamepad
  19000. */
  19001. id: string;
  19002. /**
  19003. * The index of the gamepad
  19004. */
  19005. index: number;
  19006. /**
  19007. * The browser gamepad
  19008. */
  19009. browserGamepad: any;
  19010. /**
  19011. * Specifies what type of gamepad this represents
  19012. */
  19013. type: number;
  19014. private _leftStick;
  19015. private _rightStick;
  19016. /** @hidden */
  19017. _isConnected: boolean;
  19018. private _leftStickAxisX;
  19019. private _leftStickAxisY;
  19020. private _rightStickAxisX;
  19021. private _rightStickAxisY;
  19022. /**
  19023. * Triggered when the left control stick has been changed
  19024. */
  19025. private _onleftstickchanged;
  19026. /**
  19027. * Triggered when the right control stick has been changed
  19028. */
  19029. private _onrightstickchanged;
  19030. /**
  19031. * Represents a gamepad controller
  19032. */
  19033. static GAMEPAD: number;
  19034. /**
  19035. * Represents a generic controller
  19036. */
  19037. static GENERIC: number;
  19038. /**
  19039. * Represents an XBox controller
  19040. */
  19041. static XBOX: number;
  19042. /**
  19043. * Represents a pose-enabled controller
  19044. */
  19045. static POSE_ENABLED: number;
  19046. /**
  19047. * Represents an Dual Shock controller
  19048. */
  19049. static DUALSHOCK: number;
  19050. /**
  19051. * Specifies whether the left control stick should be Y-inverted
  19052. */
  19053. protected _invertLeftStickY: boolean;
  19054. /**
  19055. * Specifies if the gamepad has been connected
  19056. */
  19057. get isConnected(): boolean;
  19058. /**
  19059. * Initializes the gamepad
  19060. * @param id The id of the gamepad
  19061. * @param index The index of the gamepad
  19062. * @param browserGamepad The browser gamepad
  19063. * @param leftStickX The x component of the left joystick
  19064. * @param leftStickY The y component of the left joystick
  19065. * @param rightStickX The x component of the right joystick
  19066. * @param rightStickY The y component of the right joystick
  19067. */
  19068. constructor(
  19069. /**
  19070. * The id of the gamepad
  19071. */
  19072. id: string,
  19073. /**
  19074. * The index of the gamepad
  19075. */
  19076. index: number,
  19077. /**
  19078. * The browser gamepad
  19079. */
  19080. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19081. /**
  19082. * Callback triggered when the left joystick has changed
  19083. * @param callback
  19084. */
  19085. onleftstickchanged(callback: (values: StickValues) => void): void;
  19086. /**
  19087. * Callback triggered when the right joystick has changed
  19088. * @param callback
  19089. */
  19090. onrightstickchanged(callback: (values: StickValues) => void): void;
  19091. /**
  19092. * Gets the left joystick
  19093. */
  19094. get leftStick(): StickValues;
  19095. /**
  19096. * Sets the left joystick values
  19097. */
  19098. set leftStick(newValues: StickValues);
  19099. /**
  19100. * Gets the right joystick
  19101. */
  19102. get rightStick(): StickValues;
  19103. /**
  19104. * Sets the right joystick value
  19105. */
  19106. set rightStick(newValues: StickValues);
  19107. /**
  19108. * Updates the gamepad joystick positions
  19109. */
  19110. update(): void;
  19111. /**
  19112. * Disposes the gamepad
  19113. */
  19114. dispose(): void;
  19115. }
  19116. /**
  19117. * Represents a generic gamepad
  19118. */
  19119. export class GenericPad extends Gamepad {
  19120. private _buttons;
  19121. private _onbuttondown;
  19122. private _onbuttonup;
  19123. /**
  19124. * Observable triggered when a button has been pressed
  19125. */
  19126. onButtonDownObservable: Observable<number>;
  19127. /**
  19128. * Observable triggered when a button has been released
  19129. */
  19130. onButtonUpObservable: Observable<number>;
  19131. /**
  19132. * Callback triggered when a button has been pressed
  19133. * @param callback Called when a button has been pressed
  19134. */
  19135. onbuttondown(callback: (buttonPressed: number) => void): void;
  19136. /**
  19137. * Callback triggered when a button has been released
  19138. * @param callback Called when a button has been released
  19139. */
  19140. onbuttonup(callback: (buttonReleased: number) => void): void;
  19141. /**
  19142. * Initializes the generic gamepad
  19143. * @param id The id of the generic gamepad
  19144. * @param index The index of the generic gamepad
  19145. * @param browserGamepad The browser gamepad
  19146. */
  19147. constructor(id: string, index: number, browserGamepad: any);
  19148. private _setButtonValue;
  19149. /**
  19150. * Updates the generic gamepad
  19151. */
  19152. update(): void;
  19153. /**
  19154. * Disposes the generic gamepad
  19155. */
  19156. dispose(): void;
  19157. }
  19158. }
  19159. declare module BABYLON {
  19160. /**
  19161. * Defines the types of pose enabled controllers that are supported
  19162. */
  19163. export enum PoseEnabledControllerType {
  19164. /**
  19165. * HTC Vive
  19166. */
  19167. VIVE = 0,
  19168. /**
  19169. * Oculus Rift
  19170. */
  19171. OCULUS = 1,
  19172. /**
  19173. * Windows mixed reality
  19174. */
  19175. WINDOWS = 2,
  19176. /**
  19177. * Samsung gear VR
  19178. */
  19179. GEAR_VR = 3,
  19180. /**
  19181. * Google Daydream
  19182. */
  19183. DAYDREAM = 4,
  19184. /**
  19185. * Generic
  19186. */
  19187. GENERIC = 5
  19188. }
  19189. /**
  19190. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19191. */
  19192. export interface MutableGamepadButton {
  19193. /**
  19194. * Value of the button/trigger
  19195. */
  19196. value: number;
  19197. /**
  19198. * If the button/trigger is currently touched
  19199. */
  19200. touched: boolean;
  19201. /**
  19202. * If the button/trigger is currently pressed
  19203. */
  19204. pressed: boolean;
  19205. }
  19206. /**
  19207. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19208. * @hidden
  19209. */
  19210. export interface ExtendedGamepadButton extends GamepadButton {
  19211. /**
  19212. * If the button/trigger is currently pressed
  19213. */
  19214. readonly pressed: boolean;
  19215. /**
  19216. * If the button/trigger is currently touched
  19217. */
  19218. readonly touched: boolean;
  19219. /**
  19220. * Value of the button/trigger
  19221. */
  19222. readonly value: number;
  19223. }
  19224. /** @hidden */
  19225. export interface _GamePadFactory {
  19226. /**
  19227. * Returns whether or not the current gamepad can be created for this type of controller.
  19228. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19229. * @returns true if it can be created, otherwise false
  19230. */
  19231. canCreate(gamepadInfo: any): boolean;
  19232. /**
  19233. * Creates a new instance of the Gamepad.
  19234. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19235. * @returns the new gamepad instance
  19236. */
  19237. create(gamepadInfo: any): Gamepad;
  19238. }
  19239. /**
  19240. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19241. */
  19242. export class PoseEnabledControllerHelper {
  19243. /** @hidden */
  19244. static _ControllerFactories: _GamePadFactory[];
  19245. /** @hidden */
  19246. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19247. /**
  19248. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19249. * @param vrGamepad the gamepad to initialized
  19250. * @returns a vr controller of the type the gamepad identified as
  19251. */
  19252. static InitiateController(vrGamepad: any): Gamepad;
  19253. }
  19254. /**
  19255. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19256. */
  19257. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19258. /**
  19259. * If the controller is used in a webXR session
  19260. */
  19261. isXR: boolean;
  19262. private _deviceRoomPosition;
  19263. private _deviceRoomRotationQuaternion;
  19264. /**
  19265. * The device position in babylon space
  19266. */
  19267. devicePosition: Vector3;
  19268. /**
  19269. * The device rotation in babylon space
  19270. */
  19271. deviceRotationQuaternion: Quaternion;
  19272. /**
  19273. * The scale factor of the device in babylon space
  19274. */
  19275. deviceScaleFactor: number;
  19276. /**
  19277. * (Likely devicePosition should be used instead) The device position in its room space
  19278. */
  19279. position: Vector3;
  19280. /**
  19281. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19282. */
  19283. rotationQuaternion: Quaternion;
  19284. /**
  19285. * The type of controller (Eg. Windows mixed reality)
  19286. */
  19287. controllerType: PoseEnabledControllerType;
  19288. protected _calculatedPosition: Vector3;
  19289. private _calculatedRotation;
  19290. /**
  19291. * The raw pose from the device
  19292. */
  19293. rawPose: DevicePose;
  19294. private _trackPosition;
  19295. private _maxRotationDistFromHeadset;
  19296. private _draggedRoomRotation;
  19297. /**
  19298. * @hidden
  19299. */
  19300. _disableTrackPosition(fixedPosition: Vector3): void;
  19301. /**
  19302. * Internal, the mesh attached to the controller
  19303. * @hidden
  19304. */
  19305. _mesh: Nullable<AbstractMesh>;
  19306. private _poseControlledCamera;
  19307. private _leftHandSystemQuaternion;
  19308. /**
  19309. * Internal, matrix used to convert room space to babylon space
  19310. * @hidden
  19311. */
  19312. _deviceToWorld: Matrix;
  19313. /**
  19314. * Node to be used when casting a ray from the controller
  19315. * @hidden
  19316. */
  19317. _pointingPoseNode: Nullable<TransformNode>;
  19318. /**
  19319. * Name of the child mesh that can be used to cast a ray from the controller
  19320. */
  19321. static readonly POINTING_POSE: string;
  19322. /**
  19323. * Creates a new PoseEnabledController from a gamepad
  19324. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19325. */
  19326. constructor(browserGamepad: any);
  19327. private _workingMatrix;
  19328. /**
  19329. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19330. */
  19331. update(): void;
  19332. /**
  19333. * Updates only the pose device and mesh without doing any button event checking
  19334. */
  19335. protected _updatePoseAndMesh(): void;
  19336. /**
  19337. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19338. * @param poseData raw pose fromthe device
  19339. */
  19340. updateFromDevice(poseData: DevicePose): void;
  19341. /**
  19342. * @hidden
  19343. */
  19344. _meshAttachedObservable: Observable<AbstractMesh>;
  19345. /**
  19346. * Attaches a mesh to the controller
  19347. * @param mesh the mesh to be attached
  19348. */
  19349. attachToMesh(mesh: AbstractMesh): void;
  19350. /**
  19351. * Attaches the controllers mesh to a camera
  19352. * @param camera the camera the mesh should be attached to
  19353. */
  19354. attachToPoseControlledCamera(camera: TargetCamera): void;
  19355. /**
  19356. * Disposes of the controller
  19357. */
  19358. dispose(): void;
  19359. /**
  19360. * The mesh that is attached to the controller
  19361. */
  19362. get mesh(): Nullable<AbstractMesh>;
  19363. /**
  19364. * Gets the ray of the controller in the direction the controller is pointing
  19365. * @param length the length the resulting ray should be
  19366. * @returns a ray in the direction the controller is pointing
  19367. */
  19368. getForwardRay(length?: number): Ray;
  19369. }
  19370. }
  19371. declare module BABYLON {
  19372. /**
  19373. * Defines the WebVRController object that represents controllers tracked in 3D space
  19374. */
  19375. export abstract class WebVRController extends PoseEnabledController {
  19376. /**
  19377. * Internal, the default controller model for the controller
  19378. */
  19379. protected _defaultModel: Nullable<AbstractMesh>;
  19380. /**
  19381. * Fired when the trigger state has changed
  19382. */
  19383. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19384. /**
  19385. * Fired when the main button state has changed
  19386. */
  19387. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19388. /**
  19389. * Fired when the secondary button state has changed
  19390. */
  19391. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19392. /**
  19393. * Fired when the pad state has changed
  19394. */
  19395. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19396. /**
  19397. * Fired when controllers stick values have changed
  19398. */
  19399. onPadValuesChangedObservable: Observable<StickValues>;
  19400. /**
  19401. * Array of button availible on the controller
  19402. */
  19403. protected _buttons: Array<MutableGamepadButton>;
  19404. private _onButtonStateChange;
  19405. /**
  19406. * Fired when a controller button's state has changed
  19407. * @param callback the callback containing the button that was modified
  19408. */
  19409. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19410. /**
  19411. * X and Y axis corresponding to the controllers joystick
  19412. */
  19413. pad: StickValues;
  19414. /**
  19415. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19416. */
  19417. hand: string;
  19418. /**
  19419. * The default controller model for the controller
  19420. */
  19421. get defaultModel(): Nullable<AbstractMesh>;
  19422. /**
  19423. * Creates a new WebVRController from a gamepad
  19424. * @param vrGamepad the gamepad that the WebVRController should be created from
  19425. */
  19426. constructor(vrGamepad: any);
  19427. /**
  19428. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19429. */
  19430. update(): void;
  19431. /**
  19432. * Function to be called when a button is modified
  19433. */
  19434. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19435. /**
  19436. * Loads a mesh and attaches it to the controller
  19437. * @param scene the scene the mesh should be added to
  19438. * @param meshLoaded callback for when the mesh has been loaded
  19439. */
  19440. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19441. private _setButtonValue;
  19442. private _changes;
  19443. private _checkChanges;
  19444. /**
  19445. * Disposes of th webVRCOntroller
  19446. */
  19447. dispose(): void;
  19448. }
  19449. }
  19450. declare module BABYLON {
  19451. /**
  19452. * The HemisphericLight simulates the ambient environment light,
  19453. * so the passed direction is the light reflection direction, not the incoming direction.
  19454. */
  19455. export class HemisphericLight extends Light {
  19456. /**
  19457. * The groundColor is the light in the opposite direction to the one specified during creation.
  19458. * 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.
  19459. */
  19460. groundColor: Color3;
  19461. /**
  19462. * The light reflection direction, not the incoming direction.
  19463. */
  19464. direction: Vector3;
  19465. /**
  19466. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19467. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19468. * The HemisphericLight can't cast shadows.
  19469. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19470. * @param name The friendly name of the light
  19471. * @param direction The direction of the light reflection
  19472. * @param scene The scene the light belongs to
  19473. */
  19474. constructor(name: string, direction: Vector3, scene: Scene);
  19475. protected _buildUniformLayout(): void;
  19476. /**
  19477. * Returns the string "HemisphericLight".
  19478. * @return The class name
  19479. */
  19480. getClassName(): string;
  19481. /**
  19482. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19483. * Returns the updated direction.
  19484. * @param target The target the direction should point to
  19485. * @return The computed direction
  19486. */
  19487. setDirectionToTarget(target: Vector3): Vector3;
  19488. /**
  19489. * Returns the shadow generator associated to the light.
  19490. * @returns Always null for hemispheric lights because it does not support shadows.
  19491. */
  19492. getShadowGenerator(): Nullable<IShadowGenerator>;
  19493. /**
  19494. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19495. * @param effect The effect to update
  19496. * @param lightIndex The index of the light in the effect to update
  19497. * @returns The hemispheric light
  19498. */
  19499. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19500. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19501. /**
  19502. * Computes the world matrix of the node
  19503. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19504. * @param useWasUpdatedFlag defines a reserved property
  19505. * @returns the world matrix
  19506. */
  19507. computeWorldMatrix(): Matrix;
  19508. /**
  19509. * Returns the integer 3.
  19510. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19511. */
  19512. getTypeID(): number;
  19513. /**
  19514. * Prepares the list of defines specific to the light type.
  19515. * @param defines the list of defines
  19516. * @param lightIndex defines the index of the light for the effect
  19517. */
  19518. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19519. }
  19520. }
  19521. declare module BABYLON {
  19522. /** @hidden */
  19523. export var vrMultiviewToSingleviewPixelShader: {
  19524. name: string;
  19525. shader: string;
  19526. };
  19527. }
  19528. declare module BABYLON {
  19529. /**
  19530. * Renders to multiple views with a single draw call
  19531. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19532. */
  19533. export class MultiviewRenderTarget extends RenderTargetTexture {
  19534. /**
  19535. * Creates a multiview render target
  19536. * @param scene scene used with the render target
  19537. * @param size the size of the render target (used for each view)
  19538. */
  19539. constructor(scene: Scene, size?: number | {
  19540. width: number;
  19541. height: number;
  19542. } | {
  19543. ratio: number;
  19544. });
  19545. /**
  19546. * @hidden
  19547. * @param faceIndex the face index, if its a cube texture
  19548. */
  19549. _bindFrameBuffer(faceIndex?: number): void;
  19550. /**
  19551. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19552. * @returns the view count
  19553. */
  19554. getViewCount(): number;
  19555. }
  19556. }
  19557. declare module BABYLON {
  19558. interface Engine {
  19559. /**
  19560. * Creates a new multiview render target
  19561. * @param width defines the width of the texture
  19562. * @param height defines the height of the texture
  19563. * @returns the created multiview texture
  19564. */
  19565. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19566. /**
  19567. * Binds a multiview framebuffer to be drawn to
  19568. * @param multiviewTexture texture to bind
  19569. */
  19570. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19571. }
  19572. interface Camera {
  19573. /**
  19574. * @hidden
  19575. * 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)
  19576. */
  19577. _useMultiviewToSingleView: boolean;
  19578. /**
  19579. * @hidden
  19580. * 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)
  19581. */
  19582. _multiviewTexture: Nullable<RenderTargetTexture>;
  19583. /**
  19584. * @hidden
  19585. * ensures the multiview texture of the camera exists and has the specified width/height
  19586. * @param width height to set on the multiview texture
  19587. * @param height width to set on the multiview texture
  19588. */
  19589. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19590. }
  19591. interface Scene {
  19592. /** @hidden */
  19593. _transformMatrixR: Matrix;
  19594. /** @hidden */
  19595. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19596. /** @hidden */
  19597. _createMultiviewUbo(): void;
  19598. /** @hidden */
  19599. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19600. /** @hidden */
  19601. _renderMultiviewToSingleView(camera: Camera): void;
  19602. }
  19603. }
  19604. declare module BABYLON {
  19605. /**
  19606. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19607. * This will not be used for webXR as it supports displaying texture arrays directly
  19608. */
  19609. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19610. /**
  19611. * Initializes a VRMultiviewToSingleview
  19612. * @param name name of the post process
  19613. * @param camera camera to be applied to
  19614. * @param scaleFactor scaling factor to the size of the output texture
  19615. */
  19616. constructor(name: string, camera: Camera, scaleFactor: number);
  19617. }
  19618. }
  19619. declare module BABYLON {
  19620. /**
  19621. * Interface used to define additional presentation attributes
  19622. */
  19623. export interface IVRPresentationAttributes {
  19624. /**
  19625. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19626. */
  19627. highRefreshRate: boolean;
  19628. /**
  19629. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19630. */
  19631. foveationLevel: number;
  19632. }
  19633. interface Engine {
  19634. /** @hidden */
  19635. _vrDisplay: any;
  19636. /** @hidden */
  19637. _vrSupported: boolean;
  19638. /** @hidden */
  19639. _oldSize: Size;
  19640. /** @hidden */
  19641. _oldHardwareScaleFactor: number;
  19642. /** @hidden */
  19643. _vrExclusivePointerMode: boolean;
  19644. /** @hidden */
  19645. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19646. /** @hidden */
  19647. _onVRDisplayPointerRestricted: () => void;
  19648. /** @hidden */
  19649. _onVRDisplayPointerUnrestricted: () => void;
  19650. /** @hidden */
  19651. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19652. /** @hidden */
  19653. _onVrDisplayDisconnect: Nullable<() => void>;
  19654. /** @hidden */
  19655. _onVrDisplayPresentChange: Nullable<() => void>;
  19656. /**
  19657. * Observable signaled when VR display mode changes
  19658. */
  19659. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19660. /**
  19661. * Observable signaled when VR request present is complete
  19662. */
  19663. onVRRequestPresentComplete: Observable<boolean>;
  19664. /**
  19665. * Observable signaled when VR request present starts
  19666. */
  19667. onVRRequestPresentStart: Observable<Engine>;
  19668. /**
  19669. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19670. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19671. */
  19672. isInVRExclusivePointerMode: boolean;
  19673. /**
  19674. * Gets a boolean indicating if a webVR device was detected
  19675. * @returns true if a webVR device was detected
  19676. */
  19677. isVRDevicePresent(): boolean;
  19678. /**
  19679. * Gets the current webVR device
  19680. * @returns the current webVR device (or null)
  19681. */
  19682. getVRDevice(): any;
  19683. /**
  19684. * Initializes a webVR display and starts listening to display change events
  19685. * The onVRDisplayChangedObservable will be notified upon these changes
  19686. * @returns A promise containing a VRDisplay and if vr is supported
  19687. */
  19688. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19689. /** @hidden */
  19690. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19691. /**
  19692. * Gets or sets the presentation attributes used to configure VR rendering
  19693. */
  19694. vrPresentationAttributes?: IVRPresentationAttributes;
  19695. /**
  19696. * Call this function to switch to webVR mode
  19697. * Will do nothing if webVR is not supported or if there is no webVR device
  19698. * @param options the webvr options provided to the camera. mainly used for multiview
  19699. * @see https://doc.babylonjs.com/how_to/webvr_camera
  19700. */
  19701. enableVR(options: WebVROptions): void;
  19702. /** @hidden */
  19703. _onVRFullScreenTriggered(): void;
  19704. }
  19705. }
  19706. declare module BABYLON {
  19707. /**
  19708. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19709. * IMPORTANT!! The data is right-hand data.
  19710. * @export
  19711. * @interface DevicePose
  19712. */
  19713. export interface DevicePose {
  19714. /**
  19715. * The position of the device, values in array are [x,y,z].
  19716. */
  19717. readonly position: Nullable<Float32Array>;
  19718. /**
  19719. * The linearVelocity of the device, values in array are [x,y,z].
  19720. */
  19721. readonly linearVelocity: Nullable<Float32Array>;
  19722. /**
  19723. * The linearAcceleration of the device, values in array are [x,y,z].
  19724. */
  19725. readonly linearAcceleration: Nullable<Float32Array>;
  19726. /**
  19727. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19728. */
  19729. readonly orientation: Nullable<Float32Array>;
  19730. /**
  19731. * The angularVelocity of the device, values in array are [x,y,z].
  19732. */
  19733. readonly angularVelocity: Nullable<Float32Array>;
  19734. /**
  19735. * The angularAcceleration of the device, values in array are [x,y,z].
  19736. */
  19737. readonly angularAcceleration: Nullable<Float32Array>;
  19738. }
  19739. /**
  19740. * Interface representing a pose controlled object in Babylon.
  19741. * A pose controlled object has both regular pose values as well as pose values
  19742. * from an external device such as a VR head mounted display
  19743. */
  19744. export interface PoseControlled {
  19745. /**
  19746. * The position of the object in babylon space.
  19747. */
  19748. position: Vector3;
  19749. /**
  19750. * The rotation quaternion of the object in babylon space.
  19751. */
  19752. rotationQuaternion: Quaternion;
  19753. /**
  19754. * The position of the device in babylon space.
  19755. */
  19756. devicePosition?: Vector3;
  19757. /**
  19758. * The rotation quaternion of the device in babylon space.
  19759. */
  19760. deviceRotationQuaternion: Quaternion;
  19761. /**
  19762. * The raw pose coming from the device.
  19763. */
  19764. rawPose: Nullable<DevicePose>;
  19765. /**
  19766. * The scale of the device to be used when translating from device space to babylon space.
  19767. */
  19768. deviceScaleFactor: number;
  19769. /**
  19770. * Updates the poseControlled values based on the input device pose.
  19771. * @param poseData the pose data to update the object with
  19772. */
  19773. updateFromDevice(poseData: DevicePose): void;
  19774. }
  19775. /**
  19776. * Set of options to customize the webVRCamera
  19777. */
  19778. export interface WebVROptions {
  19779. /**
  19780. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19781. */
  19782. trackPosition?: boolean;
  19783. /**
  19784. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19785. */
  19786. positionScale?: number;
  19787. /**
  19788. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19789. */
  19790. displayName?: string;
  19791. /**
  19792. * Should the native controller meshes be initialized. (default: true)
  19793. */
  19794. controllerMeshes?: boolean;
  19795. /**
  19796. * Creating a default HemiLight only on controllers. (default: true)
  19797. */
  19798. defaultLightingOnControllers?: boolean;
  19799. /**
  19800. * If you don't want to use the default VR button of the helper. (default: false)
  19801. */
  19802. useCustomVRButton?: boolean;
  19803. /**
  19804. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19805. */
  19806. customVRButton?: HTMLButtonElement;
  19807. /**
  19808. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19809. */
  19810. rayLength?: number;
  19811. /**
  19812. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19813. */
  19814. defaultHeight?: number;
  19815. /**
  19816. * If multiview should be used if availible (default: false)
  19817. */
  19818. useMultiview?: boolean;
  19819. }
  19820. /**
  19821. * This represents a WebVR camera.
  19822. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19823. * @example https://doc.babylonjs.com/how_to/webvr_camera
  19824. */
  19825. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19826. private webVROptions;
  19827. /**
  19828. * @hidden
  19829. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19830. */
  19831. _vrDevice: any;
  19832. /**
  19833. * The rawPose of the vrDevice.
  19834. */
  19835. rawPose: Nullable<DevicePose>;
  19836. private _onVREnabled;
  19837. private _specsVersion;
  19838. private _attached;
  19839. private _frameData;
  19840. protected _descendants: Array<Node>;
  19841. private _deviceRoomPosition;
  19842. /** @hidden */
  19843. _deviceRoomRotationQuaternion: Quaternion;
  19844. private _standingMatrix;
  19845. /**
  19846. * Represents device position in babylon space.
  19847. */
  19848. devicePosition: Vector3;
  19849. /**
  19850. * Represents device rotation in babylon space.
  19851. */
  19852. deviceRotationQuaternion: Quaternion;
  19853. /**
  19854. * The scale of the device to be used when translating from device space to babylon space.
  19855. */
  19856. deviceScaleFactor: number;
  19857. private _deviceToWorld;
  19858. private _worldToDevice;
  19859. /**
  19860. * References to the webVR controllers for the vrDevice.
  19861. */
  19862. controllers: Array<WebVRController>;
  19863. /**
  19864. * Emits an event when a controller is attached.
  19865. */
  19866. onControllersAttachedObservable: Observable<WebVRController[]>;
  19867. /**
  19868. * Emits an event when a controller's mesh has been loaded;
  19869. */
  19870. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19871. /**
  19872. * Emits an event when the HMD's pose has been updated.
  19873. */
  19874. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19875. private _poseSet;
  19876. /**
  19877. * If the rig cameras be used as parent instead of this camera.
  19878. */
  19879. rigParenting: boolean;
  19880. private _lightOnControllers;
  19881. private _defaultHeight?;
  19882. /**
  19883. * Instantiates a WebVRFreeCamera.
  19884. * @param name The name of the WebVRFreeCamera
  19885. * @param position The starting anchor position for the camera
  19886. * @param scene The scene the camera belongs to
  19887. * @param webVROptions a set of customizable options for the webVRCamera
  19888. */
  19889. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19890. /**
  19891. * Gets the device distance from the ground in meters.
  19892. * @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.
  19893. */
  19894. deviceDistanceToRoomGround(): number;
  19895. /**
  19896. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19897. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19898. */
  19899. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19900. /**
  19901. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19902. * @returns A promise with a boolean set to if the standing matrix is supported.
  19903. */
  19904. useStandingMatrixAsync(): Promise<boolean>;
  19905. /**
  19906. * Disposes the camera
  19907. */
  19908. dispose(): void;
  19909. /**
  19910. * Gets a vrController by name.
  19911. * @param name The name of the controller to retreive
  19912. * @returns the controller matching the name specified or null if not found
  19913. */
  19914. getControllerByName(name: string): Nullable<WebVRController>;
  19915. private _leftController;
  19916. /**
  19917. * The controller corresponding to the users left hand.
  19918. */
  19919. get leftController(): Nullable<WebVRController>;
  19920. private _rightController;
  19921. /**
  19922. * The controller corresponding to the users right hand.
  19923. */
  19924. get rightController(): Nullable<WebVRController>;
  19925. /**
  19926. * Casts a ray forward from the vrCamera's gaze.
  19927. * @param length Length of the ray (default: 100)
  19928. * @returns the ray corresponding to the gaze
  19929. */
  19930. getForwardRay(length?: number): Ray;
  19931. /**
  19932. * @hidden
  19933. * Updates the camera based on device's frame data
  19934. */
  19935. _checkInputs(): void;
  19936. /**
  19937. * Updates the poseControlled values based on the input device pose.
  19938. * @param poseData Pose coming from the device
  19939. */
  19940. updateFromDevice(poseData: DevicePose): void;
  19941. private _htmlElementAttached;
  19942. private _detachIfAttached;
  19943. /**
  19944. * WebVR's attach control will start broadcasting frames to the device.
  19945. * Note that in certain browsers (chrome for example) this function must be called
  19946. * within a user-interaction callback. Example:
  19947. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19948. *
  19949. * @param element html element to attach the vrDevice to
  19950. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  19951. */
  19952. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19953. /**
  19954. * Detaches the camera from the html element and disables VR
  19955. *
  19956. * @param element html element to detach from
  19957. */
  19958. detachControl(element: HTMLElement): void;
  19959. /**
  19960. * @returns the name of this class
  19961. */
  19962. getClassName(): string;
  19963. /**
  19964. * Calls resetPose on the vrDisplay
  19965. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  19966. */
  19967. resetToCurrentRotation(): void;
  19968. /**
  19969. * @hidden
  19970. * Updates the rig cameras (left and right eye)
  19971. */
  19972. _updateRigCameras(): void;
  19973. private _workingVector;
  19974. private _oneVector;
  19975. private _workingMatrix;
  19976. private updateCacheCalled;
  19977. private _correctPositionIfNotTrackPosition;
  19978. /**
  19979. * @hidden
  19980. * Updates the cached values of the camera
  19981. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  19982. */
  19983. _updateCache(ignoreParentClass?: boolean): void;
  19984. /**
  19985. * @hidden
  19986. * Get current device position in babylon world
  19987. */
  19988. _computeDevicePosition(): void;
  19989. /**
  19990. * Updates the current device position and rotation in the babylon world
  19991. */
  19992. update(): void;
  19993. /**
  19994. * @hidden
  19995. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  19996. * @returns an identity matrix
  19997. */
  19998. _getViewMatrix(): Matrix;
  19999. private _tmpMatrix;
  20000. /**
  20001. * This function is called by the two RIG cameras.
  20002. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20003. * @hidden
  20004. */
  20005. _getWebVRViewMatrix(): Matrix;
  20006. /** @hidden */
  20007. _getWebVRProjectionMatrix(): Matrix;
  20008. private _onGamepadConnectedObserver;
  20009. private _onGamepadDisconnectedObserver;
  20010. private _updateCacheWhenTrackingDisabledObserver;
  20011. /**
  20012. * Initializes the controllers and their meshes
  20013. */
  20014. initControllers(): void;
  20015. }
  20016. }
  20017. declare module BABYLON {
  20018. /**
  20019. * "Static Class" containing the most commonly used helper while dealing with material for
  20020. * rendering purpose.
  20021. *
  20022. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20023. *
  20024. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20025. */
  20026. export class MaterialHelper {
  20027. /**
  20028. * Bind the current view position to an effect.
  20029. * @param effect The effect to be bound
  20030. * @param scene The scene the eyes position is used from
  20031. * @param variableName name of the shader variable that will hold the eye position
  20032. */
  20033. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20034. /**
  20035. * Helps preparing the defines values about the UVs in used in the effect.
  20036. * UVs are shared as much as we can accross channels in the shaders.
  20037. * @param texture The texture we are preparing the UVs for
  20038. * @param defines The defines to update
  20039. * @param key The channel key "diffuse", "specular"... used in the shader
  20040. */
  20041. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20042. /**
  20043. * Binds a texture matrix value to its corrsponding uniform
  20044. * @param texture The texture to bind the matrix for
  20045. * @param uniformBuffer The uniform buffer receivin the data
  20046. * @param key The channel key "diffuse", "specular"... used in the shader
  20047. */
  20048. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20049. /**
  20050. * Gets the current status of the fog (should it be enabled?)
  20051. * @param mesh defines the mesh to evaluate for fog support
  20052. * @param scene defines the hosting scene
  20053. * @returns true if fog must be enabled
  20054. */
  20055. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20056. /**
  20057. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20058. * @param mesh defines the current mesh
  20059. * @param scene defines the current scene
  20060. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20061. * @param pointsCloud defines if point cloud rendering has to be turned on
  20062. * @param fogEnabled defines if fog has to be turned on
  20063. * @param alphaTest defines if alpha testing has to be turned on
  20064. * @param defines defines the current list of defines
  20065. */
  20066. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20067. /**
  20068. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20069. * @param scene defines the current scene
  20070. * @param engine defines the current engine
  20071. * @param defines specifies the list of active defines
  20072. * @param useInstances defines if instances have to be turned on
  20073. * @param useClipPlane defines if clip plane have to be turned on
  20074. * @param useInstances defines if instances have to be turned on
  20075. * @param useThinInstances defines if thin instances have to be turned on
  20076. */
  20077. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20078. /**
  20079. * Prepares the defines for bones
  20080. * @param mesh The mesh containing the geometry data we will draw
  20081. * @param defines The defines to update
  20082. */
  20083. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20084. /**
  20085. * Prepares the defines for morph targets
  20086. * @param mesh The mesh containing the geometry data we will draw
  20087. * @param defines The defines to update
  20088. */
  20089. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20090. /**
  20091. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20092. * @param mesh The mesh containing the geometry data we will draw
  20093. * @param defines The defines to update
  20094. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20095. * @param useBones Precise whether bones should be used or not (override mesh info)
  20096. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20097. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20098. * @returns false if defines are considered not dirty and have not been checked
  20099. */
  20100. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20101. /**
  20102. * Prepares the defines related to multiview
  20103. * @param scene The scene we are intending to draw
  20104. * @param defines The defines to update
  20105. */
  20106. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20107. /**
  20108. * Prepares the defines related to the prepass
  20109. * @param scene The scene we are intending to draw
  20110. * @param defines The defines to update
  20111. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20112. */
  20113. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20114. /**
  20115. * Prepares the defines related to the light information passed in parameter
  20116. * @param scene The scene we are intending to draw
  20117. * @param mesh The mesh the effect is compiling for
  20118. * @param light The light the effect is compiling for
  20119. * @param lightIndex The index of the light
  20120. * @param defines The defines to update
  20121. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20122. * @param state Defines the current state regarding what is needed (normals, etc...)
  20123. */
  20124. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20125. needNormals: boolean;
  20126. needRebuild: boolean;
  20127. shadowEnabled: boolean;
  20128. specularEnabled: boolean;
  20129. lightmapMode: boolean;
  20130. }): void;
  20131. /**
  20132. * Prepares the defines related to the light information passed in parameter
  20133. * @param scene The scene we are intending to draw
  20134. * @param mesh The mesh the effect is compiling for
  20135. * @param defines The defines to update
  20136. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20137. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20138. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20139. * @returns true if normals will be required for the rest of the effect
  20140. */
  20141. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20142. /**
  20143. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20144. * @param lightIndex defines the light index
  20145. * @param uniformsList The uniform list
  20146. * @param samplersList The sampler list
  20147. * @param projectedLightTexture defines if projected texture must be used
  20148. * @param uniformBuffersList defines an optional list of uniform buffers
  20149. */
  20150. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20151. /**
  20152. * Prepares the uniforms and samplers list to be used in the effect
  20153. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20154. * @param samplersList The sampler list
  20155. * @param defines The defines helping in the list generation
  20156. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20157. */
  20158. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20159. /**
  20160. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20161. * @param defines The defines to update while falling back
  20162. * @param fallbacks The authorized effect fallbacks
  20163. * @param maxSimultaneousLights The maximum number of lights allowed
  20164. * @param rank the current rank of the Effect
  20165. * @returns The newly affected rank
  20166. */
  20167. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20168. private static _TmpMorphInfluencers;
  20169. /**
  20170. * Prepares the list of attributes required for morph targets according to the effect defines.
  20171. * @param attribs The current list of supported attribs
  20172. * @param mesh The mesh to prepare the morph targets attributes for
  20173. * @param influencers The number of influencers
  20174. */
  20175. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20176. /**
  20177. * Prepares the list of attributes required for morph targets according to the effect defines.
  20178. * @param attribs The current list of supported attribs
  20179. * @param mesh The mesh to prepare the morph targets attributes for
  20180. * @param defines The current Defines of the effect
  20181. */
  20182. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20183. /**
  20184. * Prepares the list of attributes required for bones according to the effect defines.
  20185. * @param attribs The current list of supported attribs
  20186. * @param mesh The mesh to prepare the bones attributes for
  20187. * @param defines The current Defines of the effect
  20188. * @param fallbacks The current efffect fallback strategy
  20189. */
  20190. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20191. /**
  20192. * Check and prepare the list of attributes required for instances according to the effect defines.
  20193. * @param attribs The current list of supported attribs
  20194. * @param defines The current MaterialDefines of the effect
  20195. */
  20196. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20197. /**
  20198. * Add the list of attributes required for instances to the attribs array.
  20199. * @param attribs The current list of supported attribs
  20200. */
  20201. static PushAttributesForInstances(attribs: string[]): void;
  20202. /**
  20203. * Binds the light information to the effect.
  20204. * @param light The light containing the generator
  20205. * @param effect The effect we are binding the data to
  20206. * @param lightIndex The light index in the effect used to render
  20207. */
  20208. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20209. /**
  20210. * Binds the lights information from the scene to the effect for the given mesh.
  20211. * @param light Light to bind
  20212. * @param lightIndex Light index
  20213. * @param scene The scene where the light belongs to
  20214. * @param effect The effect we are binding the data to
  20215. * @param useSpecular Defines if specular is supported
  20216. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20217. */
  20218. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20219. /**
  20220. * Binds the lights information from the scene to the effect for the given mesh.
  20221. * @param scene The scene the lights belongs to
  20222. * @param mesh The mesh we are binding the information to render
  20223. * @param effect The effect we are binding the data to
  20224. * @param defines The generated defines for the effect
  20225. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20226. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20227. */
  20228. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20229. private static _tempFogColor;
  20230. /**
  20231. * Binds the fog information from the scene to the effect for the given mesh.
  20232. * @param scene The scene the lights belongs to
  20233. * @param mesh The mesh we are binding the information to render
  20234. * @param effect The effect we are binding the data to
  20235. * @param linearSpace Defines if the fog effect is applied in linear space
  20236. */
  20237. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20238. /**
  20239. * Binds the bones information from the mesh to the effect.
  20240. * @param mesh The mesh we are binding the information to render
  20241. * @param effect The effect we are binding the data to
  20242. */
  20243. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20244. /**
  20245. * Binds the morph targets information from the mesh to the effect.
  20246. * @param abstractMesh The mesh we are binding the information to render
  20247. * @param effect The effect we are binding the data to
  20248. */
  20249. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20250. /**
  20251. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20252. * @param defines The generated defines used in the effect
  20253. * @param effect The effect we are binding the data to
  20254. * @param scene The scene we are willing to render with logarithmic scale for
  20255. */
  20256. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20257. /**
  20258. * Binds the clip plane information from the scene to the effect.
  20259. * @param scene The scene the clip plane information are extracted from
  20260. * @param effect The effect we are binding the data to
  20261. */
  20262. static BindClipPlane(effect: Effect, scene: Scene): void;
  20263. }
  20264. }
  20265. declare module BABYLON {
  20266. /**
  20267. * Block used to expose an input value
  20268. */
  20269. export class InputBlock extends NodeMaterialBlock {
  20270. private _mode;
  20271. private _associatedVariableName;
  20272. private _storedValue;
  20273. private _valueCallback;
  20274. private _type;
  20275. private _animationType;
  20276. /** Gets or set a value used to limit the range of float values */
  20277. min: number;
  20278. /** Gets or set a value used to limit the range of float values */
  20279. max: number;
  20280. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20281. isBoolean: boolean;
  20282. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20283. matrixMode: number;
  20284. /** @hidden */
  20285. _systemValue: Nullable<NodeMaterialSystemValues>;
  20286. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20287. visibleInInspector: boolean;
  20288. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20289. isConstant: boolean;
  20290. /** Gets or sets the group to use to display this block in the Inspector */
  20291. groupInInspector: string;
  20292. /** Gets an observable raised when the value is changed */
  20293. onValueChangedObservable: Observable<InputBlock>;
  20294. /**
  20295. * Gets or sets the connection point type (default is float)
  20296. */
  20297. get type(): NodeMaterialBlockConnectionPointTypes;
  20298. /**
  20299. * Creates a new InputBlock
  20300. * @param name defines the block name
  20301. * @param target defines the target of that block (Vertex by default)
  20302. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20303. */
  20304. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20305. /**
  20306. * Validates if a name is a reserve word.
  20307. * @param newName the new name to be given to the node.
  20308. * @returns false if the name is a reserve word, else true.
  20309. */
  20310. validateBlockName(newName: string): boolean;
  20311. /**
  20312. * Gets the output component
  20313. */
  20314. get output(): NodeMaterialConnectionPoint;
  20315. /**
  20316. * Set the source of this connection point to a vertex attribute
  20317. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20318. * @returns the current connection point
  20319. */
  20320. setAsAttribute(attributeName?: string): InputBlock;
  20321. /**
  20322. * Set the source of this connection point to a system value
  20323. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20324. * @returns the current connection point
  20325. */
  20326. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20327. /**
  20328. * Gets or sets the value of that point.
  20329. * Please note that this value will be ignored if valueCallback is defined
  20330. */
  20331. get value(): any;
  20332. set value(value: any);
  20333. /**
  20334. * Gets or sets a callback used to get the value of that point.
  20335. * Please note that setting this value will force the connection point to ignore the value property
  20336. */
  20337. get valueCallback(): () => any;
  20338. set valueCallback(value: () => any);
  20339. /**
  20340. * Gets or sets the associated variable name in the shader
  20341. */
  20342. get associatedVariableName(): string;
  20343. set associatedVariableName(value: string);
  20344. /** Gets or sets the type of animation applied to the input */
  20345. get animationType(): AnimatedInputBlockTypes;
  20346. set animationType(value: AnimatedInputBlockTypes);
  20347. /**
  20348. * Gets a boolean indicating that this connection point not defined yet
  20349. */
  20350. get isUndefined(): boolean;
  20351. /**
  20352. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20353. * In this case the connection point name must be the name of the uniform to use.
  20354. * Can only be set on inputs
  20355. */
  20356. get isUniform(): boolean;
  20357. set isUniform(value: boolean);
  20358. /**
  20359. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20360. * In this case the connection point name must be the name of the attribute to use
  20361. * Can only be set on inputs
  20362. */
  20363. get isAttribute(): boolean;
  20364. set isAttribute(value: boolean);
  20365. /**
  20366. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20367. * Can only be set on exit points
  20368. */
  20369. get isVarying(): boolean;
  20370. set isVarying(value: boolean);
  20371. /**
  20372. * Gets a boolean indicating that the current connection point is a system value
  20373. */
  20374. get isSystemValue(): boolean;
  20375. /**
  20376. * Gets or sets the current well known value or null if not defined as a system value
  20377. */
  20378. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20379. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20380. /**
  20381. * Gets the current class name
  20382. * @returns the class name
  20383. */
  20384. getClassName(): string;
  20385. /**
  20386. * Animate the input if animationType !== None
  20387. * @param scene defines the rendering scene
  20388. */
  20389. animate(scene: Scene): void;
  20390. private _emitDefine;
  20391. initialize(state: NodeMaterialBuildState): void;
  20392. /**
  20393. * Set the input block to its default value (based on its type)
  20394. */
  20395. setDefaultValue(): void;
  20396. private _emitConstant;
  20397. /** @hidden */
  20398. get _noContextSwitch(): boolean;
  20399. private _emit;
  20400. /** @hidden */
  20401. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20402. /** @hidden */
  20403. _transmit(effect: Effect, scene: Scene): void;
  20404. protected _buildBlock(state: NodeMaterialBuildState): void;
  20405. protected _dumpPropertiesCode(): string;
  20406. dispose(): void;
  20407. serialize(): any;
  20408. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20409. }
  20410. }
  20411. declare module BABYLON {
  20412. /**
  20413. * Enum used to define the compatibility state between two connection points
  20414. */
  20415. export enum NodeMaterialConnectionPointCompatibilityStates {
  20416. /** Points are compatibles */
  20417. Compatible = 0,
  20418. /** Points are incompatible because of their types */
  20419. TypeIncompatible = 1,
  20420. /** Points are incompatible because of their targets (vertex vs fragment) */
  20421. TargetIncompatible = 2
  20422. }
  20423. /**
  20424. * Defines the direction of a connection point
  20425. */
  20426. export enum NodeMaterialConnectionPointDirection {
  20427. /** Input */
  20428. Input = 0,
  20429. /** Output */
  20430. Output = 1
  20431. }
  20432. /**
  20433. * Defines a connection point for a block
  20434. */
  20435. export class NodeMaterialConnectionPoint {
  20436. /** @hidden */
  20437. _ownerBlock: NodeMaterialBlock;
  20438. /** @hidden */
  20439. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20440. private _endpoints;
  20441. private _associatedVariableName;
  20442. private _direction;
  20443. /** @hidden */
  20444. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20445. /** @hidden */
  20446. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20447. private _type;
  20448. /** @hidden */
  20449. _enforceAssociatedVariableName: boolean;
  20450. /** Gets the direction of the point */
  20451. get direction(): NodeMaterialConnectionPointDirection;
  20452. /** Indicates that this connection point needs dual validation before being connected to another point */
  20453. needDualDirectionValidation: boolean;
  20454. /**
  20455. * Gets or sets the additional types supported by this connection point
  20456. */
  20457. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20458. /**
  20459. * Gets or sets the additional types excluded by this connection point
  20460. */
  20461. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20462. /**
  20463. * Observable triggered when this point is connected
  20464. */
  20465. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20466. /**
  20467. * Gets or sets the associated variable name in the shader
  20468. */
  20469. get associatedVariableName(): string;
  20470. set associatedVariableName(value: string);
  20471. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20472. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20473. /**
  20474. * Gets or sets the connection point type (default is float)
  20475. */
  20476. get type(): NodeMaterialBlockConnectionPointTypes;
  20477. set type(value: NodeMaterialBlockConnectionPointTypes);
  20478. /**
  20479. * Gets or sets the connection point name
  20480. */
  20481. name: string;
  20482. /**
  20483. * Gets or sets the connection point name
  20484. */
  20485. displayName: string;
  20486. /**
  20487. * Gets or sets a boolean indicating that this connection point can be omitted
  20488. */
  20489. isOptional: boolean;
  20490. /**
  20491. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  20492. */
  20493. isExposedOnFrame: boolean;
  20494. /**
  20495. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20496. */
  20497. define: string;
  20498. /** @hidden */
  20499. _prioritizeVertex: boolean;
  20500. private _target;
  20501. /** Gets or sets the target of that connection point */
  20502. get target(): NodeMaterialBlockTargets;
  20503. set target(value: NodeMaterialBlockTargets);
  20504. /**
  20505. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20506. */
  20507. get isConnected(): boolean;
  20508. /**
  20509. * Gets a boolean indicating that the current point is connected to an input block
  20510. */
  20511. get isConnectedToInputBlock(): boolean;
  20512. /**
  20513. * Gets a the connected input block (if any)
  20514. */
  20515. get connectInputBlock(): Nullable<InputBlock>;
  20516. /** Get the other side of the connection (if any) */
  20517. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20518. /** Get the block that owns this connection point */
  20519. get ownerBlock(): NodeMaterialBlock;
  20520. /** Get the block connected on the other side of this connection (if any) */
  20521. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20522. /** Get the block connected on the endpoints of this connection (if any) */
  20523. get connectedBlocks(): Array<NodeMaterialBlock>;
  20524. /** Gets the list of connected endpoints */
  20525. get endpoints(): NodeMaterialConnectionPoint[];
  20526. /** Gets a boolean indicating if that output point is connected to at least one input */
  20527. get hasEndpoints(): boolean;
  20528. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20529. get isConnectedInVertexShader(): boolean;
  20530. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20531. get isConnectedInFragmentShader(): boolean;
  20532. /**
  20533. * Creates a block suitable to be used as an input for this input point.
  20534. * If null is returned, a block based on the point type will be created.
  20535. * @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
  20536. */
  20537. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20538. /**
  20539. * Creates a new connection point
  20540. * @param name defines the connection point name
  20541. * @param ownerBlock defines the block hosting this connection point
  20542. * @param direction defines the direction of the connection point
  20543. */
  20544. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20545. /**
  20546. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20547. * @returns the class name
  20548. */
  20549. getClassName(): string;
  20550. /**
  20551. * Gets a boolean indicating if the current point can be connected to another point
  20552. * @param connectionPoint defines the other connection point
  20553. * @returns a boolean
  20554. */
  20555. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20556. /**
  20557. * Gets a number indicating if the current point can be connected to another point
  20558. * @param connectionPoint defines the other connection point
  20559. * @returns a number defining the compatibility state
  20560. */
  20561. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20562. /**
  20563. * Connect this point to another connection point
  20564. * @param connectionPoint defines the other connection point
  20565. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20566. * @returns the current connection point
  20567. */
  20568. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20569. /**
  20570. * Disconnect this point from one of his endpoint
  20571. * @param endpoint defines the other connection point
  20572. * @returns the current connection point
  20573. */
  20574. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20575. /**
  20576. * Serializes this point in a JSON representation
  20577. * @param isInput defines if the connection point is an input (default is true)
  20578. * @returns the serialized point object
  20579. */
  20580. serialize(isInput?: boolean): any;
  20581. /**
  20582. * Release resources
  20583. */
  20584. dispose(): void;
  20585. }
  20586. }
  20587. declare module BABYLON {
  20588. /**
  20589. * Enum used to define the material modes
  20590. */
  20591. export enum NodeMaterialModes {
  20592. /** Regular material */
  20593. Material = 0,
  20594. /** For post process */
  20595. PostProcess = 1,
  20596. /** For particle system */
  20597. Particle = 2
  20598. }
  20599. }
  20600. declare module BABYLON {
  20601. /**
  20602. * Block used to read a texture from a sampler
  20603. */
  20604. export class TextureBlock extends NodeMaterialBlock {
  20605. private _defineName;
  20606. private _linearDefineName;
  20607. private _gammaDefineName;
  20608. private _tempTextureRead;
  20609. private _samplerName;
  20610. private _transformedUVName;
  20611. private _textureTransformName;
  20612. private _textureInfoName;
  20613. private _mainUVName;
  20614. private _mainUVDefineName;
  20615. private _fragmentOnly;
  20616. /**
  20617. * Gets or sets the texture associated with the node
  20618. */
  20619. texture: Nullable<Texture>;
  20620. /**
  20621. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20622. */
  20623. convertToGammaSpace: boolean;
  20624. /**
  20625. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20626. */
  20627. convertToLinearSpace: boolean;
  20628. /**
  20629. * Create a new TextureBlock
  20630. * @param name defines the block name
  20631. */
  20632. constructor(name: string, fragmentOnly?: boolean);
  20633. /**
  20634. * Gets the current class name
  20635. * @returns the class name
  20636. */
  20637. getClassName(): string;
  20638. /**
  20639. * Gets the uv input component
  20640. */
  20641. get uv(): NodeMaterialConnectionPoint;
  20642. /**
  20643. * Gets the rgba output component
  20644. */
  20645. get rgba(): NodeMaterialConnectionPoint;
  20646. /**
  20647. * Gets the rgb output component
  20648. */
  20649. get rgb(): NodeMaterialConnectionPoint;
  20650. /**
  20651. * Gets the r output component
  20652. */
  20653. get r(): NodeMaterialConnectionPoint;
  20654. /**
  20655. * Gets the g output component
  20656. */
  20657. get g(): NodeMaterialConnectionPoint;
  20658. /**
  20659. * Gets the b output component
  20660. */
  20661. get b(): NodeMaterialConnectionPoint;
  20662. /**
  20663. * Gets the a output component
  20664. */
  20665. get a(): NodeMaterialConnectionPoint;
  20666. get target(): NodeMaterialBlockTargets;
  20667. autoConfigure(material: NodeMaterial): void;
  20668. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  20669. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20670. isReady(): boolean;
  20671. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20672. private get _isMixed();
  20673. private _injectVertexCode;
  20674. private _writeTextureRead;
  20675. private _writeOutput;
  20676. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20677. protected _dumpPropertiesCode(): string;
  20678. serialize(): any;
  20679. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20680. }
  20681. }
  20682. declare module BABYLON {
  20683. /** @hidden */
  20684. export var reflectionFunction: {
  20685. name: string;
  20686. shader: string;
  20687. };
  20688. }
  20689. declare module BABYLON {
  20690. /**
  20691. * Base block used to read a reflection texture from a sampler
  20692. */
  20693. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  20694. /** @hidden */
  20695. _define3DName: string;
  20696. /** @hidden */
  20697. _defineCubicName: string;
  20698. /** @hidden */
  20699. _defineExplicitName: string;
  20700. /** @hidden */
  20701. _defineProjectionName: string;
  20702. /** @hidden */
  20703. _defineLocalCubicName: string;
  20704. /** @hidden */
  20705. _defineSphericalName: string;
  20706. /** @hidden */
  20707. _definePlanarName: string;
  20708. /** @hidden */
  20709. _defineEquirectangularName: string;
  20710. /** @hidden */
  20711. _defineMirroredEquirectangularFixedName: string;
  20712. /** @hidden */
  20713. _defineEquirectangularFixedName: string;
  20714. /** @hidden */
  20715. _defineSkyboxName: string;
  20716. /** @hidden */
  20717. _defineOppositeZ: string;
  20718. /** @hidden */
  20719. _cubeSamplerName: string;
  20720. /** @hidden */
  20721. _2DSamplerName: string;
  20722. protected _positionUVWName: string;
  20723. protected _directionWName: string;
  20724. protected _reflectionVectorName: string;
  20725. /** @hidden */
  20726. _reflectionCoordsName: string;
  20727. /** @hidden */
  20728. _reflectionMatrixName: string;
  20729. protected _reflectionColorName: string;
  20730. /**
  20731. * Gets or sets the texture associated with the node
  20732. */
  20733. texture: Nullable<BaseTexture>;
  20734. /**
  20735. * Create a new ReflectionTextureBaseBlock
  20736. * @param name defines the block name
  20737. */
  20738. constructor(name: string);
  20739. /**
  20740. * Gets the current class name
  20741. * @returns the class name
  20742. */
  20743. getClassName(): string;
  20744. /**
  20745. * Gets the world position input component
  20746. */
  20747. abstract get position(): NodeMaterialConnectionPoint;
  20748. /**
  20749. * Gets the world position input component
  20750. */
  20751. abstract get worldPosition(): NodeMaterialConnectionPoint;
  20752. /**
  20753. * Gets the world normal input component
  20754. */
  20755. abstract get worldNormal(): NodeMaterialConnectionPoint;
  20756. /**
  20757. * Gets the world input component
  20758. */
  20759. abstract get world(): NodeMaterialConnectionPoint;
  20760. /**
  20761. * Gets the camera (or eye) position component
  20762. */
  20763. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  20764. /**
  20765. * Gets the view input component
  20766. */
  20767. abstract get view(): NodeMaterialConnectionPoint;
  20768. protected _getTexture(): Nullable<BaseTexture>;
  20769. autoConfigure(material: NodeMaterial): void;
  20770. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20771. isReady(): boolean;
  20772. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20773. /**
  20774. * Gets the code to inject in the vertex shader
  20775. * @param state current state of the node material building
  20776. * @returns the shader code
  20777. */
  20778. handleVertexSide(state: NodeMaterialBuildState): string;
  20779. /**
  20780. * Handles the inits for the fragment code path
  20781. * @param state node material build state
  20782. */
  20783. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  20784. /**
  20785. * Generates the reflection coords code for the fragment code path
  20786. * @param worldNormalVarName name of the world normal variable
  20787. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  20788. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  20789. * @returns the shader code
  20790. */
  20791. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  20792. /**
  20793. * Generates the reflection color code for the fragment code path
  20794. * @param lodVarName name of the lod variable
  20795. * @param swizzleLookupTexture swizzle to use for the final color variable
  20796. * @returns the shader code
  20797. */
  20798. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  20799. /**
  20800. * Generates the code corresponding to the connected output points
  20801. * @param state node material build state
  20802. * @param varName name of the variable to output
  20803. * @returns the shader code
  20804. */
  20805. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  20806. protected _buildBlock(state: NodeMaterialBuildState): this;
  20807. protected _dumpPropertiesCode(): string;
  20808. serialize(): any;
  20809. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20810. }
  20811. }
  20812. declare module BABYLON {
  20813. /**
  20814. * Defines a connection point to be used for points with a custom object type
  20815. */
  20816. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  20817. private _blockType;
  20818. private _blockName;
  20819. private _nameForCheking?;
  20820. /**
  20821. * Creates a new connection point
  20822. * @param name defines the connection point name
  20823. * @param ownerBlock defines the block hosting this connection point
  20824. * @param direction defines the direction of the connection point
  20825. */
  20826. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  20827. /**
  20828. * Gets a number indicating if the current point can be connected to another point
  20829. * @param connectionPoint defines the other connection point
  20830. * @returns a number defining the compatibility state
  20831. */
  20832. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20833. /**
  20834. * Creates a block suitable to be used as an input for this input point.
  20835. * If null is returned, a block based on the point type will be created.
  20836. * @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
  20837. */
  20838. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20839. }
  20840. }
  20841. declare module BABYLON {
  20842. /**
  20843. * Enum defining the type of properties that can be edited in the property pages in the NME
  20844. */
  20845. export enum PropertyTypeForEdition {
  20846. /** property is a boolean */
  20847. Boolean = 0,
  20848. /** property is a float */
  20849. Float = 1,
  20850. /** property is a Vector2 */
  20851. Vector2 = 2,
  20852. /** property is a list of values */
  20853. List = 3
  20854. }
  20855. /**
  20856. * Interface that defines an option in a variable of type list
  20857. */
  20858. export interface IEditablePropertyListOption {
  20859. /** label of the option */
  20860. "label": string;
  20861. /** value of the option */
  20862. "value": number;
  20863. }
  20864. /**
  20865. * Interface that defines the options available for an editable property
  20866. */
  20867. export interface IEditablePropertyOption {
  20868. /** min value */
  20869. "min"?: number;
  20870. /** max value */
  20871. "max"?: number;
  20872. /** notifiers: indicates which actions to take when the property is changed */
  20873. "notifiers"?: {
  20874. /** the material should be rebuilt */
  20875. "rebuild"?: boolean;
  20876. /** the preview should be updated */
  20877. "update"?: boolean;
  20878. };
  20879. /** list of the options for a variable of type list */
  20880. "options"?: IEditablePropertyListOption[];
  20881. }
  20882. /**
  20883. * Interface that describes an editable property
  20884. */
  20885. export interface IPropertyDescriptionForEdition {
  20886. /** name of the property */
  20887. "propertyName": string;
  20888. /** display name of the property */
  20889. "displayName": string;
  20890. /** type of the property */
  20891. "type": PropertyTypeForEdition;
  20892. /** group of the property - all properties with the same group value will be displayed in a specific section */
  20893. "groupName": string;
  20894. /** options for the property */
  20895. "options": IEditablePropertyOption;
  20896. }
  20897. /**
  20898. * Decorator that flags a property in a node material block as being editable
  20899. */
  20900. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  20901. }
  20902. declare module BABYLON {
  20903. /**
  20904. * Block used to implement the refraction part of the sub surface module of the PBR material
  20905. */
  20906. export class RefractionBlock extends NodeMaterialBlock {
  20907. /** @hidden */
  20908. _define3DName: string;
  20909. /** @hidden */
  20910. _refractionMatrixName: string;
  20911. /** @hidden */
  20912. _defineLODRefractionAlpha: string;
  20913. /** @hidden */
  20914. _defineLinearSpecularRefraction: string;
  20915. /** @hidden */
  20916. _defineOppositeZ: string;
  20917. /** @hidden */
  20918. _cubeSamplerName: string;
  20919. /** @hidden */
  20920. _2DSamplerName: string;
  20921. /** @hidden */
  20922. _vRefractionMicrosurfaceInfosName: string;
  20923. /** @hidden */
  20924. _vRefractionInfosName: string;
  20925. private _scene;
  20926. /**
  20927. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20928. * Materials half opaque for instance using refraction could benefit from this control.
  20929. */
  20930. linkRefractionWithTransparency: boolean;
  20931. /**
  20932. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20933. */
  20934. invertRefractionY: boolean;
  20935. /**
  20936. * Gets or sets the texture associated with the node
  20937. */
  20938. texture: Nullable<BaseTexture>;
  20939. /**
  20940. * Create a new RefractionBlock
  20941. * @param name defines the block name
  20942. */
  20943. constructor(name: string);
  20944. /**
  20945. * Gets the current class name
  20946. * @returns the class name
  20947. */
  20948. getClassName(): string;
  20949. /**
  20950. * Gets the intensity input component
  20951. */
  20952. get intensity(): NodeMaterialConnectionPoint;
  20953. /**
  20954. * Gets the index of refraction input component
  20955. */
  20956. get indexOfRefraction(): NodeMaterialConnectionPoint;
  20957. /**
  20958. * Gets the tint at distance input component
  20959. */
  20960. get tintAtDistance(): NodeMaterialConnectionPoint;
  20961. /**
  20962. * Gets the view input component
  20963. */
  20964. get view(): NodeMaterialConnectionPoint;
  20965. /**
  20966. * Gets the refraction object output component
  20967. */
  20968. get refraction(): NodeMaterialConnectionPoint;
  20969. /**
  20970. * Returns true if the block has a texture
  20971. */
  20972. get hasTexture(): boolean;
  20973. protected _getTexture(): Nullable<BaseTexture>;
  20974. autoConfigure(material: NodeMaterial): void;
  20975. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20976. isReady(): boolean;
  20977. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  20978. /**
  20979. * Gets the main code of the block (fragment side)
  20980. * @param state current state of the node material building
  20981. * @returns the shader code
  20982. */
  20983. getCode(state: NodeMaterialBuildState): string;
  20984. protected _buildBlock(state: NodeMaterialBuildState): this;
  20985. protected _dumpPropertiesCode(): string;
  20986. serialize(): any;
  20987. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20988. }
  20989. }
  20990. declare module BABYLON {
  20991. /**
  20992. * Base block used as input for post process
  20993. */
  20994. export class CurrentScreenBlock extends NodeMaterialBlock {
  20995. private _samplerName;
  20996. private _linearDefineName;
  20997. private _gammaDefineName;
  20998. private _mainUVName;
  20999. private _tempTextureRead;
  21000. /**
  21001. * Gets or sets the texture associated with the node
  21002. */
  21003. texture: Nullable<BaseTexture>;
  21004. /**
  21005. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21006. */
  21007. convertToGammaSpace: boolean;
  21008. /**
  21009. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21010. */
  21011. convertToLinearSpace: boolean;
  21012. /**
  21013. * Create a new CurrentScreenBlock
  21014. * @param name defines the block name
  21015. */
  21016. constructor(name: string);
  21017. /**
  21018. * Gets the current class name
  21019. * @returns the class name
  21020. */
  21021. getClassName(): string;
  21022. /**
  21023. * Gets the uv input component
  21024. */
  21025. get uv(): NodeMaterialConnectionPoint;
  21026. /**
  21027. * Gets the rgba output component
  21028. */
  21029. get rgba(): NodeMaterialConnectionPoint;
  21030. /**
  21031. * Gets the rgb output component
  21032. */
  21033. get rgb(): NodeMaterialConnectionPoint;
  21034. /**
  21035. * Gets the r output component
  21036. */
  21037. get r(): NodeMaterialConnectionPoint;
  21038. /**
  21039. * Gets the g output component
  21040. */
  21041. get g(): NodeMaterialConnectionPoint;
  21042. /**
  21043. * Gets the b output component
  21044. */
  21045. get b(): NodeMaterialConnectionPoint;
  21046. /**
  21047. * Gets the a output component
  21048. */
  21049. get a(): NodeMaterialConnectionPoint;
  21050. /**
  21051. * Initialize the block and prepare the context for build
  21052. * @param state defines the state that will be used for the build
  21053. */
  21054. initialize(state: NodeMaterialBuildState): void;
  21055. get target(): NodeMaterialBlockTargets;
  21056. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21057. isReady(): boolean;
  21058. private _injectVertexCode;
  21059. private _writeTextureRead;
  21060. private _writeOutput;
  21061. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21062. serialize(): any;
  21063. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21064. }
  21065. }
  21066. declare module BABYLON {
  21067. /**
  21068. * Base block used for the particle texture
  21069. */
  21070. export class ParticleTextureBlock extends NodeMaterialBlock {
  21071. private _samplerName;
  21072. private _linearDefineName;
  21073. private _gammaDefineName;
  21074. private _tempTextureRead;
  21075. /**
  21076. * Gets or sets the texture associated with the node
  21077. */
  21078. texture: Nullable<BaseTexture>;
  21079. /**
  21080. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21081. */
  21082. convertToGammaSpace: boolean;
  21083. /**
  21084. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21085. */
  21086. convertToLinearSpace: boolean;
  21087. /**
  21088. * Create a new ParticleTextureBlock
  21089. * @param name defines the block name
  21090. */
  21091. constructor(name: string);
  21092. /**
  21093. * Gets the current class name
  21094. * @returns the class name
  21095. */
  21096. getClassName(): string;
  21097. /**
  21098. * Gets the uv input component
  21099. */
  21100. get uv(): NodeMaterialConnectionPoint;
  21101. /**
  21102. * Gets the rgba output component
  21103. */
  21104. get rgba(): NodeMaterialConnectionPoint;
  21105. /**
  21106. * Gets the rgb output component
  21107. */
  21108. get rgb(): NodeMaterialConnectionPoint;
  21109. /**
  21110. * Gets the r output component
  21111. */
  21112. get r(): NodeMaterialConnectionPoint;
  21113. /**
  21114. * Gets the g output component
  21115. */
  21116. get g(): NodeMaterialConnectionPoint;
  21117. /**
  21118. * Gets the b output component
  21119. */
  21120. get b(): NodeMaterialConnectionPoint;
  21121. /**
  21122. * Gets the a output component
  21123. */
  21124. get a(): NodeMaterialConnectionPoint;
  21125. /**
  21126. * Initialize the block and prepare the context for build
  21127. * @param state defines the state that will be used for the build
  21128. */
  21129. initialize(state: NodeMaterialBuildState): void;
  21130. autoConfigure(material: NodeMaterial): void;
  21131. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21132. isReady(): boolean;
  21133. private _writeOutput;
  21134. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21135. serialize(): any;
  21136. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21137. }
  21138. }
  21139. declare module BABYLON {
  21140. /**
  21141. * Class used to store shared data between 2 NodeMaterialBuildState
  21142. */
  21143. export class NodeMaterialBuildStateSharedData {
  21144. /**
  21145. * Gets the list of emitted varyings
  21146. */
  21147. temps: string[];
  21148. /**
  21149. * Gets the list of emitted varyings
  21150. */
  21151. varyings: string[];
  21152. /**
  21153. * Gets the varying declaration string
  21154. */
  21155. varyingDeclaration: string;
  21156. /**
  21157. * Input blocks
  21158. */
  21159. inputBlocks: InputBlock[];
  21160. /**
  21161. * Input blocks
  21162. */
  21163. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21164. /**
  21165. * Bindable blocks (Blocks that need to set data to the effect)
  21166. */
  21167. bindableBlocks: NodeMaterialBlock[];
  21168. /**
  21169. * List of blocks that can provide a compilation fallback
  21170. */
  21171. blocksWithFallbacks: NodeMaterialBlock[];
  21172. /**
  21173. * List of blocks that can provide a define update
  21174. */
  21175. blocksWithDefines: NodeMaterialBlock[];
  21176. /**
  21177. * List of blocks that can provide a repeatable content
  21178. */
  21179. repeatableContentBlocks: NodeMaterialBlock[];
  21180. /**
  21181. * List of blocks that can provide a dynamic list of uniforms
  21182. */
  21183. dynamicUniformBlocks: NodeMaterialBlock[];
  21184. /**
  21185. * List of blocks that can block the isReady function for the material
  21186. */
  21187. blockingBlocks: NodeMaterialBlock[];
  21188. /**
  21189. * Gets the list of animated inputs
  21190. */
  21191. animatedInputs: InputBlock[];
  21192. /**
  21193. * Build Id used to avoid multiple recompilations
  21194. */
  21195. buildId: number;
  21196. /** List of emitted variables */
  21197. variableNames: {
  21198. [key: string]: number;
  21199. };
  21200. /** List of emitted defines */
  21201. defineNames: {
  21202. [key: string]: number;
  21203. };
  21204. /** Should emit comments? */
  21205. emitComments: boolean;
  21206. /** Emit build activity */
  21207. verbose: boolean;
  21208. /** Gets or sets the hosting scene */
  21209. scene: Scene;
  21210. /**
  21211. * Gets the compilation hints emitted at compilation time
  21212. */
  21213. hints: {
  21214. needWorldViewMatrix: boolean;
  21215. needWorldViewProjectionMatrix: boolean;
  21216. needAlphaBlending: boolean;
  21217. needAlphaTesting: boolean;
  21218. };
  21219. /**
  21220. * List of compilation checks
  21221. */
  21222. checks: {
  21223. emitVertex: boolean;
  21224. emitFragment: boolean;
  21225. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21226. };
  21227. /**
  21228. * Is vertex program allowed to be empty?
  21229. */
  21230. allowEmptyVertexProgram: boolean;
  21231. /** Creates a new shared data */
  21232. constructor();
  21233. /**
  21234. * Emits console errors and exceptions if there is a failing check
  21235. */
  21236. emitErrors(): void;
  21237. }
  21238. }
  21239. declare module BABYLON {
  21240. /**
  21241. * Class used to store node based material build state
  21242. */
  21243. export class NodeMaterialBuildState {
  21244. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21245. supportUniformBuffers: boolean;
  21246. /**
  21247. * Gets the list of emitted attributes
  21248. */
  21249. attributes: string[];
  21250. /**
  21251. * Gets the list of emitted uniforms
  21252. */
  21253. uniforms: string[];
  21254. /**
  21255. * Gets the list of emitted constants
  21256. */
  21257. constants: string[];
  21258. /**
  21259. * Gets the list of emitted samplers
  21260. */
  21261. samplers: string[];
  21262. /**
  21263. * Gets the list of emitted functions
  21264. */
  21265. functions: {
  21266. [key: string]: string;
  21267. };
  21268. /**
  21269. * Gets the list of emitted extensions
  21270. */
  21271. extensions: {
  21272. [key: string]: string;
  21273. };
  21274. /**
  21275. * Gets the target of the compilation state
  21276. */
  21277. target: NodeMaterialBlockTargets;
  21278. /**
  21279. * Gets the list of emitted counters
  21280. */
  21281. counters: {
  21282. [key: string]: number;
  21283. };
  21284. /**
  21285. * Shared data between multiple NodeMaterialBuildState instances
  21286. */
  21287. sharedData: NodeMaterialBuildStateSharedData;
  21288. /** @hidden */
  21289. _vertexState: NodeMaterialBuildState;
  21290. /** @hidden */
  21291. _attributeDeclaration: string;
  21292. /** @hidden */
  21293. _uniformDeclaration: string;
  21294. /** @hidden */
  21295. _constantDeclaration: string;
  21296. /** @hidden */
  21297. _samplerDeclaration: string;
  21298. /** @hidden */
  21299. _varyingTransfer: string;
  21300. /** @hidden */
  21301. _injectAtEnd: string;
  21302. private _repeatableContentAnchorIndex;
  21303. /** @hidden */
  21304. _builtCompilationString: string;
  21305. /**
  21306. * Gets the emitted compilation strings
  21307. */
  21308. compilationString: string;
  21309. /**
  21310. * Finalize the compilation strings
  21311. * @param state defines the current compilation state
  21312. */
  21313. finalize(state: NodeMaterialBuildState): void;
  21314. /** @hidden */
  21315. get _repeatableContentAnchor(): string;
  21316. /** @hidden */
  21317. _getFreeVariableName(prefix: string): string;
  21318. /** @hidden */
  21319. _getFreeDefineName(prefix: string): string;
  21320. /** @hidden */
  21321. _excludeVariableName(name: string): void;
  21322. /** @hidden */
  21323. _emit2DSampler(name: string): void;
  21324. /** @hidden */
  21325. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21326. /** @hidden */
  21327. _emitExtension(name: string, extension: string, define?: string): void;
  21328. /** @hidden */
  21329. _emitFunction(name: string, code: string, comments: string): void;
  21330. /** @hidden */
  21331. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21332. replaceStrings?: {
  21333. search: RegExp;
  21334. replace: string;
  21335. }[];
  21336. repeatKey?: string;
  21337. }): string;
  21338. /** @hidden */
  21339. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21340. repeatKey?: string;
  21341. removeAttributes?: boolean;
  21342. removeUniforms?: boolean;
  21343. removeVaryings?: boolean;
  21344. removeIfDef?: boolean;
  21345. replaceStrings?: {
  21346. search: RegExp;
  21347. replace: string;
  21348. }[];
  21349. }, storeKey?: string): void;
  21350. /** @hidden */
  21351. _registerTempVariable(name: string): boolean;
  21352. /** @hidden */
  21353. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21354. /** @hidden */
  21355. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21356. /** @hidden */
  21357. _emitFloat(value: number): string;
  21358. }
  21359. }
  21360. declare module BABYLON {
  21361. /**
  21362. * Helper class used to generate session unique ID
  21363. */
  21364. export class UniqueIdGenerator {
  21365. private static _UniqueIdCounter;
  21366. /**
  21367. * Gets an unique (relatively to the current scene) Id
  21368. */
  21369. static get UniqueId(): number;
  21370. }
  21371. }
  21372. declare module BABYLON {
  21373. /**
  21374. * Defines a block that can be used inside a node based material
  21375. */
  21376. export class NodeMaterialBlock {
  21377. private _buildId;
  21378. private _buildTarget;
  21379. private _target;
  21380. private _isFinalMerger;
  21381. private _isInput;
  21382. private _name;
  21383. protected _isUnique: boolean;
  21384. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21385. inputsAreExclusive: boolean;
  21386. /** @hidden */
  21387. _codeVariableName: string;
  21388. /** @hidden */
  21389. _inputs: NodeMaterialConnectionPoint[];
  21390. /** @hidden */
  21391. _outputs: NodeMaterialConnectionPoint[];
  21392. /** @hidden */
  21393. _preparationId: number;
  21394. /**
  21395. * Gets the name of the block
  21396. */
  21397. get name(): string;
  21398. /**
  21399. * Sets the name of the block. Will check if the name is valid.
  21400. */
  21401. set name(newName: string);
  21402. /**
  21403. * Gets or sets the unique id of the node
  21404. */
  21405. uniqueId: number;
  21406. /**
  21407. * Gets or sets the comments associated with this block
  21408. */
  21409. comments: string;
  21410. /**
  21411. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21412. */
  21413. get isUnique(): boolean;
  21414. /**
  21415. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21416. */
  21417. get isFinalMerger(): boolean;
  21418. /**
  21419. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21420. */
  21421. get isInput(): boolean;
  21422. /**
  21423. * Gets or sets the build Id
  21424. */
  21425. get buildId(): number;
  21426. set buildId(value: number);
  21427. /**
  21428. * Gets or sets the target of the block
  21429. */
  21430. get target(): NodeMaterialBlockTargets;
  21431. set target(value: NodeMaterialBlockTargets);
  21432. /**
  21433. * Gets the list of input points
  21434. */
  21435. get inputs(): NodeMaterialConnectionPoint[];
  21436. /** Gets the list of output points */
  21437. get outputs(): NodeMaterialConnectionPoint[];
  21438. /**
  21439. * Find an input by its name
  21440. * @param name defines the name of the input to look for
  21441. * @returns the input or null if not found
  21442. */
  21443. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21444. /**
  21445. * Find an output by its name
  21446. * @param name defines the name of the outputto look for
  21447. * @returns the output or null if not found
  21448. */
  21449. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21450. /**
  21451. * Creates a new NodeMaterialBlock
  21452. * @param name defines the block name
  21453. * @param target defines the target of that block (Vertex by default)
  21454. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21455. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21456. */
  21457. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21458. /**
  21459. * Initialize the block and prepare the context for build
  21460. * @param state defines the state that will be used for the build
  21461. */
  21462. initialize(state: NodeMaterialBuildState): void;
  21463. /**
  21464. * Bind data to effect. Will only be called for blocks with isBindable === true
  21465. * @param effect defines the effect to bind data to
  21466. * @param nodeMaterial defines the hosting NodeMaterial
  21467. * @param mesh defines the mesh that will be rendered
  21468. * @param subMesh defines the submesh that will be rendered
  21469. */
  21470. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21471. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21472. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21473. protected _writeFloat(value: number): string;
  21474. /**
  21475. * Gets the current class name e.g. "NodeMaterialBlock"
  21476. * @returns the class name
  21477. */
  21478. getClassName(): string;
  21479. /**
  21480. * Register a new input. Must be called inside a block constructor
  21481. * @param name defines the connection point name
  21482. * @param type defines the connection point type
  21483. * @param isOptional defines a boolean indicating that this input can be omitted
  21484. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21485. * @param point an already created connection point. If not provided, create a new one
  21486. * @returns the current block
  21487. */
  21488. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21489. /**
  21490. * Register a new output. Must be called inside a block constructor
  21491. * @param name defines the connection point name
  21492. * @param type defines the connection point type
  21493. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21494. * @param point an already created connection point. If not provided, create a new one
  21495. * @returns the current block
  21496. */
  21497. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21498. /**
  21499. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21500. * @param forOutput defines an optional connection point to check compatibility with
  21501. * @returns the first available input or null
  21502. */
  21503. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21504. /**
  21505. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21506. * @param forBlock defines an optional block to check compatibility with
  21507. * @returns the first available input or null
  21508. */
  21509. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21510. /**
  21511. * Gets the sibling of the given output
  21512. * @param current defines the current output
  21513. * @returns the next output in the list or null
  21514. */
  21515. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21516. /**
  21517. * Connect current block with another block
  21518. * @param other defines the block to connect with
  21519. * @param options define the various options to help pick the right connections
  21520. * @returns the current block
  21521. */
  21522. connectTo(other: NodeMaterialBlock, options?: {
  21523. input?: string;
  21524. output?: string;
  21525. outputSwizzle?: string;
  21526. }): this | undefined;
  21527. protected _buildBlock(state: NodeMaterialBuildState): void;
  21528. /**
  21529. * Add uniforms, samplers and uniform buffers at compilation time
  21530. * @param state defines the state to update
  21531. * @param nodeMaterial defines the node material requesting the update
  21532. * @param defines defines the material defines to update
  21533. * @param uniformBuffers defines the list of uniform buffer names
  21534. */
  21535. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21536. /**
  21537. * Add potential fallbacks if shader compilation fails
  21538. * @param mesh defines the mesh to be rendered
  21539. * @param fallbacks defines the current prioritized list of fallbacks
  21540. */
  21541. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21542. /**
  21543. * Initialize defines for shader compilation
  21544. * @param mesh defines the mesh to be rendered
  21545. * @param nodeMaterial defines the node material requesting the update
  21546. * @param defines defines the material defines to update
  21547. * @param useInstances specifies that instances should be used
  21548. */
  21549. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21550. /**
  21551. * Update defines for shader compilation
  21552. * @param mesh defines the mesh to be rendered
  21553. * @param nodeMaterial defines the node material requesting the update
  21554. * @param defines defines the material defines to update
  21555. * @param useInstances specifies that instances should be used
  21556. * @param subMesh defines which submesh to render
  21557. */
  21558. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21559. /**
  21560. * Lets the block try to connect some inputs automatically
  21561. * @param material defines the hosting NodeMaterial
  21562. */
  21563. autoConfigure(material: NodeMaterial): void;
  21564. /**
  21565. * Function called when a block is declared as repeatable content generator
  21566. * @param vertexShaderState defines the current compilation state for the vertex shader
  21567. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21568. * @param mesh defines the mesh to be rendered
  21569. * @param defines defines the material defines to update
  21570. */
  21571. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21572. /**
  21573. * Checks if the block is ready
  21574. * @param mesh defines the mesh to be rendered
  21575. * @param nodeMaterial defines the node material requesting the update
  21576. * @param defines defines the material defines to update
  21577. * @param useInstances specifies that instances should be used
  21578. * @returns true if the block is ready
  21579. */
  21580. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21581. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21582. private _processBuild;
  21583. /**
  21584. * Validates the new name for the block node.
  21585. * @param newName the new name to be given to the node.
  21586. * @returns false if the name is a reserve word, else true.
  21587. */
  21588. validateBlockName(newName: string): boolean;
  21589. /**
  21590. * Compile the current node and generate the shader code
  21591. * @param state defines the current compilation state (uniforms, samplers, current string)
  21592. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21593. * @returns true if already built
  21594. */
  21595. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21596. protected _inputRename(name: string): string;
  21597. protected _outputRename(name: string): string;
  21598. protected _dumpPropertiesCode(): string;
  21599. /** @hidden */
  21600. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21601. /** @hidden */
  21602. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21603. /**
  21604. * Clone the current block to a new identical block
  21605. * @param scene defines the hosting scene
  21606. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21607. * @returns a copy of the current block
  21608. */
  21609. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21610. /**
  21611. * Serializes this block in a JSON representation
  21612. * @returns the serialized block object
  21613. */
  21614. serialize(): any;
  21615. /** @hidden */
  21616. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21617. private _deserializePortDisplayNamesAndExposedOnFrame;
  21618. /**
  21619. * Release resources
  21620. */
  21621. dispose(): void;
  21622. }
  21623. }
  21624. declare module BABYLON {
  21625. /**
  21626. * Base class of materials working in push mode in babylon JS
  21627. * @hidden
  21628. */
  21629. export class PushMaterial extends Material {
  21630. protected _activeEffect: Effect;
  21631. protected _normalMatrix: Matrix;
  21632. constructor(name: string, scene: Scene);
  21633. getEffect(): Effect;
  21634. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21635. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21636. /**
  21637. * Binds the given world matrix to the active effect
  21638. *
  21639. * @param world the matrix to bind
  21640. */
  21641. bindOnlyWorldMatrix(world: Matrix): void;
  21642. /**
  21643. * Binds the given normal matrix to the active effect
  21644. *
  21645. * @param normalMatrix the matrix to bind
  21646. */
  21647. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21648. bind(world: Matrix, mesh?: Mesh): void;
  21649. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21650. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21651. }
  21652. }
  21653. declare module BABYLON {
  21654. /**
  21655. * Root class for all node material optimizers
  21656. */
  21657. export class NodeMaterialOptimizer {
  21658. /**
  21659. * Function used to optimize a NodeMaterial graph
  21660. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  21661. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  21662. */
  21663. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  21664. }
  21665. }
  21666. declare module BABYLON {
  21667. /**
  21668. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  21669. */
  21670. export class TransformBlock extends NodeMaterialBlock {
  21671. /**
  21672. * Defines the value to use to complement W value to transform it to a Vector4
  21673. */
  21674. complementW: number;
  21675. /**
  21676. * Defines the value to use to complement z value to transform it to a Vector4
  21677. */
  21678. complementZ: number;
  21679. /**
  21680. * Creates a new TransformBlock
  21681. * @param name defines the block name
  21682. */
  21683. constructor(name: string);
  21684. /**
  21685. * Gets the current class name
  21686. * @returns the class name
  21687. */
  21688. getClassName(): string;
  21689. /**
  21690. * Gets the vector input
  21691. */
  21692. get vector(): NodeMaterialConnectionPoint;
  21693. /**
  21694. * Gets the output component
  21695. */
  21696. get output(): NodeMaterialConnectionPoint;
  21697. /**
  21698. * Gets the xyz output component
  21699. */
  21700. get xyz(): NodeMaterialConnectionPoint;
  21701. /**
  21702. * Gets the matrix transform input
  21703. */
  21704. get transform(): NodeMaterialConnectionPoint;
  21705. protected _buildBlock(state: NodeMaterialBuildState): this;
  21706. /**
  21707. * Update defines for shader compilation
  21708. * @param mesh defines the mesh to be rendered
  21709. * @param nodeMaterial defines the node material requesting the update
  21710. * @param defines defines the material defines to update
  21711. * @param useInstances specifies that instances should be used
  21712. * @param subMesh defines which submesh to render
  21713. */
  21714. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21715. serialize(): any;
  21716. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21717. protected _dumpPropertiesCode(): string;
  21718. }
  21719. }
  21720. declare module BABYLON {
  21721. /**
  21722. * Block used to output the vertex position
  21723. */
  21724. export class VertexOutputBlock extends NodeMaterialBlock {
  21725. /**
  21726. * Creates a new VertexOutputBlock
  21727. * @param name defines the block name
  21728. */
  21729. constructor(name: string);
  21730. /**
  21731. * Gets the current class name
  21732. * @returns the class name
  21733. */
  21734. getClassName(): string;
  21735. /**
  21736. * Gets the vector input component
  21737. */
  21738. get vector(): NodeMaterialConnectionPoint;
  21739. protected _buildBlock(state: NodeMaterialBuildState): this;
  21740. }
  21741. }
  21742. declare module BABYLON {
  21743. /**
  21744. * Block used to output the final color
  21745. */
  21746. export class FragmentOutputBlock extends NodeMaterialBlock {
  21747. /**
  21748. * Create a new FragmentOutputBlock
  21749. * @param name defines the block name
  21750. */
  21751. constructor(name: string);
  21752. /**
  21753. * Gets the current class name
  21754. * @returns the class name
  21755. */
  21756. getClassName(): string;
  21757. /**
  21758. * Gets the rgba input component
  21759. */
  21760. get rgba(): NodeMaterialConnectionPoint;
  21761. /**
  21762. * Gets the rgb input component
  21763. */
  21764. get rgb(): NodeMaterialConnectionPoint;
  21765. /**
  21766. * Gets the a input component
  21767. */
  21768. get a(): NodeMaterialConnectionPoint;
  21769. protected _buildBlock(state: NodeMaterialBuildState): this;
  21770. }
  21771. }
  21772. declare module BABYLON {
  21773. /**
  21774. * Block used for the particle ramp gradient section
  21775. */
  21776. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  21777. /**
  21778. * Create a new ParticleRampGradientBlock
  21779. * @param name defines the block name
  21780. */
  21781. constructor(name: string);
  21782. /**
  21783. * Gets the current class name
  21784. * @returns the class name
  21785. */
  21786. getClassName(): string;
  21787. /**
  21788. * Gets the color input component
  21789. */
  21790. get color(): NodeMaterialConnectionPoint;
  21791. /**
  21792. * Gets the rampColor output component
  21793. */
  21794. get rampColor(): NodeMaterialConnectionPoint;
  21795. /**
  21796. * Initialize the block and prepare the context for build
  21797. * @param state defines the state that will be used for the build
  21798. */
  21799. initialize(state: NodeMaterialBuildState): void;
  21800. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21801. }
  21802. }
  21803. declare module BABYLON {
  21804. /**
  21805. * Block used for the particle blend multiply section
  21806. */
  21807. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  21808. /**
  21809. * Create a new ParticleBlendMultiplyBlock
  21810. * @param name defines the block name
  21811. */
  21812. constructor(name: string);
  21813. /**
  21814. * Gets the current class name
  21815. * @returns the class name
  21816. */
  21817. getClassName(): string;
  21818. /**
  21819. * Gets the color input component
  21820. */
  21821. get color(): NodeMaterialConnectionPoint;
  21822. /**
  21823. * Gets the alphaTexture input component
  21824. */
  21825. get alphaTexture(): NodeMaterialConnectionPoint;
  21826. /**
  21827. * Gets the alphaColor input component
  21828. */
  21829. get alphaColor(): NodeMaterialConnectionPoint;
  21830. /**
  21831. * Gets the blendColor output component
  21832. */
  21833. get blendColor(): NodeMaterialConnectionPoint;
  21834. /**
  21835. * Initialize the block and prepare the context for build
  21836. * @param state defines the state that will be used for the build
  21837. */
  21838. initialize(state: NodeMaterialBuildState): void;
  21839. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21840. }
  21841. }
  21842. declare module BABYLON {
  21843. /**
  21844. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  21845. */
  21846. export class VectorMergerBlock extends NodeMaterialBlock {
  21847. /**
  21848. * Create a new VectorMergerBlock
  21849. * @param name defines the block name
  21850. */
  21851. constructor(name: string);
  21852. /**
  21853. * Gets the current class name
  21854. * @returns the class name
  21855. */
  21856. getClassName(): string;
  21857. /**
  21858. * Gets the xyz component (input)
  21859. */
  21860. get xyzIn(): NodeMaterialConnectionPoint;
  21861. /**
  21862. * Gets the xy component (input)
  21863. */
  21864. get xyIn(): NodeMaterialConnectionPoint;
  21865. /**
  21866. * Gets the x component (input)
  21867. */
  21868. get x(): NodeMaterialConnectionPoint;
  21869. /**
  21870. * Gets the y component (input)
  21871. */
  21872. get y(): NodeMaterialConnectionPoint;
  21873. /**
  21874. * Gets the z component (input)
  21875. */
  21876. get z(): NodeMaterialConnectionPoint;
  21877. /**
  21878. * Gets the w component (input)
  21879. */
  21880. get w(): NodeMaterialConnectionPoint;
  21881. /**
  21882. * Gets the xyzw component (output)
  21883. */
  21884. get xyzw(): NodeMaterialConnectionPoint;
  21885. /**
  21886. * Gets the xyz component (output)
  21887. */
  21888. get xyzOut(): NodeMaterialConnectionPoint;
  21889. /**
  21890. * Gets the xy component (output)
  21891. */
  21892. get xyOut(): NodeMaterialConnectionPoint;
  21893. /**
  21894. * Gets the xy component (output)
  21895. * @deprecated Please use xyOut instead.
  21896. */
  21897. get xy(): NodeMaterialConnectionPoint;
  21898. /**
  21899. * Gets the xyz component (output)
  21900. * @deprecated Please use xyzOut instead.
  21901. */
  21902. get xyz(): NodeMaterialConnectionPoint;
  21903. protected _buildBlock(state: NodeMaterialBuildState): this;
  21904. }
  21905. }
  21906. declare module BABYLON {
  21907. /**
  21908. * Block used to remap a float from a range to a new one
  21909. */
  21910. export class RemapBlock extends NodeMaterialBlock {
  21911. /**
  21912. * Gets or sets the source range
  21913. */
  21914. sourceRange: Vector2;
  21915. /**
  21916. * Gets or sets the target range
  21917. */
  21918. targetRange: Vector2;
  21919. /**
  21920. * Creates a new RemapBlock
  21921. * @param name defines the block name
  21922. */
  21923. constructor(name: string);
  21924. /**
  21925. * Gets the current class name
  21926. * @returns the class name
  21927. */
  21928. getClassName(): string;
  21929. /**
  21930. * Gets the input component
  21931. */
  21932. get input(): NodeMaterialConnectionPoint;
  21933. /**
  21934. * Gets the source min input component
  21935. */
  21936. get sourceMin(): NodeMaterialConnectionPoint;
  21937. /**
  21938. * Gets the source max input component
  21939. */
  21940. get sourceMax(): NodeMaterialConnectionPoint;
  21941. /**
  21942. * Gets the target min input component
  21943. */
  21944. get targetMin(): NodeMaterialConnectionPoint;
  21945. /**
  21946. * Gets the target max input component
  21947. */
  21948. get targetMax(): NodeMaterialConnectionPoint;
  21949. /**
  21950. * Gets the output component
  21951. */
  21952. get output(): NodeMaterialConnectionPoint;
  21953. protected _buildBlock(state: NodeMaterialBuildState): this;
  21954. protected _dumpPropertiesCode(): string;
  21955. serialize(): any;
  21956. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21957. }
  21958. }
  21959. declare module BABYLON {
  21960. /**
  21961. * Block used to multiply 2 values
  21962. */
  21963. export class MultiplyBlock extends NodeMaterialBlock {
  21964. /**
  21965. * Creates a new MultiplyBlock
  21966. * @param name defines the block name
  21967. */
  21968. constructor(name: string);
  21969. /**
  21970. * Gets the current class name
  21971. * @returns the class name
  21972. */
  21973. getClassName(): string;
  21974. /**
  21975. * Gets the left operand input component
  21976. */
  21977. get left(): NodeMaterialConnectionPoint;
  21978. /**
  21979. * Gets the right operand input component
  21980. */
  21981. get right(): NodeMaterialConnectionPoint;
  21982. /**
  21983. * Gets the output component
  21984. */
  21985. get output(): NodeMaterialConnectionPoint;
  21986. protected _buildBlock(state: NodeMaterialBuildState): this;
  21987. }
  21988. }
  21989. declare module BABYLON {
  21990. /**
  21991. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  21992. */
  21993. export class ColorSplitterBlock extends NodeMaterialBlock {
  21994. /**
  21995. * Create a new ColorSplitterBlock
  21996. * @param name defines the block name
  21997. */
  21998. constructor(name: string);
  21999. /**
  22000. * Gets the current class name
  22001. * @returns the class name
  22002. */
  22003. getClassName(): string;
  22004. /**
  22005. * Gets the rgba component (input)
  22006. */
  22007. get rgba(): NodeMaterialConnectionPoint;
  22008. /**
  22009. * Gets the rgb component (input)
  22010. */
  22011. get rgbIn(): NodeMaterialConnectionPoint;
  22012. /**
  22013. * Gets the rgb component (output)
  22014. */
  22015. get rgbOut(): NodeMaterialConnectionPoint;
  22016. /**
  22017. * Gets the r component (output)
  22018. */
  22019. get r(): NodeMaterialConnectionPoint;
  22020. /**
  22021. * Gets the g component (output)
  22022. */
  22023. get g(): NodeMaterialConnectionPoint;
  22024. /**
  22025. * Gets the b component (output)
  22026. */
  22027. get b(): NodeMaterialConnectionPoint;
  22028. /**
  22029. * Gets the a component (output)
  22030. */
  22031. get a(): NodeMaterialConnectionPoint;
  22032. protected _inputRename(name: string): string;
  22033. protected _outputRename(name: string): string;
  22034. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22035. }
  22036. }
  22037. declare module BABYLON {
  22038. /**
  22039. * Interface used to configure the node material editor
  22040. */
  22041. export interface INodeMaterialEditorOptions {
  22042. /** Define the URl to load node editor script */
  22043. editorURL?: string;
  22044. }
  22045. /** @hidden */
  22046. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22047. NORMAL: boolean;
  22048. TANGENT: boolean;
  22049. UV1: boolean;
  22050. /** BONES */
  22051. NUM_BONE_INFLUENCERS: number;
  22052. BonesPerMesh: number;
  22053. BONETEXTURE: boolean;
  22054. /** MORPH TARGETS */
  22055. MORPHTARGETS: boolean;
  22056. MORPHTARGETS_NORMAL: boolean;
  22057. MORPHTARGETS_TANGENT: boolean;
  22058. MORPHTARGETS_UV: boolean;
  22059. NUM_MORPH_INFLUENCERS: number;
  22060. /** IMAGE PROCESSING */
  22061. IMAGEPROCESSING: boolean;
  22062. VIGNETTE: boolean;
  22063. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22064. VIGNETTEBLENDMODEOPAQUE: boolean;
  22065. TONEMAPPING: boolean;
  22066. TONEMAPPING_ACES: boolean;
  22067. CONTRAST: boolean;
  22068. EXPOSURE: boolean;
  22069. COLORCURVES: boolean;
  22070. COLORGRADING: boolean;
  22071. COLORGRADING3D: boolean;
  22072. SAMPLER3DGREENDEPTH: boolean;
  22073. SAMPLER3DBGRMAP: boolean;
  22074. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22075. /** MISC. */
  22076. BUMPDIRECTUV: number;
  22077. constructor();
  22078. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22079. }
  22080. /**
  22081. * Class used to configure NodeMaterial
  22082. */
  22083. export interface INodeMaterialOptions {
  22084. /**
  22085. * Defines if blocks should emit comments
  22086. */
  22087. emitComments: boolean;
  22088. }
  22089. /**
  22090. * Class used to create a node based material built by assembling shader blocks
  22091. */
  22092. export class NodeMaterial extends PushMaterial {
  22093. private static _BuildIdGenerator;
  22094. private _options;
  22095. private _vertexCompilationState;
  22096. private _fragmentCompilationState;
  22097. private _sharedData;
  22098. private _buildId;
  22099. private _buildWasSuccessful;
  22100. private _cachedWorldViewMatrix;
  22101. private _cachedWorldViewProjectionMatrix;
  22102. private _optimizers;
  22103. private _animationFrame;
  22104. /** Define the Url to load node editor script */
  22105. static EditorURL: string;
  22106. /** Define the Url to load snippets */
  22107. static SnippetUrl: string;
  22108. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22109. static IgnoreTexturesAtLoadTime: boolean;
  22110. private BJSNODEMATERIALEDITOR;
  22111. /** Get the inspector from bundle or global */
  22112. private _getGlobalNodeMaterialEditor;
  22113. /**
  22114. * Snippet ID if the material was created from the snippet server
  22115. */
  22116. snippetId: string;
  22117. /**
  22118. * Gets or sets data used by visual editor
  22119. * @see https://nme.babylonjs.com
  22120. */
  22121. editorData: any;
  22122. /**
  22123. * 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)
  22124. */
  22125. ignoreAlpha: boolean;
  22126. /**
  22127. * Defines the maximum number of lights that can be used in the material
  22128. */
  22129. maxSimultaneousLights: number;
  22130. /**
  22131. * Observable raised when the material is built
  22132. */
  22133. onBuildObservable: Observable<NodeMaterial>;
  22134. /**
  22135. * Gets or sets the root nodes of the material vertex shader
  22136. */
  22137. _vertexOutputNodes: NodeMaterialBlock[];
  22138. /**
  22139. * Gets or sets the root nodes of the material fragment (pixel) shader
  22140. */
  22141. _fragmentOutputNodes: NodeMaterialBlock[];
  22142. /** Gets or sets options to control the node material overall behavior */
  22143. get options(): INodeMaterialOptions;
  22144. set options(options: INodeMaterialOptions);
  22145. /**
  22146. * Default configuration related to image processing available in the standard Material.
  22147. */
  22148. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22149. /**
  22150. * Gets the image processing configuration used either in this material.
  22151. */
  22152. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22153. /**
  22154. * Sets the Default image processing configuration used either in the this material.
  22155. *
  22156. * If sets to null, the scene one is in use.
  22157. */
  22158. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22159. /**
  22160. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22161. */
  22162. attachedBlocks: NodeMaterialBlock[];
  22163. /**
  22164. * Specifies the mode of the node material
  22165. * @hidden
  22166. */
  22167. _mode: NodeMaterialModes;
  22168. /**
  22169. * Gets the mode property
  22170. */
  22171. get mode(): NodeMaterialModes;
  22172. /**
  22173. * Create a new node based material
  22174. * @param name defines the material name
  22175. * @param scene defines the hosting scene
  22176. * @param options defines creation option
  22177. */
  22178. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22179. /**
  22180. * Gets the current class name of the material e.g. "NodeMaterial"
  22181. * @returns the class name
  22182. */
  22183. getClassName(): string;
  22184. /**
  22185. * Keep track of the image processing observer to allow dispose and replace.
  22186. */
  22187. private _imageProcessingObserver;
  22188. /**
  22189. * Attaches a new image processing configuration to the Standard Material.
  22190. * @param configuration
  22191. */
  22192. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22193. /**
  22194. * Get a block by its name
  22195. * @param name defines the name of the block to retrieve
  22196. * @returns the required block or null if not found
  22197. */
  22198. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22199. /**
  22200. * Get a block by its name
  22201. * @param predicate defines the predicate used to find the good candidate
  22202. * @returns the required block or null if not found
  22203. */
  22204. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22205. /**
  22206. * Get an input block by its name
  22207. * @param predicate defines the predicate used to find the good candidate
  22208. * @returns the required input block or null if not found
  22209. */
  22210. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22211. /**
  22212. * Gets the list of input blocks attached to this material
  22213. * @returns an array of InputBlocks
  22214. */
  22215. getInputBlocks(): InputBlock[];
  22216. /**
  22217. * Adds a new optimizer to the list of optimizers
  22218. * @param optimizer defines the optimizers to add
  22219. * @returns the current material
  22220. */
  22221. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22222. /**
  22223. * Remove an optimizer from the list of optimizers
  22224. * @param optimizer defines the optimizers to remove
  22225. * @returns the current material
  22226. */
  22227. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22228. /**
  22229. * Add a new block to the list of output nodes
  22230. * @param node defines the node to add
  22231. * @returns the current material
  22232. */
  22233. addOutputNode(node: NodeMaterialBlock): this;
  22234. /**
  22235. * Remove a block from the list of root nodes
  22236. * @param node defines the node to remove
  22237. * @returns the current material
  22238. */
  22239. removeOutputNode(node: NodeMaterialBlock): this;
  22240. private _addVertexOutputNode;
  22241. private _removeVertexOutputNode;
  22242. private _addFragmentOutputNode;
  22243. private _removeFragmentOutputNode;
  22244. /**
  22245. * Specifies if the material will require alpha blending
  22246. * @returns a boolean specifying if alpha blending is needed
  22247. */
  22248. needAlphaBlending(): boolean;
  22249. /**
  22250. * Specifies if this material should be rendered in alpha test mode
  22251. * @returns a boolean specifying if an alpha test is needed.
  22252. */
  22253. needAlphaTesting(): boolean;
  22254. private _initializeBlock;
  22255. private _resetDualBlocks;
  22256. /**
  22257. * Remove a block from the current node material
  22258. * @param block defines the block to remove
  22259. */
  22260. removeBlock(block: NodeMaterialBlock): void;
  22261. /**
  22262. * Build the material and generates the inner effect
  22263. * @param verbose defines if the build should log activity
  22264. */
  22265. build(verbose?: boolean): void;
  22266. /**
  22267. * Runs an otpimization phase to try to improve the shader code
  22268. */
  22269. optimize(): void;
  22270. private _prepareDefinesForAttributes;
  22271. /**
  22272. * Create a post process from the material
  22273. * @param camera The camera to apply the render pass to.
  22274. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22275. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22276. * @param engine The engine which the post process will be applied. (default: current engine)
  22277. * @param reusable If the post process can be reused on the same frame. (default: false)
  22278. * @param textureType Type of textures used when performing the post process. (default: 0)
  22279. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22280. * @returns the post process created
  22281. */
  22282. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22283. /**
  22284. * Create the post process effect from the material
  22285. * @param postProcess The post process to create the effect for
  22286. */
  22287. createEffectForPostProcess(postProcess: PostProcess): void;
  22288. private _createEffectOrPostProcess;
  22289. private _createEffectForParticles;
  22290. /**
  22291. * Create the effect to be used as the custom effect for a particle system
  22292. * @param particleSystem Particle system to create the effect for
  22293. * @param onCompiled defines a function to call when the effect creation is successful
  22294. * @param onError defines a function to call when the effect creation has failed
  22295. */
  22296. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22297. private _processDefines;
  22298. /**
  22299. * Get if the submesh is ready to be used and all its information available.
  22300. * Child classes can use it to update shaders
  22301. * @param mesh defines the mesh to check
  22302. * @param subMesh defines which submesh to check
  22303. * @param useInstances specifies that instances should be used
  22304. * @returns a boolean indicating that the submesh is ready or not
  22305. */
  22306. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22307. /**
  22308. * Get a string representing the shaders built by the current node graph
  22309. */
  22310. get compiledShaders(): string;
  22311. /**
  22312. * Binds the world matrix to the material
  22313. * @param world defines the world transformation matrix
  22314. */
  22315. bindOnlyWorldMatrix(world: Matrix): void;
  22316. /**
  22317. * Binds the submesh to this material by preparing the effect and shader to draw
  22318. * @param world defines the world transformation matrix
  22319. * @param mesh defines the mesh containing the submesh
  22320. * @param subMesh defines the submesh to bind the material to
  22321. */
  22322. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22323. /**
  22324. * Gets the active textures from the material
  22325. * @returns an array of textures
  22326. */
  22327. getActiveTextures(): BaseTexture[];
  22328. /**
  22329. * Gets the list of texture blocks
  22330. * @returns an array of texture blocks
  22331. */
  22332. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22333. /**
  22334. * Specifies if the material uses a texture
  22335. * @param texture defines the texture to check against the material
  22336. * @returns a boolean specifying if the material uses the texture
  22337. */
  22338. hasTexture(texture: BaseTexture): boolean;
  22339. /**
  22340. * Disposes the material
  22341. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22342. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22343. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22344. */
  22345. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22346. /** Creates the node editor window. */
  22347. private _createNodeEditor;
  22348. /**
  22349. * Launch the node material editor
  22350. * @param config Define the configuration of the editor
  22351. * @return a promise fulfilled when the node editor is visible
  22352. */
  22353. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22354. /**
  22355. * Clear the current material
  22356. */
  22357. clear(): void;
  22358. /**
  22359. * Clear the current material and set it to a default state
  22360. */
  22361. setToDefault(): void;
  22362. /**
  22363. * Clear the current material and set it to a default state for post process
  22364. */
  22365. setToDefaultPostProcess(): void;
  22366. /**
  22367. * Clear the current material and set it to a default state for particle
  22368. */
  22369. setToDefaultParticle(): void;
  22370. /**
  22371. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22372. * @param url defines the url to load from
  22373. * @returns a promise that will fullfil when the material is fully loaded
  22374. */
  22375. loadAsync(url: string): Promise<void>;
  22376. private _gatherBlocks;
  22377. /**
  22378. * Generate a string containing the code declaration required to create an equivalent of this material
  22379. * @returns a string
  22380. */
  22381. generateCode(): string;
  22382. /**
  22383. * Serializes this material in a JSON representation
  22384. * @returns the serialized material object
  22385. */
  22386. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22387. private _restoreConnections;
  22388. /**
  22389. * Clear the current graph and load a new one from a serialization object
  22390. * @param source defines the JSON representation of the material
  22391. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22392. * @param merge defines whether or not the source must be merged or replace the current content
  22393. */
  22394. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  22395. /**
  22396. * Makes a duplicate of the current material.
  22397. * @param name - name to use for the new material.
  22398. */
  22399. clone(name: string): NodeMaterial;
  22400. /**
  22401. * Creates a node material from parsed material data
  22402. * @param source defines the JSON representation of the material
  22403. * @param scene defines the hosting scene
  22404. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22405. * @returns a new node material
  22406. */
  22407. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22408. /**
  22409. * Creates a node material from a snippet saved in a remote file
  22410. * @param name defines the name of the material to create
  22411. * @param url defines the url to load from
  22412. * @param scene defines the hosting scene
  22413. * @returns a promise that will resolve to the new node material
  22414. */
  22415. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22416. /**
  22417. * Creates a node material from a snippet saved by the node material editor
  22418. * @param snippetId defines the snippet to load
  22419. * @param scene defines the hosting scene
  22420. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22421. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22422. * @returns a promise that will resolve to the new node material
  22423. */
  22424. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22425. /**
  22426. * Creates a new node material set to default basic configuration
  22427. * @param name defines the name of the material
  22428. * @param scene defines the hosting scene
  22429. * @returns a new NodeMaterial
  22430. */
  22431. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22432. }
  22433. }
  22434. declare module BABYLON {
  22435. /**
  22436. * Size options for a post process
  22437. */
  22438. export type PostProcessOptions = {
  22439. width: number;
  22440. height: number;
  22441. };
  22442. /**
  22443. * PostProcess can be used to apply a shader to a texture after it has been rendered
  22444. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  22445. */
  22446. export class PostProcess {
  22447. /** Name of the PostProcess. */
  22448. name: string;
  22449. /**
  22450. * Gets or sets the unique id of the post process
  22451. */
  22452. uniqueId: number;
  22453. /**
  22454. * Width of the texture to apply the post process on
  22455. */
  22456. width: number;
  22457. /**
  22458. * Height of the texture to apply the post process on
  22459. */
  22460. height: number;
  22461. /**
  22462. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  22463. */
  22464. nodeMaterialSource: Nullable<NodeMaterial>;
  22465. /**
  22466. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  22467. * @hidden
  22468. */
  22469. _outputTexture: Nullable<InternalTexture>;
  22470. /**
  22471. * Sampling mode used by the shader
  22472. * See https://doc.babylonjs.com/classes/3.1/texture
  22473. */
  22474. renderTargetSamplingMode: number;
  22475. /**
  22476. * Clear color to use when screen clearing
  22477. */
  22478. clearColor: Color4;
  22479. /**
  22480. * If the buffer needs to be cleared before applying the post process. (default: true)
  22481. * Should be set to false if shader will overwrite all previous pixels.
  22482. */
  22483. autoClear: boolean;
  22484. /**
  22485. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  22486. */
  22487. alphaMode: number;
  22488. /**
  22489. * Sets the setAlphaBlendConstants of the babylon engine
  22490. */
  22491. alphaConstants: Color4;
  22492. /**
  22493. * Animations to be used for the post processing
  22494. */
  22495. animations: Animation[];
  22496. /**
  22497. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  22498. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  22499. */
  22500. enablePixelPerfectMode: boolean;
  22501. /**
  22502. * Force the postprocess to be applied without taking in account viewport
  22503. */
  22504. forceFullscreenViewport: boolean;
  22505. /**
  22506. * List of inspectable custom properties (used by the Inspector)
  22507. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22508. */
  22509. inspectableCustomProperties: IInspectable[];
  22510. /**
  22511. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  22512. *
  22513. * | Value | Type | Description |
  22514. * | ----- | ----------------------------------- | ----------- |
  22515. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  22516. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  22517. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  22518. *
  22519. */
  22520. scaleMode: number;
  22521. /**
  22522. * Force textures to be a power of two (default: false)
  22523. */
  22524. alwaysForcePOT: boolean;
  22525. private _samples;
  22526. /**
  22527. * Number of sample textures (default: 1)
  22528. */
  22529. get samples(): number;
  22530. set samples(n: number);
  22531. /**
  22532. * Modify the scale of the post process to be the same as the viewport (default: false)
  22533. */
  22534. adaptScaleToCurrentViewport: boolean;
  22535. private _camera;
  22536. protected _scene: Scene;
  22537. private _engine;
  22538. private _options;
  22539. private _reusable;
  22540. private _textureType;
  22541. private _textureFormat;
  22542. /**
  22543. * Smart array of input and output textures for the post process.
  22544. * @hidden
  22545. */
  22546. _textures: SmartArray<InternalTexture>;
  22547. /**
  22548. * The index in _textures that corresponds to the output texture.
  22549. * @hidden
  22550. */
  22551. _currentRenderTextureInd: number;
  22552. private _effect;
  22553. private _samplers;
  22554. private _fragmentUrl;
  22555. private _vertexUrl;
  22556. private _parameters;
  22557. private _scaleRatio;
  22558. protected _indexParameters: any;
  22559. private _shareOutputWithPostProcess;
  22560. private _texelSize;
  22561. private _forcedOutputTexture;
  22562. /**
  22563. * Returns the fragment url or shader name used in the post process.
  22564. * @returns the fragment url or name in the shader store.
  22565. */
  22566. getEffectName(): string;
  22567. /**
  22568. * An event triggered when the postprocess is activated.
  22569. */
  22570. onActivateObservable: Observable<Camera>;
  22571. private _onActivateObserver;
  22572. /**
  22573. * A function that is added to the onActivateObservable
  22574. */
  22575. set onActivate(callback: Nullable<(camera: Camera) => void>);
  22576. /**
  22577. * An event triggered when the postprocess changes its size.
  22578. */
  22579. onSizeChangedObservable: Observable<PostProcess>;
  22580. private _onSizeChangedObserver;
  22581. /**
  22582. * A function that is added to the onSizeChangedObservable
  22583. */
  22584. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  22585. /**
  22586. * An event triggered when the postprocess applies its effect.
  22587. */
  22588. onApplyObservable: Observable<Effect>;
  22589. private _onApplyObserver;
  22590. /**
  22591. * A function that is added to the onApplyObservable
  22592. */
  22593. set onApply(callback: (effect: Effect) => void);
  22594. /**
  22595. * An event triggered before rendering the postprocess
  22596. */
  22597. onBeforeRenderObservable: Observable<Effect>;
  22598. private _onBeforeRenderObserver;
  22599. /**
  22600. * A function that is added to the onBeforeRenderObservable
  22601. */
  22602. set onBeforeRender(callback: (effect: Effect) => void);
  22603. /**
  22604. * An event triggered after rendering the postprocess
  22605. */
  22606. onAfterRenderObservable: Observable<Effect>;
  22607. private _onAfterRenderObserver;
  22608. /**
  22609. * A function that is added to the onAfterRenderObservable
  22610. */
  22611. set onAfterRender(callback: (efect: Effect) => void);
  22612. /**
  22613. * 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
  22614. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  22615. */
  22616. get inputTexture(): InternalTexture;
  22617. set inputTexture(value: InternalTexture);
  22618. /**
  22619. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  22620. * the only way to unset it is to use this function to restore its internal state
  22621. */
  22622. restoreDefaultInputTexture(): void;
  22623. /**
  22624. * Gets the camera which post process is applied to.
  22625. * @returns The camera the post process is applied to.
  22626. */
  22627. getCamera(): Camera;
  22628. /**
  22629. * Gets the texel size of the postprocess.
  22630. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  22631. */
  22632. get texelSize(): Vector2;
  22633. /**
  22634. * Creates a new instance PostProcess
  22635. * @param name The name of the PostProcess.
  22636. * @param fragmentUrl The url of the fragment shader to be used.
  22637. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  22638. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  22639. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22640. * @param camera The camera to apply the render pass to.
  22641. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22642. * @param engine The engine which the post process will be applied. (default: current engine)
  22643. * @param reusable If the post process can be reused on the same frame. (default: false)
  22644. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  22645. * @param textureType Type of textures used when performing the post process. (default: 0)
  22646. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  22647. * @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
  22648. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  22649. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22650. */
  22651. constructor(
  22652. /** Name of the PostProcess. */
  22653. 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);
  22654. /**
  22655. * Gets a string idenfifying the name of the class
  22656. * @returns "PostProcess" string
  22657. */
  22658. getClassName(): string;
  22659. /**
  22660. * Gets the engine which this post process belongs to.
  22661. * @returns The engine the post process was enabled with.
  22662. */
  22663. getEngine(): Engine;
  22664. /**
  22665. * The effect that is created when initializing the post process.
  22666. * @returns The created effect corresponding the the postprocess.
  22667. */
  22668. getEffect(): Effect;
  22669. /**
  22670. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  22671. * @param postProcess The post process to share the output with.
  22672. * @returns This post process.
  22673. */
  22674. shareOutputWith(postProcess: PostProcess): PostProcess;
  22675. /**
  22676. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  22677. * This should be called if the post process that shares output with this post process is disabled/disposed.
  22678. */
  22679. useOwnOutput(): void;
  22680. /**
  22681. * Updates the effect with the current post process compile time values and recompiles the shader.
  22682. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22683. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22684. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22685. * @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
  22686. * @param onCompiled Called when the shader has been compiled.
  22687. * @param onError Called if there is an error when compiling a shader.
  22688. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  22689. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  22690. */
  22691. 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;
  22692. /**
  22693. * The post process is reusable if it can be used multiple times within one frame.
  22694. * @returns If the post process is reusable
  22695. */
  22696. isReusable(): boolean;
  22697. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  22698. markTextureDirty(): void;
  22699. /**
  22700. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  22701. * 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.
  22702. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  22703. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  22704. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  22705. * @returns The target texture that was bound to be written to.
  22706. */
  22707. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  22708. /**
  22709. * If the post process is supported.
  22710. */
  22711. get isSupported(): boolean;
  22712. /**
  22713. * The aspect ratio of the output texture.
  22714. */
  22715. get aspectRatio(): number;
  22716. /**
  22717. * Get a value indicating if the post-process is ready to be used
  22718. * @returns true if the post-process is ready (shader is compiled)
  22719. */
  22720. isReady(): boolean;
  22721. /**
  22722. * Binds all textures and uniforms to the shader, this will be run on every pass.
  22723. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  22724. */
  22725. apply(): Nullable<Effect>;
  22726. private _disposeTextures;
  22727. /**
  22728. * Disposes the post process.
  22729. * @param camera The camera to dispose the post process on.
  22730. */
  22731. dispose(camera?: Camera): void;
  22732. }
  22733. }
  22734. declare module BABYLON {
  22735. /** @hidden */
  22736. export var kernelBlurVaryingDeclaration: {
  22737. name: string;
  22738. shader: string;
  22739. };
  22740. }
  22741. declare module BABYLON {
  22742. /** @hidden */
  22743. export var kernelBlurFragment: {
  22744. name: string;
  22745. shader: string;
  22746. };
  22747. }
  22748. declare module BABYLON {
  22749. /** @hidden */
  22750. export var kernelBlurFragment2: {
  22751. name: string;
  22752. shader: string;
  22753. };
  22754. }
  22755. declare module BABYLON {
  22756. /** @hidden */
  22757. export var kernelBlurPixelShader: {
  22758. name: string;
  22759. shader: string;
  22760. };
  22761. }
  22762. declare module BABYLON {
  22763. /** @hidden */
  22764. export var kernelBlurVertex: {
  22765. name: string;
  22766. shader: string;
  22767. };
  22768. }
  22769. declare module BABYLON {
  22770. /** @hidden */
  22771. export var kernelBlurVertexShader: {
  22772. name: string;
  22773. shader: string;
  22774. };
  22775. }
  22776. declare module BABYLON {
  22777. /**
  22778. * The Blur Post Process which blurs an image based on a kernel and direction.
  22779. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  22780. */
  22781. export class BlurPostProcess extends PostProcess {
  22782. /** The direction in which to blur the image. */
  22783. direction: Vector2;
  22784. private blockCompilation;
  22785. protected _kernel: number;
  22786. protected _idealKernel: number;
  22787. protected _packedFloat: boolean;
  22788. private _staticDefines;
  22789. /**
  22790. * Sets the length in pixels of the blur sample region
  22791. */
  22792. set kernel(v: number);
  22793. /**
  22794. * Gets the length in pixels of the blur sample region
  22795. */
  22796. get kernel(): number;
  22797. /**
  22798. * Sets wether or not the blur needs to unpack/repack floats
  22799. */
  22800. set packedFloat(v: boolean);
  22801. /**
  22802. * Gets wether or not the blur is unpacking/repacking floats
  22803. */
  22804. get packedFloat(): boolean;
  22805. /**
  22806. * Creates a new instance BlurPostProcess
  22807. * @param name The name of the effect.
  22808. * @param direction The direction in which to blur the image.
  22809. * @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.
  22810. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22811. * @param camera The camera to apply the render pass to.
  22812. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22813. * @param engine The engine which the post process will be applied. (default: current engine)
  22814. * @param reusable If the post process can be reused on the same frame. (default: false)
  22815. * @param textureType Type of textures used when performing the post process. (default: 0)
  22816. * @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)
  22817. */
  22818. constructor(name: string,
  22819. /** The direction in which to blur the image. */
  22820. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  22821. /**
  22822. * Updates the effect with the current post process compile time values and recompiles the shader.
  22823. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  22824. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  22825. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  22826. * @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
  22827. * @param onCompiled Called when the shader has been compiled.
  22828. * @param onError Called if there is an error when compiling a shader.
  22829. */
  22830. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22831. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22832. /**
  22833. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  22834. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  22835. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  22836. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  22837. * The gaps between physical kernels are compensated for in the weighting of the samples
  22838. * @param idealKernel Ideal blur kernel.
  22839. * @return Nearest best kernel.
  22840. */
  22841. protected _nearestBestKernel(idealKernel: number): number;
  22842. /**
  22843. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  22844. * @param x The point on the Gaussian distribution to sample.
  22845. * @return the value of the Gaussian function at x.
  22846. */
  22847. protected _gaussianWeight(x: number): number;
  22848. /**
  22849. * Generates a string that can be used as a floating point number in GLSL.
  22850. * @param x Value to print.
  22851. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  22852. * @return GLSL float string.
  22853. */
  22854. protected _glslFloat(x: number, decimalFigures?: number): string;
  22855. }
  22856. }
  22857. declare module BABYLON {
  22858. /**
  22859. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22860. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22861. * You can then easily use it as a reflectionTexture on a flat surface.
  22862. * In case the surface is not a plane, please consider relying on reflection probes.
  22863. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22864. */
  22865. export class MirrorTexture extends RenderTargetTexture {
  22866. private scene;
  22867. /**
  22868. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  22869. * 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.
  22870. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22871. */
  22872. mirrorPlane: Plane;
  22873. /**
  22874. * Define the blur ratio used to blur the reflection if needed.
  22875. */
  22876. set blurRatio(value: number);
  22877. get blurRatio(): number;
  22878. /**
  22879. * Define the adaptive blur kernel used to blur the reflection if needed.
  22880. * This will autocompute the closest best match for the `blurKernel`
  22881. */
  22882. set adaptiveBlurKernel(value: number);
  22883. /**
  22884. * Define the blur kernel used to blur the reflection if needed.
  22885. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22886. */
  22887. set blurKernel(value: number);
  22888. /**
  22889. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  22890. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22891. */
  22892. set blurKernelX(value: number);
  22893. get blurKernelX(): number;
  22894. /**
  22895. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  22896. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  22897. */
  22898. set blurKernelY(value: number);
  22899. get blurKernelY(): number;
  22900. private _autoComputeBlurKernel;
  22901. protected _onRatioRescale(): void;
  22902. private _updateGammaSpace;
  22903. private _imageProcessingConfigChangeObserver;
  22904. private _transformMatrix;
  22905. private _mirrorMatrix;
  22906. private _savedViewMatrix;
  22907. private _blurX;
  22908. private _blurY;
  22909. private _adaptiveBlurKernel;
  22910. private _blurKernelX;
  22911. private _blurKernelY;
  22912. private _blurRatio;
  22913. /**
  22914. * Instantiates a Mirror Texture.
  22915. * Mirror texture can be used to simulate the view from a mirror in a scene.
  22916. * It will dynamically be rendered every frame to adapt to the camera point of view.
  22917. * You can then easily use it as a reflectionTexture on a flat surface.
  22918. * In case the surface is not a plane, please consider relying on reflection probes.
  22919. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  22920. * @param name
  22921. * @param size
  22922. * @param scene
  22923. * @param generateMipMaps
  22924. * @param type
  22925. * @param samplingMode
  22926. * @param generateDepthBuffer
  22927. */
  22928. constructor(name: string, size: number | {
  22929. width: number;
  22930. height: number;
  22931. } | {
  22932. ratio: number;
  22933. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  22934. private _preparePostProcesses;
  22935. /**
  22936. * Clone the mirror texture.
  22937. * @returns the cloned texture
  22938. */
  22939. clone(): MirrorTexture;
  22940. /**
  22941. * Serialize the texture to a JSON representation you could use in Parse later on
  22942. * @returns the serialized JSON representation
  22943. */
  22944. serialize(): any;
  22945. /**
  22946. * Dispose the texture and release its associated resources.
  22947. */
  22948. dispose(): void;
  22949. }
  22950. }
  22951. declare module BABYLON {
  22952. /**
  22953. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  22954. * @see https://doc.babylonjs.com/babylon101/materials#texture
  22955. */
  22956. export class Texture extends BaseTexture {
  22957. /**
  22958. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  22959. */
  22960. static SerializeBuffers: boolean;
  22961. /** @hidden */
  22962. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  22963. /** @hidden */
  22964. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  22965. /** @hidden */
  22966. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  22967. /** nearest is mag = nearest and min = nearest and mip = linear */
  22968. static readonly NEAREST_SAMPLINGMODE: number;
  22969. /** nearest is mag = nearest and min = nearest and mip = linear */
  22970. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  22971. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22972. static readonly BILINEAR_SAMPLINGMODE: number;
  22973. /** Bilinear is mag = linear and min = linear and mip = nearest */
  22974. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  22975. /** Trilinear is mag = linear and min = linear and mip = linear */
  22976. static readonly TRILINEAR_SAMPLINGMODE: number;
  22977. /** Trilinear is mag = linear and min = linear and mip = linear */
  22978. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  22979. /** mag = nearest and min = nearest and mip = nearest */
  22980. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  22981. /** mag = nearest and min = linear and mip = nearest */
  22982. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  22983. /** mag = nearest and min = linear and mip = linear */
  22984. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  22985. /** mag = nearest and min = linear and mip = none */
  22986. static readonly NEAREST_LINEAR: number;
  22987. /** mag = nearest and min = nearest and mip = none */
  22988. static readonly NEAREST_NEAREST: number;
  22989. /** mag = linear and min = nearest and mip = nearest */
  22990. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  22991. /** mag = linear and min = nearest and mip = linear */
  22992. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  22993. /** mag = linear and min = linear and mip = none */
  22994. static readonly LINEAR_LINEAR: number;
  22995. /** mag = linear and min = nearest and mip = none */
  22996. static readonly LINEAR_NEAREST: number;
  22997. /** Explicit coordinates mode */
  22998. static readonly EXPLICIT_MODE: number;
  22999. /** Spherical coordinates mode */
  23000. static readonly SPHERICAL_MODE: number;
  23001. /** Planar coordinates mode */
  23002. static readonly PLANAR_MODE: number;
  23003. /** Cubic coordinates mode */
  23004. static readonly CUBIC_MODE: number;
  23005. /** Projection coordinates mode */
  23006. static readonly PROJECTION_MODE: number;
  23007. /** Inverse Cubic coordinates mode */
  23008. static readonly SKYBOX_MODE: number;
  23009. /** Inverse Cubic coordinates mode */
  23010. static readonly INVCUBIC_MODE: number;
  23011. /** Equirectangular coordinates mode */
  23012. static readonly EQUIRECTANGULAR_MODE: number;
  23013. /** Equirectangular Fixed coordinates mode */
  23014. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23015. /** Equirectangular Fixed Mirrored coordinates mode */
  23016. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23017. /** Texture is not repeating outside of 0..1 UVs */
  23018. static readonly CLAMP_ADDRESSMODE: number;
  23019. /** Texture is repeating outside of 0..1 UVs */
  23020. static readonly WRAP_ADDRESSMODE: number;
  23021. /** Texture is repeating and mirrored */
  23022. static readonly MIRROR_ADDRESSMODE: number;
  23023. /**
  23024. * 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
  23025. */
  23026. static UseSerializedUrlIfAny: boolean;
  23027. /**
  23028. * Define the url of the texture.
  23029. */
  23030. url: Nullable<string>;
  23031. /**
  23032. * Define an offset on the texture to offset the u coordinates of the UVs
  23033. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23034. */
  23035. uOffset: number;
  23036. /**
  23037. * Define an offset on the texture to offset the v coordinates of the UVs
  23038. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23039. */
  23040. vOffset: number;
  23041. /**
  23042. * Define an offset on the texture to scale the u coordinates of the UVs
  23043. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23044. */
  23045. uScale: number;
  23046. /**
  23047. * Define an offset on the texture to scale the v coordinates of the UVs
  23048. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23049. */
  23050. vScale: number;
  23051. /**
  23052. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23053. * @see https://doc.babylonjs.com/how_to/more_materials
  23054. */
  23055. uAng: number;
  23056. /**
  23057. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23058. * @see https://doc.babylonjs.com/how_to/more_materials
  23059. */
  23060. vAng: number;
  23061. /**
  23062. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23063. * @see https://doc.babylonjs.com/how_to/more_materials
  23064. */
  23065. wAng: number;
  23066. /**
  23067. * Defines the center of rotation (U)
  23068. */
  23069. uRotationCenter: number;
  23070. /**
  23071. * Defines the center of rotation (V)
  23072. */
  23073. vRotationCenter: number;
  23074. /**
  23075. * Defines the center of rotation (W)
  23076. */
  23077. wRotationCenter: number;
  23078. /**
  23079. * Are mip maps generated for this texture or not.
  23080. */
  23081. get noMipmap(): boolean;
  23082. /**
  23083. * List of inspectable custom properties (used by the Inspector)
  23084. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23085. */
  23086. inspectableCustomProperties: Nullable<IInspectable[]>;
  23087. private _noMipmap;
  23088. /** @hidden */
  23089. _invertY: boolean;
  23090. private _rowGenerationMatrix;
  23091. private _cachedTextureMatrix;
  23092. private _projectionModeMatrix;
  23093. private _t0;
  23094. private _t1;
  23095. private _t2;
  23096. private _cachedUOffset;
  23097. private _cachedVOffset;
  23098. private _cachedUScale;
  23099. private _cachedVScale;
  23100. private _cachedUAng;
  23101. private _cachedVAng;
  23102. private _cachedWAng;
  23103. private _cachedProjectionMatrixId;
  23104. private _cachedCoordinatesMode;
  23105. /** @hidden */
  23106. protected _initialSamplingMode: number;
  23107. /** @hidden */
  23108. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23109. private _deleteBuffer;
  23110. protected _format: Nullable<number>;
  23111. private _delayedOnLoad;
  23112. private _delayedOnError;
  23113. private _mimeType?;
  23114. /**
  23115. * Observable triggered once the texture has been loaded.
  23116. */
  23117. onLoadObservable: Observable<Texture>;
  23118. protected _isBlocking: boolean;
  23119. /**
  23120. * Is the texture preventing material to render while loading.
  23121. * If false, a default texture will be used instead of the loading one during the preparation step.
  23122. */
  23123. set isBlocking(value: boolean);
  23124. get isBlocking(): boolean;
  23125. /**
  23126. * Get the current sampling mode associated with the texture.
  23127. */
  23128. get samplingMode(): number;
  23129. /**
  23130. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23131. */
  23132. get invertY(): boolean;
  23133. /**
  23134. * Instantiates a new texture.
  23135. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23136. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23137. * @param url defines the url of the picture to load as a texture
  23138. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23139. * @param noMipmap defines if the texture will require mip maps or not
  23140. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23141. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23142. * @param onLoad defines a callback triggered when the texture has been loaded
  23143. * @param onError defines a callback triggered when an error occurred during the loading session
  23144. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23145. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23146. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23147. * @param mimeType defines an optional mime type information
  23148. */
  23149. 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);
  23150. /**
  23151. * Update the url (and optional buffer) of this texture if url was null during construction.
  23152. * @param url the url of the texture
  23153. * @param buffer the buffer of the texture (defaults to null)
  23154. * @param onLoad callback called when the texture is loaded (defaults to null)
  23155. */
  23156. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23157. /**
  23158. * Finish the loading sequence of a texture flagged as delayed load.
  23159. * @hidden
  23160. */
  23161. delayLoad(): void;
  23162. private _prepareRowForTextureGeneration;
  23163. /**
  23164. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23165. * @returns the transform matrix of the texture.
  23166. */
  23167. getTextureMatrix(uBase?: number): Matrix;
  23168. /**
  23169. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23170. * @returns The reflection texture transform
  23171. */
  23172. getReflectionTextureMatrix(): Matrix;
  23173. /**
  23174. * Clones the texture.
  23175. * @returns the cloned texture
  23176. */
  23177. clone(): Texture;
  23178. /**
  23179. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23180. * @returns The JSON representation of the texture
  23181. */
  23182. serialize(): any;
  23183. /**
  23184. * Get the current class name of the texture useful for serialization or dynamic coding.
  23185. * @returns "Texture"
  23186. */
  23187. getClassName(): string;
  23188. /**
  23189. * Dispose the texture and release its associated resources.
  23190. */
  23191. dispose(): void;
  23192. /**
  23193. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23194. * @param parsedTexture Define the JSON representation of the texture
  23195. * @param scene Define the scene the parsed texture should be instantiated in
  23196. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23197. * @returns The parsed texture if successful
  23198. */
  23199. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23200. /**
  23201. * Creates a texture from its base 64 representation.
  23202. * @param data Define the base64 payload without the data: prefix
  23203. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23204. * @param scene Define the scene the texture should belong to
  23205. * @param noMipmap Forces the texture to not create mip map information if true
  23206. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23207. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23208. * @param onLoad define a callback triggered when the texture has been loaded
  23209. * @param onError define a callback triggered when an error occurred during the loading session
  23210. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23211. * @returns the created texture
  23212. */
  23213. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23214. /**
  23215. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23216. * @param data Define the base64 payload without the data: prefix
  23217. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23218. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23219. * @param scene Define the scene the texture should belong to
  23220. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23221. * @param noMipmap Forces the texture to not create mip map information if true
  23222. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23223. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23224. * @param onLoad define a callback triggered when the texture has been loaded
  23225. * @param onError define a callback triggered when an error occurred during the loading session
  23226. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23227. * @returns the created texture
  23228. */
  23229. 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;
  23230. }
  23231. }
  23232. declare module BABYLON {
  23233. /**
  23234. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23235. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23236. */
  23237. export class PostProcessManager {
  23238. private _scene;
  23239. private _indexBuffer;
  23240. private _vertexBuffers;
  23241. /**
  23242. * Creates a new instance PostProcess
  23243. * @param scene The scene that the post process is associated with.
  23244. */
  23245. constructor(scene: Scene);
  23246. private _prepareBuffers;
  23247. private _buildIndexBuffer;
  23248. /**
  23249. * Rebuilds the vertex buffers of the manager.
  23250. * @hidden
  23251. */
  23252. _rebuild(): void;
  23253. /**
  23254. * Prepares a frame to be run through a post process.
  23255. * @param sourceTexture The input texture to the post procesess. (default: null)
  23256. * @param postProcesses An array of post processes to be run. (default: null)
  23257. * @returns True if the post processes were able to be run.
  23258. * @hidden
  23259. */
  23260. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23261. /**
  23262. * Manually render a set of post processes to a texture.
  23263. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23264. * @param postProcesses An array of post processes to be run.
  23265. * @param targetTexture The target texture to render to.
  23266. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23267. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23268. * @param lodLevel defines which lod of the texture to render to
  23269. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  23270. */
  23271. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  23272. /**
  23273. * Finalize the result of the output of the postprocesses.
  23274. * @param doNotPresent If true the result will not be displayed to the screen.
  23275. * @param targetTexture The target texture to render to.
  23276. * @param faceIndex The index of the face to bind the target texture to.
  23277. * @param postProcesses The array of post processes to render.
  23278. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  23279. * @hidden
  23280. */
  23281. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  23282. /**
  23283. * Disposes of the post process manager.
  23284. */
  23285. dispose(): void;
  23286. }
  23287. }
  23288. declare module BABYLON {
  23289. /**
  23290. * This Helps creating a texture that will be created from a camera in your scene.
  23291. * It is basically a dynamic texture that could be used to create special effects for instance.
  23292. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  23293. */
  23294. export class RenderTargetTexture extends Texture {
  23295. isCube: boolean;
  23296. /**
  23297. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  23298. */
  23299. static readonly REFRESHRATE_RENDER_ONCE: number;
  23300. /**
  23301. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  23302. */
  23303. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  23304. /**
  23305. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  23306. * the central point of your effect and can save a lot of performances.
  23307. */
  23308. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  23309. /**
  23310. * Use this predicate to dynamically define the list of mesh you want to render.
  23311. * If set, the renderList property will be overwritten.
  23312. */
  23313. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  23314. private _renderList;
  23315. /**
  23316. * Use this list to define the list of mesh you want to render.
  23317. */
  23318. get renderList(): Nullable<Array<AbstractMesh>>;
  23319. set renderList(value: Nullable<Array<AbstractMesh>>);
  23320. /**
  23321. * Use this function to overload the renderList array at rendering time.
  23322. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  23323. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  23324. * the cube (if the RTT is a cube, else layerOrFace=0).
  23325. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  23326. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  23327. * hold dummy elements!
  23328. */
  23329. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  23330. private _hookArray;
  23331. /**
  23332. * Define if particles should be rendered in your texture.
  23333. */
  23334. renderParticles: boolean;
  23335. /**
  23336. * Define if sprites should be rendered in your texture.
  23337. */
  23338. renderSprites: boolean;
  23339. /**
  23340. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  23341. */
  23342. coordinatesMode: number;
  23343. /**
  23344. * Define the camera used to render the texture.
  23345. */
  23346. activeCamera: Nullable<Camera>;
  23347. /**
  23348. * Override the mesh isReady function with your own one.
  23349. */
  23350. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  23351. /**
  23352. * Override the render function of the texture with your own one.
  23353. */
  23354. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  23355. /**
  23356. * Define if camera post processes should be use while rendering the texture.
  23357. */
  23358. useCameraPostProcesses: boolean;
  23359. /**
  23360. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  23361. */
  23362. ignoreCameraViewport: boolean;
  23363. private _postProcessManager;
  23364. private _postProcesses;
  23365. private _resizeObserver;
  23366. /**
  23367. * An event triggered when the texture is unbind.
  23368. */
  23369. onBeforeBindObservable: Observable<RenderTargetTexture>;
  23370. /**
  23371. * An event triggered when the texture is unbind.
  23372. */
  23373. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  23374. private _onAfterUnbindObserver;
  23375. /**
  23376. * Set a after unbind callback in the texture.
  23377. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  23378. */
  23379. set onAfterUnbind(callback: () => void);
  23380. /**
  23381. * An event triggered before rendering the texture
  23382. */
  23383. onBeforeRenderObservable: Observable<number>;
  23384. private _onBeforeRenderObserver;
  23385. /**
  23386. * Set a before render callback in the texture.
  23387. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  23388. */
  23389. set onBeforeRender(callback: (faceIndex: number) => void);
  23390. /**
  23391. * An event triggered after rendering the texture
  23392. */
  23393. onAfterRenderObservable: Observable<number>;
  23394. private _onAfterRenderObserver;
  23395. /**
  23396. * Set a after render callback in the texture.
  23397. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  23398. */
  23399. set onAfterRender(callback: (faceIndex: number) => void);
  23400. /**
  23401. * An event triggered after the texture clear
  23402. */
  23403. onClearObservable: Observable<Engine>;
  23404. private _onClearObserver;
  23405. /**
  23406. * Set a clear callback in the texture.
  23407. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  23408. */
  23409. set onClear(callback: (Engine: Engine) => void);
  23410. /**
  23411. * An event triggered when the texture is resized.
  23412. */
  23413. onResizeObservable: Observable<RenderTargetTexture>;
  23414. /**
  23415. * Define the clear color of the Render Target if it should be different from the scene.
  23416. */
  23417. clearColor: Color4;
  23418. protected _size: number | {
  23419. width: number;
  23420. height: number;
  23421. layers?: number;
  23422. };
  23423. protected _initialSizeParameter: number | {
  23424. width: number;
  23425. height: number;
  23426. } | {
  23427. ratio: number;
  23428. };
  23429. protected _sizeRatio: Nullable<number>;
  23430. /** @hidden */
  23431. _generateMipMaps: boolean;
  23432. protected _renderingManager: RenderingManager;
  23433. /** @hidden */
  23434. _waitingRenderList: string[];
  23435. protected _doNotChangeAspectRatio: boolean;
  23436. protected _currentRefreshId: number;
  23437. protected _refreshRate: number;
  23438. protected _textureMatrix: Matrix;
  23439. protected _samples: number;
  23440. protected _renderTargetOptions: RenderTargetCreationOptions;
  23441. /**
  23442. * Gets render target creation options that were used.
  23443. */
  23444. get renderTargetOptions(): RenderTargetCreationOptions;
  23445. protected _onRatioRescale(): void;
  23446. /**
  23447. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  23448. * It must define where the camera used to render the texture is set
  23449. */
  23450. boundingBoxPosition: Vector3;
  23451. private _boundingBoxSize;
  23452. /**
  23453. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  23454. * When defined, the cubemap will switch to local mode
  23455. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  23456. * @example https://www.babylonjs-playground.com/#RNASML
  23457. */
  23458. set boundingBoxSize(value: Vector3);
  23459. get boundingBoxSize(): Vector3;
  23460. /**
  23461. * In case the RTT has been created with a depth texture, get the associated
  23462. * depth texture.
  23463. * Otherwise, return null.
  23464. */
  23465. get depthStencilTexture(): Nullable<InternalTexture>;
  23466. /**
  23467. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  23468. * or used a shadow, depth texture...
  23469. * @param name The friendly name of the texture
  23470. * @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)
  23471. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  23472. * @param generateMipMaps True if mip maps need to be generated after render.
  23473. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  23474. * @param type The type of the buffer in the RTT (int, half float, float...)
  23475. * @param isCube True if a cube texture needs to be created
  23476. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  23477. * @param generateDepthBuffer True to generate a depth buffer
  23478. * @param generateStencilBuffer True to generate a stencil buffer
  23479. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  23480. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  23481. * @param delayAllocation if the texture allocation should be delayed (default: false)
  23482. */
  23483. constructor(name: string, size: number | {
  23484. width: number;
  23485. height: number;
  23486. layers?: number;
  23487. } | {
  23488. ratio: number;
  23489. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  23490. /**
  23491. * Creates a depth stencil texture.
  23492. * This is only available in WebGL 2 or with the depth texture extension available.
  23493. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  23494. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  23495. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  23496. */
  23497. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  23498. private _processSizeParameter;
  23499. /**
  23500. * Define the number of samples to use in case of MSAA.
  23501. * It defaults to one meaning no MSAA has been enabled.
  23502. */
  23503. get samples(): number;
  23504. set samples(value: number);
  23505. /**
  23506. * Resets the refresh counter of the texture and start bak from scratch.
  23507. * Could be useful to regenerate the texture if it is setup to render only once.
  23508. */
  23509. resetRefreshCounter(): void;
  23510. /**
  23511. * Define the refresh rate of the texture or the rendering frequency.
  23512. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  23513. */
  23514. get refreshRate(): number;
  23515. set refreshRate(value: number);
  23516. /**
  23517. * Adds a post process to the render target rendering passes.
  23518. * @param postProcess define the post process to add
  23519. */
  23520. addPostProcess(postProcess: PostProcess): void;
  23521. /**
  23522. * Clear all the post processes attached to the render target
  23523. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  23524. */
  23525. clearPostProcesses(dispose?: boolean): void;
  23526. /**
  23527. * Remove one of the post process from the list of attached post processes to the texture
  23528. * @param postProcess define the post process to remove from the list
  23529. */
  23530. removePostProcess(postProcess: PostProcess): void;
  23531. /** @hidden */
  23532. _shouldRender(): boolean;
  23533. /**
  23534. * Gets the actual render size of the texture.
  23535. * @returns the width of the render size
  23536. */
  23537. getRenderSize(): number;
  23538. /**
  23539. * Gets the actual render width of the texture.
  23540. * @returns the width of the render size
  23541. */
  23542. getRenderWidth(): number;
  23543. /**
  23544. * Gets the actual render height of the texture.
  23545. * @returns the height of the render size
  23546. */
  23547. getRenderHeight(): number;
  23548. /**
  23549. * Gets the actual number of layers of the texture.
  23550. * @returns the number of layers
  23551. */
  23552. getRenderLayers(): number;
  23553. /**
  23554. * Get if the texture can be rescaled or not.
  23555. */
  23556. get canRescale(): boolean;
  23557. /**
  23558. * Resize the texture using a ratio.
  23559. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  23560. */
  23561. scale(ratio: number): void;
  23562. /**
  23563. * Get the texture reflection matrix used to rotate/transform the reflection.
  23564. * @returns the reflection matrix
  23565. */
  23566. getReflectionTextureMatrix(): Matrix;
  23567. /**
  23568. * Resize the texture to a new desired size.
  23569. * Be carrefull as it will recreate all the data in the new texture.
  23570. * @param size Define the new size. It can be:
  23571. * - a number for squared texture,
  23572. * - an object containing { width: number, height: number }
  23573. * - or an object containing a ratio { ratio: number }
  23574. */
  23575. resize(size: number | {
  23576. width: number;
  23577. height: number;
  23578. } | {
  23579. ratio: number;
  23580. }): void;
  23581. private _defaultRenderListPrepared;
  23582. /**
  23583. * Renders all the objects from the render list into the texture.
  23584. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  23585. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  23586. */
  23587. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  23588. private _bestReflectionRenderTargetDimension;
  23589. private _prepareRenderingManager;
  23590. /**
  23591. * @hidden
  23592. * @param faceIndex face index to bind to if this is a cubetexture
  23593. * @param layer defines the index of the texture to bind in the array
  23594. */
  23595. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  23596. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23597. private renderToTarget;
  23598. /**
  23599. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  23600. * This allowed control for front to back rendering or reversly depending of the special needs.
  23601. *
  23602. * @param renderingGroupId The rendering group id corresponding to its index
  23603. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  23604. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  23605. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  23606. */
  23607. 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;
  23608. /**
  23609. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  23610. *
  23611. * @param renderingGroupId The rendering group id corresponding to its index
  23612. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  23613. */
  23614. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  23615. /**
  23616. * Clones the texture.
  23617. * @returns the cloned texture
  23618. */
  23619. clone(): RenderTargetTexture;
  23620. /**
  23621. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23622. * @returns The JSON representation of the texture
  23623. */
  23624. serialize(): any;
  23625. /**
  23626. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  23627. */
  23628. disposeFramebufferObjects(): void;
  23629. /**
  23630. * Dispose the texture and release its associated resources.
  23631. */
  23632. dispose(): void;
  23633. /** @hidden */
  23634. _rebuild(): void;
  23635. /**
  23636. * Clear the info related to rendering groups preventing retention point in material dispose.
  23637. */
  23638. freeRenderingGroups(): void;
  23639. /**
  23640. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  23641. * @returns the view count
  23642. */
  23643. getViewCount(): number;
  23644. }
  23645. }
  23646. declare module BABYLON {
  23647. /**
  23648. * Class used to manipulate GUIDs
  23649. */
  23650. export class GUID {
  23651. /**
  23652. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23653. * Be aware Math.random() could cause collisions, but:
  23654. * "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"
  23655. * @returns a pseudo random id
  23656. */
  23657. static RandomId(): string;
  23658. }
  23659. }
  23660. declare module BABYLON {
  23661. /**
  23662. * Options to be used when creating a shadow depth material
  23663. */
  23664. export interface IIOptionShadowDepthMaterial {
  23665. /** Variables in the vertex shader code that need to have their names remapped.
  23666. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  23667. * "var_name" should be either: worldPos or vNormalW
  23668. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  23669. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  23670. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  23671. */
  23672. remappedVariables?: string[];
  23673. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  23674. standalone?: boolean;
  23675. }
  23676. /**
  23677. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  23678. */
  23679. export class ShadowDepthWrapper {
  23680. private _scene;
  23681. private _options?;
  23682. private _baseMaterial;
  23683. private _onEffectCreatedObserver;
  23684. private _subMeshToEffect;
  23685. private _subMeshToDepthEffect;
  23686. private _meshes;
  23687. /** @hidden */
  23688. _matriceNames: any;
  23689. /** Gets the standalone status of the wrapper */
  23690. get standalone(): boolean;
  23691. /** Gets the base material the wrapper is built upon */
  23692. get baseMaterial(): Material;
  23693. /**
  23694. * Instantiate a new shadow depth wrapper.
  23695. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  23696. * generate the shadow depth map. For more information, please refer to the documentation:
  23697. * https://doc.babylonjs.com/babylon101/shadows
  23698. * @param baseMaterial Material to wrap
  23699. * @param scene Define the scene the material belongs to
  23700. * @param options Options used to create the wrapper
  23701. */
  23702. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  23703. /**
  23704. * Gets the effect to use to generate the depth map
  23705. * @param subMesh subMesh to get the effect for
  23706. * @param shadowGenerator shadow generator to get the effect for
  23707. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  23708. */
  23709. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  23710. /**
  23711. * Specifies that the submesh is ready to be used for depth rendering
  23712. * @param subMesh submesh to check
  23713. * @param defines the list of defines to take into account when checking the effect
  23714. * @param shadowGenerator combined with subMesh, it defines the effect to check
  23715. * @param useInstances specifies that instances should be used
  23716. * @returns a boolean indicating that the submesh is ready or not
  23717. */
  23718. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  23719. /**
  23720. * Disposes the resources
  23721. */
  23722. dispose(): void;
  23723. private _makeEffect;
  23724. }
  23725. }
  23726. declare module BABYLON {
  23727. interface ThinEngine {
  23728. /**
  23729. * Unbind a list of render target textures from the webGL context
  23730. * This is used only when drawBuffer extension or webGL2 are active
  23731. * @param textures defines the render target textures to unbind
  23732. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  23733. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  23734. */
  23735. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  23736. /**
  23737. * Create a multi render target texture
  23738. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  23739. * @param size defines the size of the texture
  23740. * @param options defines the creation options
  23741. * @returns the cube texture as an InternalTexture
  23742. */
  23743. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  23744. /**
  23745. * Update the sample count for a given multiple render target texture
  23746. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  23747. * @param textures defines the textures to update
  23748. * @param samples defines the sample count to set
  23749. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  23750. */
  23751. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  23752. /**
  23753. * Select a subsets of attachments to draw to.
  23754. * @param attachments gl attachments
  23755. */
  23756. bindAttachments(attachments: number[]): void;
  23757. }
  23758. }
  23759. declare module BABYLON {
  23760. /**
  23761. * Creation options of the multi render target texture.
  23762. */
  23763. export interface IMultiRenderTargetOptions {
  23764. /**
  23765. * Define if the texture needs to create mip maps after render.
  23766. */
  23767. generateMipMaps?: boolean;
  23768. /**
  23769. * Define the types of all the draw buffers we want to create
  23770. */
  23771. types?: number[];
  23772. /**
  23773. * Define the sampling modes of all the draw buffers we want to create
  23774. */
  23775. samplingModes?: number[];
  23776. /**
  23777. * Define if a depth buffer is required
  23778. */
  23779. generateDepthBuffer?: boolean;
  23780. /**
  23781. * Define if a stencil buffer is required
  23782. */
  23783. generateStencilBuffer?: boolean;
  23784. /**
  23785. * Define if a depth texture is required instead of a depth buffer
  23786. */
  23787. generateDepthTexture?: boolean;
  23788. /**
  23789. * Define the number of desired draw buffers
  23790. */
  23791. textureCount?: number;
  23792. /**
  23793. * Define if aspect ratio should be adapted to the texture or stay the scene one
  23794. */
  23795. doNotChangeAspectRatio?: boolean;
  23796. /**
  23797. * Define the default type of the buffers we are creating
  23798. */
  23799. defaultType?: number;
  23800. }
  23801. /**
  23802. * A multi render target, like a render target provides the ability to render to a texture.
  23803. * Unlike the render target, it can render to several draw buffers in one draw.
  23804. * This is specially interesting in deferred rendering or for any effects requiring more than
  23805. * just one color from a single pass.
  23806. */
  23807. export class MultiRenderTarget extends RenderTargetTexture {
  23808. private _internalTextures;
  23809. private _textures;
  23810. private _multiRenderTargetOptions;
  23811. private _count;
  23812. /**
  23813. * Get if draw buffers are currently supported by the used hardware and browser.
  23814. */
  23815. get isSupported(): boolean;
  23816. /**
  23817. * Get the list of textures generated by the multi render target.
  23818. */
  23819. get textures(): Texture[];
  23820. /**
  23821. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  23822. */
  23823. get count(): number;
  23824. /**
  23825. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  23826. */
  23827. get depthTexture(): Texture;
  23828. /**
  23829. * Set the wrapping mode on U of all the textures we are rendering to.
  23830. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23831. */
  23832. set wrapU(wrap: number);
  23833. /**
  23834. * Set the wrapping mode on V of all the textures we are rendering to.
  23835. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23836. */
  23837. set wrapV(wrap: number);
  23838. /**
  23839. * Instantiate a new multi render target texture.
  23840. * A multi render target, like a render target provides the ability to render to a texture.
  23841. * Unlike the render target, it can render to several draw buffers in one draw.
  23842. * This is specially interesting in deferred rendering or for any effects requiring more than
  23843. * just one color from a single pass.
  23844. * @param name Define the name of the texture
  23845. * @param size Define the size of the buffers to render to
  23846. * @param count Define the number of target we are rendering into
  23847. * @param scene Define the scene the texture belongs to
  23848. * @param options Define the options used to create the multi render target
  23849. */
  23850. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  23851. /** @hidden */
  23852. _rebuild(): void;
  23853. private _createInternalTextures;
  23854. private _createTextures;
  23855. /**
  23856. * Define the number of samples used if MSAA is enabled.
  23857. */
  23858. get samples(): number;
  23859. set samples(value: number);
  23860. /**
  23861. * Resize all the textures in the multi render target.
  23862. * Be carrefull as it will recreate all the data in the new texture.
  23863. * @param size Define the new size
  23864. */
  23865. resize(size: any): void;
  23866. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23867. /**
  23868. * Dispose the render targets and their associated resources
  23869. */
  23870. dispose(): void;
  23871. /**
  23872. * Release all the underlying texture used as draw buffers.
  23873. */
  23874. releaseInternalTextures(): void;
  23875. }
  23876. }
  23877. declare module BABYLON {
  23878. /** @hidden */
  23879. export var imageProcessingPixelShader: {
  23880. name: string;
  23881. shader: string;
  23882. };
  23883. }
  23884. declare module BABYLON {
  23885. /**
  23886. * ImageProcessingPostProcess
  23887. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  23888. */
  23889. export class ImageProcessingPostProcess extends PostProcess {
  23890. /**
  23891. * Default configuration related to image processing available in the PBR Material.
  23892. */
  23893. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23894. /**
  23895. * Gets the image processing configuration used either in this material.
  23896. */
  23897. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23898. /**
  23899. * Sets the Default image processing configuration used either in the this material.
  23900. *
  23901. * If sets to null, the scene one is in use.
  23902. */
  23903. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23904. /**
  23905. * Keep track of the image processing observer to allow dispose and replace.
  23906. */
  23907. private _imageProcessingObserver;
  23908. /**
  23909. * Attaches a new image processing configuration to the PBR Material.
  23910. * @param configuration
  23911. */
  23912. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  23913. /**
  23914. * If the post process is supported.
  23915. */
  23916. get isSupported(): boolean;
  23917. /**
  23918. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23919. */
  23920. get colorCurves(): Nullable<ColorCurves>;
  23921. /**
  23922. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23923. */
  23924. set colorCurves(value: Nullable<ColorCurves>);
  23925. /**
  23926. * Gets wether the color curves effect is enabled.
  23927. */
  23928. get colorCurvesEnabled(): boolean;
  23929. /**
  23930. * Sets wether the color curves effect is enabled.
  23931. */
  23932. set colorCurvesEnabled(value: boolean);
  23933. /**
  23934. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23935. */
  23936. get colorGradingTexture(): Nullable<BaseTexture>;
  23937. /**
  23938. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23939. */
  23940. set colorGradingTexture(value: Nullable<BaseTexture>);
  23941. /**
  23942. * Gets wether the color grading effect is enabled.
  23943. */
  23944. get colorGradingEnabled(): boolean;
  23945. /**
  23946. * Gets wether the color grading effect is enabled.
  23947. */
  23948. set colorGradingEnabled(value: boolean);
  23949. /**
  23950. * Gets exposure used in the effect.
  23951. */
  23952. get exposure(): number;
  23953. /**
  23954. * Sets exposure used in the effect.
  23955. */
  23956. set exposure(value: number);
  23957. /**
  23958. * Gets wether tonemapping is enabled or not.
  23959. */
  23960. get toneMappingEnabled(): boolean;
  23961. /**
  23962. * Sets wether tonemapping is enabled or not
  23963. */
  23964. set toneMappingEnabled(value: boolean);
  23965. /**
  23966. * Gets the type of tone mapping effect.
  23967. */
  23968. get toneMappingType(): number;
  23969. /**
  23970. * Sets the type of tone mapping effect.
  23971. */
  23972. set toneMappingType(value: number);
  23973. /**
  23974. * Gets contrast used in the effect.
  23975. */
  23976. get contrast(): number;
  23977. /**
  23978. * Sets contrast used in the effect.
  23979. */
  23980. set contrast(value: number);
  23981. /**
  23982. * Gets Vignette stretch size.
  23983. */
  23984. get vignetteStretch(): number;
  23985. /**
  23986. * Sets Vignette stretch size.
  23987. */
  23988. set vignetteStretch(value: number);
  23989. /**
  23990. * Gets Vignette centre X Offset.
  23991. */
  23992. get vignetteCentreX(): number;
  23993. /**
  23994. * Sets Vignette centre X Offset.
  23995. */
  23996. set vignetteCentreX(value: number);
  23997. /**
  23998. * Gets Vignette centre Y Offset.
  23999. */
  24000. get vignetteCentreY(): number;
  24001. /**
  24002. * Sets Vignette centre Y Offset.
  24003. */
  24004. set vignetteCentreY(value: number);
  24005. /**
  24006. * Gets Vignette weight or intensity of the vignette effect.
  24007. */
  24008. get vignetteWeight(): number;
  24009. /**
  24010. * Sets Vignette weight or intensity of the vignette effect.
  24011. */
  24012. set vignetteWeight(value: number);
  24013. /**
  24014. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24015. * if vignetteEnabled is set to true.
  24016. */
  24017. get vignetteColor(): Color4;
  24018. /**
  24019. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24020. * if vignetteEnabled is set to true.
  24021. */
  24022. set vignetteColor(value: Color4);
  24023. /**
  24024. * Gets Camera field of view used by the Vignette effect.
  24025. */
  24026. get vignetteCameraFov(): number;
  24027. /**
  24028. * Sets Camera field of view used by the Vignette effect.
  24029. */
  24030. set vignetteCameraFov(value: number);
  24031. /**
  24032. * Gets the vignette blend mode allowing different kind of effect.
  24033. */
  24034. get vignetteBlendMode(): number;
  24035. /**
  24036. * Sets the vignette blend mode allowing different kind of effect.
  24037. */
  24038. set vignetteBlendMode(value: number);
  24039. /**
  24040. * Gets wether the vignette effect is enabled.
  24041. */
  24042. get vignetteEnabled(): boolean;
  24043. /**
  24044. * Sets wether the vignette effect is enabled.
  24045. */
  24046. set vignetteEnabled(value: boolean);
  24047. private _fromLinearSpace;
  24048. /**
  24049. * Gets wether the input of the processing is in Gamma or Linear Space.
  24050. */
  24051. get fromLinearSpace(): boolean;
  24052. /**
  24053. * Sets wether the input of the processing is in Gamma or Linear Space.
  24054. */
  24055. set fromLinearSpace(value: boolean);
  24056. /**
  24057. * Defines cache preventing GC.
  24058. */
  24059. private _defines;
  24060. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  24061. /**
  24062. * "ImageProcessingPostProcess"
  24063. * @returns "ImageProcessingPostProcess"
  24064. */
  24065. getClassName(): string;
  24066. /**
  24067. * @hidden
  24068. */
  24069. _updateParameters(): void;
  24070. dispose(camera?: Camera): void;
  24071. }
  24072. }
  24073. declare module BABYLON {
  24074. /** @hidden */
  24075. export var fibonacci: {
  24076. name: string;
  24077. shader: string;
  24078. };
  24079. }
  24080. declare module BABYLON {
  24081. /** @hidden */
  24082. export var subSurfaceScatteringFunctions: {
  24083. name: string;
  24084. shader: string;
  24085. };
  24086. }
  24087. declare module BABYLON {
  24088. /** @hidden */
  24089. export var diffusionProfile: {
  24090. name: string;
  24091. shader: string;
  24092. };
  24093. }
  24094. declare module BABYLON {
  24095. /** @hidden */
  24096. export var subSurfaceScatteringPixelShader: {
  24097. name: string;
  24098. shader: string;
  24099. };
  24100. }
  24101. declare module BABYLON {
  24102. /**
  24103. * Sub surface scattering post process
  24104. */
  24105. export class SubSurfaceScatteringPostProcess extends PostProcess {
  24106. /** @hidden */
  24107. texelWidth: number;
  24108. /** @hidden */
  24109. texelHeight: number;
  24110. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  24111. }
  24112. }
  24113. declare module BABYLON {
  24114. /**
  24115. * Interface for defining prepass effects in the prepass post-process pipeline
  24116. */
  24117. export interface PrePassEffectConfiguration {
  24118. /**
  24119. * Post process to attach for this effect
  24120. */
  24121. postProcess: PostProcess;
  24122. /**
  24123. * Is the effect enabled
  24124. */
  24125. enabled: boolean;
  24126. /**
  24127. * Disposes the effect configuration
  24128. */
  24129. dispose(): void;
  24130. /**
  24131. * Disposes the effect configuration
  24132. */
  24133. createPostProcess: () => PostProcess;
  24134. }
  24135. }
  24136. declare module BABYLON {
  24137. /**
  24138. * Contains all parameters needed for the prepass to perform
  24139. * screen space subsurface scattering
  24140. */
  24141. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  24142. private _ssDiffusionS;
  24143. private _ssFilterRadii;
  24144. private _ssDiffusionD;
  24145. /**
  24146. * Post process to attach for screen space subsurface scattering
  24147. */
  24148. postProcess: SubSurfaceScatteringPostProcess;
  24149. /**
  24150. * Diffusion profile color for subsurface scattering
  24151. */
  24152. get ssDiffusionS(): number[];
  24153. /**
  24154. * Diffusion profile max color channel value for subsurface scattering
  24155. */
  24156. get ssDiffusionD(): number[];
  24157. /**
  24158. * Diffusion profile filter radius for subsurface scattering
  24159. */
  24160. get ssFilterRadii(): number[];
  24161. /**
  24162. * Is subsurface enabled
  24163. */
  24164. enabled: boolean;
  24165. /**
  24166. * Diffusion profile colors for subsurface scattering
  24167. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  24168. * See ...
  24169. * Note that you can only store up to 5 of them
  24170. */
  24171. ssDiffusionProfileColors: Color3[];
  24172. /**
  24173. * Defines the ratio real world => scene units.
  24174. * Used for subsurface scattering
  24175. */
  24176. metersPerUnit: number;
  24177. private _scene;
  24178. /**
  24179. * Builds a subsurface configuration object
  24180. * @param scene The scene
  24181. */
  24182. constructor(scene: Scene);
  24183. /**
  24184. * Adds a new diffusion profile.
  24185. * Useful for more realistic subsurface scattering on diverse materials.
  24186. * @param color The color of the diffusion profile. Should be the average color of the material.
  24187. * @return The index of the diffusion profile for the material subsurface configuration
  24188. */
  24189. addDiffusionProfile(color: Color3): number;
  24190. /**
  24191. * Creates the sss post process
  24192. * @return The created post process
  24193. */
  24194. createPostProcess(): SubSurfaceScatteringPostProcess;
  24195. /**
  24196. * Deletes all diffusion profiles.
  24197. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  24198. */
  24199. clearAllDiffusionProfiles(): void;
  24200. /**
  24201. * Disposes this object
  24202. */
  24203. dispose(): void;
  24204. /**
  24205. * @hidden
  24206. * https://zero-radiance.github.io/post/sampling-diffusion/
  24207. *
  24208. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  24209. * ------------------------------------------------------------------------------------
  24210. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  24211. * PDF[r, phi, s] = r * R[r, phi, s]
  24212. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  24213. * ------------------------------------------------------------------------------------
  24214. * We importance sample the color channel with the widest scattering distance.
  24215. */
  24216. getDiffusionProfileParameters(color: Color3): number;
  24217. /**
  24218. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  24219. * 'u' is the random number (the value of the CDF): [0, 1).
  24220. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  24221. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  24222. */
  24223. private _sampleBurleyDiffusionProfile;
  24224. }
  24225. }
  24226. declare module BABYLON {
  24227. /**
  24228. * Renders a pre pass of the scene
  24229. * This means every mesh in the scene will be rendered to a render target texture
  24230. * And then this texture will be composited to the rendering canvas with post processes
  24231. * It is necessary for effects like subsurface scattering or deferred shading
  24232. */
  24233. export class PrePassRenderer {
  24234. /** @hidden */
  24235. static _SceneComponentInitialization: (scene: Scene) => void;
  24236. private _scene;
  24237. private _engine;
  24238. private _isDirty;
  24239. /**
  24240. * Number of textures in the multi render target texture where the scene is directly rendered
  24241. */
  24242. readonly mrtCount: number;
  24243. /**
  24244. * The render target where the scene is directly rendered
  24245. */
  24246. prePassRT: MultiRenderTarget;
  24247. private _mrtTypes;
  24248. private _multiRenderAttachments;
  24249. private _defaultAttachments;
  24250. private _clearAttachments;
  24251. private _postProcesses;
  24252. private readonly _clearColor;
  24253. /**
  24254. * Image processing post process for composition
  24255. */
  24256. imageProcessingPostProcess: ImageProcessingPostProcess;
  24257. /**
  24258. * Configuration for sub surface scattering post process
  24259. */
  24260. subSurfaceConfiguration: SubSurfaceConfiguration;
  24261. /**
  24262. * Should materials render their geometry on the MRT
  24263. */
  24264. materialsShouldRenderGeometry: boolean;
  24265. /**
  24266. * Should materials render the irradiance information on the MRT
  24267. */
  24268. materialsShouldRenderIrradiance: boolean;
  24269. private _enabled;
  24270. /**
  24271. * Indicates if the prepass is enabled
  24272. */
  24273. get enabled(): boolean;
  24274. /**
  24275. * How many samples are used for MSAA of the scene render target
  24276. */
  24277. get samples(): number;
  24278. set samples(n: number);
  24279. /**
  24280. * Instanciates a prepass renderer
  24281. * @param scene The scene
  24282. */
  24283. constructor(scene: Scene);
  24284. private _initializeAttachments;
  24285. private _createCompositionEffect;
  24286. /**
  24287. * Indicates if rendering a prepass is supported
  24288. */
  24289. get isSupported(): boolean;
  24290. /**
  24291. * Sets the proper output textures to draw in the engine.
  24292. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  24293. */
  24294. bindAttachmentsForEffect(effect: Effect): void;
  24295. /**
  24296. * @hidden
  24297. */
  24298. _beforeCameraDraw(): void;
  24299. /**
  24300. * @hidden
  24301. */
  24302. _afterCameraDraw(): void;
  24303. private _checkRTSize;
  24304. private _bindFrameBuffer;
  24305. /**
  24306. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  24307. */
  24308. clear(): void;
  24309. private _setState;
  24310. private _enable;
  24311. private _disable;
  24312. private _resetPostProcessChain;
  24313. private _bindPostProcessChain;
  24314. /**
  24315. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  24316. */
  24317. markAsDirty(): void;
  24318. private _update;
  24319. /**
  24320. * Disposes the prepass renderer.
  24321. */
  24322. dispose(): void;
  24323. }
  24324. }
  24325. declare module BABYLON {
  24326. /**
  24327. * Options for compiling materials.
  24328. */
  24329. export interface IMaterialCompilationOptions {
  24330. /**
  24331. * Defines whether clip planes are enabled.
  24332. */
  24333. clipPlane: boolean;
  24334. /**
  24335. * Defines whether instances are enabled.
  24336. */
  24337. useInstances: boolean;
  24338. }
  24339. /**
  24340. * Options passed when calling customShaderNameResolve
  24341. */
  24342. export interface ICustomShaderNameResolveOptions {
  24343. /**
  24344. * 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
  24345. */
  24346. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  24347. }
  24348. /**
  24349. * Base class for the main features of a material in Babylon.js
  24350. */
  24351. export class Material implements IAnimatable {
  24352. /**
  24353. * Returns the triangle fill mode
  24354. */
  24355. static readonly TriangleFillMode: number;
  24356. /**
  24357. * Returns the wireframe mode
  24358. */
  24359. static readonly WireFrameFillMode: number;
  24360. /**
  24361. * Returns the point fill mode
  24362. */
  24363. static readonly PointFillMode: number;
  24364. /**
  24365. * Returns the point list draw mode
  24366. */
  24367. static readonly PointListDrawMode: number;
  24368. /**
  24369. * Returns the line list draw mode
  24370. */
  24371. static readonly LineListDrawMode: number;
  24372. /**
  24373. * Returns the line loop draw mode
  24374. */
  24375. static readonly LineLoopDrawMode: number;
  24376. /**
  24377. * Returns the line strip draw mode
  24378. */
  24379. static readonly LineStripDrawMode: number;
  24380. /**
  24381. * Returns the triangle strip draw mode
  24382. */
  24383. static readonly TriangleStripDrawMode: number;
  24384. /**
  24385. * Returns the triangle fan draw mode
  24386. */
  24387. static readonly TriangleFanDrawMode: number;
  24388. /**
  24389. * Stores the clock-wise side orientation
  24390. */
  24391. static readonly ClockWiseSideOrientation: number;
  24392. /**
  24393. * Stores the counter clock-wise side orientation
  24394. */
  24395. static readonly CounterClockWiseSideOrientation: number;
  24396. /**
  24397. * The dirty texture flag value
  24398. */
  24399. static readonly TextureDirtyFlag: number;
  24400. /**
  24401. * The dirty light flag value
  24402. */
  24403. static readonly LightDirtyFlag: number;
  24404. /**
  24405. * The dirty fresnel flag value
  24406. */
  24407. static readonly FresnelDirtyFlag: number;
  24408. /**
  24409. * The dirty attribute flag value
  24410. */
  24411. static readonly AttributesDirtyFlag: number;
  24412. /**
  24413. * The dirty misc flag value
  24414. */
  24415. static readonly MiscDirtyFlag: number;
  24416. /**
  24417. * The all dirty flag value
  24418. */
  24419. static readonly AllDirtyFlag: number;
  24420. /**
  24421. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  24422. */
  24423. static readonly MATERIAL_OPAQUE: number;
  24424. /**
  24425. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  24426. */
  24427. static readonly MATERIAL_ALPHATEST: number;
  24428. /**
  24429. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24430. */
  24431. static readonly MATERIAL_ALPHABLEND: number;
  24432. /**
  24433. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24434. * They are also discarded below the alpha cutoff threshold to improve performances.
  24435. */
  24436. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  24437. /**
  24438. * The Whiteout method is used to blend normals.
  24439. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24440. */
  24441. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  24442. /**
  24443. * The Reoriented Normal Mapping method is used to blend normals.
  24444. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24445. */
  24446. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  24447. /**
  24448. * Custom callback helping to override the default shader used in the material.
  24449. */
  24450. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  24451. /**
  24452. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  24453. */
  24454. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  24455. /**
  24456. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  24457. * This means that the material can keep using a previous shader while a new one is being compiled.
  24458. * This is mostly used when shader parallel compilation is supported (true by default)
  24459. */
  24460. allowShaderHotSwapping: boolean;
  24461. /**
  24462. * The ID of the material
  24463. */
  24464. id: string;
  24465. /**
  24466. * Gets or sets the unique id of the material
  24467. */
  24468. uniqueId: number;
  24469. /**
  24470. * The name of the material
  24471. */
  24472. name: string;
  24473. /**
  24474. * Gets or sets user defined metadata
  24475. */
  24476. metadata: any;
  24477. /**
  24478. * For internal use only. Please do not use.
  24479. */
  24480. reservedDataStore: any;
  24481. /**
  24482. * Specifies if the ready state should be checked on each call
  24483. */
  24484. checkReadyOnEveryCall: boolean;
  24485. /**
  24486. * Specifies if the ready state should be checked once
  24487. */
  24488. checkReadyOnlyOnce: boolean;
  24489. /**
  24490. * The state of the material
  24491. */
  24492. state: string;
  24493. /**
  24494. * If the material can be rendered to several textures with MRT extension
  24495. */
  24496. get canRenderToMRT(): boolean;
  24497. /**
  24498. * The alpha value of the material
  24499. */
  24500. protected _alpha: number;
  24501. /**
  24502. * List of inspectable custom properties (used by the Inspector)
  24503. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24504. */
  24505. inspectableCustomProperties: IInspectable[];
  24506. /**
  24507. * Sets the alpha value of the material
  24508. */
  24509. set alpha(value: number);
  24510. /**
  24511. * Gets the alpha value of the material
  24512. */
  24513. get alpha(): number;
  24514. /**
  24515. * Specifies if back face culling is enabled
  24516. */
  24517. protected _backFaceCulling: boolean;
  24518. /**
  24519. * Sets the back-face culling state
  24520. */
  24521. set backFaceCulling(value: boolean);
  24522. /**
  24523. * Gets the back-face culling state
  24524. */
  24525. get backFaceCulling(): boolean;
  24526. /**
  24527. * Stores the value for side orientation
  24528. */
  24529. sideOrientation: number;
  24530. /**
  24531. * Callback triggered when the material is compiled
  24532. */
  24533. onCompiled: Nullable<(effect: Effect) => void>;
  24534. /**
  24535. * Callback triggered when an error occurs
  24536. */
  24537. onError: Nullable<(effect: Effect, errors: string) => void>;
  24538. /**
  24539. * Callback triggered to get the render target textures
  24540. */
  24541. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  24542. /**
  24543. * Gets a boolean indicating that current material needs to register RTT
  24544. */
  24545. get hasRenderTargetTextures(): boolean;
  24546. /**
  24547. * Specifies if the material should be serialized
  24548. */
  24549. doNotSerialize: boolean;
  24550. /**
  24551. * @hidden
  24552. */
  24553. _storeEffectOnSubMeshes: boolean;
  24554. /**
  24555. * Stores the animations for the material
  24556. */
  24557. animations: Nullable<Array<Animation>>;
  24558. /**
  24559. * An event triggered when the material is disposed
  24560. */
  24561. onDisposeObservable: Observable<Material>;
  24562. /**
  24563. * An observer which watches for dispose events
  24564. */
  24565. private _onDisposeObserver;
  24566. private _onUnBindObservable;
  24567. /**
  24568. * Called during a dispose event
  24569. */
  24570. set onDispose(callback: () => void);
  24571. private _onBindObservable;
  24572. /**
  24573. * An event triggered when the material is bound
  24574. */
  24575. get onBindObservable(): Observable<AbstractMesh>;
  24576. /**
  24577. * An observer which watches for bind events
  24578. */
  24579. private _onBindObserver;
  24580. /**
  24581. * Called during a bind event
  24582. */
  24583. set onBind(callback: (Mesh: AbstractMesh) => void);
  24584. /**
  24585. * An event triggered when the material is unbound
  24586. */
  24587. get onUnBindObservable(): Observable<Material>;
  24588. protected _onEffectCreatedObservable: Nullable<Observable<{
  24589. effect: Effect;
  24590. subMesh: Nullable<SubMesh>;
  24591. }>>;
  24592. /**
  24593. * An event triggered when the effect is (re)created
  24594. */
  24595. get onEffectCreatedObservable(): Observable<{
  24596. effect: Effect;
  24597. subMesh: Nullable<SubMesh>;
  24598. }>;
  24599. /**
  24600. * Stores the value of the alpha mode
  24601. */
  24602. private _alphaMode;
  24603. /**
  24604. * Sets the value of the alpha mode.
  24605. *
  24606. * | Value | Type | Description |
  24607. * | --- | --- | --- |
  24608. * | 0 | ALPHA_DISABLE | |
  24609. * | 1 | ALPHA_ADD | |
  24610. * | 2 | ALPHA_COMBINE | |
  24611. * | 3 | ALPHA_SUBTRACT | |
  24612. * | 4 | ALPHA_MULTIPLY | |
  24613. * | 5 | ALPHA_MAXIMIZED | |
  24614. * | 6 | ALPHA_ONEONE | |
  24615. * | 7 | ALPHA_PREMULTIPLIED | |
  24616. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  24617. * | 9 | ALPHA_INTERPOLATE | |
  24618. * | 10 | ALPHA_SCREENMODE | |
  24619. *
  24620. */
  24621. set alphaMode(value: number);
  24622. /**
  24623. * Gets the value of the alpha mode
  24624. */
  24625. get alphaMode(): number;
  24626. /**
  24627. * Stores the state of the need depth pre-pass value
  24628. */
  24629. private _needDepthPrePass;
  24630. /**
  24631. * Sets the need depth pre-pass value
  24632. */
  24633. set needDepthPrePass(value: boolean);
  24634. /**
  24635. * Gets the depth pre-pass value
  24636. */
  24637. get needDepthPrePass(): boolean;
  24638. /**
  24639. * Specifies if depth writing should be disabled
  24640. */
  24641. disableDepthWrite: boolean;
  24642. /**
  24643. * Specifies if color writing should be disabled
  24644. */
  24645. disableColorWrite: boolean;
  24646. /**
  24647. * Specifies if depth writing should be forced
  24648. */
  24649. forceDepthWrite: boolean;
  24650. /**
  24651. * Specifies the depth function that should be used. 0 means the default engine function
  24652. */
  24653. depthFunction: number;
  24654. /**
  24655. * Specifies if there should be a separate pass for culling
  24656. */
  24657. separateCullingPass: boolean;
  24658. /**
  24659. * Stores the state specifing if fog should be enabled
  24660. */
  24661. private _fogEnabled;
  24662. /**
  24663. * Sets the state for enabling fog
  24664. */
  24665. set fogEnabled(value: boolean);
  24666. /**
  24667. * Gets the value of the fog enabled state
  24668. */
  24669. get fogEnabled(): boolean;
  24670. /**
  24671. * Stores the size of points
  24672. */
  24673. pointSize: number;
  24674. /**
  24675. * Stores the z offset value
  24676. */
  24677. zOffset: number;
  24678. get wireframe(): boolean;
  24679. /**
  24680. * Sets the state of wireframe mode
  24681. */
  24682. set wireframe(value: boolean);
  24683. /**
  24684. * Gets the value specifying if point clouds are enabled
  24685. */
  24686. get pointsCloud(): boolean;
  24687. /**
  24688. * Sets the state of point cloud mode
  24689. */
  24690. set pointsCloud(value: boolean);
  24691. /**
  24692. * Gets the material fill mode
  24693. */
  24694. get fillMode(): number;
  24695. /**
  24696. * Sets the material fill mode
  24697. */
  24698. set fillMode(value: number);
  24699. /**
  24700. * @hidden
  24701. * Stores the effects for the material
  24702. */
  24703. _effect: Nullable<Effect>;
  24704. /**
  24705. * Specifies if uniform buffers should be used
  24706. */
  24707. private _useUBO;
  24708. /**
  24709. * Stores a reference to the scene
  24710. */
  24711. private _scene;
  24712. /**
  24713. * Stores the fill mode state
  24714. */
  24715. private _fillMode;
  24716. /**
  24717. * Specifies if the depth write state should be cached
  24718. */
  24719. private _cachedDepthWriteState;
  24720. /**
  24721. * Specifies if the color write state should be cached
  24722. */
  24723. private _cachedColorWriteState;
  24724. /**
  24725. * Specifies if the depth function state should be cached
  24726. */
  24727. private _cachedDepthFunctionState;
  24728. /**
  24729. * Stores the uniform buffer
  24730. */
  24731. protected _uniformBuffer: UniformBuffer;
  24732. /** @hidden */
  24733. _indexInSceneMaterialArray: number;
  24734. /** @hidden */
  24735. meshMap: Nullable<{
  24736. [id: string]: AbstractMesh | undefined;
  24737. }>;
  24738. /**
  24739. * Creates a material instance
  24740. * @param name defines the name of the material
  24741. * @param scene defines the scene to reference
  24742. * @param doNotAdd specifies if the material should be added to the scene
  24743. */
  24744. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24745. /**
  24746. * Returns a string representation of the current material
  24747. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24748. * @returns a string with material information
  24749. */
  24750. toString(fullDetails?: boolean): string;
  24751. /**
  24752. * Gets the class name of the material
  24753. * @returns a string with the class name of the material
  24754. */
  24755. getClassName(): string;
  24756. /**
  24757. * Specifies if updates for the material been locked
  24758. */
  24759. get isFrozen(): boolean;
  24760. /**
  24761. * Locks updates for the material
  24762. */
  24763. freeze(): void;
  24764. /**
  24765. * Unlocks updates for the material
  24766. */
  24767. unfreeze(): void;
  24768. /**
  24769. * Specifies if the material is ready to be used
  24770. * @param mesh defines the mesh to check
  24771. * @param useInstances specifies if instances should be used
  24772. * @returns a boolean indicating if the material is ready to be used
  24773. */
  24774. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24775. /**
  24776. * Specifies that the submesh is ready to be used
  24777. * @param mesh defines the mesh to check
  24778. * @param subMesh defines which submesh to check
  24779. * @param useInstances specifies that instances should be used
  24780. * @returns a boolean indicating that the submesh is ready or not
  24781. */
  24782. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24783. /**
  24784. * Returns the material effect
  24785. * @returns the effect associated with the material
  24786. */
  24787. getEffect(): Nullable<Effect>;
  24788. /**
  24789. * Returns the current scene
  24790. * @returns a Scene
  24791. */
  24792. getScene(): Scene;
  24793. /**
  24794. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24795. */
  24796. protected _forceAlphaTest: boolean;
  24797. /**
  24798. * The transparency mode of the material.
  24799. */
  24800. protected _transparencyMode: Nullable<number>;
  24801. /**
  24802. * Gets the current transparency mode.
  24803. */
  24804. get transparencyMode(): Nullable<number>;
  24805. /**
  24806. * Sets the transparency mode of the material.
  24807. *
  24808. * | Value | Type | Description |
  24809. * | ----- | ----------------------------------- | ----------- |
  24810. * | 0 | OPAQUE | |
  24811. * | 1 | ALPHATEST | |
  24812. * | 2 | ALPHABLEND | |
  24813. * | 3 | ALPHATESTANDBLEND | |
  24814. *
  24815. */
  24816. set transparencyMode(value: Nullable<number>);
  24817. /**
  24818. * Returns true if alpha blending should be disabled.
  24819. */
  24820. protected get _disableAlphaBlending(): boolean;
  24821. /**
  24822. * Specifies whether or not this material should be rendered in alpha blend mode.
  24823. * @returns a boolean specifying if alpha blending is needed
  24824. */
  24825. needAlphaBlending(): boolean;
  24826. /**
  24827. * Specifies if the mesh will require alpha blending
  24828. * @param mesh defines the mesh to check
  24829. * @returns a boolean specifying if alpha blending is needed for the mesh
  24830. */
  24831. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  24832. /**
  24833. * Specifies whether or not this material should be rendered in alpha test mode.
  24834. * @returns a boolean specifying if an alpha test is needed.
  24835. */
  24836. needAlphaTesting(): boolean;
  24837. /**
  24838. * Specifies if material alpha testing should be turned on for the mesh
  24839. * @param mesh defines the mesh to check
  24840. */
  24841. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  24842. /**
  24843. * Gets the texture used for the alpha test
  24844. * @returns the texture to use for alpha testing
  24845. */
  24846. getAlphaTestTexture(): Nullable<BaseTexture>;
  24847. /**
  24848. * Marks the material to indicate that it needs to be re-calculated
  24849. */
  24850. markDirty(): void;
  24851. /** @hidden */
  24852. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  24853. /**
  24854. * Binds the material to the mesh
  24855. * @param world defines the world transformation matrix
  24856. * @param mesh defines the mesh to bind the material to
  24857. */
  24858. bind(world: Matrix, mesh?: Mesh): void;
  24859. /**
  24860. * Binds the submesh to the material
  24861. * @param world defines the world transformation matrix
  24862. * @param mesh defines the mesh containing the submesh
  24863. * @param subMesh defines the submesh to bind the material to
  24864. */
  24865. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24866. /**
  24867. * Binds the world matrix to the material
  24868. * @param world defines the world transformation matrix
  24869. */
  24870. bindOnlyWorldMatrix(world: Matrix): void;
  24871. /**
  24872. * Binds the scene's uniform buffer to the effect.
  24873. * @param effect defines the effect to bind to the scene uniform buffer
  24874. * @param sceneUbo defines the uniform buffer storing scene data
  24875. */
  24876. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  24877. /**
  24878. * Binds the view matrix to the effect
  24879. * @param effect defines the effect to bind the view matrix to
  24880. */
  24881. bindView(effect: Effect): void;
  24882. /**
  24883. * Binds the view projection matrix to the effect
  24884. * @param effect defines the effect to bind the view projection matrix to
  24885. */
  24886. bindViewProjection(effect: Effect): void;
  24887. /**
  24888. * Processes to execute after binding the material to a mesh
  24889. * @param mesh defines the rendered mesh
  24890. */
  24891. protected _afterBind(mesh?: Mesh): void;
  24892. /**
  24893. * Unbinds the material from the mesh
  24894. */
  24895. unbind(): void;
  24896. /**
  24897. * Gets the active textures from the material
  24898. * @returns an array of textures
  24899. */
  24900. getActiveTextures(): BaseTexture[];
  24901. /**
  24902. * Specifies if the material uses a texture
  24903. * @param texture defines the texture to check against the material
  24904. * @returns a boolean specifying if the material uses the texture
  24905. */
  24906. hasTexture(texture: BaseTexture): boolean;
  24907. /**
  24908. * Makes a duplicate of the material, and gives it a new name
  24909. * @param name defines the new name for the duplicated material
  24910. * @returns the cloned material
  24911. */
  24912. clone(name: string): Nullable<Material>;
  24913. /**
  24914. * Gets the meshes bound to the material
  24915. * @returns an array of meshes bound to the material
  24916. */
  24917. getBindedMeshes(): AbstractMesh[];
  24918. /**
  24919. * Force shader compilation
  24920. * @param mesh defines the mesh associated with this material
  24921. * @param onCompiled defines a function to execute once the material is compiled
  24922. * @param options defines the options to configure the compilation
  24923. * @param onError defines a function to execute if the material fails compiling
  24924. */
  24925. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  24926. /**
  24927. * Force shader compilation
  24928. * @param mesh defines the mesh that will use this material
  24929. * @param options defines additional options for compiling the shaders
  24930. * @returns a promise that resolves when the compilation completes
  24931. */
  24932. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  24933. private static readonly _AllDirtyCallBack;
  24934. private static readonly _ImageProcessingDirtyCallBack;
  24935. private static readonly _TextureDirtyCallBack;
  24936. private static readonly _FresnelDirtyCallBack;
  24937. private static readonly _MiscDirtyCallBack;
  24938. private static readonly _LightsDirtyCallBack;
  24939. private static readonly _AttributeDirtyCallBack;
  24940. private static _FresnelAndMiscDirtyCallBack;
  24941. private static _TextureAndMiscDirtyCallBack;
  24942. private static readonly _DirtyCallbackArray;
  24943. private static readonly _RunDirtyCallBacks;
  24944. /**
  24945. * Marks a define in the material to indicate that it needs to be re-computed
  24946. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  24947. */
  24948. markAsDirty(flag: number): void;
  24949. /**
  24950. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  24951. * @param func defines a function which checks material defines against the submeshes
  24952. */
  24953. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  24954. /**
  24955. * Indicates that the scene should check if the rendering now needs a prepass
  24956. */
  24957. protected _markScenePrePassDirty(): void;
  24958. /**
  24959. * Indicates that we need to re-calculated for all submeshes
  24960. */
  24961. protected _markAllSubMeshesAsAllDirty(): void;
  24962. /**
  24963. * Indicates that image processing needs to be re-calculated for all submeshes
  24964. */
  24965. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  24966. /**
  24967. * Indicates that textures need to be re-calculated for all submeshes
  24968. */
  24969. protected _markAllSubMeshesAsTexturesDirty(): void;
  24970. /**
  24971. * Indicates that fresnel needs to be re-calculated for all submeshes
  24972. */
  24973. protected _markAllSubMeshesAsFresnelDirty(): void;
  24974. /**
  24975. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  24976. */
  24977. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  24978. /**
  24979. * Indicates that lights need to be re-calculated for all submeshes
  24980. */
  24981. protected _markAllSubMeshesAsLightsDirty(): void;
  24982. /**
  24983. * Indicates that attributes need to be re-calculated for all submeshes
  24984. */
  24985. protected _markAllSubMeshesAsAttributesDirty(): void;
  24986. /**
  24987. * Indicates that misc needs to be re-calculated for all submeshes
  24988. */
  24989. protected _markAllSubMeshesAsMiscDirty(): void;
  24990. /**
  24991. * Indicates that textures and misc need to be re-calculated for all submeshes
  24992. */
  24993. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  24994. /**
  24995. * Sets the required values to the prepass renderer.
  24996. * @param prePassRenderer defines the prepass renderer to setup.
  24997. * @returns true if the pre pass is needed.
  24998. */
  24999. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  25000. /**
  25001. * Disposes the material
  25002. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25003. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25004. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  25005. */
  25006. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  25007. /** @hidden */
  25008. private releaseVertexArrayObject;
  25009. /**
  25010. * Serializes this material
  25011. * @returns the serialized material object
  25012. */
  25013. serialize(): any;
  25014. /**
  25015. * Creates a material from parsed material data
  25016. * @param parsedMaterial defines parsed material data
  25017. * @param scene defines the hosting scene
  25018. * @param rootUrl defines the root URL to use to load textures
  25019. * @returns a new material
  25020. */
  25021. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  25022. }
  25023. }
  25024. declare module BABYLON {
  25025. /**
  25026. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25027. * separate meshes. This can be use to improve performances.
  25028. * @see https://doc.babylonjs.com/how_to/multi_materials
  25029. */
  25030. export class MultiMaterial extends Material {
  25031. private _subMaterials;
  25032. /**
  25033. * Gets or Sets the list of Materials used within the multi material.
  25034. * They need to be ordered according to the submeshes order in the associated mesh
  25035. */
  25036. get subMaterials(): Nullable<Material>[];
  25037. set subMaterials(value: Nullable<Material>[]);
  25038. /**
  25039. * Function used to align with Node.getChildren()
  25040. * @returns the list of Materials used within the multi material
  25041. */
  25042. getChildren(): Nullable<Material>[];
  25043. /**
  25044. * Instantiates a new Multi Material
  25045. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25046. * separate meshes. This can be use to improve performances.
  25047. * @see https://doc.babylonjs.com/how_to/multi_materials
  25048. * @param name Define the name in the scene
  25049. * @param scene Define the scene the material belongs to
  25050. */
  25051. constructor(name: string, scene: Scene);
  25052. private _hookArray;
  25053. /**
  25054. * Get one of the submaterial by its index in the submaterials array
  25055. * @param index The index to look the sub material at
  25056. * @returns The Material if the index has been defined
  25057. */
  25058. getSubMaterial(index: number): Nullable<Material>;
  25059. /**
  25060. * Get the list of active textures for the whole sub materials list.
  25061. * @returns All the textures that will be used during the rendering
  25062. */
  25063. getActiveTextures(): BaseTexture[];
  25064. /**
  25065. * Gets the current class name of the material e.g. "MultiMaterial"
  25066. * Mainly use in serialization.
  25067. * @returns the class name
  25068. */
  25069. getClassName(): string;
  25070. /**
  25071. * Checks if the material is ready to render the requested sub mesh
  25072. * @param mesh Define the mesh the submesh belongs to
  25073. * @param subMesh Define the sub mesh to look readyness for
  25074. * @param useInstances Define whether or not the material is used with instances
  25075. * @returns true if ready, otherwise false
  25076. */
  25077. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25078. /**
  25079. * Clones the current material and its related sub materials
  25080. * @param name Define the name of the newly cloned material
  25081. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  25082. * @returns the cloned material
  25083. */
  25084. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  25085. /**
  25086. * Serializes the materials into a JSON representation.
  25087. * @returns the JSON representation
  25088. */
  25089. serialize(): any;
  25090. /**
  25091. * Dispose the material and release its associated resources
  25092. * @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)
  25093. * @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)
  25094. * @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)
  25095. */
  25096. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  25097. /**
  25098. * Creates a MultiMaterial from parsed MultiMaterial data.
  25099. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  25100. * @param scene defines the hosting scene
  25101. * @returns a new MultiMaterial
  25102. */
  25103. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  25104. }
  25105. }
  25106. declare module BABYLON {
  25107. /**
  25108. * Defines a subdivision inside a mesh
  25109. */
  25110. export class SubMesh implements ICullable {
  25111. /** the material index to use */
  25112. materialIndex: number;
  25113. /** vertex index start */
  25114. verticesStart: number;
  25115. /** vertices count */
  25116. verticesCount: number;
  25117. /** index start */
  25118. indexStart: number;
  25119. /** indices count */
  25120. indexCount: number;
  25121. /** @hidden */
  25122. _materialDefines: Nullable<MaterialDefines>;
  25123. /** @hidden */
  25124. _materialEffect: Nullable<Effect>;
  25125. /** @hidden */
  25126. _effectOverride: Nullable<Effect>;
  25127. /**
  25128. * Gets material defines used by the effect associated to the sub mesh
  25129. */
  25130. get materialDefines(): Nullable<MaterialDefines>;
  25131. /**
  25132. * Sets material defines used by the effect associated to the sub mesh
  25133. */
  25134. set materialDefines(defines: Nullable<MaterialDefines>);
  25135. /**
  25136. * Gets associated effect
  25137. */
  25138. get effect(): Nullable<Effect>;
  25139. /**
  25140. * Sets associated effect (effect used to render this submesh)
  25141. * @param effect defines the effect to associate with
  25142. * @param defines defines the set of defines used to compile this effect
  25143. */
  25144. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  25145. /** @hidden */
  25146. _linesIndexCount: number;
  25147. private _mesh;
  25148. private _renderingMesh;
  25149. private _boundingInfo;
  25150. private _linesIndexBuffer;
  25151. /** @hidden */
  25152. _lastColliderWorldVertices: Nullable<Vector3[]>;
  25153. /** @hidden */
  25154. _trianglePlanes: Plane[];
  25155. /** @hidden */
  25156. _lastColliderTransformMatrix: Nullable<Matrix>;
  25157. /** @hidden */
  25158. _renderId: number;
  25159. /** @hidden */
  25160. _alphaIndex: number;
  25161. /** @hidden */
  25162. _distanceToCamera: number;
  25163. /** @hidden */
  25164. _id: number;
  25165. private _currentMaterial;
  25166. /**
  25167. * Add a new submesh to a mesh
  25168. * @param materialIndex defines the material index to use
  25169. * @param verticesStart defines vertex index start
  25170. * @param verticesCount defines vertices count
  25171. * @param indexStart defines index start
  25172. * @param indexCount defines indices count
  25173. * @param mesh defines the parent mesh
  25174. * @param renderingMesh defines an optional rendering mesh
  25175. * @param createBoundingBox defines if bounding box should be created for this submesh
  25176. * @returns the new submesh
  25177. */
  25178. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  25179. /**
  25180. * Creates a new submesh
  25181. * @param materialIndex defines the material index to use
  25182. * @param verticesStart defines vertex index start
  25183. * @param verticesCount defines vertices count
  25184. * @param indexStart defines index start
  25185. * @param indexCount defines indices count
  25186. * @param mesh defines the parent mesh
  25187. * @param renderingMesh defines an optional rendering mesh
  25188. * @param createBoundingBox defines if bounding box should be created for this submesh
  25189. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  25190. */
  25191. constructor(
  25192. /** the material index to use */
  25193. materialIndex: number,
  25194. /** vertex index start */
  25195. verticesStart: number,
  25196. /** vertices count */
  25197. verticesCount: number,
  25198. /** index start */
  25199. indexStart: number,
  25200. /** indices count */
  25201. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  25202. /**
  25203. * Returns true if this submesh covers the entire parent mesh
  25204. * @ignorenaming
  25205. */
  25206. get IsGlobal(): boolean;
  25207. /**
  25208. * Returns the submesh BoudingInfo object
  25209. * @returns current bounding info (or mesh's one if the submesh is global)
  25210. */
  25211. getBoundingInfo(): BoundingInfo;
  25212. /**
  25213. * Sets the submesh BoundingInfo
  25214. * @param boundingInfo defines the new bounding info to use
  25215. * @returns the SubMesh
  25216. */
  25217. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  25218. /**
  25219. * Returns the mesh of the current submesh
  25220. * @return the parent mesh
  25221. */
  25222. getMesh(): AbstractMesh;
  25223. /**
  25224. * Returns the rendering mesh of the submesh
  25225. * @returns the rendering mesh (could be different from parent mesh)
  25226. */
  25227. getRenderingMesh(): Mesh;
  25228. /**
  25229. * Returns the replacement mesh of the submesh
  25230. * @returns the replacement mesh (could be different from parent mesh)
  25231. */
  25232. getReplacementMesh(): Nullable<AbstractMesh>;
  25233. /**
  25234. * Returns the effective mesh of the submesh
  25235. * @returns the effective mesh (could be different from parent mesh)
  25236. */
  25237. getEffectiveMesh(): AbstractMesh;
  25238. /**
  25239. * Returns the submesh material
  25240. * @returns null or the current material
  25241. */
  25242. getMaterial(): Nullable<Material>;
  25243. private _IsMultiMaterial;
  25244. /**
  25245. * Sets a new updated BoundingInfo object to the submesh
  25246. * @param data defines an optional position array to use to determine the bounding info
  25247. * @returns the SubMesh
  25248. */
  25249. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  25250. /** @hidden */
  25251. _checkCollision(collider: Collider): boolean;
  25252. /**
  25253. * Updates the submesh BoundingInfo
  25254. * @param world defines the world matrix to use to update the bounding info
  25255. * @returns the submesh
  25256. */
  25257. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  25258. /**
  25259. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  25260. * @param frustumPlanes defines the frustum planes
  25261. * @returns true if the submesh is intersecting with the frustum
  25262. */
  25263. isInFrustum(frustumPlanes: Plane[]): boolean;
  25264. /**
  25265. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  25266. * @param frustumPlanes defines the frustum planes
  25267. * @returns true if the submesh is inside the frustum
  25268. */
  25269. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25270. /**
  25271. * Renders the submesh
  25272. * @param enableAlphaMode defines if alpha needs to be used
  25273. * @returns the submesh
  25274. */
  25275. render(enableAlphaMode: boolean): SubMesh;
  25276. /**
  25277. * @hidden
  25278. */
  25279. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  25280. /**
  25281. * Checks if the submesh intersects with a ray
  25282. * @param ray defines the ray to test
  25283. * @returns true is the passed ray intersects the submesh bounding box
  25284. */
  25285. canIntersects(ray: Ray): boolean;
  25286. /**
  25287. * Intersects current submesh with a ray
  25288. * @param ray defines the ray to test
  25289. * @param positions defines mesh's positions array
  25290. * @param indices defines mesh's indices array
  25291. * @param fastCheck defines if the first intersection will be used (and not the closest)
  25292. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25293. * @returns intersection info or null if no intersection
  25294. */
  25295. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  25296. /** @hidden */
  25297. private _intersectLines;
  25298. /** @hidden */
  25299. private _intersectUnIndexedLines;
  25300. /** @hidden */
  25301. private _intersectTriangles;
  25302. /** @hidden */
  25303. private _intersectUnIndexedTriangles;
  25304. /** @hidden */
  25305. _rebuild(): void;
  25306. /**
  25307. * Creates a new submesh from the passed mesh
  25308. * @param newMesh defines the new hosting mesh
  25309. * @param newRenderingMesh defines an optional rendering mesh
  25310. * @returns the new submesh
  25311. */
  25312. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  25313. /**
  25314. * Release associated resources
  25315. */
  25316. dispose(): void;
  25317. /**
  25318. * Gets the class name
  25319. * @returns the string "SubMesh".
  25320. */
  25321. getClassName(): string;
  25322. /**
  25323. * Creates a new submesh from indices data
  25324. * @param materialIndex the index of the main mesh material
  25325. * @param startIndex the index where to start the copy in the mesh indices array
  25326. * @param indexCount the number of indices to copy then from the startIndex
  25327. * @param mesh the main mesh to create the submesh from
  25328. * @param renderingMesh the optional rendering mesh
  25329. * @returns a new submesh
  25330. */
  25331. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  25332. }
  25333. }
  25334. declare module BABYLON {
  25335. /**
  25336. * Class used to represent data loading progression
  25337. */
  25338. export class SceneLoaderFlags {
  25339. private static _ForceFullSceneLoadingForIncremental;
  25340. private static _ShowLoadingScreen;
  25341. private static _CleanBoneMatrixWeights;
  25342. private static _loggingLevel;
  25343. /**
  25344. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  25345. */
  25346. static get ForceFullSceneLoadingForIncremental(): boolean;
  25347. static set ForceFullSceneLoadingForIncremental(value: boolean);
  25348. /**
  25349. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  25350. */
  25351. static get ShowLoadingScreen(): boolean;
  25352. static set ShowLoadingScreen(value: boolean);
  25353. /**
  25354. * Defines the current logging level (while loading the scene)
  25355. * @ignorenaming
  25356. */
  25357. static get loggingLevel(): number;
  25358. static set loggingLevel(value: number);
  25359. /**
  25360. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  25361. */
  25362. static get CleanBoneMatrixWeights(): boolean;
  25363. static set CleanBoneMatrixWeights(value: boolean);
  25364. }
  25365. }
  25366. declare module BABYLON {
  25367. /**
  25368. * Class used to store geometry data (vertex buffers + index buffer)
  25369. */
  25370. export class Geometry implements IGetSetVerticesData {
  25371. /**
  25372. * Gets or sets the ID of the geometry
  25373. */
  25374. id: string;
  25375. /**
  25376. * Gets or sets the unique ID of the geometry
  25377. */
  25378. uniqueId: number;
  25379. /**
  25380. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25381. */
  25382. delayLoadState: number;
  25383. /**
  25384. * Gets the file containing the data to load when running in delay load state
  25385. */
  25386. delayLoadingFile: Nullable<string>;
  25387. /**
  25388. * Callback called when the geometry is updated
  25389. */
  25390. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25391. private _scene;
  25392. private _engine;
  25393. private _meshes;
  25394. private _totalVertices;
  25395. /** @hidden */
  25396. _indices: IndicesArray;
  25397. /** @hidden */
  25398. _vertexBuffers: {
  25399. [key: string]: VertexBuffer;
  25400. };
  25401. private _isDisposed;
  25402. private _extend;
  25403. private _boundingBias;
  25404. /** @hidden */
  25405. _delayInfo: Array<string>;
  25406. private _indexBuffer;
  25407. private _indexBufferIsUpdatable;
  25408. /** @hidden */
  25409. _boundingInfo: Nullable<BoundingInfo>;
  25410. /** @hidden */
  25411. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25412. /** @hidden */
  25413. _softwareSkinningFrameId: number;
  25414. private _vertexArrayObjects;
  25415. private _updatable;
  25416. /** @hidden */
  25417. _positions: Nullable<Vector3[]>;
  25418. /**
  25419. * 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
  25420. */
  25421. get boundingBias(): Vector2;
  25422. /**
  25423. * 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
  25424. */
  25425. set boundingBias(value: Vector2);
  25426. /**
  25427. * Static function used to attach a new empty geometry to a mesh
  25428. * @param mesh defines the mesh to attach the geometry to
  25429. * @returns the new Geometry
  25430. */
  25431. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25432. /** Get the list of meshes using this geometry */
  25433. get meshes(): Mesh[];
  25434. /**
  25435. * 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
  25436. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  25437. */
  25438. useBoundingInfoFromGeometry: boolean;
  25439. /**
  25440. * Creates a new geometry
  25441. * @param id defines the unique ID
  25442. * @param scene defines the hosting scene
  25443. * @param vertexData defines the VertexData used to get geometry data
  25444. * @param updatable defines if geometry must be updatable (false by default)
  25445. * @param mesh defines the mesh that will be associated with the geometry
  25446. */
  25447. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25448. /**
  25449. * Gets the current extend of the geometry
  25450. */
  25451. get extend(): {
  25452. minimum: Vector3;
  25453. maximum: Vector3;
  25454. };
  25455. /**
  25456. * Gets the hosting scene
  25457. * @returns the hosting Scene
  25458. */
  25459. getScene(): Scene;
  25460. /**
  25461. * Gets the hosting engine
  25462. * @returns the hosting Engine
  25463. */
  25464. getEngine(): Engine;
  25465. /**
  25466. * Defines if the geometry is ready to use
  25467. * @returns true if the geometry is ready to be used
  25468. */
  25469. isReady(): boolean;
  25470. /**
  25471. * Gets a value indicating that the geometry should not be serialized
  25472. */
  25473. get doNotSerialize(): boolean;
  25474. /** @hidden */
  25475. _rebuild(): void;
  25476. /**
  25477. * Affects all geometry data in one call
  25478. * @param vertexData defines the geometry data
  25479. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25480. */
  25481. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25482. /**
  25483. * Set specific vertex data
  25484. * @param kind defines the data kind (Position, normal, etc...)
  25485. * @param data defines the vertex data to use
  25486. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25487. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25488. */
  25489. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25490. /**
  25491. * Removes a specific vertex data
  25492. * @param kind defines the data kind (Position, normal, etc...)
  25493. */
  25494. removeVerticesData(kind: string): void;
  25495. /**
  25496. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25497. * @param buffer defines the vertex buffer to use
  25498. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25499. */
  25500. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25501. /**
  25502. * Update a specific vertex buffer
  25503. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  25504. * It will do nothing if the buffer is not updatable
  25505. * @param kind defines the data kind (Position, normal, etc...)
  25506. * @param data defines the data to use
  25507. * @param offset defines the offset in the target buffer where to store the data
  25508. * @param useBytes set to true if the offset is in bytes
  25509. */
  25510. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25511. /**
  25512. * Update a specific vertex buffer
  25513. * This function will create a new buffer if the current one is not updatable
  25514. * @param kind defines the data kind (Position, normal, etc...)
  25515. * @param data defines the data to use
  25516. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25517. */
  25518. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25519. private _updateBoundingInfo;
  25520. /** @hidden */
  25521. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  25522. /**
  25523. * Gets total number of vertices
  25524. * @returns the total number of vertices
  25525. */
  25526. getTotalVertices(): number;
  25527. /**
  25528. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25529. * @param kind defines the data kind (Position, normal, etc...)
  25530. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25531. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25532. * @returns a float array containing vertex data
  25533. */
  25534. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25535. /**
  25536. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25537. * @param kind defines the data kind (Position, normal, etc...)
  25538. * @returns true if the vertex buffer with the specified kind is updatable
  25539. */
  25540. isVertexBufferUpdatable(kind: string): boolean;
  25541. /**
  25542. * Gets a specific vertex buffer
  25543. * @param kind defines the data kind (Position, normal, etc...)
  25544. * @returns a VertexBuffer
  25545. */
  25546. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25547. /**
  25548. * Returns all vertex buffers
  25549. * @return an object holding all vertex buffers indexed by kind
  25550. */
  25551. getVertexBuffers(): Nullable<{
  25552. [key: string]: VertexBuffer;
  25553. }>;
  25554. /**
  25555. * Gets a boolean indicating if specific vertex buffer is present
  25556. * @param kind defines the data kind (Position, normal, etc...)
  25557. * @returns true if data is present
  25558. */
  25559. isVerticesDataPresent(kind: string): boolean;
  25560. /**
  25561. * Gets a list of all attached data kinds (Position, normal, etc...)
  25562. * @returns a list of string containing all kinds
  25563. */
  25564. getVerticesDataKinds(): string[];
  25565. /**
  25566. * Update index buffer
  25567. * @param indices defines the indices to store in the index buffer
  25568. * @param offset defines the offset in the target buffer where to store the data
  25569. * @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)
  25570. */
  25571. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  25572. /**
  25573. * Creates a new index buffer
  25574. * @param indices defines the indices to store in the index buffer
  25575. * @param totalVertices defines the total number of vertices (could be null)
  25576. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25577. */
  25578. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25579. /**
  25580. * Return the total number of indices
  25581. * @returns the total number of indices
  25582. */
  25583. getTotalIndices(): number;
  25584. /**
  25585. * Gets the index buffer array
  25586. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25587. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25588. * @returns the index buffer array
  25589. */
  25590. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25591. /**
  25592. * Gets the index buffer
  25593. * @return the index buffer
  25594. */
  25595. getIndexBuffer(): Nullable<DataBuffer>;
  25596. /** @hidden */
  25597. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25598. /**
  25599. * Release the associated resources for a specific mesh
  25600. * @param mesh defines the source mesh
  25601. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25602. */
  25603. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25604. /**
  25605. * Apply current geometry to a given mesh
  25606. * @param mesh defines the mesh to apply geometry to
  25607. */
  25608. applyToMesh(mesh: Mesh): void;
  25609. private _updateExtend;
  25610. private _applyToMesh;
  25611. private notifyUpdate;
  25612. /**
  25613. * Load the geometry if it was flagged as delay loaded
  25614. * @param scene defines the hosting scene
  25615. * @param onLoaded defines a callback called when the geometry is loaded
  25616. */
  25617. load(scene: Scene, onLoaded?: () => void): void;
  25618. private _queueLoad;
  25619. /**
  25620. * Invert the geometry to move from a right handed system to a left handed one.
  25621. */
  25622. toLeftHanded(): void;
  25623. /** @hidden */
  25624. _resetPointsArrayCache(): void;
  25625. /** @hidden */
  25626. _generatePointsArray(): boolean;
  25627. /**
  25628. * Gets a value indicating if the geometry is disposed
  25629. * @returns true if the geometry was disposed
  25630. */
  25631. isDisposed(): boolean;
  25632. private _disposeVertexArrayObjects;
  25633. /**
  25634. * Free all associated resources
  25635. */
  25636. dispose(): void;
  25637. /**
  25638. * Clone the current geometry into a new geometry
  25639. * @param id defines the unique ID of the new geometry
  25640. * @returns a new geometry object
  25641. */
  25642. copy(id: string): Geometry;
  25643. /**
  25644. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25645. * @return a JSON representation of the current geometry data (without the vertices data)
  25646. */
  25647. serialize(): any;
  25648. private toNumberArray;
  25649. /**
  25650. * Serialize all vertices data into a JSON oject
  25651. * @returns a JSON representation of the current geometry data
  25652. */
  25653. serializeVerticeData(): any;
  25654. /**
  25655. * Extracts a clone of a mesh geometry
  25656. * @param mesh defines the source mesh
  25657. * @param id defines the unique ID of the new geometry object
  25658. * @returns the new geometry object
  25659. */
  25660. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25661. /**
  25662. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25663. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25664. * Be aware Math.random() could cause collisions, but:
  25665. * "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"
  25666. * @returns a string containing a new GUID
  25667. */
  25668. static RandomId(): string;
  25669. /** @hidden */
  25670. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25671. private static _CleanMatricesWeights;
  25672. /**
  25673. * Create a new geometry from persisted data (Using .babylon file format)
  25674. * @param parsedVertexData defines the persisted data
  25675. * @param scene defines the hosting scene
  25676. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25677. * @returns the new geometry object
  25678. */
  25679. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25680. }
  25681. }
  25682. declare module BABYLON {
  25683. /**
  25684. * Define an interface for all classes that will get and set the data on vertices
  25685. */
  25686. export interface IGetSetVerticesData {
  25687. /**
  25688. * Gets a boolean indicating if specific vertex data is present
  25689. * @param kind defines the vertex data kind to use
  25690. * @returns true is data kind is present
  25691. */
  25692. isVerticesDataPresent(kind: string): boolean;
  25693. /**
  25694. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25695. * @param kind defines the data kind (Position, normal, etc...)
  25696. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25697. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25698. * @returns a float array containing vertex data
  25699. */
  25700. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25701. /**
  25702. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25703. * @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.
  25704. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25705. * @returns the indices array or an empty array if the mesh has no geometry
  25706. */
  25707. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25708. /**
  25709. * Set specific vertex data
  25710. * @param kind defines the data kind (Position, normal, etc...)
  25711. * @param data defines the vertex data to use
  25712. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25713. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25714. */
  25715. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  25716. /**
  25717. * Update a specific associated vertex buffer
  25718. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25719. * - VertexBuffer.PositionKind
  25720. * - VertexBuffer.UVKind
  25721. * - VertexBuffer.UV2Kind
  25722. * - VertexBuffer.UV3Kind
  25723. * - VertexBuffer.UV4Kind
  25724. * - VertexBuffer.UV5Kind
  25725. * - VertexBuffer.UV6Kind
  25726. * - VertexBuffer.ColorKind
  25727. * - VertexBuffer.MatricesIndicesKind
  25728. * - VertexBuffer.MatricesIndicesExtraKind
  25729. * - VertexBuffer.MatricesWeightsKind
  25730. * - VertexBuffer.MatricesWeightsExtraKind
  25731. * @param data defines the data source
  25732. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25733. * @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)
  25734. */
  25735. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  25736. /**
  25737. * Creates a new index buffer
  25738. * @param indices defines the indices to store in the index buffer
  25739. * @param totalVertices defines the total number of vertices (could be null)
  25740. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25741. */
  25742. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25743. }
  25744. /**
  25745. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25746. */
  25747. export class VertexData {
  25748. /**
  25749. * Mesh side orientation : usually the external or front surface
  25750. */
  25751. static readonly FRONTSIDE: number;
  25752. /**
  25753. * Mesh side orientation : usually the internal or back surface
  25754. */
  25755. static readonly BACKSIDE: number;
  25756. /**
  25757. * Mesh side orientation : both internal and external or front and back surfaces
  25758. */
  25759. static readonly DOUBLESIDE: number;
  25760. /**
  25761. * Mesh side orientation : by default, `FRONTSIDE`
  25762. */
  25763. static readonly DEFAULTSIDE: number;
  25764. /**
  25765. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25766. */
  25767. positions: Nullable<FloatArray>;
  25768. /**
  25769. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25770. */
  25771. normals: Nullable<FloatArray>;
  25772. /**
  25773. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25774. */
  25775. tangents: Nullable<FloatArray>;
  25776. /**
  25777. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25778. */
  25779. uvs: Nullable<FloatArray>;
  25780. /**
  25781. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25782. */
  25783. uvs2: Nullable<FloatArray>;
  25784. /**
  25785. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25786. */
  25787. uvs3: Nullable<FloatArray>;
  25788. /**
  25789. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25790. */
  25791. uvs4: Nullable<FloatArray>;
  25792. /**
  25793. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25794. */
  25795. uvs5: Nullable<FloatArray>;
  25796. /**
  25797. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25798. */
  25799. uvs6: Nullable<FloatArray>;
  25800. /**
  25801. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25802. */
  25803. colors: Nullable<FloatArray>;
  25804. /**
  25805. * 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).
  25806. */
  25807. matricesIndices: Nullable<FloatArray>;
  25808. /**
  25809. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  25810. */
  25811. matricesWeights: Nullable<FloatArray>;
  25812. /**
  25813. * An array extending the number of possible indices
  25814. */
  25815. matricesIndicesExtra: Nullable<FloatArray>;
  25816. /**
  25817. * An array extending the number of possible weights when the number of indices is extended
  25818. */
  25819. matricesWeightsExtra: Nullable<FloatArray>;
  25820. /**
  25821. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  25822. */
  25823. indices: Nullable<IndicesArray>;
  25824. /**
  25825. * Uses the passed data array to set the set the values for the specified kind of data
  25826. * @param data a linear array of floating numbers
  25827. * @param kind the type of data that is being set, eg positions, colors etc
  25828. */
  25829. set(data: FloatArray, kind: string): void;
  25830. /**
  25831. * Associates the vertexData to the passed Mesh.
  25832. * Sets it as updatable or not (default `false`)
  25833. * @param mesh the mesh the vertexData is applied to
  25834. * @param updatable when used and having the value true allows new data to update the vertexData
  25835. * @returns the VertexData
  25836. */
  25837. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  25838. /**
  25839. * Associates the vertexData to the passed Geometry.
  25840. * Sets it as updatable or not (default `false`)
  25841. * @param geometry the geometry the vertexData is applied to
  25842. * @param updatable when used and having the value true allows new data to update the vertexData
  25843. * @returns VertexData
  25844. */
  25845. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  25846. /**
  25847. * Updates the associated mesh
  25848. * @param mesh the mesh to be updated
  25849. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25850. * @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
  25851. * @returns VertexData
  25852. */
  25853. updateMesh(mesh: Mesh): VertexData;
  25854. /**
  25855. * Updates the associated geometry
  25856. * @param geometry the geometry to be updated
  25857. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  25858. * @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
  25859. * @returns VertexData.
  25860. */
  25861. updateGeometry(geometry: Geometry): VertexData;
  25862. private _applyTo;
  25863. private _update;
  25864. /**
  25865. * Transforms each position and each normal of the vertexData according to the passed Matrix
  25866. * @param matrix the transforming matrix
  25867. * @returns the VertexData
  25868. */
  25869. transform(matrix: Matrix): VertexData;
  25870. /**
  25871. * Merges the passed VertexData into the current one
  25872. * @param other the VertexData to be merged into the current one
  25873. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  25874. * @returns the modified VertexData
  25875. */
  25876. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  25877. private _mergeElement;
  25878. private _validate;
  25879. /**
  25880. * Serializes the VertexData
  25881. * @returns a serialized object
  25882. */
  25883. serialize(): any;
  25884. /**
  25885. * Extracts the vertexData from a mesh
  25886. * @param mesh the mesh from which to extract the VertexData
  25887. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  25888. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25889. * @returns the object VertexData associated to the passed mesh
  25890. */
  25891. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25892. /**
  25893. * Extracts the vertexData from the geometry
  25894. * @param geometry the geometry from which to extract the VertexData
  25895. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  25896. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  25897. * @returns the object VertexData associated to the passed mesh
  25898. */
  25899. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  25900. private static _ExtractFrom;
  25901. /**
  25902. * Creates the VertexData for a Ribbon
  25903. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  25904. * * pathArray array of paths, each of which an array of successive Vector3
  25905. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  25906. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  25907. * * 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
  25908. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25909. * * 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)
  25910. * * 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)
  25911. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  25912. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  25913. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  25914. * @returns the VertexData of the ribbon
  25915. */
  25916. static CreateRibbon(options: {
  25917. pathArray: Vector3[][];
  25918. closeArray?: boolean;
  25919. closePath?: boolean;
  25920. offset?: number;
  25921. sideOrientation?: number;
  25922. frontUVs?: Vector4;
  25923. backUVs?: Vector4;
  25924. invertUV?: boolean;
  25925. uvs?: Vector2[];
  25926. colors?: Color4[];
  25927. }): VertexData;
  25928. /**
  25929. * Creates the VertexData for a box
  25930. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25931. * * size sets the width, height and depth of the box to the value of size, optional default 1
  25932. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  25933. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  25934. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  25935. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25936. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25937. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25938. * * 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)
  25939. * * 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)
  25940. * @returns the VertexData of the box
  25941. */
  25942. static CreateBox(options: {
  25943. size?: number;
  25944. width?: number;
  25945. height?: number;
  25946. depth?: number;
  25947. faceUV?: Vector4[];
  25948. faceColors?: Color4[];
  25949. sideOrientation?: number;
  25950. frontUVs?: Vector4;
  25951. backUVs?: Vector4;
  25952. }): VertexData;
  25953. /**
  25954. * Creates the VertexData for a tiled box
  25955. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25956. * * faceTiles sets the pattern, tile size and number of tiles for a face
  25957. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  25958. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  25959. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25960. * @returns the VertexData of the box
  25961. */
  25962. static CreateTiledBox(options: {
  25963. pattern?: number;
  25964. width?: number;
  25965. height?: number;
  25966. depth?: number;
  25967. tileSize?: number;
  25968. tileWidth?: number;
  25969. tileHeight?: number;
  25970. alignHorizontal?: number;
  25971. alignVertical?: number;
  25972. faceUV?: Vector4[];
  25973. faceColors?: Color4[];
  25974. sideOrientation?: number;
  25975. }): VertexData;
  25976. /**
  25977. * Creates the VertexData for a tiled plane
  25978. * @param options an object used to set the following optional parameters for the box, required but can be empty
  25979. * * pattern a limited pattern arrangement depending on the number
  25980. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  25981. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  25982. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  25983. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25984. * * 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)
  25985. * * 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)
  25986. * @returns the VertexData of the tiled plane
  25987. */
  25988. static CreateTiledPlane(options: {
  25989. pattern?: number;
  25990. tileSize?: number;
  25991. tileWidth?: number;
  25992. tileHeight?: number;
  25993. size?: number;
  25994. width?: number;
  25995. height?: number;
  25996. alignHorizontal?: number;
  25997. alignVertical?: number;
  25998. sideOrientation?: number;
  25999. frontUVs?: Vector4;
  26000. backUVs?: Vector4;
  26001. }): VertexData;
  26002. /**
  26003. * Creates the VertexData for an ellipsoid, defaults to a sphere
  26004. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26005. * * segments sets the number of horizontal strips optional, default 32
  26006. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  26007. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  26008. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  26009. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  26010. * * 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
  26011. * * 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
  26012. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26013. * * 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)
  26014. * * 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)
  26015. * @returns the VertexData of the ellipsoid
  26016. */
  26017. static CreateSphere(options: {
  26018. segments?: number;
  26019. diameter?: number;
  26020. diameterX?: number;
  26021. diameterY?: number;
  26022. diameterZ?: number;
  26023. arc?: number;
  26024. slice?: number;
  26025. sideOrientation?: number;
  26026. frontUVs?: Vector4;
  26027. backUVs?: Vector4;
  26028. }): VertexData;
  26029. /**
  26030. * Creates the VertexData for a cylinder, cone or prism
  26031. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26032. * * height sets the height (y direction) of the cylinder, optional, default 2
  26033. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  26034. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  26035. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  26036. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26037. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  26038. * * 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
  26039. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26040. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26041. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  26042. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  26043. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26044. * * 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)
  26045. * * 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)
  26046. * @returns the VertexData of the cylinder, cone or prism
  26047. */
  26048. static CreateCylinder(options: {
  26049. height?: number;
  26050. diameterTop?: number;
  26051. diameterBottom?: number;
  26052. diameter?: number;
  26053. tessellation?: number;
  26054. subdivisions?: number;
  26055. arc?: number;
  26056. faceColors?: Color4[];
  26057. faceUV?: Vector4[];
  26058. hasRings?: boolean;
  26059. enclose?: boolean;
  26060. sideOrientation?: number;
  26061. frontUVs?: Vector4;
  26062. backUVs?: Vector4;
  26063. }): VertexData;
  26064. /**
  26065. * Creates the VertexData for a torus
  26066. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26067. * * diameter the diameter of the torus, optional default 1
  26068. * * thickness the diameter of the tube forming the torus, optional default 0.5
  26069. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26070. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26071. * * 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)
  26072. * * 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)
  26073. * @returns the VertexData of the torus
  26074. */
  26075. static CreateTorus(options: {
  26076. diameter?: number;
  26077. thickness?: number;
  26078. tessellation?: number;
  26079. sideOrientation?: number;
  26080. frontUVs?: Vector4;
  26081. backUVs?: Vector4;
  26082. }): VertexData;
  26083. /**
  26084. * Creates the VertexData of the LineSystem
  26085. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  26086. * - lines an array of lines, each line being an array of successive Vector3
  26087. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  26088. * @returns the VertexData of the LineSystem
  26089. */
  26090. static CreateLineSystem(options: {
  26091. lines: Vector3[][];
  26092. colors?: Nullable<Color4[][]>;
  26093. }): VertexData;
  26094. /**
  26095. * Create the VertexData for a DashedLines
  26096. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  26097. * - points an array successive Vector3
  26098. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  26099. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  26100. * - dashNb the intended total number of dashes, optional, default 200
  26101. * @returns the VertexData for the DashedLines
  26102. */
  26103. static CreateDashedLines(options: {
  26104. points: Vector3[];
  26105. dashSize?: number;
  26106. gapSize?: number;
  26107. dashNb?: number;
  26108. }): VertexData;
  26109. /**
  26110. * Creates the VertexData for a Ground
  26111. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26112. * - width the width (x direction) of the ground, optional, default 1
  26113. * - height the height (z direction) of the ground, optional, default 1
  26114. * - subdivisions the number of subdivisions per side, optional, default 1
  26115. * @returns the VertexData of the Ground
  26116. */
  26117. static CreateGround(options: {
  26118. width?: number;
  26119. height?: number;
  26120. subdivisions?: number;
  26121. subdivisionsX?: number;
  26122. subdivisionsY?: number;
  26123. }): VertexData;
  26124. /**
  26125. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  26126. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26127. * * xmin the ground minimum X coordinate, optional, default -1
  26128. * * zmin the ground minimum Z coordinate, optional, default -1
  26129. * * xmax the ground maximum X coordinate, optional, default 1
  26130. * * zmax the ground maximum Z coordinate, optional, default 1
  26131. * * 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}
  26132. * * 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}
  26133. * @returns the VertexData of the TiledGround
  26134. */
  26135. static CreateTiledGround(options: {
  26136. xmin: number;
  26137. zmin: number;
  26138. xmax: number;
  26139. zmax: number;
  26140. subdivisions?: {
  26141. w: number;
  26142. h: number;
  26143. };
  26144. precision?: {
  26145. w: number;
  26146. h: number;
  26147. };
  26148. }): VertexData;
  26149. /**
  26150. * Creates the VertexData of the Ground designed from a heightmap
  26151. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  26152. * * width the width (x direction) of the ground
  26153. * * height the height (z direction) of the ground
  26154. * * subdivisions the number of subdivisions per side
  26155. * * minHeight the minimum altitude on the ground, optional, default 0
  26156. * * maxHeight the maximum altitude on the ground, optional default 1
  26157. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  26158. * * buffer the array holding the image color data
  26159. * * bufferWidth the width of image
  26160. * * bufferHeight the height of image
  26161. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  26162. * @returns the VertexData of the Ground designed from a heightmap
  26163. */
  26164. static CreateGroundFromHeightMap(options: {
  26165. width: number;
  26166. height: number;
  26167. subdivisions: number;
  26168. minHeight: number;
  26169. maxHeight: number;
  26170. colorFilter: Color3;
  26171. buffer: Uint8Array;
  26172. bufferWidth: number;
  26173. bufferHeight: number;
  26174. alphaFilter: number;
  26175. }): VertexData;
  26176. /**
  26177. * Creates the VertexData for a Plane
  26178. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  26179. * * size sets the width and height of the plane to the value of size, optional default 1
  26180. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  26181. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  26182. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26183. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  26184. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  26185. * @returns the VertexData of the box
  26186. */
  26187. static CreatePlane(options: {
  26188. size?: number;
  26189. width?: number;
  26190. height?: number;
  26191. sideOrientation?: number;
  26192. frontUVs?: Vector4;
  26193. backUVs?: Vector4;
  26194. }): VertexData;
  26195. /**
  26196. * Creates the VertexData of the Disc or regular Polygon
  26197. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  26198. * * radius the radius of the disc, optional default 0.5
  26199. * * tessellation the number of polygon sides, optional, default 64
  26200. * * 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
  26201. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26202. * * 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)
  26203. * * 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)
  26204. * @returns the VertexData of the box
  26205. */
  26206. static CreateDisc(options: {
  26207. radius?: number;
  26208. tessellation?: number;
  26209. arc?: number;
  26210. sideOrientation?: number;
  26211. frontUVs?: Vector4;
  26212. backUVs?: Vector4;
  26213. }): VertexData;
  26214. /**
  26215. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  26216. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  26217. * @param polygon a mesh built from polygonTriangulation.build()
  26218. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26219. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26220. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26221. * @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)
  26222. * @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)
  26223. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  26224. * @returns the VertexData of the Polygon
  26225. */
  26226. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  26227. /**
  26228. * Creates the VertexData of the IcoSphere
  26229. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  26230. * * radius the radius of the IcoSphere, optional default 1
  26231. * * radiusX allows stretching in the x direction, optional, default radius
  26232. * * radiusY allows stretching in the y direction, optional, default radius
  26233. * * radiusZ allows stretching in the z direction, optional, default radius
  26234. * * flat when true creates a flat shaded mesh, optional, default true
  26235. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26236. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26237. * * 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)
  26238. * * 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)
  26239. * @returns the VertexData of the IcoSphere
  26240. */
  26241. static CreateIcoSphere(options: {
  26242. radius?: number;
  26243. radiusX?: number;
  26244. radiusY?: number;
  26245. radiusZ?: number;
  26246. flat?: boolean;
  26247. subdivisions?: number;
  26248. sideOrientation?: number;
  26249. frontUVs?: Vector4;
  26250. backUVs?: Vector4;
  26251. }): VertexData;
  26252. /**
  26253. * Creates the VertexData for a Polyhedron
  26254. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  26255. * * type provided types are:
  26256. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  26257. * * 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)
  26258. * * size the size of the IcoSphere, optional default 1
  26259. * * sizeX allows stretching in the x direction, optional, default size
  26260. * * sizeY allows stretching in the y direction, optional, default size
  26261. * * sizeZ allows stretching in the z direction, optional, default size
  26262. * * 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
  26263. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26264. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26265. * * flat when true creates a flat shaded mesh, optional, default true
  26266. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26267. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26268. * * 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)
  26269. * * 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)
  26270. * @returns the VertexData of the Polyhedron
  26271. */
  26272. static CreatePolyhedron(options: {
  26273. type?: number;
  26274. size?: number;
  26275. sizeX?: number;
  26276. sizeY?: number;
  26277. sizeZ?: number;
  26278. custom?: any;
  26279. faceUV?: Vector4[];
  26280. faceColors?: Color4[];
  26281. flat?: boolean;
  26282. sideOrientation?: number;
  26283. frontUVs?: Vector4;
  26284. backUVs?: Vector4;
  26285. }): VertexData;
  26286. /**
  26287. * Creates the VertexData for a TorusKnot
  26288. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  26289. * * radius the radius of the torus knot, optional, default 2
  26290. * * tube the thickness of the tube, optional, default 0.5
  26291. * * radialSegments the number of sides on each tube segments, optional, default 32
  26292. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  26293. * * p the number of windings around the z axis, optional, default 2
  26294. * * q the number of windings around the x axis, optional, default 3
  26295. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26296. * * 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)
  26297. * * 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)
  26298. * @returns the VertexData of the Torus Knot
  26299. */
  26300. static CreateTorusKnot(options: {
  26301. radius?: number;
  26302. tube?: number;
  26303. radialSegments?: number;
  26304. tubularSegments?: number;
  26305. p?: number;
  26306. q?: number;
  26307. sideOrientation?: number;
  26308. frontUVs?: Vector4;
  26309. backUVs?: Vector4;
  26310. }): VertexData;
  26311. /**
  26312. * Compute normals for given positions and indices
  26313. * @param positions an array of vertex positions, [...., x, y, z, ......]
  26314. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  26315. * @param normals an array of vertex normals, [...., x, y, z, ......]
  26316. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  26317. * * facetNormals : optional array of facet normals (vector3)
  26318. * * facetPositions : optional array of facet positions (vector3)
  26319. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  26320. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  26321. * * bInfo : optional bounding info, required for facetPartitioning computation
  26322. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  26323. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  26324. * * useRightHandedSystem: optional boolean to for right handed system computation
  26325. * * depthSort : optional boolean to enable the facet depth sort computation
  26326. * * distanceTo : optional Vector3 to compute the facet depth from this location
  26327. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  26328. */
  26329. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  26330. facetNormals?: any;
  26331. facetPositions?: any;
  26332. facetPartitioning?: any;
  26333. ratio?: number;
  26334. bInfo?: any;
  26335. bbSize?: Vector3;
  26336. subDiv?: any;
  26337. useRightHandedSystem?: boolean;
  26338. depthSort?: boolean;
  26339. distanceTo?: Vector3;
  26340. depthSortedFacets?: any;
  26341. }): void;
  26342. /** @hidden */
  26343. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  26344. /**
  26345. * Applies VertexData created from the imported parameters to the geometry
  26346. * @param parsedVertexData the parsed data from an imported file
  26347. * @param geometry the geometry to apply the VertexData to
  26348. */
  26349. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  26350. }
  26351. }
  26352. declare module BABYLON {
  26353. /**
  26354. * Defines a target to use with MorphTargetManager
  26355. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26356. */
  26357. export class MorphTarget implements IAnimatable {
  26358. /** defines the name of the target */
  26359. name: string;
  26360. /**
  26361. * Gets or sets the list of animations
  26362. */
  26363. animations: Animation[];
  26364. private _scene;
  26365. private _positions;
  26366. private _normals;
  26367. private _tangents;
  26368. private _uvs;
  26369. private _influence;
  26370. private _uniqueId;
  26371. /**
  26372. * Observable raised when the influence changes
  26373. */
  26374. onInfluenceChanged: Observable<boolean>;
  26375. /** @hidden */
  26376. _onDataLayoutChanged: Observable<void>;
  26377. /**
  26378. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  26379. */
  26380. get influence(): number;
  26381. set influence(influence: number);
  26382. /**
  26383. * Gets or sets the id of the morph Target
  26384. */
  26385. id: string;
  26386. private _animationPropertiesOverride;
  26387. /**
  26388. * Gets or sets the animation properties override
  26389. */
  26390. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26391. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26392. /**
  26393. * Creates a new MorphTarget
  26394. * @param name defines the name of the target
  26395. * @param influence defines the influence to use
  26396. * @param scene defines the scene the morphtarget belongs to
  26397. */
  26398. constructor(
  26399. /** defines the name of the target */
  26400. name: string, influence?: number, scene?: Nullable<Scene>);
  26401. /**
  26402. * Gets the unique ID of this manager
  26403. */
  26404. get uniqueId(): number;
  26405. /**
  26406. * Gets a boolean defining if the target contains position data
  26407. */
  26408. get hasPositions(): boolean;
  26409. /**
  26410. * Gets a boolean defining if the target contains normal data
  26411. */
  26412. get hasNormals(): boolean;
  26413. /**
  26414. * Gets a boolean defining if the target contains tangent data
  26415. */
  26416. get hasTangents(): boolean;
  26417. /**
  26418. * Gets a boolean defining if the target contains texture coordinates data
  26419. */
  26420. get hasUVs(): boolean;
  26421. /**
  26422. * Affects position data to this target
  26423. * @param data defines the position data to use
  26424. */
  26425. setPositions(data: Nullable<FloatArray>): void;
  26426. /**
  26427. * Gets the position data stored in this target
  26428. * @returns a FloatArray containing the position data (or null if not present)
  26429. */
  26430. getPositions(): Nullable<FloatArray>;
  26431. /**
  26432. * Affects normal data to this target
  26433. * @param data defines the normal data to use
  26434. */
  26435. setNormals(data: Nullable<FloatArray>): void;
  26436. /**
  26437. * Gets the normal data stored in this target
  26438. * @returns a FloatArray containing the normal data (or null if not present)
  26439. */
  26440. getNormals(): Nullable<FloatArray>;
  26441. /**
  26442. * Affects tangent data to this target
  26443. * @param data defines the tangent data to use
  26444. */
  26445. setTangents(data: Nullable<FloatArray>): void;
  26446. /**
  26447. * Gets the tangent data stored in this target
  26448. * @returns a FloatArray containing the tangent data (or null if not present)
  26449. */
  26450. getTangents(): Nullable<FloatArray>;
  26451. /**
  26452. * Affects texture coordinates data to this target
  26453. * @param data defines the texture coordinates data to use
  26454. */
  26455. setUVs(data: Nullable<FloatArray>): void;
  26456. /**
  26457. * Gets the texture coordinates data stored in this target
  26458. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  26459. */
  26460. getUVs(): Nullable<FloatArray>;
  26461. /**
  26462. * Clone the current target
  26463. * @returns a new MorphTarget
  26464. */
  26465. clone(): MorphTarget;
  26466. /**
  26467. * Serializes the current target into a Serialization object
  26468. * @returns the serialized object
  26469. */
  26470. serialize(): any;
  26471. /**
  26472. * Returns the string "MorphTarget"
  26473. * @returns "MorphTarget"
  26474. */
  26475. getClassName(): string;
  26476. /**
  26477. * Creates a new target from serialized data
  26478. * @param serializationObject defines the serialized data to use
  26479. * @returns a new MorphTarget
  26480. */
  26481. static Parse(serializationObject: any): MorphTarget;
  26482. /**
  26483. * Creates a MorphTarget from mesh data
  26484. * @param mesh defines the source mesh
  26485. * @param name defines the name to use for the new target
  26486. * @param influence defines the influence to attach to the target
  26487. * @returns a new MorphTarget
  26488. */
  26489. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  26490. }
  26491. }
  26492. declare module BABYLON {
  26493. /**
  26494. * This class is used to deform meshes using morphing between different targets
  26495. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26496. */
  26497. export class MorphTargetManager {
  26498. private _targets;
  26499. private _targetInfluenceChangedObservers;
  26500. private _targetDataLayoutChangedObservers;
  26501. private _activeTargets;
  26502. private _scene;
  26503. private _influences;
  26504. private _supportsNormals;
  26505. private _supportsTangents;
  26506. private _supportsUVs;
  26507. private _vertexCount;
  26508. private _uniqueId;
  26509. private _tempInfluences;
  26510. /**
  26511. * Gets or sets a boolean indicating if normals must be morphed
  26512. */
  26513. enableNormalMorphing: boolean;
  26514. /**
  26515. * Gets or sets a boolean indicating if tangents must be morphed
  26516. */
  26517. enableTangentMorphing: boolean;
  26518. /**
  26519. * Gets or sets a boolean indicating if UV must be morphed
  26520. */
  26521. enableUVMorphing: boolean;
  26522. /**
  26523. * Creates a new MorphTargetManager
  26524. * @param scene defines the current scene
  26525. */
  26526. constructor(scene?: Nullable<Scene>);
  26527. /**
  26528. * Gets the unique ID of this manager
  26529. */
  26530. get uniqueId(): number;
  26531. /**
  26532. * Gets the number of vertices handled by this manager
  26533. */
  26534. get vertexCount(): number;
  26535. /**
  26536. * Gets a boolean indicating if this manager supports morphing of normals
  26537. */
  26538. get supportsNormals(): boolean;
  26539. /**
  26540. * Gets a boolean indicating if this manager supports morphing of tangents
  26541. */
  26542. get supportsTangents(): boolean;
  26543. /**
  26544. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  26545. */
  26546. get supportsUVs(): boolean;
  26547. /**
  26548. * Gets the number of targets stored in this manager
  26549. */
  26550. get numTargets(): number;
  26551. /**
  26552. * Gets the number of influencers (ie. the number of targets with influences > 0)
  26553. */
  26554. get numInfluencers(): number;
  26555. /**
  26556. * Gets the list of influences (one per target)
  26557. */
  26558. get influences(): Float32Array;
  26559. /**
  26560. * Gets the active target at specified index. An active target is a target with an influence > 0
  26561. * @param index defines the index to check
  26562. * @returns the requested target
  26563. */
  26564. getActiveTarget(index: number): MorphTarget;
  26565. /**
  26566. * Gets the target at specified index
  26567. * @param index defines the index to check
  26568. * @returns the requested target
  26569. */
  26570. getTarget(index: number): MorphTarget;
  26571. /**
  26572. * Add a new target to this manager
  26573. * @param target defines the target to add
  26574. */
  26575. addTarget(target: MorphTarget): void;
  26576. /**
  26577. * Removes a target from the manager
  26578. * @param target defines the target to remove
  26579. */
  26580. removeTarget(target: MorphTarget): void;
  26581. /**
  26582. * Clone the current manager
  26583. * @returns a new MorphTargetManager
  26584. */
  26585. clone(): MorphTargetManager;
  26586. /**
  26587. * Serializes the current manager into a Serialization object
  26588. * @returns the serialized object
  26589. */
  26590. serialize(): any;
  26591. private _syncActiveTargets;
  26592. /**
  26593. * Syncrhonize the targets with all the meshes using this morph target manager
  26594. */
  26595. synchronize(): void;
  26596. /**
  26597. * Creates a new MorphTargetManager from serialized data
  26598. * @param serializationObject defines the serialized data
  26599. * @param scene defines the hosting scene
  26600. * @returns the new MorphTargetManager
  26601. */
  26602. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  26603. }
  26604. }
  26605. declare module BABYLON {
  26606. /**
  26607. * Class used to represent a specific level of detail of a mesh
  26608. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26609. */
  26610. export class MeshLODLevel {
  26611. /** Defines the distance where this level should start being displayed */
  26612. distance: number;
  26613. /** Defines the mesh to use to render this level */
  26614. mesh: Nullable<Mesh>;
  26615. /**
  26616. * Creates a new LOD level
  26617. * @param distance defines the distance where this level should star being displayed
  26618. * @param mesh defines the mesh to use to render this level
  26619. */
  26620. constructor(
  26621. /** Defines the distance where this level should start being displayed */
  26622. distance: number,
  26623. /** Defines the mesh to use to render this level */
  26624. mesh: Nullable<Mesh>);
  26625. }
  26626. }
  26627. declare module BABYLON {
  26628. /**
  26629. * Helper class used to generate a canvas to manipulate images
  26630. */
  26631. export class CanvasGenerator {
  26632. /**
  26633. * Create a new canvas (or offscreen canvas depending on the context)
  26634. * @param width defines the expected width
  26635. * @param height defines the expected height
  26636. * @return a new canvas or offscreen canvas
  26637. */
  26638. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  26639. }
  26640. }
  26641. declare module BABYLON {
  26642. /**
  26643. * Mesh representing the gorund
  26644. */
  26645. export class GroundMesh extends Mesh {
  26646. /** If octree should be generated */
  26647. generateOctree: boolean;
  26648. private _heightQuads;
  26649. /** @hidden */
  26650. _subdivisionsX: number;
  26651. /** @hidden */
  26652. _subdivisionsY: number;
  26653. /** @hidden */
  26654. _width: number;
  26655. /** @hidden */
  26656. _height: number;
  26657. /** @hidden */
  26658. _minX: number;
  26659. /** @hidden */
  26660. _maxX: number;
  26661. /** @hidden */
  26662. _minZ: number;
  26663. /** @hidden */
  26664. _maxZ: number;
  26665. constructor(name: string, scene: Scene);
  26666. /**
  26667. * "GroundMesh"
  26668. * @returns "GroundMesh"
  26669. */
  26670. getClassName(): string;
  26671. /**
  26672. * The minimum of x and y subdivisions
  26673. */
  26674. get subdivisions(): number;
  26675. /**
  26676. * X subdivisions
  26677. */
  26678. get subdivisionsX(): number;
  26679. /**
  26680. * Y subdivisions
  26681. */
  26682. get subdivisionsY(): number;
  26683. /**
  26684. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26685. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26686. * @param chunksCount the number of subdivisions for x and y
  26687. * @param octreeBlocksSize (Default: 32)
  26688. */
  26689. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26690. /**
  26691. * Returns a height (y) value in the Worl system :
  26692. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26693. * @param x x coordinate
  26694. * @param z z coordinate
  26695. * @returns the ground y position if (x, z) are outside the ground surface.
  26696. */
  26697. getHeightAtCoordinates(x: number, z: number): number;
  26698. /**
  26699. * Returns a normalized vector (Vector3) orthogonal to the ground
  26700. * at the ground coordinates (x, z) expressed in the World system.
  26701. * @param x x coordinate
  26702. * @param z z coordinate
  26703. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26704. */
  26705. getNormalAtCoordinates(x: number, z: number): Vector3;
  26706. /**
  26707. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26708. * at the ground coordinates (x, z) expressed in the World system.
  26709. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26710. * @param x x coordinate
  26711. * @param z z coordinate
  26712. * @param ref vector to store the result
  26713. * @returns the GroundMesh.
  26714. */
  26715. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26716. /**
  26717. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26718. * if the ground has been updated.
  26719. * This can be used in the render loop.
  26720. * @returns the GroundMesh.
  26721. */
  26722. updateCoordinateHeights(): GroundMesh;
  26723. private _getFacetAt;
  26724. private _initHeightQuads;
  26725. private _computeHeightQuads;
  26726. /**
  26727. * Serializes this ground mesh
  26728. * @param serializationObject object to write serialization to
  26729. */
  26730. serialize(serializationObject: any): void;
  26731. /**
  26732. * Parses a serialized ground mesh
  26733. * @param parsedMesh the serialized mesh
  26734. * @param scene the scene to create the ground mesh in
  26735. * @returns the created ground mesh
  26736. */
  26737. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26738. }
  26739. }
  26740. declare module BABYLON {
  26741. /**
  26742. * Interface for Physics-Joint data
  26743. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26744. */
  26745. export interface PhysicsJointData {
  26746. /**
  26747. * The main pivot of the joint
  26748. */
  26749. mainPivot?: Vector3;
  26750. /**
  26751. * The connected pivot of the joint
  26752. */
  26753. connectedPivot?: Vector3;
  26754. /**
  26755. * The main axis of the joint
  26756. */
  26757. mainAxis?: Vector3;
  26758. /**
  26759. * The connected axis of the joint
  26760. */
  26761. connectedAxis?: Vector3;
  26762. /**
  26763. * The collision of the joint
  26764. */
  26765. collision?: boolean;
  26766. /**
  26767. * Native Oimo/Cannon/Energy data
  26768. */
  26769. nativeParams?: any;
  26770. }
  26771. /**
  26772. * This is a holder class for the physics joint created by the physics plugin
  26773. * It holds a set of functions to control the underlying joint
  26774. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26775. */
  26776. export class PhysicsJoint {
  26777. /**
  26778. * The type of the physics joint
  26779. */
  26780. type: number;
  26781. /**
  26782. * The data for the physics joint
  26783. */
  26784. jointData: PhysicsJointData;
  26785. private _physicsJoint;
  26786. protected _physicsPlugin: IPhysicsEnginePlugin;
  26787. /**
  26788. * Initializes the physics joint
  26789. * @param type The type of the physics joint
  26790. * @param jointData The data for the physics joint
  26791. */
  26792. constructor(
  26793. /**
  26794. * The type of the physics joint
  26795. */
  26796. type: number,
  26797. /**
  26798. * The data for the physics joint
  26799. */
  26800. jointData: PhysicsJointData);
  26801. /**
  26802. * Gets the physics joint
  26803. */
  26804. get physicsJoint(): any;
  26805. /**
  26806. * Sets the physics joint
  26807. */
  26808. set physicsJoint(newJoint: any);
  26809. /**
  26810. * Sets the physics plugin
  26811. */
  26812. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  26813. /**
  26814. * Execute a function that is physics-plugin specific.
  26815. * @param {Function} func the function that will be executed.
  26816. * It accepts two parameters: the physics world and the physics joint
  26817. */
  26818. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  26819. /**
  26820. * Distance-Joint type
  26821. */
  26822. static DistanceJoint: number;
  26823. /**
  26824. * Hinge-Joint type
  26825. */
  26826. static HingeJoint: number;
  26827. /**
  26828. * Ball-and-Socket joint type
  26829. */
  26830. static BallAndSocketJoint: number;
  26831. /**
  26832. * Wheel-Joint type
  26833. */
  26834. static WheelJoint: number;
  26835. /**
  26836. * Slider-Joint type
  26837. */
  26838. static SliderJoint: number;
  26839. /**
  26840. * Prismatic-Joint type
  26841. */
  26842. static PrismaticJoint: number;
  26843. /**
  26844. * Universal-Joint type
  26845. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  26846. */
  26847. static UniversalJoint: number;
  26848. /**
  26849. * Hinge-Joint 2 type
  26850. */
  26851. static Hinge2Joint: number;
  26852. /**
  26853. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  26854. */
  26855. static PointToPointJoint: number;
  26856. /**
  26857. * Spring-Joint type
  26858. */
  26859. static SpringJoint: number;
  26860. /**
  26861. * Lock-Joint type
  26862. */
  26863. static LockJoint: number;
  26864. }
  26865. /**
  26866. * A class representing a physics distance joint
  26867. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26868. */
  26869. export class DistanceJoint extends PhysicsJoint {
  26870. /**
  26871. *
  26872. * @param jointData The data for the Distance-Joint
  26873. */
  26874. constructor(jointData: DistanceJointData);
  26875. /**
  26876. * Update the predefined distance.
  26877. * @param maxDistance The maximum preferred distance
  26878. * @param minDistance The minimum preferred distance
  26879. */
  26880. updateDistance(maxDistance: number, minDistance?: number): void;
  26881. }
  26882. /**
  26883. * Represents a Motor-Enabled Joint
  26884. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26885. */
  26886. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  26887. /**
  26888. * Initializes the Motor-Enabled Joint
  26889. * @param type The type of the joint
  26890. * @param jointData The physica joint data for the joint
  26891. */
  26892. constructor(type: number, jointData: PhysicsJointData);
  26893. /**
  26894. * Set the motor values.
  26895. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26896. * @param force the force to apply
  26897. * @param maxForce max force for this motor.
  26898. */
  26899. setMotor(force?: number, maxForce?: number): void;
  26900. /**
  26901. * Set the motor's limits.
  26902. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26903. * @param upperLimit The upper limit of the motor
  26904. * @param lowerLimit The lower limit of the motor
  26905. */
  26906. setLimit(upperLimit: number, lowerLimit?: number): void;
  26907. }
  26908. /**
  26909. * This class represents a single physics Hinge-Joint
  26910. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26911. */
  26912. export class HingeJoint extends MotorEnabledJoint {
  26913. /**
  26914. * Initializes the Hinge-Joint
  26915. * @param jointData The joint data for the Hinge-Joint
  26916. */
  26917. constructor(jointData: PhysicsJointData);
  26918. /**
  26919. * Set the motor values.
  26920. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26921. * @param {number} force the force to apply
  26922. * @param {number} maxForce max force for this motor.
  26923. */
  26924. setMotor(force?: number, maxForce?: number): void;
  26925. /**
  26926. * Set the motor's limits.
  26927. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26928. * @param upperLimit The upper limit of the motor
  26929. * @param lowerLimit The lower limit of the motor
  26930. */
  26931. setLimit(upperLimit: number, lowerLimit?: number): void;
  26932. }
  26933. /**
  26934. * This class represents a dual hinge physics joint (same as wheel joint)
  26935. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26936. */
  26937. export class Hinge2Joint extends MotorEnabledJoint {
  26938. /**
  26939. * Initializes the Hinge2-Joint
  26940. * @param jointData The joint data for the Hinge2-Joint
  26941. */
  26942. constructor(jointData: PhysicsJointData);
  26943. /**
  26944. * Set the motor values.
  26945. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26946. * @param {number} targetSpeed the speed the motor is to reach
  26947. * @param {number} maxForce max force for this motor.
  26948. * @param {motorIndex} the motor's index, 0 or 1.
  26949. */
  26950. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  26951. /**
  26952. * Set the motor limits.
  26953. * Attention, this function is plugin specific. Engines won't react 100% the same.
  26954. * @param {number} upperLimit the upper limit
  26955. * @param {number} lowerLimit lower limit
  26956. * @param {motorIndex} the motor's index, 0 or 1.
  26957. */
  26958. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26959. }
  26960. /**
  26961. * Interface for a motor enabled joint
  26962. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26963. */
  26964. export interface IMotorEnabledJoint {
  26965. /**
  26966. * Physics joint
  26967. */
  26968. physicsJoint: any;
  26969. /**
  26970. * Sets the motor of the motor-enabled joint
  26971. * @param force The force of the motor
  26972. * @param maxForce The maximum force of the motor
  26973. * @param motorIndex The index of the motor
  26974. */
  26975. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  26976. /**
  26977. * Sets the limit of the motor
  26978. * @param upperLimit The upper limit of the motor
  26979. * @param lowerLimit The lower limit of the motor
  26980. * @param motorIndex The index of the motor
  26981. */
  26982. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  26983. }
  26984. /**
  26985. * Joint data for a Distance-Joint
  26986. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26987. */
  26988. export interface DistanceJointData extends PhysicsJointData {
  26989. /**
  26990. * Max distance the 2 joint objects can be apart
  26991. */
  26992. maxDistance: number;
  26993. }
  26994. /**
  26995. * Joint data from a spring joint
  26996. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26997. */
  26998. export interface SpringJointData extends PhysicsJointData {
  26999. /**
  27000. * Length of the spring
  27001. */
  27002. length: number;
  27003. /**
  27004. * Stiffness of the spring
  27005. */
  27006. stiffness: number;
  27007. /**
  27008. * Damping of the spring
  27009. */
  27010. damping: number;
  27011. /** this callback will be called when applying the force to the impostors. */
  27012. forceApplicationCallback: () => void;
  27013. }
  27014. }
  27015. declare module BABYLON {
  27016. /**
  27017. * Holds the data for the raycast result
  27018. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27019. */
  27020. export class PhysicsRaycastResult {
  27021. private _hasHit;
  27022. private _hitDistance;
  27023. private _hitNormalWorld;
  27024. private _hitPointWorld;
  27025. private _rayFromWorld;
  27026. private _rayToWorld;
  27027. /**
  27028. * Gets if there was a hit
  27029. */
  27030. get hasHit(): boolean;
  27031. /**
  27032. * Gets the distance from the hit
  27033. */
  27034. get hitDistance(): number;
  27035. /**
  27036. * Gets the hit normal/direction in the world
  27037. */
  27038. get hitNormalWorld(): Vector3;
  27039. /**
  27040. * Gets the hit point in the world
  27041. */
  27042. get hitPointWorld(): Vector3;
  27043. /**
  27044. * Gets the ray "start point" of the ray in the world
  27045. */
  27046. get rayFromWorld(): Vector3;
  27047. /**
  27048. * Gets the ray "end point" of the ray in the world
  27049. */
  27050. get rayToWorld(): Vector3;
  27051. /**
  27052. * Sets the hit data (normal & point in world space)
  27053. * @param hitNormalWorld defines the normal in world space
  27054. * @param hitPointWorld defines the point in world space
  27055. */
  27056. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  27057. /**
  27058. * Sets the distance from the start point to the hit point
  27059. * @param distance
  27060. */
  27061. setHitDistance(distance: number): void;
  27062. /**
  27063. * Calculates the distance manually
  27064. */
  27065. calculateHitDistance(): void;
  27066. /**
  27067. * Resets all the values to default
  27068. * @param from The from point on world space
  27069. * @param to The to point on world space
  27070. */
  27071. reset(from?: Vector3, to?: Vector3): void;
  27072. }
  27073. /**
  27074. * Interface for the size containing width and height
  27075. */
  27076. interface IXYZ {
  27077. /**
  27078. * X
  27079. */
  27080. x: number;
  27081. /**
  27082. * Y
  27083. */
  27084. y: number;
  27085. /**
  27086. * Z
  27087. */
  27088. z: number;
  27089. }
  27090. }
  27091. declare module BABYLON {
  27092. /**
  27093. * Interface used to describe a physics joint
  27094. */
  27095. export interface PhysicsImpostorJoint {
  27096. /** Defines the main impostor to which the joint is linked */
  27097. mainImpostor: PhysicsImpostor;
  27098. /** Defines the impostor that is connected to the main impostor using this joint */
  27099. connectedImpostor: PhysicsImpostor;
  27100. /** Defines the joint itself */
  27101. joint: PhysicsJoint;
  27102. }
  27103. /** @hidden */
  27104. export interface IPhysicsEnginePlugin {
  27105. world: any;
  27106. name: string;
  27107. setGravity(gravity: Vector3): void;
  27108. setTimeStep(timeStep: number): void;
  27109. getTimeStep(): number;
  27110. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  27111. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27112. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27113. generatePhysicsBody(impostor: PhysicsImpostor): void;
  27114. removePhysicsBody(impostor: PhysicsImpostor): void;
  27115. generateJoint(joint: PhysicsImpostorJoint): void;
  27116. removeJoint(joint: PhysicsImpostorJoint): void;
  27117. isSupported(): boolean;
  27118. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  27119. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  27120. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27121. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27122. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27123. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27124. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  27125. getBodyMass(impostor: PhysicsImpostor): number;
  27126. getBodyFriction(impostor: PhysicsImpostor): number;
  27127. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  27128. getBodyRestitution(impostor: PhysicsImpostor): number;
  27129. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  27130. getBodyPressure?(impostor: PhysicsImpostor): number;
  27131. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  27132. getBodyStiffness?(impostor: PhysicsImpostor): number;
  27133. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  27134. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  27135. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  27136. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  27137. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  27138. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27139. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27140. sleepBody(impostor: PhysicsImpostor): void;
  27141. wakeUpBody(impostor: PhysicsImpostor): void;
  27142. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27143. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  27144. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  27145. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27146. getRadius(impostor: PhysicsImpostor): number;
  27147. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  27148. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  27149. dispose(): void;
  27150. }
  27151. /**
  27152. * Interface used to define a physics engine
  27153. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27154. */
  27155. export interface IPhysicsEngine {
  27156. /**
  27157. * Gets the gravity vector used by the simulation
  27158. */
  27159. gravity: Vector3;
  27160. /**
  27161. * Sets the gravity vector used by the simulation
  27162. * @param gravity defines the gravity vector to use
  27163. */
  27164. setGravity(gravity: Vector3): void;
  27165. /**
  27166. * Set the time step of the physics engine.
  27167. * Default is 1/60.
  27168. * To slow it down, enter 1/600 for example.
  27169. * To speed it up, 1/30
  27170. * @param newTimeStep the new timestep to apply to this world.
  27171. */
  27172. setTimeStep(newTimeStep: number): void;
  27173. /**
  27174. * Get the time step of the physics engine.
  27175. * @returns the current time step
  27176. */
  27177. getTimeStep(): number;
  27178. /**
  27179. * Set the sub time step of the physics engine.
  27180. * Default is 0 meaning there is no sub steps
  27181. * To increase physics resolution precision, set a small value (like 1 ms)
  27182. * @param subTimeStep defines the new sub timestep used for physics resolution.
  27183. */
  27184. setSubTimeStep(subTimeStep: number): void;
  27185. /**
  27186. * Get the sub time step of the physics engine.
  27187. * @returns the current sub time step
  27188. */
  27189. getSubTimeStep(): number;
  27190. /**
  27191. * Release all resources
  27192. */
  27193. dispose(): void;
  27194. /**
  27195. * Gets the name of the current physics plugin
  27196. * @returns the name of the plugin
  27197. */
  27198. getPhysicsPluginName(): string;
  27199. /**
  27200. * Adding a new impostor for the impostor tracking.
  27201. * This will be done by the impostor itself.
  27202. * @param impostor the impostor to add
  27203. */
  27204. addImpostor(impostor: PhysicsImpostor): void;
  27205. /**
  27206. * Remove an impostor from the engine.
  27207. * This impostor and its mesh will not longer be updated by the physics engine.
  27208. * @param impostor the impostor to remove
  27209. */
  27210. removeImpostor(impostor: PhysicsImpostor): void;
  27211. /**
  27212. * Add a joint to the physics engine
  27213. * @param mainImpostor defines the main impostor to which the joint is added.
  27214. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  27215. * @param joint defines the joint that will connect both impostors.
  27216. */
  27217. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27218. /**
  27219. * Removes a joint from the simulation
  27220. * @param mainImpostor defines the impostor used with the joint
  27221. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  27222. * @param joint defines the joint to remove
  27223. */
  27224. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27225. /**
  27226. * Gets the current plugin used to run the simulation
  27227. * @returns current plugin
  27228. */
  27229. getPhysicsPlugin(): IPhysicsEnginePlugin;
  27230. /**
  27231. * Gets the list of physic impostors
  27232. * @returns an array of PhysicsImpostor
  27233. */
  27234. getImpostors(): Array<PhysicsImpostor>;
  27235. /**
  27236. * Gets the impostor for a physics enabled object
  27237. * @param object defines the object impersonated by the impostor
  27238. * @returns the PhysicsImpostor or null if not found
  27239. */
  27240. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27241. /**
  27242. * Gets the impostor for a physics body object
  27243. * @param body defines physics body used by the impostor
  27244. * @returns the PhysicsImpostor or null if not found
  27245. */
  27246. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  27247. /**
  27248. * Does a raycast in the physics world
  27249. * @param from when should the ray start?
  27250. * @param to when should the ray end?
  27251. * @returns PhysicsRaycastResult
  27252. */
  27253. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27254. /**
  27255. * Called by the scene. No need to call it.
  27256. * @param delta defines the timespam between frames
  27257. */
  27258. _step(delta: number): void;
  27259. }
  27260. }
  27261. declare module BABYLON {
  27262. /**
  27263. * The interface for the physics imposter parameters
  27264. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27265. */
  27266. export interface PhysicsImpostorParameters {
  27267. /**
  27268. * The mass of the physics imposter
  27269. */
  27270. mass: number;
  27271. /**
  27272. * The friction of the physics imposter
  27273. */
  27274. friction?: number;
  27275. /**
  27276. * The coefficient of restitution of the physics imposter
  27277. */
  27278. restitution?: number;
  27279. /**
  27280. * The native options of the physics imposter
  27281. */
  27282. nativeOptions?: any;
  27283. /**
  27284. * Specifies if the parent should be ignored
  27285. */
  27286. ignoreParent?: boolean;
  27287. /**
  27288. * Specifies if bi-directional transformations should be disabled
  27289. */
  27290. disableBidirectionalTransformation?: boolean;
  27291. /**
  27292. * The pressure inside the physics imposter, soft object only
  27293. */
  27294. pressure?: number;
  27295. /**
  27296. * The stiffness the physics imposter, soft object only
  27297. */
  27298. stiffness?: number;
  27299. /**
  27300. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  27301. */
  27302. velocityIterations?: number;
  27303. /**
  27304. * The number of iterations used in maintaining consistent vertex positions, soft object only
  27305. */
  27306. positionIterations?: number;
  27307. /**
  27308. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  27309. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  27310. * Add to fix multiple points
  27311. */
  27312. fixedPoints?: number;
  27313. /**
  27314. * The collision margin around a soft object
  27315. */
  27316. margin?: number;
  27317. /**
  27318. * The collision margin around a soft object
  27319. */
  27320. damping?: number;
  27321. /**
  27322. * The path for a rope based on an extrusion
  27323. */
  27324. path?: any;
  27325. /**
  27326. * The shape of an extrusion used for a rope based on an extrusion
  27327. */
  27328. shape?: any;
  27329. }
  27330. /**
  27331. * Interface for a physics-enabled object
  27332. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27333. */
  27334. export interface IPhysicsEnabledObject {
  27335. /**
  27336. * The position of the physics-enabled object
  27337. */
  27338. position: Vector3;
  27339. /**
  27340. * The rotation of the physics-enabled object
  27341. */
  27342. rotationQuaternion: Nullable<Quaternion>;
  27343. /**
  27344. * The scale of the physics-enabled object
  27345. */
  27346. scaling: Vector3;
  27347. /**
  27348. * The rotation of the physics-enabled object
  27349. */
  27350. rotation?: Vector3;
  27351. /**
  27352. * The parent of the physics-enabled object
  27353. */
  27354. parent?: any;
  27355. /**
  27356. * The bounding info of the physics-enabled object
  27357. * @returns The bounding info of the physics-enabled object
  27358. */
  27359. getBoundingInfo(): BoundingInfo;
  27360. /**
  27361. * Computes the world matrix
  27362. * @param force Specifies if the world matrix should be computed by force
  27363. * @returns A world matrix
  27364. */
  27365. computeWorldMatrix(force: boolean): Matrix;
  27366. /**
  27367. * Gets the world matrix
  27368. * @returns A world matrix
  27369. */
  27370. getWorldMatrix?(): Matrix;
  27371. /**
  27372. * Gets the child meshes
  27373. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  27374. * @returns An array of abstract meshes
  27375. */
  27376. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  27377. /**
  27378. * Gets the vertex data
  27379. * @param kind The type of vertex data
  27380. * @returns A nullable array of numbers, or a float32 array
  27381. */
  27382. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  27383. /**
  27384. * Gets the indices from the mesh
  27385. * @returns A nullable array of index arrays
  27386. */
  27387. getIndices?(): Nullable<IndicesArray>;
  27388. /**
  27389. * Gets the scene from the mesh
  27390. * @returns the indices array or null
  27391. */
  27392. getScene?(): Scene;
  27393. /**
  27394. * Gets the absolute position from the mesh
  27395. * @returns the absolute position
  27396. */
  27397. getAbsolutePosition(): Vector3;
  27398. /**
  27399. * Gets the absolute pivot point from the mesh
  27400. * @returns the absolute pivot point
  27401. */
  27402. getAbsolutePivotPoint(): Vector3;
  27403. /**
  27404. * Rotates the mesh
  27405. * @param axis The axis of rotation
  27406. * @param amount The amount of rotation
  27407. * @param space The space of the rotation
  27408. * @returns The rotation transform node
  27409. */
  27410. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27411. /**
  27412. * Translates the mesh
  27413. * @param axis The axis of translation
  27414. * @param distance The distance of translation
  27415. * @param space The space of the translation
  27416. * @returns The transform node
  27417. */
  27418. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27419. /**
  27420. * Sets the absolute position of the mesh
  27421. * @param absolutePosition The absolute position of the mesh
  27422. * @returns The transform node
  27423. */
  27424. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27425. /**
  27426. * Gets the class name of the mesh
  27427. * @returns The class name
  27428. */
  27429. getClassName(): string;
  27430. }
  27431. /**
  27432. * Represents a physics imposter
  27433. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27434. */
  27435. export class PhysicsImpostor {
  27436. /**
  27437. * The physics-enabled object used as the physics imposter
  27438. */
  27439. object: IPhysicsEnabledObject;
  27440. /**
  27441. * The type of the physics imposter
  27442. */
  27443. type: number;
  27444. private _options;
  27445. private _scene?;
  27446. /**
  27447. * The default object size of the imposter
  27448. */
  27449. static DEFAULT_OBJECT_SIZE: Vector3;
  27450. /**
  27451. * The identity quaternion of the imposter
  27452. */
  27453. static IDENTITY_QUATERNION: Quaternion;
  27454. /** @hidden */
  27455. _pluginData: any;
  27456. private _physicsEngine;
  27457. private _physicsBody;
  27458. private _bodyUpdateRequired;
  27459. private _onBeforePhysicsStepCallbacks;
  27460. private _onAfterPhysicsStepCallbacks;
  27461. /** @hidden */
  27462. _onPhysicsCollideCallbacks: Array<{
  27463. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  27464. otherImpostors: Array<PhysicsImpostor>;
  27465. }>;
  27466. private _deltaPosition;
  27467. private _deltaRotation;
  27468. private _deltaRotationConjugated;
  27469. /** @hidden */
  27470. _isFromLine: boolean;
  27471. private _parent;
  27472. private _isDisposed;
  27473. private static _tmpVecs;
  27474. private static _tmpQuat;
  27475. /**
  27476. * Specifies if the physics imposter is disposed
  27477. */
  27478. get isDisposed(): boolean;
  27479. /**
  27480. * Gets the mass of the physics imposter
  27481. */
  27482. get mass(): number;
  27483. set mass(value: number);
  27484. /**
  27485. * Gets the coefficient of friction
  27486. */
  27487. get friction(): number;
  27488. /**
  27489. * Sets the coefficient of friction
  27490. */
  27491. set friction(value: number);
  27492. /**
  27493. * Gets the coefficient of restitution
  27494. */
  27495. get restitution(): number;
  27496. /**
  27497. * Sets the coefficient of restitution
  27498. */
  27499. set restitution(value: number);
  27500. /**
  27501. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  27502. */
  27503. get pressure(): number;
  27504. /**
  27505. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  27506. */
  27507. set pressure(value: number);
  27508. /**
  27509. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27510. */
  27511. get stiffness(): number;
  27512. /**
  27513. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27514. */
  27515. set stiffness(value: number);
  27516. /**
  27517. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27518. */
  27519. get velocityIterations(): number;
  27520. /**
  27521. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27522. */
  27523. set velocityIterations(value: number);
  27524. /**
  27525. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27526. */
  27527. get positionIterations(): number;
  27528. /**
  27529. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27530. */
  27531. set positionIterations(value: number);
  27532. /**
  27533. * The unique id of the physics imposter
  27534. * set by the physics engine when adding this impostor to the array
  27535. */
  27536. uniqueId: number;
  27537. /**
  27538. * @hidden
  27539. */
  27540. soft: boolean;
  27541. /**
  27542. * @hidden
  27543. */
  27544. segments: number;
  27545. private _joints;
  27546. /**
  27547. * Initializes the physics imposter
  27548. * @param object The physics-enabled object used as the physics imposter
  27549. * @param type The type of the physics imposter
  27550. * @param _options The options for the physics imposter
  27551. * @param _scene The Babylon scene
  27552. */
  27553. constructor(
  27554. /**
  27555. * The physics-enabled object used as the physics imposter
  27556. */
  27557. object: IPhysicsEnabledObject,
  27558. /**
  27559. * The type of the physics imposter
  27560. */
  27561. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  27562. /**
  27563. * This function will completly initialize this impostor.
  27564. * It will create a new body - but only if this mesh has no parent.
  27565. * If it has, this impostor will not be used other than to define the impostor
  27566. * of the child mesh.
  27567. * @hidden
  27568. */
  27569. _init(): void;
  27570. private _getPhysicsParent;
  27571. /**
  27572. * Should a new body be generated.
  27573. * @returns boolean specifying if body initialization is required
  27574. */
  27575. isBodyInitRequired(): boolean;
  27576. /**
  27577. * Sets the updated scaling
  27578. * @param updated Specifies if the scaling is updated
  27579. */
  27580. setScalingUpdated(): void;
  27581. /**
  27582. * Force a regeneration of this or the parent's impostor's body.
  27583. * Use under cautious - This will remove all joints already implemented.
  27584. */
  27585. forceUpdate(): void;
  27586. /**
  27587. * Gets the body that holds this impostor. Either its own, or its parent.
  27588. */
  27589. get physicsBody(): any;
  27590. /**
  27591. * Get the parent of the physics imposter
  27592. * @returns Physics imposter or null
  27593. */
  27594. get parent(): Nullable<PhysicsImpostor>;
  27595. /**
  27596. * Sets the parent of the physics imposter
  27597. */
  27598. set parent(value: Nullable<PhysicsImpostor>);
  27599. /**
  27600. * Set the physics body. Used mainly by the physics engine/plugin
  27601. */
  27602. set physicsBody(physicsBody: any);
  27603. /**
  27604. * Resets the update flags
  27605. */
  27606. resetUpdateFlags(): void;
  27607. /**
  27608. * Gets the object extend size
  27609. * @returns the object extend size
  27610. */
  27611. getObjectExtendSize(): Vector3;
  27612. /**
  27613. * Gets the object center
  27614. * @returns The object center
  27615. */
  27616. getObjectCenter(): Vector3;
  27617. /**
  27618. * Get a specific parameter from the options parameters
  27619. * @param paramName The object parameter name
  27620. * @returns The object parameter
  27621. */
  27622. getParam(paramName: string): any;
  27623. /**
  27624. * Sets a specific parameter in the options given to the physics plugin
  27625. * @param paramName The parameter name
  27626. * @param value The value of the parameter
  27627. */
  27628. setParam(paramName: string, value: number): void;
  27629. /**
  27630. * Specifically change the body's mass option. Won't recreate the physics body object
  27631. * @param mass The mass of the physics imposter
  27632. */
  27633. setMass(mass: number): void;
  27634. /**
  27635. * Gets the linear velocity
  27636. * @returns linear velocity or null
  27637. */
  27638. getLinearVelocity(): Nullable<Vector3>;
  27639. /**
  27640. * Sets the linear velocity
  27641. * @param velocity linear velocity or null
  27642. */
  27643. setLinearVelocity(velocity: Nullable<Vector3>): void;
  27644. /**
  27645. * Gets the angular velocity
  27646. * @returns angular velocity or null
  27647. */
  27648. getAngularVelocity(): Nullable<Vector3>;
  27649. /**
  27650. * Sets the angular velocity
  27651. * @param velocity The velocity or null
  27652. */
  27653. setAngularVelocity(velocity: Nullable<Vector3>): void;
  27654. /**
  27655. * Execute a function with the physics plugin native code
  27656. * Provide a function the will have two variables - the world object and the physics body object
  27657. * @param func The function to execute with the physics plugin native code
  27658. */
  27659. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  27660. /**
  27661. * Register a function that will be executed before the physics world is stepping forward
  27662. * @param func The function to execute before the physics world is stepped forward
  27663. */
  27664. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27665. /**
  27666. * Unregister a function that will be executed before the physics world is stepping forward
  27667. * @param func The function to execute before the physics world is stepped forward
  27668. */
  27669. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27670. /**
  27671. * Register a function that will be executed after the physics step
  27672. * @param func The function to execute after physics step
  27673. */
  27674. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27675. /**
  27676. * Unregisters a function that will be executed after the physics step
  27677. * @param func The function to execute after physics step
  27678. */
  27679. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27680. /**
  27681. * register a function that will be executed when this impostor collides against a different body
  27682. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  27683. * @param func Callback that is executed on collision
  27684. */
  27685. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  27686. /**
  27687. * Unregisters the physics imposter on contact
  27688. * @param collideAgainst The physics object to collide against
  27689. * @param func Callback to execute on collision
  27690. */
  27691. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  27692. private _tmpQuat;
  27693. private _tmpQuat2;
  27694. /**
  27695. * Get the parent rotation
  27696. * @returns The parent rotation
  27697. */
  27698. getParentsRotation(): Quaternion;
  27699. /**
  27700. * this function is executed by the physics engine.
  27701. */
  27702. beforeStep: () => void;
  27703. /**
  27704. * this function is executed by the physics engine
  27705. */
  27706. afterStep: () => void;
  27707. /**
  27708. * Legacy collision detection event support
  27709. */
  27710. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  27711. /**
  27712. * event and body object due to cannon's event-based architecture.
  27713. */
  27714. onCollide: (e: {
  27715. body: any;
  27716. }) => void;
  27717. /**
  27718. * Apply a force
  27719. * @param force The force to apply
  27720. * @param contactPoint The contact point for the force
  27721. * @returns The physics imposter
  27722. */
  27723. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27724. /**
  27725. * Apply an impulse
  27726. * @param force The impulse force
  27727. * @param contactPoint The contact point for the impulse force
  27728. * @returns The physics imposter
  27729. */
  27730. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27731. /**
  27732. * A help function to create a joint
  27733. * @param otherImpostor A physics imposter used to create a joint
  27734. * @param jointType The type of joint
  27735. * @param jointData The data for the joint
  27736. * @returns The physics imposter
  27737. */
  27738. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  27739. /**
  27740. * Add a joint to this impostor with a different impostor
  27741. * @param otherImpostor A physics imposter used to add a joint
  27742. * @param joint The joint to add
  27743. * @returns The physics imposter
  27744. */
  27745. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  27746. /**
  27747. * Add an anchor to a cloth impostor
  27748. * @param otherImpostor rigid impostor to anchor to
  27749. * @param width ratio across width from 0 to 1
  27750. * @param height ratio up height from 0 to 1
  27751. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  27752. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  27753. * @returns impostor the soft imposter
  27754. */
  27755. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27756. /**
  27757. * Add a hook to a rope impostor
  27758. * @param otherImpostor rigid impostor to anchor to
  27759. * @param length ratio across rope from 0 to 1
  27760. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  27761. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  27762. * @returns impostor the rope imposter
  27763. */
  27764. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27765. /**
  27766. * Will keep this body still, in a sleep mode.
  27767. * @returns the physics imposter
  27768. */
  27769. sleep(): PhysicsImpostor;
  27770. /**
  27771. * Wake the body up.
  27772. * @returns The physics imposter
  27773. */
  27774. wakeUp(): PhysicsImpostor;
  27775. /**
  27776. * Clones the physics imposter
  27777. * @param newObject The physics imposter clones to this physics-enabled object
  27778. * @returns A nullable physics imposter
  27779. */
  27780. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27781. /**
  27782. * Disposes the physics imposter
  27783. */
  27784. dispose(): void;
  27785. /**
  27786. * Sets the delta position
  27787. * @param position The delta position amount
  27788. */
  27789. setDeltaPosition(position: Vector3): void;
  27790. /**
  27791. * Sets the delta rotation
  27792. * @param rotation The delta rotation amount
  27793. */
  27794. setDeltaRotation(rotation: Quaternion): void;
  27795. /**
  27796. * Gets the box size of the physics imposter and stores the result in the input parameter
  27797. * @param result Stores the box size
  27798. * @returns The physics imposter
  27799. */
  27800. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  27801. /**
  27802. * Gets the radius of the physics imposter
  27803. * @returns Radius of the physics imposter
  27804. */
  27805. getRadius(): number;
  27806. /**
  27807. * Sync a bone with this impostor
  27808. * @param bone The bone to sync to the impostor.
  27809. * @param boneMesh The mesh that the bone is influencing.
  27810. * @param jointPivot The pivot of the joint / bone in local space.
  27811. * @param distToJoint Optional distance from the impostor to the joint.
  27812. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27813. */
  27814. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  27815. /**
  27816. * Sync impostor to a bone
  27817. * @param bone The bone that the impostor will be synced to.
  27818. * @param boneMesh The mesh that the bone is influencing.
  27819. * @param jointPivot The pivot of the joint / bone in local space.
  27820. * @param distToJoint Optional distance from the impostor to the joint.
  27821. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  27822. * @param boneAxis Optional vector3 axis the bone is aligned with
  27823. */
  27824. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  27825. /**
  27826. * No-Imposter type
  27827. */
  27828. static NoImpostor: number;
  27829. /**
  27830. * Sphere-Imposter type
  27831. */
  27832. static SphereImpostor: number;
  27833. /**
  27834. * Box-Imposter type
  27835. */
  27836. static BoxImpostor: number;
  27837. /**
  27838. * Plane-Imposter type
  27839. */
  27840. static PlaneImpostor: number;
  27841. /**
  27842. * Mesh-imposter type
  27843. */
  27844. static MeshImpostor: number;
  27845. /**
  27846. * Capsule-Impostor type (Ammo.js plugin only)
  27847. */
  27848. static CapsuleImpostor: number;
  27849. /**
  27850. * Cylinder-Imposter type
  27851. */
  27852. static CylinderImpostor: number;
  27853. /**
  27854. * Particle-Imposter type
  27855. */
  27856. static ParticleImpostor: number;
  27857. /**
  27858. * Heightmap-Imposter type
  27859. */
  27860. static HeightmapImpostor: number;
  27861. /**
  27862. * ConvexHull-Impostor type (Ammo.js plugin only)
  27863. */
  27864. static ConvexHullImpostor: number;
  27865. /**
  27866. * Custom-Imposter type (Ammo.js plugin only)
  27867. */
  27868. static CustomImpostor: number;
  27869. /**
  27870. * Rope-Imposter type
  27871. */
  27872. static RopeImpostor: number;
  27873. /**
  27874. * Cloth-Imposter type
  27875. */
  27876. static ClothImpostor: number;
  27877. /**
  27878. * Softbody-Imposter type
  27879. */
  27880. static SoftbodyImpostor: number;
  27881. }
  27882. }
  27883. declare module BABYLON {
  27884. /**
  27885. * @hidden
  27886. **/
  27887. export class _CreationDataStorage {
  27888. closePath?: boolean;
  27889. closeArray?: boolean;
  27890. idx: number[];
  27891. dashSize: number;
  27892. gapSize: number;
  27893. path3D: Path3D;
  27894. pathArray: Vector3[][];
  27895. arc: number;
  27896. radius: number;
  27897. cap: number;
  27898. tessellation: number;
  27899. }
  27900. /**
  27901. * @hidden
  27902. **/
  27903. class _InstanceDataStorage {
  27904. visibleInstances: any;
  27905. batchCache: _InstancesBatch;
  27906. instancesBufferSize: number;
  27907. instancesBuffer: Nullable<Buffer>;
  27908. instancesData: Float32Array;
  27909. overridenInstanceCount: number;
  27910. isFrozen: boolean;
  27911. previousBatch: Nullable<_InstancesBatch>;
  27912. hardwareInstancedRendering: boolean;
  27913. sideOrientation: number;
  27914. manualUpdate: boolean;
  27915. }
  27916. /**
  27917. * @hidden
  27918. **/
  27919. export class _InstancesBatch {
  27920. mustReturn: boolean;
  27921. visibleInstances: Nullable<InstancedMesh[]>[];
  27922. renderSelf: boolean[];
  27923. hardwareInstancedRendering: boolean[];
  27924. }
  27925. /**
  27926. * @hidden
  27927. **/
  27928. class _ThinInstanceDataStorage {
  27929. instancesCount: number;
  27930. matrixBuffer: Nullable<Buffer>;
  27931. matrixBufferSize: number;
  27932. matrixData: Nullable<Float32Array>;
  27933. boundingVectors: Array<Vector3>;
  27934. }
  27935. /**
  27936. * Class used to represent renderable models
  27937. */
  27938. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  27939. /**
  27940. * Mesh side orientation : usually the external or front surface
  27941. */
  27942. static readonly FRONTSIDE: number;
  27943. /**
  27944. * Mesh side orientation : usually the internal or back surface
  27945. */
  27946. static readonly BACKSIDE: number;
  27947. /**
  27948. * Mesh side orientation : both internal and external or front and back surfaces
  27949. */
  27950. static readonly DOUBLESIDE: number;
  27951. /**
  27952. * Mesh side orientation : by default, `FRONTSIDE`
  27953. */
  27954. static readonly DEFAULTSIDE: number;
  27955. /**
  27956. * Mesh cap setting : no cap
  27957. */
  27958. static readonly NO_CAP: number;
  27959. /**
  27960. * Mesh cap setting : one cap at the beginning of the mesh
  27961. */
  27962. static readonly CAP_START: number;
  27963. /**
  27964. * Mesh cap setting : one cap at the end of the mesh
  27965. */
  27966. static readonly CAP_END: number;
  27967. /**
  27968. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  27969. */
  27970. static readonly CAP_ALL: number;
  27971. /**
  27972. * Mesh pattern setting : no flip or rotate
  27973. */
  27974. static readonly NO_FLIP: number;
  27975. /**
  27976. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  27977. */
  27978. static readonly FLIP_TILE: number;
  27979. /**
  27980. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  27981. */
  27982. static readonly ROTATE_TILE: number;
  27983. /**
  27984. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  27985. */
  27986. static readonly FLIP_ROW: number;
  27987. /**
  27988. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  27989. */
  27990. static readonly ROTATE_ROW: number;
  27991. /**
  27992. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  27993. */
  27994. static readonly FLIP_N_ROTATE_TILE: number;
  27995. /**
  27996. * Mesh pattern setting : rotate pattern and rotate
  27997. */
  27998. static readonly FLIP_N_ROTATE_ROW: number;
  27999. /**
  28000. * Mesh tile positioning : part tiles same on left/right or top/bottom
  28001. */
  28002. static readonly CENTER: number;
  28003. /**
  28004. * Mesh tile positioning : part tiles on left
  28005. */
  28006. static readonly LEFT: number;
  28007. /**
  28008. * Mesh tile positioning : part tiles on right
  28009. */
  28010. static readonly RIGHT: number;
  28011. /**
  28012. * Mesh tile positioning : part tiles on top
  28013. */
  28014. static readonly TOP: number;
  28015. /**
  28016. * Mesh tile positioning : part tiles on bottom
  28017. */
  28018. static readonly BOTTOM: number;
  28019. /**
  28020. * Gets the default side orientation.
  28021. * @param orientation the orientation to value to attempt to get
  28022. * @returns the default orientation
  28023. * @hidden
  28024. */
  28025. static _GetDefaultSideOrientation(orientation?: number): number;
  28026. private _internalMeshDataInfo;
  28027. get computeBonesUsingShaders(): boolean;
  28028. set computeBonesUsingShaders(value: boolean);
  28029. /**
  28030. * An event triggered before rendering the mesh
  28031. */
  28032. get onBeforeRenderObservable(): Observable<Mesh>;
  28033. /**
  28034. * An event triggered before binding the mesh
  28035. */
  28036. get onBeforeBindObservable(): Observable<Mesh>;
  28037. /**
  28038. * An event triggered after rendering the mesh
  28039. */
  28040. get onAfterRenderObservable(): Observable<Mesh>;
  28041. /**
  28042. * An event triggered before drawing the mesh
  28043. */
  28044. get onBeforeDrawObservable(): Observable<Mesh>;
  28045. private _onBeforeDrawObserver;
  28046. /**
  28047. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  28048. */
  28049. set onBeforeDraw(callback: () => void);
  28050. get hasInstances(): boolean;
  28051. get hasThinInstances(): boolean;
  28052. /**
  28053. * Gets the delay loading state of the mesh (when delay loading is turned on)
  28054. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  28055. */
  28056. delayLoadState: number;
  28057. /**
  28058. * Gets the list of instances created from this mesh
  28059. * it is not supposed to be modified manually.
  28060. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  28061. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28062. */
  28063. instances: InstancedMesh[];
  28064. /**
  28065. * Gets the file containing delay loading data for this mesh
  28066. */
  28067. delayLoadingFile: string;
  28068. /** @hidden */
  28069. _binaryInfo: any;
  28070. /**
  28071. * User defined function used to change how LOD level selection is done
  28072. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28073. */
  28074. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  28075. /**
  28076. * Gets or sets the morph target manager
  28077. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  28078. */
  28079. get morphTargetManager(): Nullable<MorphTargetManager>;
  28080. set morphTargetManager(value: Nullable<MorphTargetManager>);
  28081. /** @hidden */
  28082. _creationDataStorage: Nullable<_CreationDataStorage>;
  28083. /** @hidden */
  28084. _geometry: Nullable<Geometry>;
  28085. /** @hidden */
  28086. _delayInfo: Array<string>;
  28087. /** @hidden */
  28088. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  28089. /** @hidden */
  28090. _instanceDataStorage: _InstanceDataStorage;
  28091. /** @hidden */
  28092. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  28093. private _effectiveMaterial;
  28094. /** @hidden */
  28095. _shouldGenerateFlatShading: boolean;
  28096. /** @hidden */
  28097. _originalBuilderSideOrientation: number;
  28098. /**
  28099. * Use this property to change the original side orientation defined at construction time
  28100. */
  28101. overrideMaterialSideOrientation: Nullable<number>;
  28102. /**
  28103. * Gets the source mesh (the one used to clone this one from)
  28104. */
  28105. get source(): Nullable<Mesh>;
  28106. /**
  28107. * Gets or sets a boolean indicating that this mesh does not use index buffer
  28108. */
  28109. get isUnIndexed(): boolean;
  28110. set isUnIndexed(value: boolean);
  28111. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  28112. get worldMatrixInstancedBuffer(): Float32Array;
  28113. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  28114. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  28115. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  28116. /**
  28117. * @constructor
  28118. * @param name The value used by scene.getMeshByName() to do a lookup.
  28119. * @param scene The scene to add this mesh to.
  28120. * @param parent The parent of this mesh, if it has one
  28121. * @param source An optional Mesh from which geometry is shared, cloned.
  28122. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28123. * When false, achieved by calling a clone(), also passing False.
  28124. * This will make creation of children, recursive.
  28125. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  28126. */
  28127. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  28128. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  28129. doNotInstantiate: boolean;
  28130. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  28131. /**
  28132. * Gets the class name
  28133. * @returns the string "Mesh".
  28134. */
  28135. getClassName(): string;
  28136. /** @hidden */
  28137. get _isMesh(): boolean;
  28138. /**
  28139. * Returns a description of this mesh
  28140. * @param fullDetails define if full details about this mesh must be used
  28141. * @returns a descriptive string representing this mesh
  28142. */
  28143. toString(fullDetails?: boolean): string;
  28144. /** @hidden */
  28145. _unBindEffect(): void;
  28146. /**
  28147. * Gets a boolean indicating if this mesh has LOD
  28148. */
  28149. get hasLODLevels(): boolean;
  28150. /**
  28151. * Gets the list of MeshLODLevel associated with the current mesh
  28152. * @returns an array of MeshLODLevel
  28153. */
  28154. getLODLevels(): MeshLODLevel[];
  28155. private _sortLODLevels;
  28156. /**
  28157. * Add a mesh as LOD level triggered at the given distance.
  28158. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28159. * @param distance The distance from the center of the object to show this level
  28160. * @param mesh The mesh to be added as LOD level (can be null)
  28161. * @return This mesh (for chaining)
  28162. */
  28163. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  28164. /**
  28165. * Returns the LOD level mesh at the passed distance or null if not found.
  28166. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28167. * @param distance The distance from the center of the object to show this level
  28168. * @returns a Mesh or `null`
  28169. */
  28170. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  28171. /**
  28172. * Remove a mesh from the LOD array
  28173. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28174. * @param mesh defines the mesh to be removed
  28175. * @return This mesh (for chaining)
  28176. */
  28177. removeLODLevel(mesh: Mesh): Mesh;
  28178. /**
  28179. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  28180. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28181. * @param camera defines the camera to use to compute distance
  28182. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  28183. * @return This mesh (for chaining)
  28184. */
  28185. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  28186. /**
  28187. * Gets the mesh internal Geometry object
  28188. */
  28189. get geometry(): Nullable<Geometry>;
  28190. /**
  28191. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  28192. * @returns the total number of vertices
  28193. */
  28194. getTotalVertices(): number;
  28195. /**
  28196. * Returns the content of an associated vertex buffer
  28197. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28198. * - VertexBuffer.PositionKind
  28199. * - VertexBuffer.UVKind
  28200. * - VertexBuffer.UV2Kind
  28201. * - VertexBuffer.UV3Kind
  28202. * - VertexBuffer.UV4Kind
  28203. * - VertexBuffer.UV5Kind
  28204. * - VertexBuffer.UV6Kind
  28205. * - VertexBuffer.ColorKind
  28206. * - VertexBuffer.MatricesIndicesKind
  28207. * - VertexBuffer.MatricesIndicesExtraKind
  28208. * - VertexBuffer.MatricesWeightsKind
  28209. * - VertexBuffer.MatricesWeightsExtraKind
  28210. * @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
  28211. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  28212. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  28213. */
  28214. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  28215. /**
  28216. * Returns the mesh VertexBuffer object from the requested `kind`
  28217. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28218. * - VertexBuffer.PositionKind
  28219. * - VertexBuffer.NormalKind
  28220. * - VertexBuffer.UVKind
  28221. * - VertexBuffer.UV2Kind
  28222. * - VertexBuffer.UV3Kind
  28223. * - VertexBuffer.UV4Kind
  28224. * - VertexBuffer.UV5Kind
  28225. * - VertexBuffer.UV6Kind
  28226. * - VertexBuffer.ColorKind
  28227. * - VertexBuffer.MatricesIndicesKind
  28228. * - VertexBuffer.MatricesIndicesExtraKind
  28229. * - VertexBuffer.MatricesWeightsKind
  28230. * - VertexBuffer.MatricesWeightsExtraKind
  28231. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  28232. */
  28233. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  28234. /**
  28235. * Tests if a specific vertex buffer is associated with this mesh
  28236. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28237. * - VertexBuffer.PositionKind
  28238. * - VertexBuffer.NormalKind
  28239. * - VertexBuffer.UVKind
  28240. * - VertexBuffer.UV2Kind
  28241. * - VertexBuffer.UV3Kind
  28242. * - VertexBuffer.UV4Kind
  28243. * - VertexBuffer.UV5Kind
  28244. * - VertexBuffer.UV6Kind
  28245. * - VertexBuffer.ColorKind
  28246. * - VertexBuffer.MatricesIndicesKind
  28247. * - VertexBuffer.MatricesIndicesExtraKind
  28248. * - VertexBuffer.MatricesWeightsKind
  28249. * - VertexBuffer.MatricesWeightsExtraKind
  28250. * @returns a boolean
  28251. */
  28252. isVerticesDataPresent(kind: string): boolean;
  28253. /**
  28254. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  28255. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28256. * - VertexBuffer.PositionKind
  28257. * - VertexBuffer.UVKind
  28258. * - VertexBuffer.UV2Kind
  28259. * - VertexBuffer.UV3Kind
  28260. * - VertexBuffer.UV4Kind
  28261. * - VertexBuffer.UV5Kind
  28262. * - VertexBuffer.UV6Kind
  28263. * - VertexBuffer.ColorKind
  28264. * - VertexBuffer.MatricesIndicesKind
  28265. * - VertexBuffer.MatricesIndicesExtraKind
  28266. * - VertexBuffer.MatricesWeightsKind
  28267. * - VertexBuffer.MatricesWeightsExtraKind
  28268. * @returns a boolean
  28269. */
  28270. isVertexBufferUpdatable(kind: string): boolean;
  28271. /**
  28272. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  28273. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28274. * - VertexBuffer.PositionKind
  28275. * - VertexBuffer.NormalKind
  28276. * - VertexBuffer.UVKind
  28277. * - VertexBuffer.UV2Kind
  28278. * - VertexBuffer.UV3Kind
  28279. * - VertexBuffer.UV4Kind
  28280. * - VertexBuffer.UV5Kind
  28281. * - VertexBuffer.UV6Kind
  28282. * - VertexBuffer.ColorKind
  28283. * - VertexBuffer.MatricesIndicesKind
  28284. * - VertexBuffer.MatricesIndicesExtraKind
  28285. * - VertexBuffer.MatricesWeightsKind
  28286. * - VertexBuffer.MatricesWeightsExtraKind
  28287. * @returns an array of strings
  28288. */
  28289. getVerticesDataKinds(): string[];
  28290. /**
  28291. * Returns a positive integer : the total number of indices in this mesh geometry.
  28292. * @returns the numner of indices or zero if the mesh has no geometry.
  28293. */
  28294. getTotalIndices(): number;
  28295. /**
  28296. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28297. * @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.
  28298. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  28299. * @returns the indices array or an empty array if the mesh has no geometry
  28300. */
  28301. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  28302. get isBlocked(): boolean;
  28303. /**
  28304. * Determine if the current mesh is ready to be rendered
  28305. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28306. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  28307. * @returns true if all associated assets are ready (material, textures, shaders)
  28308. */
  28309. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  28310. /**
  28311. * 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.
  28312. */
  28313. get areNormalsFrozen(): boolean;
  28314. /**
  28315. * 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.
  28316. * @returns the current mesh
  28317. */
  28318. freezeNormals(): Mesh;
  28319. /**
  28320. * 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
  28321. * @returns the current mesh
  28322. */
  28323. unfreezeNormals(): Mesh;
  28324. /**
  28325. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  28326. */
  28327. set overridenInstanceCount(count: number);
  28328. /** @hidden */
  28329. _preActivate(): Mesh;
  28330. /** @hidden */
  28331. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28332. /** @hidden */
  28333. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  28334. protected _afterComputeWorldMatrix(): void;
  28335. /** @hidden */
  28336. _postActivate(): void;
  28337. /**
  28338. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28339. * This means the mesh underlying bounding box and sphere are recomputed.
  28340. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28341. * @returns the current mesh
  28342. */
  28343. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  28344. /** @hidden */
  28345. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  28346. /**
  28347. * This function will subdivide the mesh into multiple submeshes
  28348. * @param count defines the expected number of submeshes
  28349. */
  28350. subdivide(count: number): void;
  28351. /**
  28352. * Copy a FloatArray into a specific associated vertex buffer
  28353. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28354. * - VertexBuffer.PositionKind
  28355. * - VertexBuffer.UVKind
  28356. * - VertexBuffer.UV2Kind
  28357. * - VertexBuffer.UV3Kind
  28358. * - VertexBuffer.UV4Kind
  28359. * - VertexBuffer.UV5Kind
  28360. * - VertexBuffer.UV6Kind
  28361. * - VertexBuffer.ColorKind
  28362. * - VertexBuffer.MatricesIndicesKind
  28363. * - VertexBuffer.MatricesIndicesExtraKind
  28364. * - VertexBuffer.MatricesWeightsKind
  28365. * - VertexBuffer.MatricesWeightsExtraKind
  28366. * @param data defines the data source
  28367. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28368. * @param stride defines the data stride size (can be null)
  28369. * @returns the current mesh
  28370. */
  28371. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28372. /**
  28373. * Delete a vertex buffer associated with this mesh
  28374. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  28375. * - VertexBuffer.PositionKind
  28376. * - VertexBuffer.UVKind
  28377. * - VertexBuffer.UV2Kind
  28378. * - VertexBuffer.UV3Kind
  28379. * - VertexBuffer.UV4Kind
  28380. * - VertexBuffer.UV5Kind
  28381. * - VertexBuffer.UV6Kind
  28382. * - VertexBuffer.ColorKind
  28383. * - VertexBuffer.MatricesIndicesKind
  28384. * - VertexBuffer.MatricesIndicesExtraKind
  28385. * - VertexBuffer.MatricesWeightsKind
  28386. * - VertexBuffer.MatricesWeightsExtraKind
  28387. */
  28388. removeVerticesData(kind: string): void;
  28389. /**
  28390. * Flags an associated vertex buffer as updatable
  28391. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  28392. * - VertexBuffer.PositionKind
  28393. * - VertexBuffer.UVKind
  28394. * - VertexBuffer.UV2Kind
  28395. * - VertexBuffer.UV3Kind
  28396. * - VertexBuffer.UV4Kind
  28397. * - VertexBuffer.UV5Kind
  28398. * - VertexBuffer.UV6Kind
  28399. * - VertexBuffer.ColorKind
  28400. * - VertexBuffer.MatricesIndicesKind
  28401. * - VertexBuffer.MatricesIndicesExtraKind
  28402. * - VertexBuffer.MatricesWeightsKind
  28403. * - VertexBuffer.MatricesWeightsExtraKind
  28404. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28405. */
  28406. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  28407. /**
  28408. * Sets the mesh global Vertex Buffer
  28409. * @param buffer defines the buffer to use
  28410. * @returns the current mesh
  28411. */
  28412. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  28413. /**
  28414. * Update a specific associated vertex buffer
  28415. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28416. * - VertexBuffer.PositionKind
  28417. * - VertexBuffer.UVKind
  28418. * - VertexBuffer.UV2Kind
  28419. * - VertexBuffer.UV3Kind
  28420. * - VertexBuffer.UV4Kind
  28421. * - VertexBuffer.UV5Kind
  28422. * - VertexBuffer.UV6Kind
  28423. * - VertexBuffer.ColorKind
  28424. * - VertexBuffer.MatricesIndicesKind
  28425. * - VertexBuffer.MatricesIndicesExtraKind
  28426. * - VertexBuffer.MatricesWeightsKind
  28427. * - VertexBuffer.MatricesWeightsExtraKind
  28428. * @param data defines the data source
  28429. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  28430. * @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)
  28431. * @returns the current mesh
  28432. */
  28433. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28434. /**
  28435. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  28436. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  28437. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  28438. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  28439. * @returns the current mesh
  28440. */
  28441. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  28442. /**
  28443. * Creates a un-shared specific occurence of the geometry for the mesh.
  28444. * @returns the current mesh
  28445. */
  28446. makeGeometryUnique(): Mesh;
  28447. /**
  28448. * Set the index buffer of this mesh
  28449. * @param indices defines the source data
  28450. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  28451. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  28452. * @returns the current mesh
  28453. */
  28454. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  28455. /**
  28456. * Update the current index buffer
  28457. * @param indices defines the source data
  28458. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28459. * @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)
  28460. * @returns the current mesh
  28461. */
  28462. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28463. /**
  28464. * Invert the geometry to move from a right handed system to a left handed one.
  28465. * @returns the current mesh
  28466. */
  28467. toLeftHanded(): Mesh;
  28468. /** @hidden */
  28469. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28470. /** @hidden */
  28471. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28472. /**
  28473. * Registers for this mesh a javascript function called just before the rendering process
  28474. * @param func defines the function to call before rendering this mesh
  28475. * @returns the current mesh
  28476. */
  28477. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28478. /**
  28479. * Disposes a previously registered javascript function called before the rendering
  28480. * @param func defines the function to remove
  28481. * @returns the current mesh
  28482. */
  28483. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28484. /**
  28485. * Registers for this mesh a javascript function called just after the rendering is complete
  28486. * @param func defines the function to call after rendering this mesh
  28487. * @returns the current mesh
  28488. */
  28489. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28490. /**
  28491. * Disposes a previously registered javascript function called after the rendering.
  28492. * @param func defines the function to remove
  28493. * @returns the current mesh
  28494. */
  28495. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28496. /** @hidden */
  28497. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  28498. /** @hidden */
  28499. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  28500. /** @hidden */
  28501. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  28502. /** @hidden */
  28503. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  28504. /** @hidden */
  28505. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  28506. /** @hidden */
  28507. _rebuild(): void;
  28508. /** @hidden */
  28509. _freeze(): void;
  28510. /** @hidden */
  28511. _unFreeze(): void;
  28512. /**
  28513. * 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
  28514. * @param subMesh defines the subMesh to render
  28515. * @param enableAlphaMode defines if alpha mode can be changed
  28516. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  28517. * @returns the current mesh
  28518. */
  28519. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  28520. private _onBeforeDraw;
  28521. /**
  28522. * Renormalize the mesh and patch it up if there are no weights
  28523. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  28524. * However in the case of zero weights then we set just a single influence to 1.
  28525. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  28526. */
  28527. cleanMatrixWeights(): void;
  28528. private normalizeSkinFourWeights;
  28529. private normalizeSkinWeightsAndExtra;
  28530. /**
  28531. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  28532. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  28533. * the user know there was an issue with importing the mesh
  28534. * @returns a validation object with skinned, valid and report string
  28535. */
  28536. validateSkinning(): {
  28537. skinned: boolean;
  28538. valid: boolean;
  28539. report: string;
  28540. };
  28541. /** @hidden */
  28542. _checkDelayState(): Mesh;
  28543. private _queueLoad;
  28544. /**
  28545. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28546. * A mesh is in the frustum if its bounding box intersects the frustum
  28547. * @param frustumPlanes defines the frustum to test
  28548. * @returns true if the mesh is in the frustum planes
  28549. */
  28550. isInFrustum(frustumPlanes: Plane[]): boolean;
  28551. /**
  28552. * Sets the mesh material by the material or multiMaterial `id` property
  28553. * @param id is a string identifying the material or the multiMaterial
  28554. * @returns the current mesh
  28555. */
  28556. setMaterialByID(id: string): Mesh;
  28557. /**
  28558. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  28559. * @returns an array of IAnimatable
  28560. */
  28561. getAnimatables(): IAnimatable[];
  28562. /**
  28563. * Modifies the mesh geometry according to the passed transformation matrix.
  28564. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  28565. * The mesh normals are modified using the same transformation.
  28566. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28567. * @param transform defines the transform matrix to use
  28568. * @see https://doc.babylonjs.com/resources/baking_transformations
  28569. * @returns the current mesh
  28570. */
  28571. bakeTransformIntoVertices(transform: Matrix): Mesh;
  28572. /**
  28573. * Modifies the mesh geometry according to its own current World Matrix.
  28574. * The mesh World Matrix is then reset.
  28575. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  28576. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28577. * @see https://doc.babylonjs.com/resources/baking_transformations
  28578. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  28579. * @returns the current mesh
  28580. */
  28581. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  28582. /** @hidden */
  28583. get _positions(): Nullable<Vector3[]>;
  28584. /** @hidden */
  28585. _resetPointsArrayCache(): Mesh;
  28586. /** @hidden */
  28587. _generatePointsArray(): boolean;
  28588. /**
  28589. * Returns a new Mesh object generated from the current mesh properties.
  28590. * This method must not get confused with createInstance()
  28591. * @param name is a string, the name given to the new mesh
  28592. * @param newParent can be any Node object (default `null`)
  28593. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  28594. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  28595. * @returns a new mesh
  28596. */
  28597. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  28598. /**
  28599. * Releases resources associated with this mesh.
  28600. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28601. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28602. */
  28603. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28604. /** @hidden */
  28605. _disposeInstanceSpecificData(): void;
  28606. /** @hidden */
  28607. _disposeThinInstanceSpecificData(): void;
  28608. /**
  28609. * Modifies the mesh geometry according to a displacement map.
  28610. * 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.
  28611. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28612. * @param url is a string, the URL from the image file is to be downloaded.
  28613. * @param minHeight is the lower limit of the displacement.
  28614. * @param maxHeight is the upper limit of the displacement.
  28615. * @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.
  28616. * @param uvOffset is an optional vector2 used to offset UV.
  28617. * @param uvScale is an optional vector2 used to scale UV.
  28618. * @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.
  28619. * @returns the Mesh.
  28620. */
  28621. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28622. /**
  28623. * Modifies the mesh geometry according to a displacementMap buffer.
  28624. * 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.
  28625. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28626. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  28627. * @param heightMapWidth is the width of the buffer image.
  28628. * @param heightMapHeight is the height of the buffer image.
  28629. * @param minHeight is the lower limit of the displacement.
  28630. * @param maxHeight is the upper limit of the displacement.
  28631. * @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.
  28632. * @param uvOffset is an optional vector2 used to offset UV.
  28633. * @param uvScale is an optional vector2 used to scale UV.
  28634. * @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.
  28635. * @returns the Mesh.
  28636. */
  28637. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28638. /**
  28639. * Modify the mesh to get a flat shading rendering.
  28640. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  28641. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  28642. * @returns current mesh
  28643. */
  28644. convertToFlatShadedMesh(): Mesh;
  28645. /**
  28646. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  28647. * In other words, more vertices, no more indices and a single bigger VBO.
  28648. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  28649. * @returns current mesh
  28650. */
  28651. convertToUnIndexedMesh(): Mesh;
  28652. /**
  28653. * Inverses facet orientations.
  28654. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28655. * @param flipNormals will also inverts the normals
  28656. * @returns current mesh
  28657. */
  28658. flipFaces(flipNormals?: boolean): Mesh;
  28659. /**
  28660. * Increase the number of facets and hence vertices in a mesh
  28661. * Vertex normals are interpolated from existing vertex normals
  28662. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28663. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  28664. */
  28665. increaseVertices(numberPerEdge: number): void;
  28666. /**
  28667. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  28668. * This will undo any application of covertToFlatShadedMesh
  28669. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28670. */
  28671. forceSharedVertices(): void;
  28672. /** @hidden */
  28673. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  28674. /** @hidden */
  28675. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  28676. /**
  28677. * Creates a new InstancedMesh object from the mesh model.
  28678. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28679. * @param name defines the name of the new instance
  28680. * @returns a new InstancedMesh
  28681. */
  28682. createInstance(name: string): InstancedMesh;
  28683. /**
  28684. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  28685. * After this call, all the mesh instances have the same submeshes than the current mesh.
  28686. * @returns the current mesh
  28687. */
  28688. synchronizeInstances(): Mesh;
  28689. /**
  28690. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  28691. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  28692. * This should be used together with the simplification to avoid disappearing triangles.
  28693. * @param successCallback an optional success callback to be called after the optimization finished.
  28694. * @returns the current mesh
  28695. */
  28696. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  28697. /**
  28698. * Serialize current mesh
  28699. * @param serializationObject defines the object which will receive the serialization data
  28700. */
  28701. serialize(serializationObject: any): void;
  28702. /** @hidden */
  28703. _syncGeometryWithMorphTargetManager(): void;
  28704. /** @hidden */
  28705. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  28706. /**
  28707. * Returns a new Mesh object parsed from the source provided.
  28708. * @param parsedMesh is the source
  28709. * @param scene defines the hosting scene
  28710. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  28711. * @returns a new Mesh
  28712. */
  28713. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  28714. /**
  28715. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  28716. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28717. * @param name defines the name of the mesh to create
  28718. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  28719. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  28720. * @param closePath creates a seam between the first and the last points of each path of the path array
  28721. * @param offset is taken in account only if the `pathArray` is containing a single path
  28722. * @param scene defines the hosting scene
  28723. * @param updatable defines if the mesh must be flagged as updatable
  28724. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28725. * @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)
  28726. * @returns a new Mesh
  28727. */
  28728. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28729. /**
  28730. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  28731. * @param name defines the name of the mesh to create
  28732. * @param radius sets the radius size (float) of the polygon (default 0.5)
  28733. * @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
  28734. * @param scene defines the hosting scene
  28735. * @param updatable defines if the mesh must be flagged as updatable
  28736. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28737. * @returns a new Mesh
  28738. */
  28739. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28740. /**
  28741. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  28742. * @param name defines the name of the mesh to create
  28743. * @param size sets the size (float) of each box side (default 1)
  28744. * @param scene defines the hosting scene
  28745. * @param updatable defines if the mesh must be flagged as updatable
  28746. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28747. * @returns a new Mesh
  28748. */
  28749. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28750. /**
  28751. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  28752. * @param name defines the name of the mesh to create
  28753. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28754. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28755. * @param scene defines the hosting scene
  28756. * @param updatable defines if the mesh must be flagged as updatable
  28757. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28758. * @returns a new Mesh
  28759. */
  28760. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28761. /**
  28762. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  28763. * @param name defines the name of the mesh to create
  28764. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  28765. * @param diameter sets the diameter size (float) of the sphere (default 1)
  28766. * @param scene defines the hosting scene
  28767. * @returns a new Mesh
  28768. */
  28769. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  28770. /**
  28771. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  28772. * @param name defines the name of the mesh to create
  28773. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  28774. * @param diameterTop set the top cap diameter (floats, default 1)
  28775. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  28776. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  28777. * @param subdivisions sets the number of rings along the cylinder height (positive integer, 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 CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  28784. /**
  28785. * Creates a torus 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 diameter sets the diameter size (float) of the torus (default 1)
  28788. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  28789. * @param tessellation sets the number of torus sides (postive integer, default 16)
  28790. * @param scene defines the hosting scene
  28791. * @param updatable defines if the mesh must be flagged as updatable
  28792. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28793. * @returns a new Mesh
  28794. */
  28795. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28796. /**
  28797. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  28798. * @param name defines the name of the mesh to create
  28799. * @param radius sets the global radius size (float) of the torus knot (default 2)
  28800. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  28801. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  28802. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  28803. * @param p the number of windings on X axis (positive integers, default 2)
  28804. * @param q the number of windings on Y axis (positive integers, default 3)
  28805. * @param scene defines the hosting scene
  28806. * @param updatable defines if the mesh must be flagged as updatable
  28807. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28808. * @returns a new Mesh
  28809. */
  28810. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28811. /**
  28812. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  28813. * @param name defines the name of the mesh to create
  28814. * @param points is an array successive Vector3
  28815. * @param scene defines the hosting scene
  28816. * @param updatable defines if the mesh must be flagged as updatable
  28817. * @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).
  28818. * @returns a new Mesh
  28819. */
  28820. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  28821. /**
  28822. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  28823. * @param name defines the name of the mesh to create
  28824. * @param points is an array successive Vector3
  28825. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  28826. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  28827. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  28828. * @param scene defines the hosting scene
  28829. * @param updatable defines if the mesh must be flagged as updatable
  28830. * @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)
  28831. * @returns a new Mesh
  28832. */
  28833. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  28834. /**
  28835. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  28836. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  28837. * 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.
  28838. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  28839. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  28840. * Remember you can only change the shape positions, not their number when updating a polygon.
  28841. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  28842. * @param name defines the name of the mesh to create
  28843. * @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
  28844. * @param scene defines the hosting scene
  28845. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28846. * @param updatable defines if the mesh must be flagged as updatable
  28847. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28848. * @param earcutInjection can be used to inject your own earcut reference
  28849. * @returns a new Mesh
  28850. */
  28851. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28852. /**
  28853. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  28854. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  28855. * @param name defines the name of the mesh to create
  28856. * @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
  28857. * @param depth defines the height of extrusion
  28858. * @param scene defines the hosting scene
  28859. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  28860. * @param updatable defines if the mesh must be flagged as updatable
  28861. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28862. * @param earcutInjection can be used to inject your own earcut reference
  28863. * @returns a new Mesh
  28864. */
  28865. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  28866. /**
  28867. * Creates an extruded shape mesh.
  28868. * 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
  28869. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28870. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28871. * @param name defines the name of the mesh to create
  28872. * @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
  28873. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28874. * @param scale is the value to scale the shape
  28875. * @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
  28876. * @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
  28877. * @param scene defines the hosting scene
  28878. * @param updatable defines if the mesh must be flagged as updatable
  28879. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28880. * @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)
  28881. * @returns a new Mesh
  28882. */
  28883. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28884. /**
  28885. * Creates an custom extruded shape mesh.
  28886. * The custom extrusion is a parametric shape.
  28887. * It has no predefined shape. Its final shape will depend on the input parameters.
  28888. * Please consider using the same method from the MeshBuilder class instead
  28889. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  28890. * @param name defines the name of the mesh to create
  28891. * @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
  28892. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  28893. * @param scaleFunction is a custom Javascript function called on each path point
  28894. * @param rotationFunction is a custom Javascript function called on each path point
  28895. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  28896. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  28897. * @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
  28898. * @param scene defines the hosting scene
  28899. * @param updatable defines if the mesh must be flagged as updatable
  28900. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28901. * @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)
  28902. * @returns a new Mesh
  28903. */
  28904. 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;
  28905. /**
  28906. * Creates lathe mesh.
  28907. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  28908. * Please consider using the same method from the MeshBuilder class instead
  28909. * @param name defines the name of the mesh to create
  28910. * @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
  28911. * @param radius is the radius value of the lathe
  28912. * @param tessellation is the side number of the lathe.
  28913. * @param scene defines the hosting scene
  28914. * @param updatable defines if the mesh must be flagged as updatable
  28915. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28916. * @returns a new Mesh
  28917. */
  28918. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28919. /**
  28920. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  28921. * @param name defines the name of the mesh to create
  28922. * @param size sets the size (float) of both sides of the plane at once (default 1)
  28923. * @param scene defines the hosting scene
  28924. * @param updatable defines if the mesh must be flagged as updatable
  28925. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28926. * @returns a new Mesh
  28927. */
  28928. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  28929. /**
  28930. * Creates a ground mesh.
  28931. * Please consider using the same method from the MeshBuilder class instead
  28932. * @param name defines the name of the mesh to create
  28933. * @param width set the width of the ground
  28934. * @param height set the height of the ground
  28935. * @param subdivisions sets the number of subdivisions per side
  28936. * @param scene defines the hosting scene
  28937. * @param updatable defines if the mesh must be flagged as updatable
  28938. * @returns a new Mesh
  28939. */
  28940. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  28941. /**
  28942. * Creates a tiled ground mesh.
  28943. * Please consider using the same method from the MeshBuilder class instead
  28944. * @param name defines the name of the mesh to create
  28945. * @param xmin set the ground minimum X coordinate
  28946. * @param zmin set the ground minimum Y coordinate
  28947. * @param xmax set the ground maximum X coordinate
  28948. * @param zmax set the ground maximum Z coordinate
  28949. * @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
  28950. * @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
  28951. * @param scene defines the hosting scene
  28952. * @param updatable defines if the mesh must be flagged as updatable
  28953. * @returns a new Mesh
  28954. */
  28955. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  28956. w: number;
  28957. h: number;
  28958. }, precision: {
  28959. w: number;
  28960. h: number;
  28961. }, scene: Scene, updatable?: boolean): Mesh;
  28962. /**
  28963. * Creates a ground mesh from a height map.
  28964. * Please consider using the same method from the MeshBuilder class instead
  28965. * @see https://doc.babylonjs.com/babylon101/height_map
  28966. * @param name defines the name of the mesh to create
  28967. * @param url sets the URL of the height map image resource
  28968. * @param width set the ground width size
  28969. * @param height set the ground height size
  28970. * @param subdivisions sets the number of subdivision per side
  28971. * @param minHeight is the minimum altitude on the ground
  28972. * @param maxHeight is the maximum altitude on the ground
  28973. * @param scene defines the hosting scene
  28974. * @param updatable defines if the mesh must be flagged as updatable
  28975. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  28976. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  28977. * @returns a new Mesh
  28978. */
  28979. 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;
  28980. /**
  28981. * Creates a tube mesh.
  28982. * The tube is a parametric shape.
  28983. * It has no predefined shape. Its final shape will depend on the input parameters.
  28984. * Please consider using the same method from the MeshBuilder class instead
  28985. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28986. * @param name defines the name of the mesh to create
  28987. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  28988. * @param radius sets the tube radius size
  28989. * @param tessellation is the number of sides on the tubular surface
  28990. * @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
  28991. * @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
  28992. * @param scene defines the hosting scene
  28993. * @param updatable defines if the mesh must be flagged as updatable
  28994. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28995. * @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)
  28996. * @returns a new Mesh
  28997. */
  28998. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  28999. (i: number, distance: number): number;
  29000. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29001. /**
  29002. * Creates a polyhedron mesh.
  29003. * Please consider using the same method from the MeshBuilder class instead.
  29004. * * 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
  29005. * * The parameter `size` (positive float, default 1) sets the polygon size
  29006. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  29007. * * 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`
  29008. * * 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
  29009. * * 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)`)
  29010. * * 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
  29011. * * 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
  29012. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29013. * * 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
  29014. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29015. * @param name defines the name of the mesh to create
  29016. * @param options defines the options used to create the mesh
  29017. * @param scene defines the hosting scene
  29018. * @returns a new Mesh
  29019. */
  29020. static CreatePolyhedron(name: string, options: {
  29021. type?: number;
  29022. size?: number;
  29023. sizeX?: number;
  29024. sizeY?: number;
  29025. sizeZ?: number;
  29026. custom?: any;
  29027. faceUV?: Vector4[];
  29028. faceColors?: Color4[];
  29029. updatable?: boolean;
  29030. sideOrientation?: number;
  29031. }, scene: Scene): Mesh;
  29032. /**
  29033. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  29034. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  29035. * * 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`)
  29036. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  29037. * * 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
  29038. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29039. * * 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
  29040. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29041. * @param name defines the name of the mesh
  29042. * @param options defines the options used to create the mesh
  29043. * @param scene defines the hosting scene
  29044. * @returns a new Mesh
  29045. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  29046. */
  29047. static CreateIcoSphere(name: string, options: {
  29048. radius?: number;
  29049. flat?: boolean;
  29050. subdivisions?: number;
  29051. sideOrientation?: number;
  29052. updatable?: boolean;
  29053. }, scene: Scene): Mesh;
  29054. /**
  29055. * Creates a decal mesh.
  29056. * Please consider using the same method from the MeshBuilder class instead.
  29057. * A decal is a mesh usually applied as a model onto the surface of another mesh
  29058. * @param name defines the name of the mesh
  29059. * @param sourceMesh defines the mesh receiving the decal
  29060. * @param position sets the position of the decal in world coordinates
  29061. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  29062. * @param size sets the decal scaling
  29063. * @param angle sets the angle to rotate the decal
  29064. * @returns a new Mesh
  29065. */
  29066. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  29067. /**
  29068. * Prepare internal position array for software CPU skinning
  29069. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  29070. */
  29071. setPositionsForCPUSkinning(): Float32Array;
  29072. /**
  29073. * Prepare internal normal array for software CPU skinning
  29074. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  29075. */
  29076. setNormalsForCPUSkinning(): Float32Array;
  29077. /**
  29078. * Updates the vertex buffer by applying transformation from the bones
  29079. * @param skeleton defines the skeleton to apply to current mesh
  29080. * @returns the current mesh
  29081. */
  29082. applySkeleton(skeleton: Skeleton): Mesh;
  29083. /**
  29084. * 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
  29085. * @param meshes defines the list of meshes to scan
  29086. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  29087. */
  29088. static MinMax(meshes: AbstractMesh[]): {
  29089. min: Vector3;
  29090. max: Vector3;
  29091. };
  29092. /**
  29093. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  29094. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  29095. * @returns a vector3
  29096. */
  29097. static Center(meshesOrMinMaxVector: {
  29098. min: Vector3;
  29099. max: Vector3;
  29100. } | AbstractMesh[]): Vector3;
  29101. /**
  29102. * Merge the array of meshes into a single mesh for performance reasons.
  29103. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  29104. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  29105. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  29106. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  29107. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  29108. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  29109. * @returns a new mesh
  29110. */
  29111. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  29112. /** @hidden */
  29113. addInstance(instance: InstancedMesh): void;
  29114. /** @hidden */
  29115. removeInstance(instance: InstancedMesh): void;
  29116. }
  29117. }
  29118. declare module BABYLON {
  29119. /**
  29120. * This is the base class of all the camera used in the application.
  29121. * @see https://doc.babylonjs.com/features/cameras
  29122. */
  29123. export class Camera extends Node {
  29124. /** @hidden */
  29125. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29126. /**
  29127. * This is the default projection mode used by the cameras.
  29128. * It helps recreating a feeling of perspective and better appreciate depth.
  29129. * This is the best way to simulate real life cameras.
  29130. */
  29131. static readonly PERSPECTIVE_CAMERA: number;
  29132. /**
  29133. * This helps creating camera with an orthographic mode.
  29134. * 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.
  29135. */
  29136. static readonly ORTHOGRAPHIC_CAMERA: number;
  29137. /**
  29138. * This is the default FOV mode for perspective cameras.
  29139. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29140. */
  29141. static readonly FOVMODE_VERTICAL_FIXED: number;
  29142. /**
  29143. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29144. */
  29145. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29146. /**
  29147. * This specifies ther is no need for a camera rig.
  29148. * Basically only one eye is rendered corresponding to the camera.
  29149. */
  29150. static readonly RIG_MODE_NONE: number;
  29151. /**
  29152. * Simulates a camera Rig with one blue eye and one red eye.
  29153. * This can be use with 3d blue and red glasses.
  29154. */
  29155. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29156. /**
  29157. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29158. */
  29159. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29160. /**
  29161. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29162. */
  29163. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29164. /**
  29165. * Defines that both eyes of the camera will be rendered over under each other.
  29166. */
  29167. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29168. /**
  29169. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  29170. */
  29171. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  29172. /**
  29173. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29174. */
  29175. static readonly RIG_MODE_VR: number;
  29176. /**
  29177. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29178. */
  29179. static readonly RIG_MODE_WEBVR: number;
  29180. /**
  29181. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29182. */
  29183. static readonly RIG_MODE_CUSTOM: number;
  29184. /**
  29185. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29186. */
  29187. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29188. /**
  29189. * Define the input manager associated with the camera.
  29190. */
  29191. inputs: CameraInputsManager<Camera>;
  29192. /** @hidden */
  29193. _position: Vector3;
  29194. /**
  29195. * Define the current local position of the camera in the scene
  29196. */
  29197. get position(): Vector3;
  29198. set position(newPosition: Vector3);
  29199. /**
  29200. * The vector the camera should consider as up.
  29201. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29202. */
  29203. upVector: Vector3;
  29204. /**
  29205. * Define the current limit on the left side for an orthographic camera
  29206. * In scene unit
  29207. */
  29208. orthoLeft: Nullable<number>;
  29209. /**
  29210. * Define the current limit on the right side for an orthographic camera
  29211. * In scene unit
  29212. */
  29213. orthoRight: Nullable<number>;
  29214. /**
  29215. * Define the current limit on the bottom side for an orthographic camera
  29216. * In scene unit
  29217. */
  29218. orthoBottom: Nullable<number>;
  29219. /**
  29220. * Define the current limit on the top side for an orthographic camera
  29221. * In scene unit
  29222. */
  29223. orthoTop: Nullable<number>;
  29224. /**
  29225. * Field Of View is set in Radians. (default is 0.8)
  29226. */
  29227. fov: number;
  29228. /**
  29229. * Define the minimum distance the camera can see from.
  29230. * This is important to note that the depth buffer are not infinite and the closer it starts
  29231. * the more your scene might encounter depth fighting issue.
  29232. */
  29233. minZ: number;
  29234. /**
  29235. * Define the maximum distance the camera can see to.
  29236. * This is important to note that the depth buffer are not infinite and the further it end
  29237. * the more your scene might encounter depth fighting issue.
  29238. */
  29239. maxZ: number;
  29240. /**
  29241. * Define the default inertia of the camera.
  29242. * This helps giving a smooth feeling to the camera movement.
  29243. */
  29244. inertia: number;
  29245. /**
  29246. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  29247. */
  29248. mode: number;
  29249. /**
  29250. * Define whether the camera is intermediate.
  29251. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29252. */
  29253. isIntermediate: boolean;
  29254. /**
  29255. * Define the viewport of the camera.
  29256. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29257. */
  29258. viewport: Viewport;
  29259. /**
  29260. * Restricts the camera to viewing objects with the same layerMask.
  29261. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29262. */
  29263. layerMask: number;
  29264. /**
  29265. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29266. */
  29267. fovMode: number;
  29268. /**
  29269. * Rig mode of the camera.
  29270. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29271. * This is normally controlled byt the camera themselves as internal use.
  29272. */
  29273. cameraRigMode: number;
  29274. /**
  29275. * Defines the distance between both "eyes" in case of a RIG
  29276. */
  29277. interaxialDistance: number;
  29278. /**
  29279. * Defines if stereoscopic rendering is done side by side or over under.
  29280. */
  29281. isStereoscopicSideBySide: boolean;
  29282. /**
  29283. * 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
  29284. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29285. * else in the scene. (Eg. security camera)
  29286. *
  29287. * 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)
  29288. */
  29289. customRenderTargets: RenderTargetTexture[];
  29290. /**
  29291. * When set, the camera will render to this render target instead of the default canvas
  29292. *
  29293. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  29294. */
  29295. outputRenderTarget: Nullable<RenderTargetTexture>;
  29296. /**
  29297. * Observable triggered when the camera view matrix has changed.
  29298. */
  29299. onViewMatrixChangedObservable: Observable<Camera>;
  29300. /**
  29301. * Observable triggered when the camera Projection matrix has changed.
  29302. */
  29303. onProjectionMatrixChangedObservable: Observable<Camera>;
  29304. /**
  29305. * Observable triggered when the inputs have been processed.
  29306. */
  29307. onAfterCheckInputsObservable: Observable<Camera>;
  29308. /**
  29309. * Observable triggered when reset has been called and applied to the camera.
  29310. */
  29311. onRestoreStateObservable: Observable<Camera>;
  29312. /**
  29313. * Is this camera a part of a rig system?
  29314. */
  29315. isRigCamera: boolean;
  29316. /**
  29317. * If isRigCamera set to true this will be set with the parent camera.
  29318. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  29319. */
  29320. rigParent?: Camera;
  29321. /** @hidden */
  29322. _cameraRigParams: any;
  29323. /** @hidden */
  29324. _rigCameras: Camera[];
  29325. /** @hidden */
  29326. _rigPostProcess: Nullable<PostProcess>;
  29327. protected _webvrViewMatrix: Matrix;
  29328. /** @hidden */
  29329. _skipRendering: boolean;
  29330. /** @hidden */
  29331. _projectionMatrix: Matrix;
  29332. /** @hidden */
  29333. _postProcesses: Nullable<PostProcess>[];
  29334. /** @hidden */
  29335. _activeMeshes: SmartArray<AbstractMesh>;
  29336. protected _globalPosition: Vector3;
  29337. /** @hidden */
  29338. _computedViewMatrix: Matrix;
  29339. private _doNotComputeProjectionMatrix;
  29340. private _transformMatrix;
  29341. private _frustumPlanes;
  29342. private _refreshFrustumPlanes;
  29343. private _storedFov;
  29344. private _stateStored;
  29345. /**
  29346. * Instantiates a new camera object.
  29347. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29348. * @see https://doc.babylonjs.com/features/cameras
  29349. * @param name Defines the name of the camera in the scene
  29350. * @param position Defines the position of the camera
  29351. * @param scene Defines the scene the camera belongs too
  29352. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29353. */
  29354. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29355. /**
  29356. * Store current camera state (fov, position, etc..)
  29357. * @returns the camera
  29358. */
  29359. storeState(): Camera;
  29360. /**
  29361. * Restores the camera state values if it has been stored. You must call storeState() first
  29362. */
  29363. protected _restoreStateValues(): boolean;
  29364. /**
  29365. * Restored camera state. You must call storeState() first.
  29366. * @returns true if restored and false otherwise
  29367. */
  29368. restoreState(): boolean;
  29369. /**
  29370. * Gets the class name of the camera.
  29371. * @returns the class name
  29372. */
  29373. getClassName(): string;
  29374. /** @hidden */
  29375. readonly _isCamera: boolean;
  29376. /**
  29377. * Gets a string representation of the camera useful for debug purpose.
  29378. * @param fullDetails Defines that a more verboe level of logging is required
  29379. * @returns the string representation
  29380. */
  29381. toString(fullDetails?: boolean): string;
  29382. /**
  29383. * Gets the current world space position of the camera.
  29384. */
  29385. get globalPosition(): Vector3;
  29386. /**
  29387. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29388. * @returns the active meshe list
  29389. */
  29390. getActiveMeshes(): SmartArray<AbstractMesh>;
  29391. /**
  29392. * Check whether a mesh is part of the current active mesh list of the camera
  29393. * @param mesh Defines the mesh to check
  29394. * @returns true if active, false otherwise
  29395. */
  29396. isActiveMesh(mesh: Mesh): boolean;
  29397. /**
  29398. * Is this camera ready to be used/rendered
  29399. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29400. * @return true if the camera is ready
  29401. */
  29402. isReady(completeCheck?: boolean): boolean;
  29403. /** @hidden */
  29404. _initCache(): void;
  29405. /** @hidden */
  29406. _updateCache(ignoreParentClass?: boolean): void;
  29407. /** @hidden */
  29408. _isSynchronized(): boolean;
  29409. /** @hidden */
  29410. _isSynchronizedViewMatrix(): boolean;
  29411. /** @hidden */
  29412. _isSynchronizedProjectionMatrix(): boolean;
  29413. /**
  29414. * Attach the input controls to a specific dom element to get the input from.
  29415. * @param element Defines the element the controls should be listened from
  29416. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29417. */
  29418. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29419. /**
  29420. * Detach the current controls from the specified dom element.
  29421. * @param element Defines the element to stop listening the inputs from
  29422. */
  29423. detachControl(element: HTMLElement): void;
  29424. /**
  29425. * Update the camera state according to the different inputs gathered during the frame.
  29426. */
  29427. update(): void;
  29428. /** @hidden */
  29429. _checkInputs(): void;
  29430. /** @hidden */
  29431. get rigCameras(): Camera[];
  29432. /**
  29433. * Gets the post process used by the rig cameras
  29434. */
  29435. get rigPostProcess(): Nullable<PostProcess>;
  29436. /**
  29437. * Internal, gets the first post proces.
  29438. * @returns the first post process to be run on this camera.
  29439. */
  29440. _getFirstPostProcess(): Nullable<PostProcess>;
  29441. private _cascadePostProcessesToRigCams;
  29442. /**
  29443. * Attach a post process to the camera.
  29444. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29445. * @param postProcess The post process to attach to the camera
  29446. * @param insertAt The position of the post process in case several of them are in use in the scene
  29447. * @returns the position the post process has been inserted at
  29448. */
  29449. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29450. /**
  29451. * Detach a post process to the camera.
  29452. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29453. * @param postProcess The post process to detach from the camera
  29454. */
  29455. detachPostProcess(postProcess: PostProcess): void;
  29456. /**
  29457. * Gets the current world matrix of the camera
  29458. */
  29459. getWorldMatrix(): Matrix;
  29460. /** @hidden */
  29461. _getViewMatrix(): Matrix;
  29462. /**
  29463. * Gets the current view matrix of the camera.
  29464. * @param force forces the camera to recompute the matrix without looking at the cached state
  29465. * @returns the view matrix
  29466. */
  29467. getViewMatrix(force?: boolean): Matrix;
  29468. /**
  29469. * Freeze the projection matrix.
  29470. * It will prevent the cache check of the camera projection compute and can speed up perf
  29471. * if no parameter of the camera are meant to change
  29472. * @param projection Defines manually a projection if necessary
  29473. */
  29474. freezeProjectionMatrix(projection?: Matrix): void;
  29475. /**
  29476. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29477. */
  29478. unfreezeProjectionMatrix(): void;
  29479. /**
  29480. * Gets the current projection matrix of the camera.
  29481. * @param force forces the camera to recompute the matrix without looking at the cached state
  29482. * @returns the projection matrix
  29483. */
  29484. getProjectionMatrix(force?: boolean): Matrix;
  29485. /**
  29486. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29487. * @returns a Matrix
  29488. */
  29489. getTransformationMatrix(): Matrix;
  29490. private _updateFrustumPlanes;
  29491. /**
  29492. * Checks if a cullable object (mesh...) is in the camera frustum
  29493. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29494. * @param target The object to check
  29495. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  29496. * @returns true if the object is in frustum otherwise false
  29497. */
  29498. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  29499. /**
  29500. * Checks if a cullable object (mesh...) is in the camera frustum
  29501. * Unlike isInFrustum this cheks the full bounding box
  29502. * @param target The object to check
  29503. * @returns true if the object is in frustum otherwise false
  29504. */
  29505. isCompletelyInFrustum(target: ICullable): boolean;
  29506. /**
  29507. * Gets a ray in the forward direction from the camera.
  29508. * @param length Defines the length of the ray to create
  29509. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29510. * @param origin Defines the start point of the ray which defaults to the camera position
  29511. * @returns the forward ray
  29512. */
  29513. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29514. /**
  29515. * Gets a ray in the forward direction from the camera.
  29516. * @param refRay the ray to (re)use when setting the values
  29517. * @param length Defines the length of the ray to create
  29518. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29519. * @param origin Defines the start point of the ray which defaults to the camera position
  29520. * @returns the forward ray
  29521. */
  29522. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29523. /**
  29524. * Releases resources associated with this node.
  29525. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29526. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29527. */
  29528. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29529. /** @hidden */
  29530. _isLeftCamera: boolean;
  29531. /**
  29532. * Gets the left camera of a rig setup in case of Rigged Camera
  29533. */
  29534. get isLeftCamera(): boolean;
  29535. /** @hidden */
  29536. _isRightCamera: boolean;
  29537. /**
  29538. * Gets the right camera of a rig setup in case of Rigged Camera
  29539. */
  29540. get isRightCamera(): boolean;
  29541. /**
  29542. * Gets the left camera of a rig setup in case of Rigged Camera
  29543. */
  29544. get leftCamera(): Nullable<FreeCamera>;
  29545. /**
  29546. * Gets the right camera of a rig setup in case of Rigged Camera
  29547. */
  29548. get rightCamera(): Nullable<FreeCamera>;
  29549. /**
  29550. * Gets the left camera target of a rig setup in case of Rigged Camera
  29551. * @returns the target position
  29552. */
  29553. getLeftTarget(): Nullable<Vector3>;
  29554. /**
  29555. * Gets the right camera target of a rig setup in case of Rigged Camera
  29556. * @returns the target position
  29557. */
  29558. getRightTarget(): Nullable<Vector3>;
  29559. /**
  29560. * @hidden
  29561. */
  29562. setCameraRigMode(mode: number, rigParams: any): void;
  29563. /** @hidden */
  29564. static _setStereoscopicRigMode(camera: Camera): void;
  29565. /** @hidden */
  29566. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29567. /** @hidden */
  29568. static _setVRRigMode(camera: Camera, rigParams: any): void;
  29569. /** @hidden */
  29570. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29571. /** @hidden */
  29572. _getVRProjectionMatrix(): Matrix;
  29573. protected _updateCameraRotationMatrix(): void;
  29574. protected _updateWebVRCameraRotationMatrix(): void;
  29575. /**
  29576. * This function MUST be overwritten by the different WebVR cameras available.
  29577. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29578. * @hidden
  29579. */
  29580. _getWebVRProjectionMatrix(): Matrix;
  29581. /**
  29582. * This function MUST be overwritten by the different WebVR cameras available.
  29583. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29584. * @hidden
  29585. */
  29586. _getWebVRViewMatrix(): Matrix;
  29587. /** @hidden */
  29588. setCameraRigParameter(name: string, value: any): void;
  29589. /**
  29590. * needs to be overridden by children so sub has required properties to be copied
  29591. * @hidden
  29592. */
  29593. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29594. /**
  29595. * May need to be overridden by children
  29596. * @hidden
  29597. */
  29598. _updateRigCameras(): void;
  29599. /** @hidden */
  29600. _setupInputs(): void;
  29601. /**
  29602. * Serialiaze the camera setup to a json represention
  29603. * @returns the JSON representation
  29604. */
  29605. serialize(): any;
  29606. /**
  29607. * Clones the current camera.
  29608. * @param name The cloned camera name
  29609. * @returns the cloned camera
  29610. */
  29611. clone(name: string): Camera;
  29612. /**
  29613. * Gets the direction of the camera relative to a given local axis.
  29614. * @param localAxis Defines the reference axis to provide a relative direction.
  29615. * @return the direction
  29616. */
  29617. getDirection(localAxis: Vector3): Vector3;
  29618. /**
  29619. * Returns the current camera absolute rotation
  29620. */
  29621. get absoluteRotation(): Quaternion;
  29622. /**
  29623. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29624. * @param localAxis Defines the reference axis to provide a relative direction.
  29625. * @param result Defines the vector to store the result in
  29626. */
  29627. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29628. /**
  29629. * Gets a camera constructor for a given camera type
  29630. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29631. * @param name The name of the camera the result will be able to instantiate
  29632. * @param scene The scene the result will construct the camera in
  29633. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29634. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29635. * @returns a factory method to construc the camera
  29636. */
  29637. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29638. /**
  29639. * Compute the world matrix of the camera.
  29640. * @returns the camera world matrix
  29641. */
  29642. computeWorldMatrix(): Matrix;
  29643. /**
  29644. * Parse a JSON and creates the camera from the parsed information
  29645. * @param parsedCamera The JSON to parse
  29646. * @param scene The scene to instantiate the camera in
  29647. * @returns the newly constructed camera
  29648. */
  29649. static Parse(parsedCamera: any, scene: Scene): Camera;
  29650. }
  29651. }
  29652. declare module BABYLON {
  29653. /**
  29654. * Class containing static functions to help procedurally build meshes
  29655. */
  29656. export class DiscBuilder {
  29657. /**
  29658. * Creates a plane polygonal mesh. By default, this is a disc
  29659. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  29660. * * 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
  29661. * * 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
  29662. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29663. * * 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
  29664. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29665. * @param name defines the name of the mesh
  29666. * @param options defines the options used to create the mesh
  29667. * @param scene defines the hosting scene
  29668. * @returns the plane polygonal mesh
  29669. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  29670. */
  29671. static CreateDisc(name: string, options: {
  29672. radius?: number;
  29673. tessellation?: number;
  29674. arc?: number;
  29675. updatable?: boolean;
  29676. sideOrientation?: number;
  29677. frontUVs?: Vector4;
  29678. backUVs?: Vector4;
  29679. }, scene?: Nullable<Scene>): Mesh;
  29680. }
  29681. }
  29682. declare module BABYLON {
  29683. /**
  29684. * Options to be used when creating a FresnelParameters.
  29685. */
  29686. export type IFresnelParametersCreationOptions = {
  29687. /**
  29688. * Define the color used on edges (grazing angle)
  29689. */
  29690. leftColor?: Color3;
  29691. /**
  29692. * Define the color used on center
  29693. */
  29694. rightColor?: Color3;
  29695. /**
  29696. * Define bias applied to computed fresnel term
  29697. */
  29698. bias?: number;
  29699. /**
  29700. * Defined the power exponent applied to fresnel term
  29701. */
  29702. power?: number;
  29703. /**
  29704. * Define if the fresnel effect is enable or not.
  29705. */
  29706. isEnabled?: boolean;
  29707. };
  29708. /**
  29709. * Serialized format for FresnelParameters.
  29710. */
  29711. export type IFresnelParametersSerialized = {
  29712. /**
  29713. * Define the color used on edges (grazing angle) [as an array]
  29714. */
  29715. leftColor: number[];
  29716. /**
  29717. * Define the color used on center [as an array]
  29718. */
  29719. rightColor: number[];
  29720. /**
  29721. * Define bias applied to computed fresnel term
  29722. */
  29723. bias: number;
  29724. /**
  29725. * Defined the power exponent applied to fresnel term
  29726. */
  29727. power?: number;
  29728. /**
  29729. * Define if the fresnel effect is enable or not.
  29730. */
  29731. isEnabled: boolean;
  29732. };
  29733. /**
  29734. * This represents all the required information to add a fresnel effect on a material:
  29735. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29736. */
  29737. export class FresnelParameters {
  29738. private _isEnabled;
  29739. /**
  29740. * Define if the fresnel effect is enable or not.
  29741. */
  29742. get isEnabled(): boolean;
  29743. set isEnabled(value: boolean);
  29744. /**
  29745. * Define the color used on edges (grazing angle)
  29746. */
  29747. leftColor: Color3;
  29748. /**
  29749. * Define the color used on center
  29750. */
  29751. rightColor: Color3;
  29752. /**
  29753. * Define bias applied to computed fresnel term
  29754. */
  29755. bias: number;
  29756. /**
  29757. * Defined the power exponent applied to fresnel term
  29758. */
  29759. power: number;
  29760. /**
  29761. * Creates a new FresnelParameters object.
  29762. *
  29763. * @param options provide your own settings to optionally to override defaults
  29764. */
  29765. constructor(options?: IFresnelParametersCreationOptions);
  29766. /**
  29767. * Clones the current fresnel and its valuues
  29768. * @returns a clone fresnel configuration
  29769. */
  29770. clone(): FresnelParameters;
  29771. /**
  29772. * Determines equality between FresnelParameters objects
  29773. * @param otherFresnelParameters defines the second operand
  29774. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  29775. */
  29776. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  29777. /**
  29778. * Serializes the current fresnel parameters to a JSON representation.
  29779. * @return the JSON serialization
  29780. */
  29781. serialize(): IFresnelParametersSerialized;
  29782. /**
  29783. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29784. * @param parsedFresnelParameters Define the JSON representation
  29785. * @returns the parsed parameters
  29786. */
  29787. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  29788. }
  29789. }
  29790. declare module BABYLON {
  29791. /**
  29792. * This groups all the flags used to control the materials channel.
  29793. */
  29794. export class MaterialFlags {
  29795. private static _DiffuseTextureEnabled;
  29796. /**
  29797. * Are diffuse textures enabled in the application.
  29798. */
  29799. static get DiffuseTextureEnabled(): boolean;
  29800. static set DiffuseTextureEnabled(value: boolean);
  29801. private static _DetailTextureEnabled;
  29802. /**
  29803. * Are detail textures enabled in the application.
  29804. */
  29805. static get DetailTextureEnabled(): boolean;
  29806. static set DetailTextureEnabled(value: boolean);
  29807. private static _AmbientTextureEnabled;
  29808. /**
  29809. * Are ambient textures enabled in the application.
  29810. */
  29811. static get AmbientTextureEnabled(): boolean;
  29812. static set AmbientTextureEnabled(value: boolean);
  29813. private static _OpacityTextureEnabled;
  29814. /**
  29815. * Are opacity textures enabled in the application.
  29816. */
  29817. static get OpacityTextureEnabled(): boolean;
  29818. static set OpacityTextureEnabled(value: boolean);
  29819. private static _ReflectionTextureEnabled;
  29820. /**
  29821. * Are reflection textures enabled in the application.
  29822. */
  29823. static get ReflectionTextureEnabled(): boolean;
  29824. static set ReflectionTextureEnabled(value: boolean);
  29825. private static _EmissiveTextureEnabled;
  29826. /**
  29827. * Are emissive textures enabled in the application.
  29828. */
  29829. static get EmissiveTextureEnabled(): boolean;
  29830. static set EmissiveTextureEnabled(value: boolean);
  29831. private static _SpecularTextureEnabled;
  29832. /**
  29833. * Are specular textures enabled in the application.
  29834. */
  29835. static get SpecularTextureEnabled(): boolean;
  29836. static set SpecularTextureEnabled(value: boolean);
  29837. private static _BumpTextureEnabled;
  29838. /**
  29839. * Are bump textures enabled in the application.
  29840. */
  29841. static get BumpTextureEnabled(): boolean;
  29842. static set BumpTextureEnabled(value: boolean);
  29843. private static _LightmapTextureEnabled;
  29844. /**
  29845. * Are lightmap textures enabled in the application.
  29846. */
  29847. static get LightmapTextureEnabled(): boolean;
  29848. static set LightmapTextureEnabled(value: boolean);
  29849. private static _RefractionTextureEnabled;
  29850. /**
  29851. * Are refraction textures enabled in the application.
  29852. */
  29853. static get RefractionTextureEnabled(): boolean;
  29854. static set RefractionTextureEnabled(value: boolean);
  29855. private static _ColorGradingTextureEnabled;
  29856. /**
  29857. * Are color grading textures enabled in the application.
  29858. */
  29859. static get ColorGradingTextureEnabled(): boolean;
  29860. static set ColorGradingTextureEnabled(value: boolean);
  29861. private static _FresnelEnabled;
  29862. /**
  29863. * Are fresnels enabled in the application.
  29864. */
  29865. static get FresnelEnabled(): boolean;
  29866. static set FresnelEnabled(value: boolean);
  29867. private static _ClearCoatTextureEnabled;
  29868. /**
  29869. * Are clear coat textures enabled in the application.
  29870. */
  29871. static get ClearCoatTextureEnabled(): boolean;
  29872. static set ClearCoatTextureEnabled(value: boolean);
  29873. private static _ClearCoatBumpTextureEnabled;
  29874. /**
  29875. * Are clear coat bump textures enabled in the application.
  29876. */
  29877. static get ClearCoatBumpTextureEnabled(): boolean;
  29878. static set ClearCoatBumpTextureEnabled(value: boolean);
  29879. private static _ClearCoatTintTextureEnabled;
  29880. /**
  29881. * Are clear coat tint textures enabled in the application.
  29882. */
  29883. static get ClearCoatTintTextureEnabled(): boolean;
  29884. static set ClearCoatTintTextureEnabled(value: boolean);
  29885. private static _SheenTextureEnabled;
  29886. /**
  29887. * Are sheen textures enabled in the application.
  29888. */
  29889. static get SheenTextureEnabled(): boolean;
  29890. static set SheenTextureEnabled(value: boolean);
  29891. private static _AnisotropicTextureEnabled;
  29892. /**
  29893. * Are anisotropic textures enabled in the application.
  29894. */
  29895. static get AnisotropicTextureEnabled(): boolean;
  29896. static set AnisotropicTextureEnabled(value: boolean);
  29897. private static _ThicknessTextureEnabled;
  29898. /**
  29899. * Are thickness textures enabled in the application.
  29900. */
  29901. static get ThicknessTextureEnabled(): boolean;
  29902. static set ThicknessTextureEnabled(value: boolean);
  29903. }
  29904. }
  29905. declare module BABYLON {
  29906. /** @hidden */
  29907. export var defaultFragmentDeclaration: {
  29908. name: string;
  29909. shader: string;
  29910. };
  29911. }
  29912. declare module BABYLON {
  29913. /** @hidden */
  29914. export var defaultUboDeclaration: {
  29915. name: string;
  29916. shader: string;
  29917. };
  29918. }
  29919. declare module BABYLON {
  29920. /** @hidden */
  29921. export var prePassDeclaration: {
  29922. name: string;
  29923. shader: string;
  29924. };
  29925. }
  29926. declare module BABYLON {
  29927. /** @hidden */
  29928. export var lightFragmentDeclaration: {
  29929. name: string;
  29930. shader: string;
  29931. };
  29932. }
  29933. declare module BABYLON {
  29934. /** @hidden */
  29935. export var lightUboDeclaration: {
  29936. name: string;
  29937. shader: string;
  29938. };
  29939. }
  29940. declare module BABYLON {
  29941. /** @hidden */
  29942. export var lightsFragmentFunctions: {
  29943. name: string;
  29944. shader: string;
  29945. };
  29946. }
  29947. declare module BABYLON {
  29948. /** @hidden */
  29949. export var shadowsFragmentFunctions: {
  29950. name: string;
  29951. shader: string;
  29952. };
  29953. }
  29954. declare module BABYLON {
  29955. /** @hidden */
  29956. export var fresnelFunction: {
  29957. name: string;
  29958. shader: string;
  29959. };
  29960. }
  29961. declare module BABYLON {
  29962. /** @hidden */
  29963. export var bumpFragmentMainFunctions: {
  29964. name: string;
  29965. shader: string;
  29966. };
  29967. }
  29968. declare module BABYLON {
  29969. /** @hidden */
  29970. export var bumpFragmentFunctions: {
  29971. name: string;
  29972. shader: string;
  29973. };
  29974. }
  29975. declare module BABYLON {
  29976. /** @hidden */
  29977. export var logDepthDeclaration: {
  29978. name: string;
  29979. shader: string;
  29980. };
  29981. }
  29982. declare module BABYLON {
  29983. /** @hidden */
  29984. export var bumpFragment: {
  29985. name: string;
  29986. shader: string;
  29987. };
  29988. }
  29989. declare module BABYLON {
  29990. /** @hidden */
  29991. export var depthPrePass: {
  29992. name: string;
  29993. shader: string;
  29994. };
  29995. }
  29996. declare module BABYLON {
  29997. /** @hidden */
  29998. export var lightFragment: {
  29999. name: string;
  30000. shader: string;
  30001. };
  30002. }
  30003. declare module BABYLON {
  30004. /** @hidden */
  30005. export var logDepthFragment: {
  30006. name: string;
  30007. shader: string;
  30008. };
  30009. }
  30010. declare module BABYLON {
  30011. /** @hidden */
  30012. export var defaultPixelShader: {
  30013. name: string;
  30014. shader: string;
  30015. };
  30016. }
  30017. declare module BABYLON {
  30018. /** @hidden */
  30019. export var defaultVertexDeclaration: {
  30020. name: string;
  30021. shader: string;
  30022. };
  30023. }
  30024. declare module BABYLON {
  30025. /** @hidden */
  30026. export var bumpVertexDeclaration: {
  30027. name: string;
  30028. shader: string;
  30029. };
  30030. }
  30031. declare module BABYLON {
  30032. /** @hidden */
  30033. export var bumpVertex: {
  30034. name: string;
  30035. shader: string;
  30036. };
  30037. }
  30038. declare module BABYLON {
  30039. /** @hidden */
  30040. export var fogVertex: {
  30041. name: string;
  30042. shader: string;
  30043. };
  30044. }
  30045. declare module BABYLON {
  30046. /** @hidden */
  30047. export var shadowsVertex: {
  30048. name: string;
  30049. shader: string;
  30050. };
  30051. }
  30052. declare module BABYLON {
  30053. /** @hidden */
  30054. export var pointCloudVertex: {
  30055. name: string;
  30056. shader: string;
  30057. };
  30058. }
  30059. declare module BABYLON {
  30060. /** @hidden */
  30061. export var logDepthVertex: {
  30062. name: string;
  30063. shader: string;
  30064. };
  30065. }
  30066. declare module BABYLON {
  30067. /** @hidden */
  30068. export var defaultVertexShader: {
  30069. name: string;
  30070. shader: string;
  30071. };
  30072. }
  30073. declare module BABYLON {
  30074. /**
  30075. * @hidden
  30076. */
  30077. export interface IMaterialDetailMapDefines {
  30078. DETAIL: boolean;
  30079. DETAILDIRECTUV: number;
  30080. DETAIL_NORMALBLENDMETHOD: number;
  30081. /** @hidden */
  30082. _areTexturesDirty: boolean;
  30083. }
  30084. /**
  30085. * Define the code related to the detail map parameters of a material
  30086. *
  30087. * Inspired from:
  30088. * 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
  30089. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  30090. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  30091. */
  30092. export class DetailMapConfiguration {
  30093. private _texture;
  30094. /**
  30095. * The detail texture of the material.
  30096. */
  30097. texture: Nullable<BaseTexture>;
  30098. /**
  30099. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  30100. * Bigger values mean stronger blending
  30101. */
  30102. diffuseBlendLevel: number;
  30103. /**
  30104. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  30105. * Bigger values mean stronger blending. Only used with PBR materials
  30106. */
  30107. roughnessBlendLevel: number;
  30108. /**
  30109. * Defines how strong the bump effect from the detail map is
  30110. * Bigger values mean stronger effect
  30111. */
  30112. bumpLevel: number;
  30113. private _normalBlendMethod;
  30114. /**
  30115. * The method used to blend the bump and detail normals together
  30116. */
  30117. normalBlendMethod: number;
  30118. private _isEnabled;
  30119. /**
  30120. * Enable or disable the detail map on this material
  30121. */
  30122. isEnabled: boolean;
  30123. /** @hidden */
  30124. private _internalMarkAllSubMeshesAsTexturesDirty;
  30125. /** @hidden */
  30126. _markAllSubMeshesAsTexturesDirty(): void;
  30127. /**
  30128. * Instantiate a new detail map
  30129. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  30130. */
  30131. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  30132. /**
  30133. * Gets whether the submesh is ready to be used or not.
  30134. * @param defines the list of "defines" to update.
  30135. * @param scene defines the scene the material belongs to.
  30136. * @returns - boolean indicating that the submesh is ready or not.
  30137. */
  30138. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  30139. /**
  30140. * Update the defines for detail map usage
  30141. * @param defines the list of "defines" to update.
  30142. * @param scene defines the scene the material belongs to.
  30143. */
  30144. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  30145. /**
  30146. * Binds the material data.
  30147. * @param uniformBuffer defines the Uniform buffer to fill in.
  30148. * @param scene defines the scene the material belongs to.
  30149. * @param isFrozen defines whether the material is frozen or not.
  30150. */
  30151. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  30152. /**
  30153. * Checks to see if a texture is used in the material.
  30154. * @param texture - Base texture to use.
  30155. * @returns - Boolean specifying if a texture is used in the material.
  30156. */
  30157. hasTexture(texture: BaseTexture): boolean;
  30158. /**
  30159. * Returns an array of the actively used textures.
  30160. * @param activeTextures Array of BaseTextures
  30161. */
  30162. getActiveTextures(activeTextures: BaseTexture[]): void;
  30163. /**
  30164. * Returns the animatable textures.
  30165. * @param animatables Array of animatable textures.
  30166. */
  30167. getAnimatables(animatables: IAnimatable[]): void;
  30168. /**
  30169. * Disposes the resources of the material.
  30170. * @param forceDisposeTextures - Forces the disposal of all textures.
  30171. */
  30172. dispose(forceDisposeTextures?: boolean): void;
  30173. /**
  30174. * Get the current class name useful for serialization or dynamic coding.
  30175. * @returns "DetailMap"
  30176. */
  30177. getClassName(): string;
  30178. /**
  30179. * Add the required uniforms to the current list.
  30180. * @param uniforms defines the current uniform list.
  30181. */
  30182. static AddUniforms(uniforms: string[]): void;
  30183. /**
  30184. * Add the required samplers to the current list.
  30185. * @param samplers defines the current sampler list.
  30186. */
  30187. static AddSamplers(samplers: string[]): void;
  30188. /**
  30189. * Add the required uniforms to the current buffer.
  30190. * @param uniformBuffer defines the current uniform buffer.
  30191. */
  30192. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  30193. /**
  30194. * Makes a duplicate of the current instance into another one.
  30195. * @param detailMap define the instance where to copy the info
  30196. */
  30197. copyTo(detailMap: DetailMapConfiguration): void;
  30198. /**
  30199. * Serializes this detail map instance
  30200. * @returns - An object with the serialized instance.
  30201. */
  30202. serialize(): any;
  30203. /**
  30204. * Parses a detail map setting from a serialized object.
  30205. * @param source - Serialized object.
  30206. * @param scene Defines the scene we are parsing for
  30207. * @param rootUrl Defines the rootUrl to load from
  30208. */
  30209. parse(source: any, scene: Scene, rootUrl: string): void;
  30210. }
  30211. }
  30212. declare module BABYLON {
  30213. /** @hidden */
  30214. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  30215. MAINUV1: boolean;
  30216. MAINUV2: boolean;
  30217. DIFFUSE: boolean;
  30218. DIFFUSEDIRECTUV: number;
  30219. DETAIL: boolean;
  30220. DETAILDIRECTUV: number;
  30221. DETAIL_NORMALBLENDMETHOD: number;
  30222. AMBIENT: boolean;
  30223. AMBIENTDIRECTUV: number;
  30224. OPACITY: boolean;
  30225. OPACITYDIRECTUV: number;
  30226. OPACITYRGB: boolean;
  30227. REFLECTION: boolean;
  30228. EMISSIVE: boolean;
  30229. EMISSIVEDIRECTUV: number;
  30230. SPECULAR: boolean;
  30231. SPECULARDIRECTUV: number;
  30232. BUMP: boolean;
  30233. BUMPDIRECTUV: number;
  30234. PARALLAX: boolean;
  30235. PARALLAXOCCLUSION: boolean;
  30236. SPECULAROVERALPHA: boolean;
  30237. CLIPPLANE: boolean;
  30238. CLIPPLANE2: boolean;
  30239. CLIPPLANE3: boolean;
  30240. CLIPPLANE4: boolean;
  30241. CLIPPLANE5: boolean;
  30242. CLIPPLANE6: boolean;
  30243. ALPHATEST: boolean;
  30244. DEPTHPREPASS: boolean;
  30245. ALPHAFROMDIFFUSE: boolean;
  30246. POINTSIZE: boolean;
  30247. FOG: boolean;
  30248. SPECULARTERM: boolean;
  30249. DIFFUSEFRESNEL: boolean;
  30250. OPACITYFRESNEL: boolean;
  30251. REFLECTIONFRESNEL: boolean;
  30252. REFRACTIONFRESNEL: boolean;
  30253. EMISSIVEFRESNEL: boolean;
  30254. FRESNEL: boolean;
  30255. NORMAL: boolean;
  30256. UV1: boolean;
  30257. UV2: boolean;
  30258. VERTEXCOLOR: boolean;
  30259. VERTEXALPHA: boolean;
  30260. NUM_BONE_INFLUENCERS: number;
  30261. BonesPerMesh: number;
  30262. BONETEXTURE: boolean;
  30263. INSTANCES: boolean;
  30264. THIN_INSTANCES: boolean;
  30265. GLOSSINESS: boolean;
  30266. ROUGHNESS: boolean;
  30267. EMISSIVEASILLUMINATION: boolean;
  30268. LINKEMISSIVEWITHDIFFUSE: boolean;
  30269. REFLECTIONFRESNELFROMSPECULAR: boolean;
  30270. LIGHTMAP: boolean;
  30271. LIGHTMAPDIRECTUV: number;
  30272. OBJECTSPACE_NORMALMAP: boolean;
  30273. USELIGHTMAPASSHADOWMAP: boolean;
  30274. REFLECTIONMAP_3D: boolean;
  30275. REFLECTIONMAP_SPHERICAL: boolean;
  30276. REFLECTIONMAP_PLANAR: boolean;
  30277. REFLECTIONMAP_CUBIC: boolean;
  30278. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  30279. REFLECTIONMAP_PROJECTION: boolean;
  30280. REFLECTIONMAP_SKYBOX: boolean;
  30281. REFLECTIONMAP_EXPLICIT: boolean;
  30282. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  30283. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  30284. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  30285. INVERTCUBICMAP: boolean;
  30286. LOGARITHMICDEPTH: boolean;
  30287. REFRACTION: boolean;
  30288. REFRACTIONMAP_3D: boolean;
  30289. REFLECTIONOVERALPHA: boolean;
  30290. TWOSIDEDLIGHTING: boolean;
  30291. SHADOWFLOAT: boolean;
  30292. MORPHTARGETS: boolean;
  30293. MORPHTARGETS_NORMAL: boolean;
  30294. MORPHTARGETS_TANGENT: boolean;
  30295. MORPHTARGETS_UV: boolean;
  30296. NUM_MORPH_INFLUENCERS: number;
  30297. NONUNIFORMSCALING: boolean;
  30298. PREMULTIPLYALPHA: boolean;
  30299. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  30300. ALPHABLEND: boolean;
  30301. PREPASS: boolean;
  30302. SCENE_MRT_COUNT: number;
  30303. RGBDLIGHTMAP: boolean;
  30304. RGBDREFLECTION: boolean;
  30305. RGBDREFRACTION: boolean;
  30306. IMAGEPROCESSING: boolean;
  30307. VIGNETTE: boolean;
  30308. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30309. VIGNETTEBLENDMODEOPAQUE: boolean;
  30310. TONEMAPPING: boolean;
  30311. TONEMAPPING_ACES: boolean;
  30312. CONTRAST: boolean;
  30313. COLORCURVES: boolean;
  30314. COLORGRADING: boolean;
  30315. COLORGRADING3D: boolean;
  30316. SAMPLER3DGREENDEPTH: boolean;
  30317. SAMPLER3DBGRMAP: boolean;
  30318. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30319. MULTIVIEW: boolean;
  30320. /**
  30321. * If the reflection texture on this material is in linear color space
  30322. * @hidden
  30323. */
  30324. IS_REFLECTION_LINEAR: boolean;
  30325. /**
  30326. * If the refraction texture on this material is in linear color space
  30327. * @hidden
  30328. */
  30329. IS_REFRACTION_LINEAR: boolean;
  30330. EXPOSURE: boolean;
  30331. constructor();
  30332. setReflectionMode(modeToEnable: string): void;
  30333. }
  30334. /**
  30335. * This is the default material used in Babylon. It is the best trade off between quality
  30336. * and performances.
  30337. * @see https://doc.babylonjs.com/babylon101/materials
  30338. */
  30339. export class StandardMaterial extends PushMaterial {
  30340. private _diffuseTexture;
  30341. /**
  30342. * The basic texture of the material as viewed under a light.
  30343. */
  30344. diffuseTexture: Nullable<BaseTexture>;
  30345. private _ambientTexture;
  30346. /**
  30347. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  30348. */
  30349. ambientTexture: Nullable<BaseTexture>;
  30350. private _opacityTexture;
  30351. /**
  30352. * Define the transparency of the material from a texture.
  30353. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  30354. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  30355. */
  30356. opacityTexture: Nullable<BaseTexture>;
  30357. private _reflectionTexture;
  30358. /**
  30359. * Define the texture used to display the reflection.
  30360. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30361. */
  30362. reflectionTexture: Nullable<BaseTexture>;
  30363. private _emissiveTexture;
  30364. /**
  30365. * Define texture of the material as if self lit.
  30366. * This will be mixed in the final result even in the absence of light.
  30367. */
  30368. emissiveTexture: Nullable<BaseTexture>;
  30369. private _specularTexture;
  30370. /**
  30371. * Define how the color and intensity of the highlight given by the light in the material.
  30372. */
  30373. specularTexture: Nullable<BaseTexture>;
  30374. private _bumpTexture;
  30375. /**
  30376. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  30377. * 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.
  30378. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  30379. */
  30380. bumpTexture: Nullable<BaseTexture>;
  30381. private _lightmapTexture;
  30382. /**
  30383. * Complex lighting can be computationally expensive to compute at runtime.
  30384. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  30385. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  30386. */
  30387. lightmapTexture: Nullable<BaseTexture>;
  30388. private _refractionTexture;
  30389. /**
  30390. * Define the texture used to display the refraction.
  30391. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30392. */
  30393. refractionTexture: Nullable<BaseTexture>;
  30394. /**
  30395. * The color of the material lit by the environmental background lighting.
  30396. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  30397. */
  30398. ambientColor: Color3;
  30399. /**
  30400. * The basic color of the material as viewed under a light.
  30401. */
  30402. diffuseColor: Color3;
  30403. /**
  30404. * Define how the color and intensity of the highlight given by the light in the material.
  30405. */
  30406. specularColor: Color3;
  30407. /**
  30408. * Define the color of the material as if self lit.
  30409. * This will be mixed in the final result even in the absence of light.
  30410. */
  30411. emissiveColor: Color3;
  30412. /**
  30413. * Defines how sharp are the highlights in the material.
  30414. * The bigger the value the sharper giving a more glossy feeling to the result.
  30415. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  30416. */
  30417. specularPower: number;
  30418. private _useAlphaFromDiffuseTexture;
  30419. /**
  30420. * Does the transparency come from the diffuse texture alpha channel.
  30421. */
  30422. useAlphaFromDiffuseTexture: boolean;
  30423. private _useEmissiveAsIllumination;
  30424. /**
  30425. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  30426. */
  30427. useEmissiveAsIllumination: boolean;
  30428. private _linkEmissiveWithDiffuse;
  30429. /**
  30430. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  30431. * the emissive level when the final color is close to one.
  30432. */
  30433. linkEmissiveWithDiffuse: boolean;
  30434. private _useSpecularOverAlpha;
  30435. /**
  30436. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  30437. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  30438. */
  30439. useSpecularOverAlpha: boolean;
  30440. private _useReflectionOverAlpha;
  30441. /**
  30442. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  30443. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  30444. */
  30445. useReflectionOverAlpha: boolean;
  30446. private _disableLighting;
  30447. /**
  30448. * Does lights from the scene impacts this material.
  30449. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  30450. */
  30451. disableLighting: boolean;
  30452. private _useObjectSpaceNormalMap;
  30453. /**
  30454. * Allows using an object space normal map (instead of tangent space).
  30455. */
  30456. useObjectSpaceNormalMap: boolean;
  30457. private _useParallax;
  30458. /**
  30459. * Is parallax enabled or not.
  30460. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30461. */
  30462. useParallax: boolean;
  30463. private _useParallaxOcclusion;
  30464. /**
  30465. * Is parallax occlusion enabled or not.
  30466. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  30467. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30468. */
  30469. useParallaxOcclusion: boolean;
  30470. /**
  30471. * 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.
  30472. */
  30473. parallaxScaleBias: number;
  30474. private _roughness;
  30475. /**
  30476. * Helps to define how blurry the reflections should appears in the material.
  30477. */
  30478. roughness: number;
  30479. /**
  30480. * In case of refraction, define the value of the index of refraction.
  30481. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30482. */
  30483. indexOfRefraction: number;
  30484. /**
  30485. * Invert the refraction texture alongside the y axis.
  30486. * It can be useful with procedural textures or probe for instance.
  30487. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30488. */
  30489. invertRefractionY: boolean;
  30490. /**
  30491. * Defines the alpha limits in alpha test mode.
  30492. */
  30493. alphaCutOff: number;
  30494. private _useLightmapAsShadowmap;
  30495. /**
  30496. * In case of light mapping, define whether the map contains light or shadow informations.
  30497. */
  30498. useLightmapAsShadowmap: boolean;
  30499. private _diffuseFresnelParameters;
  30500. /**
  30501. * Define the diffuse fresnel parameters of the material.
  30502. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30503. */
  30504. diffuseFresnelParameters: FresnelParameters;
  30505. private _opacityFresnelParameters;
  30506. /**
  30507. * Define the opacity fresnel parameters of the material.
  30508. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30509. */
  30510. opacityFresnelParameters: FresnelParameters;
  30511. private _reflectionFresnelParameters;
  30512. /**
  30513. * Define the reflection fresnel parameters of the material.
  30514. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30515. */
  30516. reflectionFresnelParameters: FresnelParameters;
  30517. private _refractionFresnelParameters;
  30518. /**
  30519. * Define the refraction fresnel parameters of the material.
  30520. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30521. */
  30522. refractionFresnelParameters: FresnelParameters;
  30523. private _emissiveFresnelParameters;
  30524. /**
  30525. * Define the emissive fresnel parameters of the material.
  30526. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30527. */
  30528. emissiveFresnelParameters: FresnelParameters;
  30529. private _useReflectionFresnelFromSpecular;
  30530. /**
  30531. * If true automatically deducts the fresnels values from the material specularity.
  30532. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30533. */
  30534. useReflectionFresnelFromSpecular: boolean;
  30535. private _useGlossinessFromSpecularMapAlpha;
  30536. /**
  30537. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  30538. */
  30539. useGlossinessFromSpecularMapAlpha: boolean;
  30540. private _maxSimultaneousLights;
  30541. /**
  30542. * Defines the maximum number of lights that can be used in the material
  30543. */
  30544. maxSimultaneousLights: number;
  30545. private _invertNormalMapX;
  30546. /**
  30547. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  30548. */
  30549. invertNormalMapX: boolean;
  30550. private _invertNormalMapY;
  30551. /**
  30552. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  30553. */
  30554. invertNormalMapY: boolean;
  30555. private _twoSidedLighting;
  30556. /**
  30557. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  30558. */
  30559. twoSidedLighting: boolean;
  30560. /**
  30561. * Default configuration related to image processing available in the standard Material.
  30562. */
  30563. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30564. /**
  30565. * Gets the image processing configuration used either in this material.
  30566. */
  30567. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  30568. /**
  30569. * Sets the Default image processing configuration used either in the this material.
  30570. *
  30571. * If sets to null, the scene one is in use.
  30572. */
  30573. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  30574. /**
  30575. * Keep track of the image processing observer to allow dispose and replace.
  30576. */
  30577. private _imageProcessingObserver;
  30578. /**
  30579. * Attaches a new image processing configuration to the Standard Material.
  30580. * @param configuration
  30581. */
  30582. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30583. /**
  30584. * Gets wether the color curves effect is enabled.
  30585. */
  30586. get cameraColorCurvesEnabled(): boolean;
  30587. /**
  30588. * Sets wether the color curves effect is enabled.
  30589. */
  30590. set cameraColorCurvesEnabled(value: boolean);
  30591. /**
  30592. * Gets wether the color grading effect is enabled.
  30593. */
  30594. get cameraColorGradingEnabled(): boolean;
  30595. /**
  30596. * Gets wether the color grading effect is enabled.
  30597. */
  30598. set cameraColorGradingEnabled(value: boolean);
  30599. /**
  30600. * Gets wether tonemapping is enabled or not.
  30601. */
  30602. get cameraToneMappingEnabled(): boolean;
  30603. /**
  30604. * Sets wether tonemapping is enabled or not
  30605. */
  30606. set cameraToneMappingEnabled(value: boolean);
  30607. /**
  30608. * The camera exposure used on this material.
  30609. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30610. * This corresponds to a photographic exposure.
  30611. */
  30612. get cameraExposure(): number;
  30613. /**
  30614. * The camera exposure used on this material.
  30615. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30616. * This corresponds to a photographic exposure.
  30617. */
  30618. set cameraExposure(value: number);
  30619. /**
  30620. * Gets The camera contrast used on this material.
  30621. */
  30622. get cameraContrast(): number;
  30623. /**
  30624. * Sets The camera contrast used on this material.
  30625. */
  30626. set cameraContrast(value: number);
  30627. /**
  30628. * Gets the Color Grading 2D Lookup Texture.
  30629. */
  30630. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  30631. /**
  30632. * Sets the Color Grading 2D Lookup Texture.
  30633. */
  30634. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  30635. /**
  30636. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30637. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30638. * 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;
  30639. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30640. */
  30641. get cameraColorCurves(): Nullable<ColorCurves>;
  30642. /**
  30643. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30644. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30645. * 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;
  30646. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30647. */
  30648. set cameraColorCurves(value: Nullable<ColorCurves>);
  30649. /**
  30650. * Can this material render to several textures at once
  30651. */
  30652. get canRenderToMRT(): boolean;
  30653. /**
  30654. * Defines the detail map parameters for the material.
  30655. */
  30656. readonly detailMap: DetailMapConfiguration;
  30657. protected _renderTargets: SmartArray<RenderTargetTexture>;
  30658. protected _worldViewProjectionMatrix: Matrix;
  30659. protected _globalAmbientColor: Color3;
  30660. protected _useLogarithmicDepth: boolean;
  30661. protected _rebuildInParallel: boolean;
  30662. /**
  30663. * Instantiates a new standard material.
  30664. * This is the default material used in Babylon. It is the best trade off between quality
  30665. * and performances.
  30666. * @see https://doc.babylonjs.com/babylon101/materials
  30667. * @param name Define the name of the material in the scene
  30668. * @param scene Define the scene the material belong to
  30669. */
  30670. constructor(name: string, scene: Scene);
  30671. /**
  30672. * Gets a boolean indicating that current material needs to register RTT
  30673. */
  30674. get hasRenderTargetTextures(): boolean;
  30675. /**
  30676. * Gets the current class name of the material e.g. "StandardMaterial"
  30677. * Mainly use in serialization.
  30678. * @returns the class name
  30679. */
  30680. getClassName(): string;
  30681. /**
  30682. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  30683. * You can try switching to logarithmic depth.
  30684. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  30685. */
  30686. get useLogarithmicDepth(): boolean;
  30687. set useLogarithmicDepth(value: boolean);
  30688. /**
  30689. * Specifies if the material will require alpha blending
  30690. * @returns a boolean specifying if alpha blending is needed
  30691. */
  30692. needAlphaBlending(): boolean;
  30693. /**
  30694. * Specifies if this material should be rendered in alpha test mode
  30695. * @returns a boolean specifying if an alpha test is needed.
  30696. */
  30697. needAlphaTesting(): boolean;
  30698. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  30699. /**
  30700. * Get the texture used for alpha test purpose.
  30701. * @returns the diffuse texture in case of the standard material.
  30702. */
  30703. getAlphaTestTexture(): Nullable<BaseTexture>;
  30704. /**
  30705. * Get if the submesh is ready to be used and all its information available.
  30706. * Child classes can use it to update shaders
  30707. * @param mesh defines the mesh to check
  30708. * @param subMesh defines which submesh to check
  30709. * @param useInstances specifies that instances should be used
  30710. * @returns a boolean indicating that the submesh is ready or not
  30711. */
  30712. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30713. /**
  30714. * Builds the material UBO layouts.
  30715. * Used internally during the effect preparation.
  30716. */
  30717. buildUniformLayout(): void;
  30718. /**
  30719. * Unbinds the material from the mesh
  30720. */
  30721. unbind(): void;
  30722. /**
  30723. * Binds the submesh to this material by preparing the effect and shader to draw
  30724. * @param world defines the world transformation matrix
  30725. * @param mesh defines the mesh containing the submesh
  30726. * @param subMesh defines the submesh to bind the material to
  30727. */
  30728. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30729. /**
  30730. * Get the list of animatables in the material.
  30731. * @returns the list of animatables object used in the material
  30732. */
  30733. getAnimatables(): IAnimatable[];
  30734. /**
  30735. * Gets the active textures from the material
  30736. * @returns an array of textures
  30737. */
  30738. getActiveTextures(): BaseTexture[];
  30739. /**
  30740. * Specifies if the material uses a texture
  30741. * @param texture defines the texture to check against the material
  30742. * @returns a boolean specifying if the material uses the texture
  30743. */
  30744. hasTexture(texture: BaseTexture): boolean;
  30745. /**
  30746. * Disposes the material
  30747. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30748. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30749. */
  30750. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  30751. /**
  30752. * Makes a duplicate of the material, and gives it a new name
  30753. * @param name defines the new name for the duplicated material
  30754. * @returns the cloned material
  30755. */
  30756. clone(name: string): StandardMaterial;
  30757. /**
  30758. * Serializes this material in a JSON representation
  30759. * @returns the serialized material object
  30760. */
  30761. serialize(): any;
  30762. /**
  30763. * Creates a standard material from parsed material data
  30764. * @param source defines the JSON representation of the material
  30765. * @param scene defines the hosting scene
  30766. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  30767. * @returns a new standard material
  30768. */
  30769. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  30770. /**
  30771. * Are diffuse textures enabled in the application.
  30772. */
  30773. static get DiffuseTextureEnabled(): boolean;
  30774. static set DiffuseTextureEnabled(value: boolean);
  30775. /**
  30776. * Are detail textures enabled in the application.
  30777. */
  30778. static get DetailTextureEnabled(): boolean;
  30779. static set DetailTextureEnabled(value: boolean);
  30780. /**
  30781. * Are ambient textures enabled in the application.
  30782. */
  30783. static get AmbientTextureEnabled(): boolean;
  30784. static set AmbientTextureEnabled(value: boolean);
  30785. /**
  30786. * Are opacity textures enabled in the application.
  30787. */
  30788. static get OpacityTextureEnabled(): boolean;
  30789. static set OpacityTextureEnabled(value: boolean);
  30790. /**
  30791. * Are reflection textures enabled in the application.
  30792. */
  30793. static get ReflectionTextureEnabled(): boolean;
  30794. static set ReflectionTextureEnabled(value: boolean);
  30795. /**
  30796. * Are emissive textures enabled in the application.
  30797. */
  30798. static get EmissiveTextureEnabled(): boolean;
  30799. static set EmissiveTextureEnabled(value: boolean);
  30800. /**
  30801. * Are specular textures enabled in the application.
  30802. */
  30803. static get SpecularTextureEnabled(): boolean;
  30804. static set SpecularTextureEnabled(value: boolean);
  30805. /**
  30806. * Are bump textures enabled in the application.
  30807. */
  30808. static get BumpTextureEnabled(): boolean;
  30809. static set BumpTextureEnabled(value: boolean);
  30810. /**
  30811. * Are lightmap textures enabled in the application.
  30812. */
  30813. static get LightmapTextureEnabled(): boolean;
  30814. static set LightmapTextureEnabled(value: boolean);
  30815. /**
  30816. * Are refraction textures enabled in the application.
  30817. */
  30818. static get RefractionTextureEnabled(): boolean;
  30819. static set RefractionTextureEnabled(value: boolean);
  30820. /**
  30821. * Are color grading textures enabled in the application.
  30822. */
  30823. static get ColorGradingTextureEnabled(): boolean;
  30824. static set ColorGradingTextureEnabled(value: boolean);
  30825. /**
  30826. * Are fresnels enabled in the application.
  30827. */
  30828. static get FresnelEnabled(): boolean;
  30829. static set FresnelEnabled(value: boolean);
  30830. }
  30831. }
  30832. declare module BABYLON {
  30833. /**
  30834. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  30835. *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.
  30836. * The SPS is also a particle system. It provides some methods to manage the particles.
  30837. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  30838. *
  30839. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  30840. */
  30841. export class SolidParticleSystem implements IDisposable {
  30842. /**
  30843. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  30844. * Example : var p = SPS.particles[i];
  30845. */
  30846. particles: SolidParticle[];
  30847. /**
  30848. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  30849. */
  30850. nbParticles: number;
  30851. /**
  30852. * If the particles must ever face the camera (default false). Useful for planar particles.
  30853. */
  30854. billboard: boolean;
  30855. /**
  30856. * Recompute normals when adding a shape
  30857. */
  30858. recomputeNormals: boolean;
  30859. /**
  30860. * This a counter ofr your own usage. It's not set by any SPS functions.
  30861. */
  30862. counter: number;
  30863. /**
  30864. * The SPS name. This name is also given to the underlying mesh.
  30865. */
  30866. name: string;
  30867. /**
  30868. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  30869. */
  30870. mesh: Mesh;
  30871. /**
  30872. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  30873. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  30874. */
  30875. vars: any;
  30876. /**
  30877. * This array is populated when the SPS is set as 'pickable'.
  30878. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  30879. * Each element of this array is an object `{idx: int, faceId: int}`.
  30880. * `idx` is the picked particle index in the `SPS.particles` array
  30881. * `faceId` is the picked face index counted within this particle.
  30882. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  30883. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  30884. * Use the method SPS.pickedParticle(pickingInfo) instead.
  30885. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  30886. */
  30887. pickedParticles: {
  30888. idx: number;
  30889. faceId: number;
  30890. }[];
  30891. /**
  30892. * This array is populated when the SPS is set as 'pickable'
  30893. * Each key of this array is a submesh index.
  30894. * Each element of this array is a second array defined like this :
  30895. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  30896. * Each element of this second array is an object `{idx: int, faceId: int}`.
  30897. * `idx` is the picked particle index in the `SPS.particles` array
  30898. * `faceId` is the picked face index counted within this particle.
  30899. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  30900. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  30901. */
  30902. pickedBySubMesh: {
  30903. idx: number;
  30904. faceId: number;
  30905. }[][];
  30906. /**
  30907. * This array is populated when `enableDepthSort` is set to true.
  30908. * Each element of this array is an instance of the class DepthSortedParticle.
  30909. */
  30910. depthSortedParticles: DepthSortedParticle[];
  30911. /**
  30912. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  30913. * @hidden
  30914. */
  30915. _bSphereOnly: boolean;
  30916. /**
  30917. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  30918. * @hidden
  30919. */
  30920. _bSphereRadiusFactor: number;
  30921. private _scene;
  30922. private _positions;
  30923. private _indices;
  30924. private _normals;
  30925. private _colors;
  30926. private _uvs;
  30927. private _indices32;
  30928. private _positions32;
  30929. private _normals32;
  30930. private _fixedNormal32;
  30931. private _colors32;
  30932. private _uvs32;
  30933. private _index;
  30934. private _updatable;
  30935. private _pickable;
  30936. private _isVisibilityBoxLocked;
  30937. private _alwaysVisible;
  30938. private _depthSort;
  30939. private _expandable;
  30940. private _shapeCounter;
  30941. private _copy;
  30942. private _color;
  30943. private _computeParticleColor;
  30944. private _computeParticleTexture;
  30945. private _computeParticleRotation;
  30946. private _computeParticleVertex;
  30947. private _computeBoundingBox;
  30948. private _depthSortParticles;
  30949. private _camera;
  30950. private _mustUnrotateFixedNormals;
  30951. private _particlesIntersect;
  30952. private _needs32Bits;
  30953. private _isNotBuilt;
  30954. private _lastParticleId;
  30955. private _idxOfId;
  30956. private _multimaterialEnabled;
  30957. private _useModelMaterial;
  30958. private _indicesByMaterial;
  30959. private _materialIndexes;
  30960. private _depthSortFunction;
  30961. private _materialSortFunction;
  30962. private _materials;
  30963. private _multimaterial;
  30964. private _materialIndexesById;
  30965. private _defaultMaterial;
  30966. private _autoUpdateSubMeshes;
  30967. private _tmpVertex;
  30968. /**
  30969. * Creates a SPS (Solid Particle System) object.
  30970. * @param name (String) is the SPS name, this will be the underlying mesh name.
  30971. * @param scene (Scene) is the scene in which the SPS is added.
  30972. * @param options defines the options of the sps e.g.
  30973. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  30974. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  30975. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  30976. * * 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.
  30977. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  30978. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  30979. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  30980. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  30981. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  30982. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  30983. */
  30984. constructor(name: string, scene: Scene, options?: {
  30985. updatable?: boolean;
  30986. isPickable?: boolean;
  30987. enableDepthSort?: boolean;
  30988. particleIntersection?: boolean;
  30989. boundingSphereOnly?: boolean;
  30990. bSphereRadiusFactor?: number;
  30991. expandable?: boolean;
  30992. useModelMaterial?: boolean;
  30993. enableMultiMaterial?: boolean;
  30994. });
  30995. /**
  30996. * Builds the SPS underlying mesh. Returns a standard Mesh.
  30997. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  30998. * @returns the created mesh
  30999. */
  31000. buildMesh(): Mesh;
  31001. /**
  31002. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  31003. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  31004. * Thus the particles generated from `digest()` have their property `position` set yet.
  31005. * @param mesh ( Mesh ) is the mesh to be digested
  31006. * @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
  31007. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  31008. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  31009. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31010. * @returns the current SPS
  31011. */
  31012. digest(mesh: Mesh, options?: {
  31013. facetNb?: number;
  31014. number?: number;
  31015. delta?: number;
  31016. storage?: [];
  31017. }): SolidParticleSystem;
  31018. /**
  31019. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  31020. * @hidden
  31021. */
  31022. private _unrotateFixedNormals;
  31023. /**
  31024. * Resets the temporary working copy particle
  31025. * @hidden
  31026. */
  31027. private _resetCopy;
  31028. /**
  31029. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  31030. * @param p the current index in the positions array to be updated
  31031. * @param ind the current index in the indices array
  31032. * @param shape a Vector3 array, the shape geometry
  31033. * @param positions the positions array to be updated
  31034. * @param meshInd the shape indices array
  31035. * @param indices the indices array to be updated
  31036. * @param meshUV the shape uv array
  31037. * @param uvs the uv array to be updated
  31038. * @param meshCol the shape color array
  31039. * @param colors the color array to be updated
  31040. * @param meshNor the shape normals array
  31041. * @param normals the normals array to be updated
  31042. * @param idx the particle index
  31043. * @param idxInShape the particle index in its shape
  31044. * @param options the addShape() method passed options
  31045. * @model the particle model
  31046. * @hidden
  31047. */
  31048. private _meshBuilder;
  31049. /**
  31050. * Returns a shape Vector3 array from positions float array
  31051. * @param positions float array
  31052. * @returns a vector3 array
  31053. * @hidden
  31054. */
  31055. private _posToShape;
  31056. /**
  31057. * Returns a shapeUV array from a float uvs (array deep copy)
  31058. * @param uvs as a float array
  31059. * @returns a shapeUV array
  31060. * @hidden
  31061. */
  31062. private _uvsToShapeUV;
  31063. /**
  31064. * Adds a new particle object in the particles array
  31065. * @param idx particle index in particles array
  31066. * @param id particle id
  31067. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  31068. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  31069. * @param model particle ModelShape object
  31070. * @param shapeId model shape identifier
  31071. * @param idxInShape index of the particle in the current model
  31072. * @param bInfo model bounding info object
  31073. * @param storage target storage array, if any
  31074. * @hidden
  31075. */
  31076. private _addParticle;
  31077. /**
  31078. * Adds some particles to the SPS from the model shape. Returns the shape id.
  31079. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  31080. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  31081. * @param nb (positive integer) the number of particles to be created from this model
  31082. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  31083. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  31084. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31085. * @returns the number of shapes in the system
  31086. */
  31087. addShape(mesh: Mesh, nb: number, options?: {
  31088. positionFunction?: any;
  31089. vertexFunction?: any;
  31090. storage?: [];
  31091. }): number;
  31092. /**
  31093. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  31094. * @hidden
  31095. */
  31096. private _rebuildParticle;
  31097. /**
  31098. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  31099. * @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.
  31100. * @returns the SPS.
  31101. */
  31102. rebuildMesh(reset?: boolean): SolidParticleSystem;
  31103. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  31104. * Returns an array with the removed particles.
  31105. * 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.
  31106. * The SPS can't be empty so at least one particle needs to remain in place.
  31107. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  31108. * @param start index of the first particle to remove
  31109. * @param end index of the last particle to remove (included)
  31110. * @returns an array populated with the removed particles
  31111. */
  31112. removeParticles(start: number, end: number): SolidParticle[];
  31113. /**
  31114. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  31115. * @param solidParticleArray an array populated with Solid Particles objects
  31116. * @returns the SPS
  31117. */
  31118. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  31119. /**
  31120. * Creates a new particle and modifies the SPS mesh geometry :
  31121. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  31122. * - calls _addParticle() to populate the particle array
  31123. * factorized code from addShape() and insertParticlesFromArray()
  31124. * @param idx particle index in the particles array
  31125. * @param i particle index in its shape
  31126. * @param modelShape particle ModelShape object
  31127. * @param shape shape vertex array
  31128. * @param meshInd shape indices array
  31129. * @param meshUV shape uv array
  31130. * @param meshCol shape color array
  31131. * @param meshNor shape normals array
  31132. * @param bbInfo shape bounding info
  31133. * @param storage target particle storage
  31134. * @options addShape() passed options
  31135. * @hidden
  31136. */
  31137. private _insertNewParticle;
  31138. /**
  31139. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  31140. * This method calls `updateParticle()` for each particle of the SPS.
  31141. * For an animated SPS, it is usually called within the render loop.
  31142. * 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.
  31143. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  31144. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  31145. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  31146. * @returns the SPS.
  31147. */
  31148. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  31149. /**
  31150. * Disposes the SPS.
  31151. */
  31152. dispose(): void;
  31153. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  31154. * idx is the particle index in the SPS
  31155. * faceId is the picked face index counted within this particle.
  31156. * Returns null if the pickInfo can't identify a picked particle.
  31157. * @param pickingInfo (PickingInfo object)
  31158. * @returns {idx: number, faceId: number} or null
  31159. */
  31160. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  31161. idx: number;
  31162. faceId: number;
  31163. }>;
  31164. /**
  31165. * Returns a SolidParticle object from its identifier : particle.id
  31166. * @param id (integer) the particle Id
  31167. * @returns the searched particle or null if not found in the SPS.
  31168. */
  31169. getParticleById(id: number): Nullable<SolidParticle>;
  31170. /**
  31171. * Returns a new array populated with the particles having the passed shapeId.
  31172. * @param shapeId (integer) the shape identifier
  31173. * @returns a new solid particle array
  31174. */
  31175. getParticlesByShapeId(shapeId: number): SolidParticle[];
  31176. /**
  31177. * Populates the passed array "ref" with the particles having the passed shapeId.
  31178. * @param shapeId the shape identifier
  31179. * @returns the SPS
  31180. * @param ref
  31181. */
  31182. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  31183. /**
  31184. * Computes the required SubMeshes according the materials assigned to the particles.
  31185. * @returns the solid particle system.
  31186. * Does nothing if called before the SPS mesh is built.
  31187. */
  31188. computeSubMeshes(): SolidParticleSystem;
  31189. /**
  31190. * Sorts the solid particles by material when MultiMaterial is enabled.
  31191. * Updates the indices32 array.
  31192. * Updates the indicesByMaterial array.
  31193. * Updates the mesh indices array.
  31194. * @returns the SPS
  31195. * @hidden
  31196. */
  31197. private _sortParticlesByMaterial;
  31198. /**
  31199. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  31200. * @hidden
  31201. */
  31202. private _setMaterialIndexesById;
  31203. /**
  31204. * Returns an array with unique values of Materials from the passed array
  31205. * @param array the material array to be checked and filtered
  31206. * @hidden
  31207. */
  31208. private _filterUniqueMaterialId;
  31209. /**
  31210. * Sets a new Standard Material as _defaultMaterial if not already set.
  31211. * @hidden
  31212. */
  31213. private _setDefaultMaterial;
  31214. /**
  31215. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  31216. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31217. * @returns the SPS.
  31218. */
  31219. refreshVisibleSize(): SolidParticleSystem;
  31220. /**
  31221. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  31222. * @param size the size (float) of the visibility box
  31223. * note : this doesn't lock the SPS mesh bounding box.
  31224. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31225. */
  31226. setVisibilityBox(size: number): void;
  31227. /**
  31228. * Gets whether the SPS as always visible or not
  31229. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31230. */
  31231. get isAlwaysVisible(): boolean;
  31232. /**
  31233. * Sets the SPS as always visible or not
  31234. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31235. */
  31236. set isAlwaysVisible(val: boolean);
  31237. /**
  31238. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31239. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31240. */
  31241. set isVisibilityBoxLocked(val: boolean);
  31242. /**
  31243. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31244. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31245. */
  31246. get isVisibilityBoxLocked(): boolean;
  31247. /**
  31248. * Tells to `setParticles()` to compute the particle rotations or not.
  31249. * Default value : true. The SPS is faster when it's set to false.
  31250. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31251. */
  31252. set computeParticleRotation(val: boolean);
  31253. /**
  31254. * Tells to `setParticles()` to compute the particle colors or not.
  31255. * Default value : true. The SPS is faster when it's set to false.
  31256. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31257. */
  31258. set computeParticleColor(val: boolean);
  31259. set computeParticleTexture(val: boolean);
  31260. /**
  31261. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  31262. * Default value : false. The SPS is faster when it's set to false.
  31263. * Note : the particle custom vertex positions aren't stored values.
  31264. */
  31265. set computeParticleVertex(val: boolean);
  31266. /**
  31267. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  31268. */
  31269. set computeBoundingBox(val: boolean);
  31270. /**
  31271. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  31272. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31273. * Default : `true`
  31274. */
  31275. set depthSortParticles(val: boolean);
  31276. /**
  31277. * Gets if `setParticles()` computes the particle rotations or not.
  31278. * Default value : true. The SPS is faster when it's set to false.
  31279. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31280. */
  31281. get computeParticleRotation(): boolean;
  31282. /**
  31283. * Gets if `setParticles()` computes the particle colors or not.
  31284. * Default value : true. The SPS is faster when it's set to false.
  31285. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31286. */
  31287. get computeParticleColor(): boolean;
  31288. /**
  31289. * Gets if `setParticles()` computes the particle textures or not.
  31290. * Default value : true. The SPS is faster when it's set to false.
  31291. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  31292. */
  31293. get computeParticleTexture(): boolean;
  31294. /**
  31295. * Gets if `setParticles()` calls 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. get computeParticleVertex(): boolean;
  31300. /**
  31301. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  31302. */
  31303. get computeBoundingBox(): boolean;
  31304. /**
  31305. * Gets if `setParticles()` sorts 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. get depthSortParticles(): boolean;
  31310. /**
  31311. * Gets if the SPS is created as expandable at construction time.
  31312. * Default : `false`
  31313. */
  31314. get expandable(): boolean;
  31315. /**
  31316. * Gets if the SPS supports the Multi Materials
  31317. */
  31318. get multimaterialEnabled(): boolean;
  31319. /**
  31320. * Gets if the SPS uses the model materials for its own multimaterial.
  31321. */
  31322. get useModelMaterial(): boolean;
  31323. /**
  31324. * The SPS used material array.
  31325. */
  31326. get materials(): Material[];
  31327. /**
  31328. * Sets the SPS MultiMaterial from the passed materials.
  31329. * Note : the passed array is internally copied and not used then by reference.
  31330. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  31331. */
  31332. setMultiMaterial(materials: Material[]): void;
  31333. /**
  31334. * The SPS computed multimaterial object
  31335. */
  31336. get multimaterial(): MultiMaterial;
  31337. set multimaterial(mm: MultiMaterial);
  31338. /**
  31339. * If the subMeshes must be updated on the next call to setParticles()
  31340. */
  31341. get autoUpdateSubMeshes(): boolean;
  31342. set autoUpdateSubMeshes(val: boolean);
  31343. /**
  31344. * This function does nothing. It may be overwritten to set all the particle first values.
  31345. * The SPS doesn't call this function, you may have to call it by your own.
  31346. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31347. */
  31348. initParticles(): void;
  31349. /**
  31350. * This function does nothing. It may be overwritten to recycle a particle.
  31351. * The SPS doesn't call this function, you may have to call it by your own.
  31352. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31353. * @param particle The particle to recycle
  31354. * @returns the recycled particle
  31355. */
  31356. recycleParticle(particle: SolidParticle): SolidParticle;
  31357. /**
  31358. * Updates a particle : this function should be overwritten by the user.
  31359. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  31360. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31361. * @example : just set a particle position or velocity and recycle conditions
  31362. * @param particle The particle to update
  31363. * @returns the updated particle
  31364. */
  31365. updateParticle(particle: SolidParticle): SolidParticle;
  31366. /**
  31367. * Updates a vertex of a particle : it can be overwritten by the user.
  31368. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  31369. * @param particle the current particle
  31370. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  31371. * @param pt the index of the current vertex in the particle shape
  31372. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  31373. * @example : just set a vertex particle position or color
  31374. * @returns the sps
  31375. */
  31376. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  31377. /**
  31378. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  31379. * This does nothing and may be overwritten by the user.
  31380. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31381. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31382. * @param update the boolean update value actually passed to setParticles()
  31383. */
  31384. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31385. /**
  31386. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  31387. * This will be passed three parameters.
  31388. * This does nothing and may be overwritten by the user.
  31389. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31390. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31391. * @param update the boolean update value actually passed to setParticles()
  31392. */
  31393. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31394. }
  31395. }
  31396. declare module BABYLON {
  31397. /**
  31398. * Represents one particle of a solid particle system.
  31399. */
  31400. export class SolidParticle {
  31401. /**
  31402. * particle global index
  31403. */
  31404. idx: number;
  31405. /**
  31406. * particle identifier
  31407. */
  31408. id: number;
  31409. /**
  31410. * The color of the particle
  31411. */
  31412. color: Nullable<Color4>;
  31413. /**
  31414. * The world space position of the particle.
  31415. */
  31416. position: Vector3;
  31417. /**
  31418. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  31419. */
  31420. rotation: Vector3;
  31421. /**
  31422. * The world space rotation quaternion of the particle.
  31423. */
  31424. rotationQuaternion: Nullable<Quaternion>;
  31425. /**
  31426. * The scaling of the particle.
  31427. */
  31428. scaling: Vector3;
  31429. /**
  31430. * The uvs of the particle.
  31431. */
  31432. uvs: Vector4;
  31433. /**
  31434. * The current speed of the particle.
  31435. */
  31436. velocity: Vector3;
  31437. /**
  31438. * The pivot point in the particle local space.
  31439. */
  31440. pivot: Vector3;
  31441. /**
  31442. * Must the particle be translated from its pivot point in its local space ?
  31443. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  31444. * Default : false
  31445. */
  31446. translateFromPivot: boolean;
  31447. /**
  31448. * Is the particle active or not ?
  31449. */
  31450. alive: boolean;
  31451. /**
  31452. * Is the particle visible or not ?
  31453. */
  31454. isVisible: boolean;
  31455. /**
  31456. * Index of this particle in the global "positions" array (Internal use)
  31457. * @hidden
  31458. */
  31459. _pos: number;
  31460. /**
  31461. * @hidden Index of this particle in the global "indices" array (Internal use)
  31462. */
  31463. _ind: number;
  31464. /**
  31465. * @hidden ModelShape of this particle (Internal use)
  31466. */
  31467. _model: ModelShape;
  31468. /**
  31469. * ModelShape id of this particle
  31470. */
  31471. shapeId: number;
  31472. /**
  31473. * Index of the particle in its shape id
  31474. */
  31475. idxInShape: number;
  31476. /**
  31477. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  31478. */
  31479. _modelBoundingInfo: BoundingInfo;
  31480. /**
  31481. * @hidden Particle BoundingInfo object (Internal use)
  31482. */
  31483. _boundingInfo: BoundingInfo;
  31484. /**
  31485. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  31486. */
  31487. _sps: SolidParticleSystem;
  31488. /**
  31489. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  31490. */
  31491. _stillInvisible: boolean;
  31492. /**
  31493. * @hidden Last computed particle rotation matrix
  31494. */
  31495. _rotationMatrix: number[];
  31496. /**
  31497. * Parent particle Id, if any.
  31498. * Default null.
  31499. */
  31500. parentId: Nullable<number>;
  31501. /**
  31502. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  31503. */
  31504. materialIndex: Nullable<number>;
  31505. /**
  31506. * Custom object or properties.
  31507. */
  31508. props: Nullable<any>;
  31509. /**
  31510. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  31511. * The possible values are :
  31512. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31513. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31514. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31515. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31516. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31517. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  31518. * */
  31519. cullingStrategy: number;
  31520. /**
  31521. * @hidden Internal global position in the SPS.
  31522. */
  31523. _globalPosition: Vector3;
  31524. /**
  31525. * Creates a Solid Particle object.
  31526. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  31527. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  31528. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  31529. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  31530. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  31531. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  31532. * @param shapeId (integer) is the model shape identifier in the SPS.
  31533. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  31534. * @param sps defines the sps it is associated to
  31535. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  31536. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  31537. */
  31538. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  31539. /**
  31540. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  31541. * @param target the particle target
  31542. * @returns the current particle
  31543. */
  31544. copyToRef(target: SolidParticle): SolidParticle;
  31545. /**
  31546. * Legacy support, changed scale to scaling
  31547. */
  31548. get scale(): Vector3;
  31549. /**
  31550. * Legacy support, changed scale to scaling
  31551. */
  31552. set scale(scale: Vector3);
  31553. /**
  31554. * Legacy support, changed quaternion to rotationQuaternion
  31555. */
  31556. get quaternion(): Nullable<Quaternion>;
  31557. /**
  31558. * Legacy support, changed quaternion to rotationQuaternion
  31559. */
  31560. set quaternion(q: Nullable<Quaternion>);
  31561. /**
  31562. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  31563. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  31564. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  31565. * @returns true if it intersects
  31566. */
  31567. intersectsMesh(target: Mesh | SolidParticle): boolean;
  31568. /**
  31569. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  31570. * A particle is in the frustum if its bounding box intersects the frustum
  31571. * @param frustumPlanes defines the frustum to test
  31572. * @returns true if the particle is in the frustum planes
  31573. */
  31574. isInFrustum(frustumPlanes: Plane[]): boolean;
  31575. /**
  31576. * get the rotation matrix of the particle
  31577. * @hidden
  31578. */
  31579. getRotationMatrix(m: Matrix): void;
  31580. }
  31581. /**
  31582. * Represents the shape of the model used by one particle of a solid particle system.
  31583. * SPS internal tool, don't use it manually.
  31584. */
  31585. export class ModelShape {
  31586. /**
  31587. * The shape id
  31588. * @hidden
  31589. */
  31590. shapeID: number;
  31591. /**
  31592. * flat array of model positions (internal use)
  31593. * @hidden
  31594. */
  31595. _shape: Vector3[];
  31596. /**
  31597. * flat array of model UVs (internal use)
  31598. * @hidden
  31599. */
  31600. _shapeUV: number[];
  31601. /**
  31602. * color array of the model
  31603. * @hidden
  31604. */
  31605. _shapeColors: number[];
  31606. /**
  31607. * indices array of the model
  31608. * @hidden
  31609. */
  31610. _indices: number[];
  31611. /**
  31612. * normals array of the model
  31613. * @hidden
  31614. */
  31615. _normals: number[];
  31616. /**
  31617. * length of the shape in the model indices array (internal use)
  31618. * @hidden
  31619. */
  31620. _indicesLength: number;
  31621. /**
  31622. * Custom position function (internal use)
  31623. * @hidden
  31624. */
  31625. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  31626. /**
  31627. * Custom vertex function (internal use)
  31628. * @hidden
  31629. */
  31630. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  31631. /**
  31632. * Model material (internal use)
  31633. * @hidden
  31634. */
  31635. _material: Nullable<Material>;
  31636. /**
  31637. * 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.
  31638. * SPS internal tool, don't use it manually.
  31639. * @hidden
  31640. */
  31641. 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>);
  31642. }
  31643. /**
  31644. * Represents a Depth Sorted Particle in the solid particle system.
  31645. * @hidden
  31646. */
  31647. export class DepthSortedParticle {
  31648. /**
  31649. * Particle index
  31650. */
  31651. idx: number;
  31652. /**
  31653. * Index of the particle in the "indices" array
  31654. */
  31655. ind: number;
  31656. /**
  31657. * Length of the particle shape in the "indices" array
  31658. */
  31659. indicesLength: number;
  31660. /**
  31661. * Squared distance from the particle to the camera
  31662. */
  31663. sqDistance: number;
  31664. /**
  31665. * Material index when used with MultiMaterials
  31666. */
  31667. materialIndex: number;
  31668. /**
  31669. * Creates a new sorted particle
  31670. * @param materialIndex
  31671. */
  31672. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  31673. }
  31674. /**
  31675. * Represents a solid particle vertex
  31676. */
  31677. export class SolidParticleVertex {
  31678. /**
  31679. * Vertex position
  31680. */
  31681. position: Vector3;
  31682. /**
  31683. * Vertex color
  31684. */
  31685. color: Color4;
  31686. /**
  31687. * Vertex UV
  31688. */
  31689. uv: Vector2;
  31690. /**
  31691. * Creates a new solid particle vertex
  31692. */
  31693. constructor();
  31694. /** Vertex x coordinate */
  31695. get x(): number;
  31696. set x(val: number);
  31697. /** Vertex y coordinate */
  31698. get y(): number;
  31699. set y(val: number);
  31700. /** Vertex z coordinate */
  31701. get z(): number;
  31702. set z(val: number);
  31703. }
  31704. }
  31705. declare module BABYLON {
  31706. /**
  31707. * @hidden
  31708. */
  31709. export class _MeshCollisionData {
  31710. _checkCollisions: boolean;
  31711. _collisionMask: number;
  31712. _collisionGroup: number;
  31713. _surroundingMeshes: Nullable<AbstractMesh[]>;
  31714. _collider: Nullable<Collider>;
  31715. _oldPositionForCollisions: Vector3;
  31716. _diffPositionForCollisions: Vector3;
  31717. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  31718. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  31719. }
  31720. }
  31721. declare module BABYLON {
  31722. /** @hidden */
  31723. class _FacetDataStorage {
  31724. facetPositions: Vector3[];
  31725. facetNormals: Vector3[];
  31726. facetPartitioning: number[][];
  31727. facetNb: number;
  31728. partitioningSubdivisions: number;
  31729. partitioningBBoxRatio: number;
  31730. facetDataEnabled: boolean;
  31731. facetParameters: any;
  31732. bbSize: Vector3;
  31733. subDiv: {
  31734. max: number;
  31735. X: number;
  31736. Y: number;
  31737. Z: number;
  31738. };
  31739. facetDepthSort: boolean;
  31740. facetDepthSortEnabled: boolean;
  31741. depthSortedIndices: IndicesArray;
  31742. depthSortedFacets: {
  31743. ind: number;
  31744. sqDistance: number;
  31745. }[];
  31746. facetDepthSortFunction: (f1: {
  31747. ind: number;
  31748. sqDistance: number;
  31749. }, f2: {
  31750. ind: number;
  31751. sqDistance: number;
  31752. }) => number;
  31753. facetDepthSortFrom: Vector3;
  31754. facetDepthSortOrigin: Vector3;
  31755. invertedMatrix: Matrix;
  31756. }
  31757. /**
  31758. * @hidden
  31759. **/
  31760. class _InternalAbstractMeshDataInfo {
  31761. _hasVertexAlpha: boolean;
  31762. _useVertexColors: boolean;
  31763. _numBoneInfluencers: number;
  31764. _applyFog: boolean;
  31765. _receiveShadows: boolean;
  31766. _facetData: _FacetDataStorage;
  31767. _visibility: number;
  31768. _skeleton: Nullable<Skeleton>;
  31769. _layerMask: number;
  31770. _computeBonesUsingShaders: boolean;
  31771. _isActive: boolean;
  31772. _onlyForInstances: boolean;
  31773. _isActiveIntermediate: boolean;
  31774. _onlyForInstancesIntermediate: boolean;
  31775. _actAsRegularMesh: boolean;
  31776. }
  31777. /**
  31778. * Class used to store all common mesh properties
  31779. */
  31780. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  31781. /** No occlusion */
  31782. static OCCLUSION_TYPE_NONE: number;
  31783. /** Occlusion set to optimisitic */
  31784. static OCCLUSION_TYPE_OPTIMISTIC: number;
  31785. /** Occlusion set to strict */
  31786. static OCCLUSION_TYPE_STRICT: number;
  31787. /** Use an accurante occlusion algorithm */
  31788. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  31789. /** Use a conservative occlusion algorithm */
  31790. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  31791. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  31792. * Test order :
  31793. * Is the bounding sphere outside the frustum ?
  31794. * If not, are the bounding box vertices outside the frustum ?
  31795. * It not, then the cullable object is in the frustum.
  31796. */
  31797. static readonly CULLINGSTRATEGY_STANDARD: number;
  31798. /** Culling strategy : Bounding Sphere Only.
  31799. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  31800. * It's also less accurate than the standard because some not visible objects can still be selected.
  31801. * Test : is the bounding sphere outside the frustum ?
  31802. * If not, then the cullable object is in the frustum.
  31803. */
  31804. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  31805. /** Culling strategy : Optimistic Inclusion.
  31806. * This in an inclusion test first, then the standard exclusion test.
  31807. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  31808. * 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.
  31809. * Anyway, it's as accurate as the standard strategy.
  31810. * Test :
  31811. * Is the cullable object bounding sphere center in the frustum ?
  31812. * If not, apply the default culling strategy.
  31813. */
  31814. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  31815. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  31816. * This in an inclusion test first, then the bounding sphere only exclusion test.
  31817. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  31818. * 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.
  31819. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  31820. * Test :
  31821. * Is the cullable object bounding sphere center in the frustum ?
  31822. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  31823. */
  31824. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  31825. /**
  31826. * No billboard
  31827. */
  31828. static get BILLBOARDMODE_NONE(): number;
  31829. /** Billboard on X axis */
  31830. static get BILLBOARDMODE_X(): number;
  31831. /** Billboard on Y axis */
  31832. static get BILLBOARDMODE_Y(): number;
  31833. /** Billboard on Z axis */
  31834. static get BILLBOARDMODE_Z(): number;
  31835. /** Billboard on all axes */
  31836. static get BILLBOARDMODE_ALL(): number;
  31837. /** Billboard on using position instead of orientation */
  31838. static get BILLBOARDMODE_USE_POSITION(): number;
  31839. /** @hidden */
  31840. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  31841. /**
  31842. * The culling strategy to use to check whether the mesh must be rendered or not.
  31843. * This value can be changed at any time and will be used on the next render mesh selection.
  31844. * The possible values are :
  31845. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31846. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31847. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31848. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31849. * Please read each static variable documentation to get details about the culling process.
  31850. * */
  31851. cullingStrategy: number;
  31852. /**
  31853. * Gets the number of facets in the mesh
  31854. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  31855. */
  31856. get facetNb(): number;
  31857. /**
  31858. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  31859. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  31860. */
  31861. get partitioningSubdivisions(): number;
  31862. set partitioningSubdivisions(nb: number);
  31863. /**
  31864. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  31865. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  31866. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  31867. */
  31868. get partitioningBBoxRatio(): number;
  31869. set partitioningBBoxRatio(ratio: number);
  31870. /**
  31871. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  31872. * Works only for updatable meshes.
  31873. * Doesn't work with multi-materials
  31874. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  31875. */
  31876. get mustDepthSortFacets(): boolean;
  31877. set mustDepthSortFacets(sort: boolean);
  31878. /**
  31879. * The location (Vector3) where the facet depth sort must be computed from.
  31880. * By default, the active camera position.
  31881. * Used only when facet depth sort is enabled
  31882. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  31883. */
  31884. get facetDepthSortFrom(): Vector3;
  31885. set facetDepthSortFrom(location: Vector3);
  31886. /**
  31887. * gets a boolean indicating if facetData is enabled
  31888. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  31889. */
  31890. get isFacetDataEnabled(): boolean;
  31891. /** @hidden */
  31892. _updateNonUniformScalingState(value: boolean): boolean;
  31893. /**
  31894. * An event triggered when this mesh collides with another one
  31895. */
  31896. onCollideObservable: Observable<AbstractMesh>;
  31897. /** Set a function to call when this mesh collides with another one */
  31898. set onCollide(callback: () => void);
  31899. /**
  31900. * An event triggered when the collision's position changes
  31901. */
  31902. onCollisionPositionChangeObservable: Observable<Vector3>;
  31903. /** Set a function to call when the collision's position changes */
  31904. set onCollisionPositionChange(callback: () => void);
  31905. /**
  31906. * An event triggered when material is changed
  31907. */
  31908. onMaterialChangedObservable: Observable<AbstractMesh>;
  31909. /**
  31910. * Gets or sets the orientation for POV movement & rotation
  31911. */
  31912. definedFacingForward: boolean;
  31913. /** @hidden */
  31914. _occlusionQuery: Nullable<WebGLQuery>;
  31915. /** @hidden */
  31916. _renderingGroup: Nullable<RenderingGroup>;
  31917. /**
  31918. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  31919. */
  31920. get visibility(): number;
  31921. /**
  31922. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  31923. */
  31924. set visibility(value: number);
  31925. /** Gets or sets the alpha index used to sort transparent meshes
  31926. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  31927. */
  31928. alphaIndex: number;
  31929. /**
  31930. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  31931. */
  31932. isVisible: boolean;
  31933. /**
  31934. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  31935. */
  31936. isPickable: boolean;
  31937. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  31938. showSubMeshesBoundingBox: boolean;
  31939. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  31940. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  31941. */
  31942. isBlocker: boolean;
  31943. /**
  31944. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  31945. */
  31946. enablePointerMoveEvents: boolean;
  31947. /**
  31948. * Specifies the rendering group id for this mesh (0 by default)
  31949. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  31950. */
  31951. renderingGroupId: number;
  31952. private _material;
  31953. /** Gets or sets current material */
  31954. get material(): Nullable<Material>;
  31955. set material(value: Nullable<Material>);
  31956. /**
  31957. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  31958. * @see https://doc.babylonjs.com/babylon101/shadows
  31959. */
  31960. get receiveShadows(): boolean;
  31961. set receiveShadows(value: boolean);
  31962. /** Defines color to use when rendering outline */
  31963. outlineColor: Color3;
  31964. /** Define width to use when rendering outline */
  31965. outlineWidth: number;
  31966. /** Defines color to use when rendering overlay */
  31967. overlayColor: Color3;
  31968. /** Defines alpha to use when rendering overlay */
  31969. overlayAlpha: number;
  31970. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  31971. get hasVertexAlpha(): boolean;
  31972. set hasVertexAlpha(value: boolean);
  31973. /** 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) */
  31974. get useVertexColors(): boolean;
  31975. set useVertexColors(value: boolean);
  31976. /**
  31977. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  31978. */
  31979. get computeBonesUsingShaders(): boolean;
  31980. set computeBonesUsingShaders(value: boolean);
  31981. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  31982. get numBoneInfluencers(): number;
  31983. set numBoneInfluencers(value: number);
  31984. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  31985. get applyFog(): boolean;
  31986. set applyFog(value: boolean);
  31987. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  31988. useOctreeForRenderingSelection: boolean;
  31989. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  31990. useOctreeForPicking: boolean;
  31991. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  31992. useOctreeForCollisions: boolean;
  31993. /**
  31994. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  31995. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  31996. */
  31997. get layerMask(): number;
  31998. set layerMask(value: number);
  31999. /**
  32000. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  32001. */
  32002. alwaysSelectAsActiveMesh: boolean;
  32003. /**
  32004. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  32005. */
  32006. doNotSyncBoundingInfo: boolean;
  32007. /**
  32008. * Gets or sets the current action manager
  32009. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  32010. */
  32011. actionManager: Nullable<AbstractActionManager>;
  32012. private _meshCollisionData;
  32013. /**
  32014. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  32015. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32016. */
  32017. ellipsoid: Vector3;
  32018. /**
  32019. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  32020. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32021. */
  32022. ellipsoidOffset: Vector3;
  32023. /**
  32024. * Gets or sets a collision mask used to mask collisions (default is -1).
  32025. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32026. */
  32027. get collisionMask(): number;
  32028. set collisionMask(mask: number);
  32029. /**
  32030. * Gets or sets the current collision group mask (-1 by default).
  32031. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32032. */
  32033. get collisionGroup(): number;
  32034. set collisionGroup(mask: number);
  32035. /**
  32036. * Gets or sets current surrounding meshes (null by default).
  32037. *
  32038. * By default collision detection is tested against every mesh in the scene.
  32039. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  32040. * meshes will be tested for the collision.
  32041. *
  32042. * Note: if set to an empty array no collision will happen when this mesh is moved.
  32043. */
  32044. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  32045. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  32046. /**
  32047. * Defines edge width used when edgesRenderer is enabled
  32048. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32049. */
  32050. edgesWidth: number;
  32051. /**
  32052. * Defines edge color used when edgesRenderer is enabled
  32053. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32054. */
  32055. edgesColor: Color4;
  32056. /** @hidden */
  32057. _edgesRenderer: Nullable<IEdgesRenderer>;
  32058. /** @hidden */
  32059. _masterMesh: Nullable<AbstractMesh>;
  32060. /** @hidden */
  32061. _boundingInfo: Nullable<BoundingInfo>;
  32062. /** @hidden */
  32063. _renderId: number;
  32064. /**
  32065. * Gets or sets the list of subMeshes
  32066. * @see https://doc.babylonjs.com/how_to/multi_materials
  32067. */
  32068. subMeshes: SubMesh[];
  32069. /** @hidden */
  32070. _intersectionsInProgress: AbstractMesh[];
  32071. /** @hidden */
  32072. _unIndexed: boolean;
  32073. /** @hidden */
  32074. _lightSources: Light[];
  32075. /** Gets the list of lights affecting that mesh */
  32076. get lightSources(): Light[];
  32077. /** @hidden */
  32078. get _positions(): Nullable<Vector3[]>;
  32079. /** @hidden */
  32080. _waitingData: {
  32081. lods: Nullable<any>;
  32082. actions: Nullable<any>;
  32083. freezeWorldMatrix: Nullable<boolean>;
  32084. };
  32085. /** @hidden */
  32086. _bonesTransformMatrices: Nullable<Float32Array>;
  32087. /** @hidden */
  32088. _transformMatrixTexture: Nullable<RawTexture>;
  32089. /**
  32090. * Gets or sets a skeleton to apply skining transformations
  32091. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32092. */
  32093. set skeleton(value: Nullable<Skeleton>);
  32094. get skeleton(): Nullable<Skeleton>;
  32095. /**
  32096. * An event triggered when the mesh is rebuilt.
  32097. */
  32098. onRebuildObservable: Observable<AbstractMesh>;
  32099. /**
  32100. * Creates a new AbstractMesh
  32101. * @param name defines the name of the mesh
  32102. * @param scene defines the hosting scene
  32103. */
  32104. constructor(name: string, scene?: Nullable<Scene>);
  32105. /**
  32106. * Returns the string "AbstractMesh"
  32107. * @returns "AbstractMesh"
  32108. */
  32109. getClassName(): string;
  32110. /**
  32111. * Gets a string representation of the current mesh
  32112. * @param fullDetails defines a boolean indicating if full details must be included
  32113. * @returns a string representation of the current mesh
  32114. */
  32115. toString(fullDetails?: boolean): string;
  32116. /**
  32117. * @hidden
  32118. */
  32119. protected _getEffectiveParent(): Nullable<Node>;
  32120. /** @hidden */
  32121. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32122. /** @hidden */
  32123. _rebuild(): void;
  32124. /** @hidden */
  32125. _resyncLightSources(): void;
  32126. /** @hidden */
  32127. _resyncLightSource(light: Light): void;
  32128. /** @hidden */
  32129. _unBindEffect(): void;
  32130. /** @hidden */
  32131. _removeLightSource(light: Light, dispose: boolean): void;
  32132. private _markSubMeshesAsDirty;
  32133. /** @hidden */
  32134. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  32135. /** @hidden */
  32136. _markSubMeshesAsAttributesDirty(): void;
  32137. /** @hidden */
  32138. _markSubMeshesAsMiscDirty(): void;
  32139. /**
  32140. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  32141. */
  32142. get scaling(): Vector3;
  32143. set scaling(newScaling: Vector3);
  32144. /**
  32145. * Returns true if the mesh is blocked. Implemented by child classes
  32146. */
  32147. get isBlocked(): boolean;
  32148. /**
  32149. * Returns the mesh itself by default. Implemented by child classes
  32150. * @param camera defines the camera to use to pick the right LOD level
  32151. * @returns the currentAbstractMesh
  32152. */
  32153. getLOD(camera: Camera): Nullable<AbstractMesh>;
  32154. /**
  32155. * Returns 0 by default. Implemented by child classes
  32156. * @returns an integer
  32157. */
  32158. getTotalVertices(): number;
  32159. /**
  32160. * Returns a positive integer : the total number of indices in this mesh geometry.
  32161. * @returns the numner of indices or zero if the mesh has no geometry.
  32162. */
  32163. getTotalIndices(): number;
  32164. /**
  32165. * Returns null by default. Implemented by child classes
  32166. * @returns null
  32167. */
  32168. getIndices(): Nullable<IndicesArray>;
  32169. /**
  32170. * Returns the array of the requested vertex data kind. Implemented by child classes
  32171. * @param kind defines the vertex data kind to use
  32172. * @returns null
  32173. */
  32174. getVerticesData(kind: string): Nullable<FloatArray>;
  32175. /**
  32176. * Sets the vertex data of the mesh geometry for the requested `kind`.
  32177. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  32178. * Note that a new underlying VertexBuffer object is created each call.
  32179. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  32180. * @param kind defines vertex data kind:
  32181. * * VertexBuffer.PositionKind
  32182. * * VertexBuffer.UVKind
  32183. * * VertexBuffer.UV2Kind
  32184. * * VertexBuffer.UV3Kind
  32185. * * VertexBuffer.UV4Kind
  32186. * * VertexBuffer.UV5Kind
  32187. * * VertexBuffer.UV6Kind
  32188. * * VertexBuffer.ColorKind
  32189. * * VertexBuffer.MatricesIndicesKind
  32190. * * VertexBuffer.MatricesIndicesExtraKind
  32191. * * VertexBuffer.MatricesWeightsKind
  32192. * * VertexBuffer.MatricesWeightsExtraKind
  32193. * @param data defines the data source
  32194. * @param updatable defines if the data must be flagged as updatable (or static)
  32195. * @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
  32196. * @returns the current mesh
  32197. */
  32198. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32199. /**
  32200. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  32201. * If the mesh has no geometry, it is simply returned as it is.
  32202. * @param kind defines vertex data kind:
  32203. * * VertexBuffer.PositionKind
  32204. * * VertexBuffer.UVKind
  32205. * * VertexBuffer.UV2Kind
  32206. * * VertexBuffer.UV3Kind
  32207. * * VertexBuffer.UV4Kind
  32208. * * VertexBuffer.UV5Kind
  32209. * * VertexBuffer.UV6Kind
  32210. * * VertexBuffer.ColorKind
  32211. * * VertexBuffer.MatricesIndicesKind
  32212. * * VertexBuffer.MatricesIndicesExtraKind
  32213. * * VertexBuffer.MatricesWeightsKind
  32214. * * VertexBuffer.MatricesWeightsExtraKind
  32215. * @param data defines the data source
  32216. * @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
  32217. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  32218. * @returns the current mesh
  32219. */
  32220. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32221. /**
  32222. * Sets the mesh indices,
  32223. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  32224. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  32225. * @param totalVertices Defines the total number of vertices
  32226. * @returns the current mesh
  32227. */
  32228. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  32229. /**
  32230. * Gets a boolean indicating if specific vertex data is present
  32231. * @param kind defines the vertex data kind to use
  32232. * @returns true is data kind is present
  32233. */
  32234. isVerticesDataPresent(kind: string): boolean;
  32235. /**
  32236. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  32237. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  32238. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  32239. * @returns a BoundingInfo
  32240. */
  32241. getBoundingInfo(): BoundingInfo;
  32242. /**
  32243. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  32244. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  32245. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  32246. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  32247. * @returns the current mesh
  32248. */
  32249. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  32250. /**
  32251. * Overwrite the current bounding info
  32252. * @param boundingInfo defines the new bounding info
  32253. * @returns the current mesh
  32254. */
  32255. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  32256. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  32257. get useBones(): boolean;
  32258. /** @hidden */
  32259. _preActivate(): void;
  32260. /** @hidden */
  32261. _preActivateForIntermediateRendering(renderId: number): void;
  32262. /** @hidden */
  32263. _activate(renderId: number, intermediateRendering: boolean): boolean;
  32264. /** @hidden */
  32265. _postActivate(): void;
  32266. /** @hidden */
  32267. _freeze(): void;
  32268. /** @hidden */
  32269. _unFreeze(): void;
  32270. /**
  32271. * Gets the current world matrix
  32272. * @returns a Matrix
  32273. */
  32274. getWorldMatrix(): Matrix;
  32275. /** @hidden */
  32276. _getWorldMatrixDeterminant(): number;
  32277. /**
  32278. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  32279. */
  32280. get isAnInstance(): boolean;
  32281. /**
  32282. * Gets a boolean indicating if this mesh has instances
  32283. */
  32284. get hasInstances(): boolean;
  32285. /**
  32286. * Gets a boolean indicating if this mesh has thin instances
  32287. */
  32288. get hasThinInstances(): boolean;
  32289. /**
  32290. * Perform relative position change from the point of view of behind the front of the mesh.
  32291. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32292. * Supports definition of mesh facing forward or backward
  32293. * @param amountRight defines the distance on the right axis
  32294. * @param amountUp defines the distance on the up axis
  32295. * @param amountForward defines the distance on the forward axis
  32296. * @returns the current mesh
  32297. */
  32298. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  32299. /**
  32300. * Calculate relative position change from the point of view of behind the front of the mesh.
  32301. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32302. * Supports definition of mesh facing forward or backward
  32303. * @param amountRight defines the distance on the right axis
  32304. * @param amountUp defines the distance on the up axis
  32305. * @param amountForward defines the distance on the forward axis
  32306. * @returns the new displacement vector
  32307. */
  32308. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  32309. /**
  32310. * Perform relative rotation change from the point of view of behind the front of the mesh.
  32311. * Supports definition of mesh facing forward or backward
  32312. * @param flipBack defines the flip
  32313. * @param twirlClockwise defines the twirl
  32314. * @param tiltRight defines the tilt
  32315. * @returns the current mesh
  32316. */
  32317. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  32318. /**
  32319. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  32320. * Supports definition of mesh facing forward or backward.
  32321. * @param flipBack defines the flip
  32322. * @param twirlClockwise defines the twirl
  32323. * @param tiltRight defines the tilt
  32324. * @returns the new rotation vector
  32325. */
  32326. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  32327. /**
  32328. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32329. * This means the mesh underlying bounding box and sphere are recomputed.
  32330. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32331. * @returns the current mesh
  32332. */
  32333. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  32334. /** @hidden */
  32335. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  32336. /** @hidden */
  32337. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  32338. /** @hidden */
  32339. _updateBoundingInfo(): AbstractMesh;
  32340. /** @hidden */
  32341. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  32342. /** @hidden */
  32343. protected _afterComputeWorldMatrix(): void;
  32344. /** @hidden */
  32345. get _effectiveMesh(): AbstractMesh;
  32346. /**
  32347. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32348. * A mesh is in the frustum if its bounding box intersects the frustum
  32349. * @param frustumPlanes defines the frustum to test
  32350. * @returns true if the mesh is in the frustum planes
  32351. */
  32352. isInFrustum(frustumPlanes: Plane[]): boolean;
  32353. /**
  32354. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  32355. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  32356. * @param frustumPlanes defines the frustum to test
  32357. * @returns true if the mesh is completely in the frustum planes
  32358. */
  32359. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  32360. /**
  32361. * True if the mesh intersects another mesh or a SolidParticle object
  32362. * @param mesh defines a target mesh or SolidParticle to test
  32363. * @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)
  32364. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  32365. * @returns true if there is an intersection
  32366. */
  32367. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  32368. /**
  32369. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  32370. * @param point defines the point to test
  32371. * @returns true if there is an intersection
  32372. */
  32373. intersectsPoint(point: Vector3): boolean;
  32374. /**
  32375. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  32376. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32377. */
  32378. get checkCollisions(): boolean;
  32379. set checkCollisions(collisionEnabled: boolean);
  32380. /**
  32381. * Gets Collider object used to compute collisions (not physics)
  32382. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32383. */
  32384. get collider(): Nullable<Collider>;
  32385. /**
  32386. * Move the mesh using collision engine
  32387. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32388. * @param displacement defines the requested displacement vector
  32389. * @returns the current mesh
  32390. */
  32391. moveWithCollisions(displacement: Vector3): AbstractMesh;
  32392. private _onCollisionPositionChange;
  32393. /** @hidden */
  32394. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  32395. /** @hidden */
  32396. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  32397. /** @hidden */
  32398. _checkCollision(collider: Collider): AbstractMesh;
  32399. /** @hidden */
  32400. _generatePointsArray(): boolean;
  32401. /**
  32402. * Checks if the passed Ray intersects with the mesh
  32403. * @param ray defines the ray to use
  32404. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  32405. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32406. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  32407. * @returns the picking info
  32408. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  32409. */
  32410. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  32411. /**
  32412. * Clones the current mesh
  32413. * @param name defines the mesh name
  32414. * @param newParent defines the new mesh parent
  32415. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  32416. * @returns the new mesh
  32417. */
  32418. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  32419. /**
  32420. * Disposes all the submeshes of the current meshnp
  32421. * @returns the current mesh
  32422. */
  32423. releaseSubMeshes(): AbstractMesh;
  32424. /**
  32425. * Releases resources associated with this abstract mesh.
  32426. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32427. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32428. */
  32429. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32430. /**
  32431. * Adds the passed mesh as a child to the current mesh
  32432. * @param mesh defines the child mesh
  32433. * @returns the current mesh
  32434. */
  32435. addChild(mesh: AbstractMesh): AbstractMesh;
  32436. /**
  32437. * Removes the passed mesh from the current mesh children list
  32438. * @param mesh defines the child mesh
  32439. * @returns the current mesh
  32440. */
  32441. removeChild(mesh: AbstractMesh): AbstractMesh;
  32442. /** @hidden */
  32443. private _initFacetData;
  32444. /**
  32445. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  32446. * This method can be called within the render loop.
  32447. * 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
  32448. * @returns the current mesh
  32449. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32450. */
  32451. updateFacetData(): AbstractMesh;
  32452. /**
  32453. * Returns the facetLocalNormals array.
  32454. * The normals are expressed in the mesh local spac
  32455. * @returns an array of Vector3
  32456. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32457. */
  32458. getFacetLocalNormals(): Vector3[];
  32459. /**
  32460. * Returns the facetLocalPositions array.
  32461. * The facet positions are expressed in the mesh local space
  32462. * @returns an array of Vector3
  32463. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32464. */
  32465. getFacetLocalPositions(): Vector3[];
  32466. /**
  32467. * Returns the facetLocalPartioning array
  32468. * @returns an array of array of numbers
  32469. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32470. */
  32471. getFacetLocalPartitioning(): number[][];
  32472. /**
  32473. * Returns the i-th facet position in the world system.
  32474. * This method allocates a new Vector3 per call
  32475. * @param i defines the facet index
  32476. * @returns a new Vector3
  32477. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32478. */
  32479. getFacetPosition(i: number): Vector3;
  32480. /**
  32481. * Sets the reference Vector3 with the i-th facet position in the world system
  32482. * @param i defines the facet index
  32483. * @param ref defines the target vector
  32484. * @returns the current mesh
  32485. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32486. */
  32487. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  32488. /**
  32489. * Returns the i-th facet normal in the world system.
  32490. * This method allocates a new Vector3 per call
  32491. * @param i defines the facet index
  32492. * @returns a new Vector3
  32493. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32494. */
  32495. getFacetNormal(i: number): Vector3;
  32496. /**
  32497. * Sets the reference Vector3 with the i-th facet normal in the world system
  32498. * @param i defines the facet index
  32499. * @param ref defines the target vector
  32500. * @returns the current mesh
  32501. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32502. */
  32503. getFacetNormalToRef(i: number, ref: Vector3): this;
  32504. /**
  32505. * 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)
  32506. * @param x defines x coordinate
  32507. * @param y defines y coordinate
  32508. * @param z defines z coordinate
  32509. * @returns the array of facet indexes
  32510. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32511. */
  32512. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  32513. /**
  32514. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  32515. * @param projected sets as the (x,y,z) world projection on the facet
  32516. * @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
  32517. * @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
  32518. * @param x defines x coordinate
  32519. * @param y defines y coordinate
  32520. * @param z defines z coordinate
  32521. * @returns the face index if found (or null instead)
  32522. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32523. */
  32524. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32525. /**
  32526. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  32527. * @param projected sets as the (x,y,z) local projection on the facet
  32528. * @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
  32529. * @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
  32530. * @param x defines x coordinate
  32531. * @param y defines y coordinate
  32532. * @param z defines z coordinate
  32533. * @returns the face index if found (or null instead)
  32534. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32535. */
  32536. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32537. /**
  32538. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  32539. * @returns the parameters
  32540. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32541. */
  32542. getFacetDataParameters(): any;
  32543. /**
  32544. * Disables the feature FacetData and frees the related memory
  32545. * @returns the current mesh
  32546. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32547. */
  32548. disableFacetData(): AbstractMesh;
  32549. /**
  32550. * Updates the AbstractMesh indices array
  32551. * @param indices defines the data source
  32552. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32553. * @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)
  32554. * @returns the current mesh
  32555. */
  32556. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32557. /**
  32558. * Creates new normals data for the mesh
  32559. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  32560. * @returns the current mesh
  32561. */
  32562. createNormals(updatable: boolean): AbstractMesh;
  32563. /**
  32564. * Align the mesh with a normal
  32565. * @param normal defines the normal to use
  32566. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  32567. * @returns the current mesh
  32568. */
  32569. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  32570. /** @hidden */
  32571. _checkOcclusionQuery(): boolean;
  32572. /**
  32573. * Disables the mesh edge rendering mode
  32574. * @returns the currentAbstractMesh
  32575. */
  32576. disableEdgesRendering(): AbstractMesh;
  32577. /**
  32578. * Enables the edge rendering mode on the mesh.
  32579. * This mode makes the mesh edges visible
  32580. * @param epsilon defines the maximal distance between two angles to detect a face
  32581. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  32582. * @returns the currentAbstractMesh
  32583. * @see https://www.babylonjs-playground.com/#19O9TU#0
  32584. */
  32585. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  32586. /**
  32587. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  32588. * @returns an array of particle systems in the scene that use the mesh as an emitter
  32589. */
  32590. getConnectedParticleSystems(): IParticleSystem[];
  32591. }
  32592. }
  32593. declare module BABYLON {
  32594. /**
  32595. * Interface used to define ActionEvent
  32596. */
  32597. export interface IActionEvent {
  32598. /** The mesh or sprite that triggered the action */
  32599. source: any;
  32600. /** The X mouse cursor position at the time of the event */
  32601. pointerX: number;
  32602. /** The Y mouse cursor position at the time of the event */
  32603. pointerY: number;
  32604. /** The mesh that is currently pointed at (can be null) */
  32605. meshUnderPointer: Nullable<AbstractMesh>;
  32606. /** the original (browser) event that triggered the ActionEvent */
  32607. sourceEvent?: any;
  32608. /** additional data for the event */
  32609. additionalData?: any;
  32610. }
  32611. /**
  32612. * ActionEvent is the event being sent when an action is triggered.
  32613. */
  32614. export class ActionEvent implements IActionEvent {
  32615. /** The mesh or sprite that triggered the action */
  32616. source: any;
  32617. /** The X mouse cursor position at the time of the event */
  32618. pointerX: number;
  32619. /** The Y mouse cursor position at the time of the event */
  32620. pointerY: number;
  32621. /** The mesh that is currently pointed at (can be null) */
  32622. meshUnderPointer: Nullable<AbstractMesh>;
  32623. /** the original (browser) event that triggered the ActionEvent */
  32624. sourceEvent?: any;
  32625. /** additional data for the event */
  32626. additionalData?: any;
  32627. /**
  32628. * Creates a new ActionEvent
  32629. * @param source The mesh or sprite that triggered the action
  32630. * @param pointerX The X mouse cursor position at the time of the event
  32631. * @param pointerY The Y mouse cursor position at the time of the event
  32632. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  32633. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  32634. * @param additionalData additional data for the event
  32635. */
  32636. constructor(
  32637. /** The mesh or sprite that triggered the action */
  32638. source: any,
  32639. /** The X mouse cursor position at the time of the event */
  32640. pointerX: number,
  32641. /** The Y mouse cursor position at the time of the event */
  32642. pointerY: number,
  32643. /** The mesh that is currently pointed at (can be null) */
  32644. meshUnderPointer: Nullable<AbstractMesh>,
  32645. /** the original (browser) event that triggered the ActionEvent */
  32646. sourceEvent?: any,
  32647. /** additional data for the event */
  32648. additionalData?: any);
  32649. /**
  32650. * Helper function to auto-create an ActionEvent from a source mesh.
  32651. * @param source The source mesh that triggered the event
  32652. * @param evt The original (browser) event
  32653. * @param additionalData additional data for the event
  32654. * @returns the new ActionEvent
  32655. */
  32656. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  32657. /**
  32658. * Helper function to auto-create an ActionEvent from a source sprite
  32659. * @param source The source sprite that triggered the event
  32660. * @param scene Scene associated with the sprite
  32661. * @param evt The original (browser) event
  32662. * @param additionalData additional data for the event
  32663. * @returns the new ActionEvent
  32664. */
  32665. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  32666. /**
  32667. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  32668. * @param scene the scene where the event occurred
  32669. * @param evt The original (browser) event
  32670. * @returns the new ActionEvent
  32671. */
  32672. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  32673. /**
  32674. * Helper function to auto-create an ActionEvent from a primitive
  32675. * @param prim defines the target primitive
  32676. * @param pointerPos defines the pointer position
  32677. * @param evt The original (browser) event
  32678. * @param additionalData additional data for the event
  32679. * @returns the new ActionEvent
  32680. */
  32681. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  32682. }
  32683. }
  32684. declare module BABYLON {
  32685. /**
  32686. * Abstract class used to decouple action Manager from scene and meshes.
  32687. * Do not instantiate.
  32688. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  32689. */
  32690. export abstract class AbstractActionManager implements IDisposable {
  32691. /** Gets the list of active triggers */
  32692. static Triggers: {
  32693. [key: string]: number;
  32694. };
  32695. /** Gets the cursor to use when hovering items */
  32696. hoverCursor: string;
  32697. /** Gets the list of actions */
  32698. actions: IAction[];
  32699. /**
  32700. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  32701. */
  32702. isRecursive: boolean;
  32703. /**
  32704. * Releases all associated resources
  32705. */
  32706. abstract dispose(): void;
  32707. /**
  32708. * Does this action manager has pointer triggers
  32709. */
  32710. abstract get hasPointerTriggers(): boolean;
  32711. /**
  32712. * Does this action manager has pick triggers
  32713. */
  32714. abstract get hasPickTriggers(): boolean;
  32715. /**
  32716. * Process a specific trigger
  32717. * @param trigger defines the trigger to process
  32718. * @param evt defines the event details to be processed
  32719. */
  32720. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  32721. /**
  32722. * Does this action manager handles actions of any of the given triggers
  32723. * @param triggers defines the triggers to be tested
  32724. * @return a boolean indicating whether one (or more) of the triggers is handled
  32725. */
  32726. abstract hasSpecificTriggers(triggers: number[]): boolean;
  32727. /**
  32728. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  32729. * speed.
  32730. * @param triggerA defines the trigger to be tested
  32731. * @param triggerB defines the trigger to be tested
  32732. * @return a boolean indicating whether one (or more) of the triggers is handled
  32733. */
  32734. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  32735. /**
  32736. * Does this action manager handles actions of a given trigger
  32737. * @param trigger defines the trigger to be tested
  32738. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  32739. * @return whether the trigger is handled
  32740. */
  32741. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  32742. /**
  32743. * Serialize this manager to a JSON object
  32744. * @param name defines the property name to store this manager
  32745. * @returns a JSON representation of this manager
  32746. */
  32747. abstract serialize(name: string): any;
  32748. /**
  32749. * Registers an action to this action manager
  32750. * @param action defines the action to be registered
  32751. * @return the action amended (prepared) after registration
  32752. */
  32753. abstract registerAction(action: IAction): Nullable<IAction>;
  32754. /**
  32755. * Unregisters an action to this action manager
  32756. * @param action defines the action to be unregistered
  32757. * @return a boolean indicating whether the action has been unregistered
  32758. */
  32759. abstract unregisterAction(action: IAction): Boolean;
  32760. /**
  32761. * Does exist one action manager with at least one trigger
  32762. **/
  32763. static get HasTriggers(): boolean;
  32764. /**
  32765. * Does exist one action manager with at least one pick trigger
  32766. **/
  32767. static get HasPickTriggers(): boolean;
  32768. /**
  32769. * Does exist one action manager that handles actions of a given trigger
  32770. * @param trigger defines the trigger to be tested
  32771. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  32772. **/
  32773. static HasSpecificTrigger(trigger: number): boolean;
  32774. }
  32775. }
  32776. declare module BABYLON {
  32777. /**
  32778. * Defines how a node can be built from a string name.
  32779. */
  32780. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  32781. /**
  32782. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  32783. */
  32784. export class Node implements IBehaviorAware<Node> {
  32785. /** @hidden */
  32786. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  32787. private static _NodeConstructors;
  32788. /**
  32789. * Add a new node constructor
  32790. * @param type defines the type name of the node to construct
  32791. * @param constructorFunc defines the constructor function
  32792. */
  32793. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  32794. /**
  32795. * Returns a node constructor based on type name
  32796. * @param type defines the type name
  32797. * @param name defines the new node name
  32798. * @param scene defines the hosting scene
  32799. * @param options defines optional options to transmit to constructors
  32800. * @returns the new constructor or null
  32801. */
  32802. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  32803. /**
  32804. * Gets or sets the name of the node
  32805. */
  32806. name: string;
  32807. /**
  32808. * Gets or sets the id of the node
  32809. */
  32810. id: string;
  32811. /**
  32812. * Gets or sets the unique id of the node
  32813. */
  32814. uniqueId: number;
  32815. /**
  32816. * Gets or sets a string used to store user defined state for the node
  32817. */
  32818. state: string;
  32819. /**
  32820. * Gets or sets an object used to store user defined information for the node
  32821. */
  32822. metadata: any;
  32823. /**
  32824. * For internal use only. Please do not use.
  32825. */
  32826. reservedDataStore: any;
  32827. /**
  32828. * List of inspectable custom properties (used by the Inspector)
  32829. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  32830. */
  32831. inspectableCustomProperties: IInspectable[];
  32832. private _doNotSerialize;
  32833. /**
  32834. * Gets or sets a boolean used to define if the node must be serialized
  32835. */
  32836. get doNotSerialize(): boolean;
  32837. set doNotSerialize(value: boolean);
  32838. /** @hidden */
  32839. _isDisposed: boolean;
  32840. /**
  32841. * Gets a list of Animations associated with the node
  32842. */
  32843. animations: Animation[];
  32844. protected _ranges: {
  32845. [name: string]: Nullable<AnimationRange>;
  32846. };
  32847. /**
  32848. * Callback raised when the node is ready to be used
  32849. */
  32850. onReady: Nullable<(node: Node) => void>;
  32851. private _isEnabled;
  32852. private _isParentEnabled;
  32853. private _isReady;
  32854. /** @hidden */
  32855. _currentRenderId: number;
  32856. private _parentUpdateId;
  32857. /** @hidden */
  32858. _childUpdateId: number;
  32859. /** @hidden */
  32860. _waitingParentId: Nullable<string>;
  32861. /** @hidden */
  32862. _scene: Scene;
  32863. /** @hidden */
  32864. _cache: any;
  32865. private _parentNode;
  32866. private _children;
  32867. /** @hidden */
  32868. _worldMatrix: Matrix;
  32869. /** @hidden */
  32870. _worldMatrixDeterminant: number;
  32871. /** @hidden */
  32872. _worldMatrixDeterminantIsDirty: boolean;
  32873. /** @hidden */
  32874. private _sceneRootNodesIndex;
  32875. /**
  32876. * Gets a boolean indicating if the node has been disposed
  32877. * @returns true if the node was disposed
  32878. */
  32879. isDisposed(): boolean;
  32880. /**
  32881. * Gets or sets the parent of the node (without keeping the current position in the scene)
  32882. * @see https://doc.babylonjs.com/how_to/parenting
  32883. */
  32884. set parent(parent: Nullable<Node>);
  32885. get parent(): Nullable<Node>;
  32886. /** @hidden */
  32887. _addToSceneRootNodes(): void;
  32888. /** @hidden */
  32889. _removeFromSceneRootNodes(): void;
  32890. private _animationPropertiesOverride;
  32891. /**
  32892. * Gets or sets the animation properties override
  32893. */
  32894. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  32895. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  32896. /**
  32897. * Gets a string idenfifying the name of the class
  32898. * @returns "Node" string
  32899. */
  32900. getClassName(): string;
  32901. /** @hidden */
  32902. readonly _isNode: boolean;
  32903. /**
  32904. * An event triggered when the mesh is disposed
  32905. */
  32906. onDisposeObservable: Observable<Node>;
  32907. private _onDisposeObserver;
  32908. /**
  32909. * Sets a callback that will be raised when the node will be disposed
  32910. */
  32911. set onDispose(callback: () => void);
  32912. /**
  32913. * Creates a new Node
  32914. * @param name the name and id to be given to this node
  32915. * @param scene the scene this node will be added to
  32916. */
  32917. constructor(name: string, scene?: Nullable<Scene>);
  32918. /**
  32919. * Gets the scene of the node
  32920. * @returns a scene
  32921. */
  32922. getScene(): Scene;
  32923. /**
  32924. * Gets the engine of the node
  32925. * @returns a Engine
  32926. */
  32927. getEngine(): Engine;
  32928. private _behaviors;
  32929. /**
  32930. * Attach a behavior to the node
  32931. * @see https://doc.babylonjs.com/features/behaviour
  32932. * @param behavior defines the behavior to attach
  32933. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  32934. * @returns the current Node
  32935. */
  32936. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  32937. /**
  32938. * Remove an attached behavior
  32939. * @see https://doc.babylonjs.com/features/behaviour
  32940. * @param behavior defines the behavior to attach
  32941. * @returns the current Node
  32942. */
  32943. removeBehavior(behavior: Behavior<Node>): Node;
  32944. /**
  32945. * Gets the list of attached behaviors
  32946. * @see https://doc.babylonjs.com/features/behaviour
  32947. */
  32948. get behaviors(): Behavior<Node>[];
  32949. /**
  32950. * Gets an attached behavior by name
  32951. * @param name defines the name of the behavior to look for
  32952. * @see https://doc.babylonjs.com/features/behaviour
  32953. * @returns null if behavior was not found else the requested behavior
  32954. */
  32955. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  32956. /**
  32957. * Returns the latest update of the World matrix
  32958. * @returns a Matrix
  32959. */
  32960. getWorldMatrix(): Matrix;
  32961. /** @hidden */
  32962. _getWorldMatrixDeterminant(): number;
  32963. /**
  32964. * Returns directly the latest state of the mesh World matrix.
  32965. * A Matrix is returned.
  32966. */
  32967. get worldMatrixFromCache(): Matrix;
  32968. /** @hidden */
  32969. _initCache(): void;
  32970. /** @hidden */
  32971. updateCache(force?: boolean): void;
  32972. /** @hidden */
  32973. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32974. /** @hidden */
  32975. _updateCache(ignoreParentClass?: boolean): void;
  32976. /** @hidden */
  32977. _isSynchronized(): boolean;
  32978. /** @hidden */
  32979. _markSyncedWithParent(): void;
  32980. /** @hidden */
  32981. isSynchronizedWithParent(): boolean;
  32982. /** @hidden */
  32983. isSynchronized(): boolean;
  32984. /**
  32985. * Is this node ready to be used/rendered
  32986. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  32987. * @return true if the node is ready
  32988. */
  32989. isReady(completeCheck?: boolean): boolean;
  32990. /**
  32991. * Is this node enabled?
  32992. * 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
  32993. * @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
  32994. * @return whether this node (and its parent) is enabled
  32995. */
  32996. isEnabled(checkAncestors?: boolean): boolean;
  32997. /** @hidden */
  32998. protected _syncParentEnabledState(): void;
  32999. /**
  33000. * Set the enabled state of this node
  33001. * @param value defines the new enabled state
  33002. */
  33003. setEnabled(value: boolean): void;
  33004. /**
  33005. * Is this node a descendant of the given node?
  33006. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  33007. * @param ancestor defines the parent node to inspect
  33008. * @returns a boolean indicating if this node is a descendant of the given node
  33009. */
  33010. isDescendantOf(ancestor: Node): boolean;
  33011. /** @hidden */
  33012. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  33013. /**
  33014. * Will return all nodes that have this node as ascendant
  33015. * @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
  33016. * @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
  33017. * @return all children nodes of all types
  33018. */
  33019. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  33020. /**
  33021. * Get all child-meshes of this node
  33022. * @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)
  33023. * @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
  33024. * @returns an array of AbstractMesh
  33025. */
  33026. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  33027. /**
  33028. * Get all direct children of this node
  33029. * @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
  33030. * @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)
  33031. * @returns an array of Node
  33032. */
  33033. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  33034. /** @hidden */
  33035. _setReady(state: boolean): void;
  33036. /**
  33037. * Get an animation by name
  33038. * @param name defines the name of the animation to look for
  33039. * @returns null if not found else the requested animation
  33040. */
  33041. getAnimationByName(name: string): Nullable<Animation>;
  33042. /**
  33043. * Creates an animation range for this node
  33044. * @param name defines the name of the range
  33045. * @param from defines the starting key
  33046. * @param to defines the end key
  33047. */
  33048. createAnimationRange(name: string, from: number, to: number): void;
  33049. /**
  33050. * Delete a specific animation range
  33051. * @param name defines the name of the range to delete
  33052. * @param deleteFrames defines if animation frames from the range must be deleted as well
  33053. */
  33054. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  33055. /**
  33056. * Get an animation range by name
  33057. * @param name defines the name of the animation range to look for
  33058. * @returns null if not found else the requested animation range
  33059. */
  33060. getAnimationRange(name: string): Nullable<AnimationRange>;
  33061. /**
  33062. * Gets the list of all animation ranges defined on this node
  33063. * @returns an array
  33064. */
  33065. getAnimationRanges(): Nullable<AnimationRange>[];
  33066. /**
  33067. * Will start the animation sequence
  33068. * @param name defines the range frames for animation sequence
  33069. * @param loop defines if the animation should loop (false by default)
  33070. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  33071. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  33072. * @returns the object created for this animation. If range does not exist, it will return null
  33073. */
  33074. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  33075. /**
  33076. * Serialize animation ranges into a JSON compatible object
  33077. * @returns serialization object
  33078. */
  33079. serializeAnimationRanges(): any;
  33080. /**
  33081. * Computes the world matrix of the node
  33082. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  33083. * @returns the world matrix
  33084. */
  33085. computeWorldMatrix(force?: boolean): Matrix;
  33086. /**
  33087. * Releases resources associated with this node.
  33088. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33089. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33090. */
  33091. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33092. /**
  33093. * Parse animation range data from a serialization object and store them into a given node
  33094. * @param node defines where to store the animation ranges
  33095. * @param parsedNode defines the serialization object to read data from
  33096. * @param scene defines the hosting scene
  33097. */
  33098. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  33099. /**
  33100. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  33101. * @param includeDescendants Include bounding info from descendants as well (true by default)
  33102. * @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
  33103. * @returns the new bounding vectors
  33104. */
  33105. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  33106. min: Vector3;
  33107. max: Vector3;
  33108. };
  33109. }
  33110. }
  33111. declare module BABYLON {
  33112. /**
  33113. * @hidden
  33114. */
  33115. export class _IAnimationState {
  33116. key: number;
  33117. repeatCount: number;
  33118. workValue?: any;
  33119. loopMode?: number;
  33120. offsetValue?: any;
  33121. highLimitValue?: any;
  33122. }
  33123. /**
  33124. * Class used to store any kind of animation
  33125. */
  33126. export class Animation {
  33127. /**Name of the animation */
  33128. name: string;
  33129. /**Property to animate */
  33130. targetProperty: string;
  33131. /**The frames per second of the animation */
  33132. framePerSecond: number;
  33133. /**The data type of the animation */
  33134. dataType: number;
  33135. /**The loop mode of the animation */
  33136. loopMode?: number | undefined;
  33137. /**Specifies if blending should be enabled */
  33138. enableBlending?: boolean | undefined;
  33139. /**
  33140. * Use matrix interpolation instead of using direct key value when animating matrices
  33141. */
  33142. static AllowMatricesInterpolation: boolean;
  33143. /**
  33144. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  33145. */
  33146. static AllowMatrixDecomposeForInterpolation: boolean;
  33147. /** Define the Url to load snippets */
  33148. static SnippetUrl: string;
  33149. /** Snippet ID if the animation was created from the snippet server */
  33150. snippetId: string;
  33151. /**
  33152. * Stores the key frames of the animation
  33153. */
  33154. private _keys;
  33155. /**
  33156. * Stores the easing function of the animation
  33157. */
  33158. private _easingFunction;
  33159. /**
  33160. * @hidden Internal use only
  33161. */
  33162. _runtimeAnimations: RuntimeAnimation[];
  33163. /**
  33164. * The set of event that will be linked to this animation
  33165. */
  33166. private _events;
  33167. /**
  33168. * Stores an array of target property paths
  33169. */
  33170. targetPropertyPath: string[];
  33171. /**
  33172. * Stores the blending speed of the animation
  33173. */
  33174. blendingSpeed: number;
  33175. /**
  33176. * Stores the animation ranges for the animation
  33177. */
  33178. private _ranges;
  33179. /**
  33180. * @hidden Internal use
  33181. */
  33182. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  33183. /**
  33184. * Sets up an animation
  33185. * @param property The property to animate
  33186. * @param animationType The animation type to apply
  33187. * @param framePerSecond The frames per second of the animation
  33188. * @param easingFunction The easing function used in the animation
  33189. * @returns The created animation
  33190. */
  33191. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  33192. /**
  33193. * Create and start an animation on a node
  33194. * @param name defines the name of the global animation that will be run on all nodes
  33195. * @param node defines the root node where the animation will take place
  33196. * @param targetProperty defines property to animate
  33197. * @param framePerSecond defines the number of frame per second yo use
  33198. * @param totalFrame defines the number of frames in total
  33199. * @param from defines the initial value
  33200. * @param to defines the final value
  33201. * @param loopMode defines which loop mode you want to use (off by default)
  33202. * @param easingFunction defines the easing function to use (linear by default)
  33203. * @param onAnimationEnd defines the callback to call when animation end
  33204. * @returns the animatable created for this animation
  33205. */
  33206. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33207. /**
  33208. * Create and start an animation on a node and its descendants
  33209. * @param name defines the name of the global animation that will be run on all nodes
  33210. * @param node defines the root node where the animation will take place
  33211. * @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
  33212. * @param targetProperty defines property to animate
  33213. * @param framePerSecond defines the number of frame per second to use
  33214. * @param totalFrame defines the number of frames in total
  33215. * @param from defines the initial value
  33216. * @param to defines the final value
  33217. * @param loopMode defines which loop mode you want to use (off by default)
  33218. * @param easingFunction defines the easing function to use (linear by default)
  33219. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33220. * @returns the list of animatables created for all nodes
  33221. * @example https://www.babylonjs-playground.com/#MH0VLI
  33222. */
  33223. 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[]>;
  33224. /**
  33225. * Creates a new animation, merges it with the existing animations and starts it
  33226. * @param name Name of the animation
  33227. * @param node Node which contains the scene that begins the animations
  33228. * @param targetProperty Specifies which property to animate
  33229. * @param framePerSecond The frames per second of the animation
  33230. * @param totalFrame The total number of frames
  33231. * @param from The frame at the beginning of the animation
  33232. * @param to The frame at the end of the animation
  33233. * @param loopMode Specifies the loop mode of the animation
  33234. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  33235. * @param onAnimationEnd Callback to run once the animation is complete
  33236. * @returns Nullable animation
  33237. */
  33238. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33239. /**
  33240. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  33241. * @param sourceAnimation defines the Animation containing keyframes to convert
  33242. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  33243. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  33244. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  33245. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  33246. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  33247. */
  33248. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  33249. /**
  33250. * Transition property of an host to the target Value
  33251. * @param property The property to transition
  33252. * @param targetValue The target Value of the property
  33253. * @param host The object where the property to animate belongs
  33254. * @param scene Scene used to run the animation
  33255. * @param frameRate Framerate (in frame/s) to use
  33256. * @param transition The transition type we want to use
  33257. * @param duration The duration of the animation, in milliseconds
  33258. * @param onAnimationEnd Callback trigger at the end of the animation
  33259. * @returns Nullable animation
  33260. */
  33261. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  33262. /**
  33263. * Return the array of runtime animations currently using this animation
  33264. */
  33265. get runtimeAnimations(): RuntimeAnimation[];
  33266. /**
  33267. * Specifies if any of the runtime animations are currently running
  33268. */
  33269. get hasRunningRuntimeAnimations(): boolean;
  33270. /**
  33271. * Initializes the animation
  33272. * @param name Name of the animation
  33273. * @param targetProperty Property to animate
  33274. * @param framePerSecond The frames per second of the animation
  33275. * @param dataType The data type of the animation
  33276. * @param loopMode The loop mode of the animation
  33277. * @param enableBlending Specifies if blending should be enabled
  33278. */
  33279. constructor(
  33280. /**Name of the animation */
  33281. name: string,
  33282. /**Property to animate */
  33283. targetProperty: string,
  33284. /**The frames per second of the animation */
  33285. framePerSecond: number,
  33286. /**The data type of the animation */
  33287. dataType: number,
  33288. /**The loop mode of the animation */
  33289. loopMode?: number | undefined,
  33290. /**Specifies if blending should be enabled */
  33291. enableBlending?: boolean | undefined);
  33292. /**
  33293. * Converts the animation to a string
  33294. * @param fullDetails support for multiple levels of logging within scene loading
  33295. * @returns String form of the animation
  33296. */
  33297. toString(fullDetails?: boolean): string;
  33298. /**
  33299. * Add an event to this animation
  33300. * @param event Event to add
  33301. */
  33302. addEvent(event: AnimationEvent): void;
  33303. /**
  33304. * Remove all events found at the given frame
  33305. * @param frame The frame to remove events from
  33306. */
  33307. removeEvents(frame: number): void;
  33308. /**
  33309. * Retrieves all the events from the animation
  33310. * @returns Events from the animation
  33311. */
  33312. getEvents(): AnimationEvent[];
  33313. /**
  33314. * Creates an animation range
  33315. * @param name Name of the animation range
  33316. * @param from Starting frame of the animation range
  33317. * @param to Ending frame of the animation
  33318. */
  33319. createRange(name: string, from: number, to: number): void;
  33320. /**
  33321. * Deletes an animation range by name
  33322. * @param name Name of the animation range to delete
  33323. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  33324. */
  33325. deleteRange(name: string, deleteFrames?: boolean): void;
  33326. /**
  33327. * Gets the animation range by name, or null if not defined
  33328. * @param name Name of the animation range
  33329. * @returns Nullable animation range
  33330. */
  33331. getRange(name: string): Nullable<AnimationRange>;
  33332. /**
  33333. * Gets the key frames from the animation
  33334. * @returns The key frames of the animation
  33335. */
  33336. getKeys(): Array<IAnimationKey>;
  33337. /**
  33338. * Gets the highest frame rate of the animation
  33339. * @returns Highest frame rate of the animation
  33340. */
  33341. getHighestFrame(): number;
  33342. /**
  33343. * Gets the easing function of the animation
  33344. * @returns Easing function of the animation
  33345. */
  33346. getEasingFunction(): IEasingFunction;
  33347. /**
  33348. * Sets the easing function of the animation
  33349. * @param easingFunction A custom mathematical formula for animation
  33350. */
  33351. setEasingFunction(easingFunction: EasingFunction): void;
  33352. /**
  33353. * Interpolates a scalar linearly
  33354. * @param startValue Start value of the animation curve
  33355. * @param endValue End value of the animation curve
  33356. * @param gradient Scalar amount to interpolate
  33357. * @returns Interpolated scalar value
  33358. */
  33359. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  33360. /**
  33361. * Interpolates a scalar cubically
  33362. * @param startValue Start value of the animation curve
  33363. * @param outTangent End tangent of the animation
  33364. * @param endValue End value of the animation curve
  33365. * @param inTangent Start tangent of the animation curve
  33366. * @param gradient Scalar amount to interpolate
  33367. * @returns Interpolated scalar value
  33368. */
  33369. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  33370. /**
  33371. * Interpolates a quaternion using a spherical linear interpolation
  33372. * @param startValue Start value of the animation curve
  33373. * @param endValue End value of the animation curve
  33374. * @param gradient Scalar amount to interpolate
  33375. * @returns Interpolated quaternion value
  33376. */
  33377. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  33378. /**
  33379. * Interpolates a quaternion cubically
  33380. * @param startValue Start value of the animation curve
  33381. * @param outTangent End tangent of the animation curve
  33382. * @param endValue End value of the animation curve
  33383. * @param inTangent Start tangent of the animation curve
  33384. * @param gradient Scalar amount to interpolate
  33385. * @returns Interpolated quaternion value
  33386. */
  33387. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  33388. /**
  33389. * Interpolates a Vector3 linearl
  33390. * @param startValue Start value of the animation curve
  33391. * @param endValue End value of the animation curve
  33392. * @param gradient Scalar amount to interpolate
  33393. * @returns Interpolated scalar value
  33394. */
  33395. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  33396. /**
  33397. * Interpolates a Vector3 cubically
  33398. * @param startValue Start value of the animation curve
  33399. * @param outTangent End tangent of the animation
  33400. * @param endValue End value of the animation curve
  33401. * @param inTangent Start tangent of the animation curve
  33402. * @param gradient Scalar amount to interpolate
  33403. * @returns InterpolatedVector3 value
  33404. */
  33405. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  33406. /**
  33407. * Interpolates a Vector2 linearly
  33408. * @param startValue Start value of the animation curve
  33409. * @param endValue End value of the animation curve
  33410. * @param gradient Scalar amount to interpolate
  33411. * @returns Interpolated Vector2 value
  33412. */
  33413. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  33414. /**
  33415. * Interpolates a Vector2 cubically
  33416. * @param startValue Start value of the animation curve
  33417. * @param outTangent End tangent of the animation
  33418. * @param endValue End value of the animation curve
  33419. * @param inTangent Start tangent of the animation curve
  33420. * @param gradient Scalar amount to interpolate
  33421. * @returns Interpolated Vector2 value
  33422. */
  33423. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  33424. /**
  33425. * Interpolates a size linearly
  33426. * @param startValue Start value of the animation curve
  33427. * @param endValue End value of the animation curve
  33428. * @param gradient Scalar amount to interpolate
  33429. * @returns Interpolated Size value
  33430. */
  33431. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  33432. /**
  33433. * Interpolates a Color3 linearly
  33434. * @param startValue Start value of the animation curve
  33435. * @param endValue End value of the animation curve
  33436. * @param gradient Scalar amount to interpolate
  33437. * @returns Interpolated Color3 value
  33438. */
  33439. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  33440. /**
  33441. * Interpolates a Color4 linearly
  33442. * @param startValue Start value of the animation curve
  33443. * @param endValue End value of the animation curve
  33444. * @param gradient Scalar amount to interpolate
  33445. * @returns Interpolated Color3 value
  33446. */
  33447. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  33448. /**
  33449. * @hidden Internal use only
  33450. */
  33451. _getKeyValue(value: any): any;
  33452. /**
  33453. * @hidden Internal use only
  33454. */
  33455. _interpolate(currentFrame: number, state: _IAnimationState): any;
  33456. /**
  33457. * Defines the function to use to interpolate matrices
  33458. * @param startValue defines the start matrix
  33459. * @param endValue defines the end matrix
  33460. * @param gradient defines the gradient between both matrices
  33461. * @param result defines an optional target matrix where to store the interpolation
  33462. * @returns the interpolated matrix
  33463. */
  33464. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  33465. /**
  33466. * Makes a copy of the animation
  33467. * @returns Cloned animation
  33468. */
  33469. clone(): Animation;
  33470. /**
  33471. * Sets the key frames of the animation
  33472. * @param values The animation key frames to set
  33473. */
  33474. setKeys(values: Array<IAnimationKey>): void;
  33475. /**
  33476. * Serializes the animation to an object
  33477. * @returns Serialized object
  33478. */
  33479. serialize(): any;
  33480. /**
  33481. * Float animation type
  33482. */
  33483. static readonly ANIMATIONTYPE_FLOAT: number;
  33484. /**
  33485. * Vector3 animation type
  33486. */
  33487. static readonly ANIMATIONTYPE_VECTOR3: number;
  33488. /**
  33489. * Quaternion animation type
  33490. */
  33491. static readonly ANIMATIONTYPE_QUATERNION: number;
  33492. /**
  33493. * Matrix animation type
  33494. */
  33495. static readonly ANIMATIONTYPE_MATRIX: number;
  33496. /**
  33497. * Color3 animation type
  33498. */
  33499. static readonly ANIMATIONTYPE_COLOR3: number;
  33500. /**
  33501. * Color3 animation type
  33502. */
  33503. static readonly ANIMATIONTYPE_COLOR4: number;
  33504. /**
  33505. * Vector2 animation type
  33506. */
  33507. static readonly ANIMATIONTYPE_VECTOR2: number;
  33508. /**
  33509. * Size animation type
  33510. */
  33511. static readonly ANIMATIONTYPE_SIZE: number;
  33512. /**
  33513. * Relative Loop Mode
  33514. */
  33515. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  33516. /**
  33517. * Cycle Loop Mode
  33518. */
  33519. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  33520. /**
  33521. * Constant Loop Mode
  33522. */
  33523. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  33524. /** @hidden */
  33525. static _UniversalLerp(left: any, right: any, amount: number): any;
  33526. /**
  33527. * Parses an animation object and creates an animation
  33528. * @param parsedAnimation Parsed animation object
  33529. * @returns Animation object
  33530. */
  33531. static Parse(parsedAnimation: any): Animation;
  33532. /**
  33533. * Appends the serialized animations from the source animations
  33534. * @param source Source containing the animations
  33535. * @param destination Target to store the animations
  33536. */
  33537. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33538. /**
  33539. * Creates a new animation or an array of animations from a snippet saved in a remote file
  33540. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  33541. * @param url defines the url to load from
  33542. * @returns a promise that will resolve to the new animation or an array of animations
  33543. */
  33544. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  33545. /**
  33546. * Creates an animation or an array of animations from a snippet saved by the Inspector
  33547. * @param snippetId defines the snippet to load
  33548. * @returns a promise that will resolve to the new animation or a new array of animations
  33549. */
  33550. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  33551. }
  33552. }
  33553. declare module BABYLON {
  33554. /**
  33555. * Interface containing an array of animations
  33556. */
  33557. export interface IAnimatable {
  33558. /**
  33559. * Array of animations
  33560. */
  33561. animations: Nullable<Array<Animation>>;
  33562. }
  33563. }
  33564. declare module BABYLON {
  33565. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  33566. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33567. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33568. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33569. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33570. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33571. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33572. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33573. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33574. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33575. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33576. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33577. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33578. /**
  33579. * Decorator used to define property that can be serialized as reference to a camera
  33580. * @param sourceName defines the name of the property to decorate
  33581. */
  33582. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33583. /**
  33584. * Class used to help serialization objects
  33585. */
  33586. export class SerializationHelper {
  33587. /** @hidden */
  33588. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  33589. /** @hidden */
  33590. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  33591. /** @hidden */
  33592. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  33593. /** @hidden */
  33594. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  33595. /**
  33596. * Appends the serialized animations from the source animations
  33597. * @param source Source containing the animations
  33598. * @param destination Target to store the animations
  33599. */
  33600. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33601. /**
  33602. * Static function used to serialized a specific entity
  33603. * @param entity defines the entity to serialize
  33604. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  33605. * @returns a JSON compatible object representing the serialization of the entity
  33606. */
  33607. static Serialize<T>(entity: T, serializationObject?: any): any;
  33608. /**
  33609. * Creates a new entity from a serialization data object
  33610. * @param creationFunction defines a function used to instanciated the new entity
  33611. * @param source defines the source serialization data
  33612. * @param scene defines the hosting scene
  33613. * @param rootUrl defines the root url for resources
  33614. * @returns a new entity
  33615. */
  33616. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  33617. /**
  33618. * Clones an object
  33619. * @param creationFunction defines the function used to instanciate the new object
  33620. * @param source defines the source object
  33621. * @returns the cloned object
  33622. */
  33623. static Clone<T>(creationFunction: () => T, source: T): T;
  33624. /**
  33625. * Instanciates a new object based on a source one (some data will be shared between both object)
  33626. * @param creationFunction defines the function used to instanciate the new object
  33627. * @param source defines the source object
  33628. * @returns the new object
  33629. */
  33630. static Instanciate<T>(creationFunction: () => T, source: T): T;
  33631. }
  33632. }
  33633. declare module BABYLON {
  33634. /**
  33635. * Base class of all the textures in babylon.
  33636. * It groups all the common properties the materials, post process, lights... might need
  33637. * in order to make a correct use of the texture.
  33638. */
  33639. export class BaseTexture implements IAnimatable {
  33640. /**
  33641. * Default anisotropic filtering level for the application.
  33642. * It is set to 4 as a good tradeoff between perf and quality.
  33643. */
  33644. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  33645. /**
  33646. * Gets or sets the unique id of the texture
  33647. */
  33648. uniqueId: number;
  33649. /**
  33650. * Define the name of the texture.
  33651. */
  33652. name: string;
  33653. /**
  33654. * Gets or sets an object used to store user defined information.
  33655. */
  33656. metadata: any;
  33657. /**
  33658. * For internal use only. Please do not use.
  33659. */
  33660. reservedDataStore: any;
  33661. private _hasAlpha;
  33662. /**
  33663. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  33664. */
  33665. set hasAlpha(value: boolean);
  33666. get hasAlpha(): boolean;
  33667. /**
  33668. * Defines if the alpha value should be determined via the rgb values.
  33669. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  33670. */
  33671. getAlphaFromRGB: boolean;
  33672. /**
  33673. * Intensity or strength of the texture.
  33674. * It is commonly used by materials to fine tune the intensity of the texture
  33675. */
  33676. level: number;
  33677. /**
  33678. * Define the UV chanel to use starting from 0 and defaulting to 0.
  33679. * This is part of the texture as textures usually maps to one uv set.
  33680. */
  33681. coordinatesIndex: number;
  33682. private _coordinatesMode;
  33683. /**
  33684. * How a texture is mapped.
  33685. *
  33686. * | Value | Type | Description |
  33687. * | ----- | ----------------------------------- | ----------- |
  33688. * | 0 | EXPLICIT_MODE | |
  33689. * | 1 | SPHERICAL_MODE | |
  33690. * | 2 | PLANAR_MODE | |
  33691. * | 3 | CUBIC_MODE | |
  33692. * | 4 | PROJECTION_MODE | |
  33693. * | 5 | SKYBOX_MODE | |
  33694. * | 6 | INVCUBIC_MODE | |
  33695. * | 7 | EQUIRECTANGULAR_MODE | |
  33696. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  33697. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  33698. */
  33699. set coordinatesMode(value: number);
  33700. get coordinatesMode(): number;
  33701. /**
  33702. * | Value | Type | Description |
  33703. * | ----- | ------------------ | ----------- |
  33704. * | 0 | CLAMP_ADDRESSMODE | |
  33705. * | 1 | WRAP_ADDRESSMODE | |
  33706. * | 2 | MIRROR_ADDRESSMODE | |
  33707. */
  33708. wrapU: number;
  33709. /**
  33710. * | Value | Type | Description |
  33711. * | ----- | ------------------ | ----------- |
  33712. * | 0 | CLAMP_ADDRESSMODE | |
  33713. * | 1 | WRAP_ADDRESSMODE | |
  33714. * | 2 | MIRROR_ADDRESSMODE | |
  33715. */
  33716. wrapV: number;
  33717. /**
  33718. * | Value | Type | Description |
  33719. * | ----- | ------------------ | ----------- |
  33720. * | 0 | CLAMP_ADDRESSMODE | |
  33721. * | 1 | WRAP_ADDRESSMODE | |
  33722. * | 2 | MIRROR_ADDRESSMODE | |
  33723. */
  33724. wrapR: number;
  33725. /**
  33726. * With compliant hardware and browser (supporting anisotropic filtering)
  33727. * this defines the level of anisotropic filtering in the texture.
  33728. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  33729. */
  33730. anisotropicFilteringLevel: number;
  33731. /**
  33732. * Define if the texture is a cube texture or if false a 2d texture.
  33733. */
  33734. get isCube(): boolean;
  33735. set isCube(value: boolean);
  33736. /**
  33737. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  33738. */
  33739. get is3D(): boolean;
  33740. set is3D(value: boolean);
  33741. /**
  33742. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  33743. */
  33744. get is2DArray(): boolean;
  33745. set is2DArray(value: boolean);
  33746. /**
  33747. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  33748. * HDR texture are usually stored in linear space.
  33749. * This only impacts the PBR and Background materials
  33750. */
  33751. gammaSpace: boolean;
  33752. /**
  33753. * Gets or sets whether or not the texture contains RGBD data.
  33754. */
  33755. get isRGBD(): boolean;
  33756. set isRGBD(value: boolean);
  33757. /**
  33758. * Is Z inverted in the texture (useful in a cube texture).
  33759. */
  33760. invertZ: boolean;
  33761. /**
  33762. * Are mip maps generated for this texture or not.
  33763. */
  33764. get noMipmap(): boolean;
  33765. /**
  33766. * @hidden
  33767. */
  33768. lodLevelInAlpha: boolean;
  33769. /**
  33770. * With prefiltered texture, defined the offset used during the prefiltering steps.
  33771. */
  33772. get lodGenerationOffset(): number;
  33773. set lodGenerationOffset(value: number);
  33774. /**
  33775. * With prefiltered texture, defined the scale used during the prefiltering steps.
  33776. */
  33777. get lodGenerationScale(): number;
  33778. set lodGenerationScale(value: number);
  33779. /**
  33780. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  33781. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  33782. * average roughness values.
  33783. */
  33784. get linearSpecularLOD(): boolean;
  33785. set linearSpecularLOD(value: boolean);
  33786. /**
  33787. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  33788. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  33789. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  33790. */
  33791. get irradianceTexture(): Nullable<BaseTexture>;
  33792. set irradianceTexture(value: Nullable<BaseTexture>);
  33793. /**
  33794. * Define if the texture is a render target.
  33795. */
  33796. isRenderTarget: boolean;
  33797. /**
  33798. * Define the unique id of the texture in the scene.
  33799. */
  33800. get uid(): string;
  33801. /** @hidden */
  33802. _prefiltered: boolean;
  33803. /**
  33804. * Return a string representation of the texture.
  33805. * @returns the texture as a string
  33806. */
  33807. toString(): string;
  33808. /**
  33809. * Get the class name of the texture.
  33810. * @returns "BaseTexture"
  33811. */
  33812. getClassName(): string;
  33813. /**
  33814. * Define the list of animation attached to the texture.
  33815. */
  33816. animations: Animation[];
  33817. /**
  33818. * An event triggered when the texture is disposed.
  33819. */
  33820. onDisposeObservable: Observable<BaseTexture>;
  33821. private _onDisposeObserver;
  33822. /**
  33823. * Callback triggered when the texture has been disposed.
  33824. * Kept for back compatibility, you can use the onDisposeObservable instead.
  33825. */
  33826. set onDispose(callback: () => void);
  33827. /**
  33828. * Define the current state of the loading sequence when in delayed load mode.
  33829. */
  33830. delayLoadState: number;
  33831. private _scene;
  33832. private _engine;
  33833. /** @hidden */
  33834. _texture: Nullable<InternalTexture>;
  33835. private _uid;
  33836. /**
  33837. * Define if the texture is preventinga material to render or not.
  33838. * If not and the texture is not ready, the engine will use a default black texture instead.
  33839. */
  33840. get isBlocking(): boolean;
  33841. /**
  33842. * Instantiates a new BaseTexture.
  33843. * Base class of all the textures in babylon.
  33844. * It groups all the common properties the materials, post process, lights... might need
  33845. * in order to make a correct use of the texture.
  33846. * @param sceneOrEngine Define the scene or engine the texture blongs to
  33847. */
  33848. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  33849. /**
  33850. * Get the scene the texture belongs to.
  33851. * @returns the scene or null if undefined
  33852. */
  33853. getScene(): Nullable<Scene>;
  33854. /** @hidden */
  33855. protected _getEngine(): Nullable<ThinEngine>;
  33856. /**
  33857. * Get the texture transform matrix used to offset tile the texture for istance.
  33858. * @returns the transformation matrix
  33859. */
  33860. getTextureMatrix(): Matrix;
  33861. /**
  33862. * Get the texture reflection matrix used to rotate/transform the reflection.
  33863. * @returns the reflection matrix
  33864. */
  33865. getReflectionTextureMatrix(): Matrix;
  33866. /**
  33867. * Get the underlying lower level texture from Babylon.
  33868. * @returns the insternal texture
  33869. */
  33870. getInternalTexture(): Nullable<InternalTexture>;
  33871. /**
  33872. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  33873. * @returns true if ready or not blocking
  33874. */
  33875. isReadyOrNotBlocking(): boolean;
  33876. /**
  33877. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  33878. * @returns true if fully ready
  33879. */
  33880. isReady(): boolean;
  33881. private _cachedSize;
  33882. /**
  33883. * Get the size of the texture.
  33884. * @returns the texture size.
  33885. */
  33886. getSize(): ISize;
  33887. /**
  33888. * Get the base size of the texture.
  33889. * It can be different from the size if the texture has been resized for POT for instance
  33890. * @returns the base size
  33891. */
  33892. getBaseSize(): ISize;
  33893. /**
  33894. * Update the sampling mode of the texture.
  33895. * Default is Trilinear mode.
  33896. *
  33897. * | Value | Type | Description |
  33898. * | ----- | ------------------ | ----------- |
  33899. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  33900. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  33901. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  33902. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  33903. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  33904. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  33905. * | 7 | NEAREST_LINEAR | |
  33906. * | 8 | NEAREST_NEAREST | |
  33907. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  33908. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  33909. * | 11 | LINEAR_LINEAR | |
  33910. * | 12 | LINEAR_NEAREST | |
  33911. *
  33912. * > _mag_: magnification filter (close to the viewer)
  33913. * > _min_: minification filter (far from the viewer)
  33914. * > _mip_: filter used between mip map levels
  33915. *@param samplingMode Define the new sampling mode of the texture
  33916. */
  33917. updateSamplingMode(samplingMode: number): void;
  33918. /**
  33919. * Scales the texture if is `canRescale()`
  33920. * @param ratio the resize factor we want to use to rescale
  33921. */
  33922. scale(ratio: number): void;
  33923. /**
  33924. * Get if the texture can rescale.
  33925. */
  33926. get canRescale(): boolean;
  33927. /** @hidden */
  33928. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  33929. /** @hidden */
  33930. _rebuild(): void;
  33931. /**
  33932. * Triggers the load sequence in delayed load mode.
  33933. */
  33934. delayLoad(): void;
  33935. /**
  33936. * Clones the texture.
  33937. * @returns the cloned texture
  33938. */
  33939. clone(): Nullable<BaseTexture>;
  33940. /**
  33941. * Get the texture underlying type (INT, FLOAT...)
  33942. */
  33943. get textureType(): number;
  33944. /**
  33945. * Get the texture underlying format (RGB, RGBA...)
  33946. */
  33947. get textureFormat(): number;
  33948. /**
  33949. * Indicates that textures need to be re-calculated for all materials
  33950. */
  33951. protected _markAllSubMeshesAsTexturesDirty(): void;
  33952. /**
  33953. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  33954. * This will returns an RGBA array buffer containing either in values (0-255) or
  33955. * float values (0-1) depending of the underlying buffer type.
  33956. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  33957. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  33958. * @param buffer defines a user defined buffer to fill with data (can be null)
  33959. * @returns The Array buffer containing the pixels data.
  33960. */
  33961. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  33962. /**
  33963. * Release and destroy the underlying lower level texture aka internalTexture.
  33964. */
  33965. releaseInternalTexture(): void;
  33966. /** @hidden */
  33967. get _lodTextureHigh(): Nullable<BaseTexture>;
  33968. /** @hidden */
  33969. get _lodTextureMid(): Nullable<BaseTexture>;
  33970. /** @hidden */
  33971. get _lodTextureLow(): Nullable<BaseTexture>;
  33972. /**
  33973. * Dispose the texture and release its associated resources.
  33974. */
  33975. dispose(): void;
  33976. /**
  33977. * Serialize the texture into a JSON representation that can be parsed later on.
  33978. * @returns the JSON representation of the texture
  33979. */
  33980. serialize(): any;
  33981. /**
  33982. * Helper function to be called back once a list of texture contains only ready textures.
  33983. * @param textures Define the list of textures to wait for
  33984. * @param callback Define the callback triggered once the entire list will be ready
  33985. */
  33986. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  33987. private static _isScene;
  33988. }
  33989. }
  33990. declare module BABYLON {
  33991. /**
  33992. * Options to be used when creating an effect.
  33993. */
  33994. export interface IEffectCreationOptions {
  33995. /**
  33996. * Atrributes that will be used in the shader.
  33997. */
  33998. attributes: string[];
  33999. /**
  34000. * Uniform varible names that will be set in the shader.
  34001. */
  34002. uniformsNames: string[];
  34003. /**
  34004. * Uniform buffer variable names that will be set in the shader.
  34005. */
  34006. uniformBuffersNames: string[];
  34007. /**
  34008. * Sampler texture variable names that will be set in the shader.
  34009. */
  34010. samplers: string[];
  34011. /**
  34012. * Define statements that will be set in the shader.
  34013. */
  34014. defines: any;
  34015. /**
  34016. * Possible fallbacks for this effect to improve performance when needed.
  34017. */
  34018. fallbacks: Nullable<IEffectFallbacks>;
  34019. /**
  34020. * Callback that will be called when the shader is compiled.
  34021. */
  34022. onCompiled: Nullable<(effect: Effect) => void>;
  34023. /**
  34024. * Callback that will be called if an error occurs during shader compilation.
  34025. */
  34026. onError: Nullable<(effect: Effect, errors: string) => void>;
  34027. /**
  34028. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34029. */
  34030. indexParameters?: any;
  34031. /**
  34032. * Max number of lights that can be used in the shader.
  34033. */
  34034. maxSimultaneousLights?: number;
  34035. /**
  34036. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  34037. */
  34038. transformFeedbackVaryings?: Nullable<string[]>;
  34039. /**
  34040. * 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
  34041. */
  34042. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  34043. /**
  34044. * Is this effect rendering to several color attachments ?
  34045. */
  34046. multiTarget?: boolean;
  34047. }
  34048. /**
  34049. * Effect containing vertex and fragment shader that can be executed on an object.
  34050. */
  34051. export class Effect implements IDisposable {
  34052. /**
  34053. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34054. */
  34055. static ShadersRepository: string;
  34056. /**
  34057. * Enable logging of the shader code when a compilation error occurs
  34058. */
  34059. static LogShaderCodeOnCompilationError: boolean;
  34060. /**
  34061. * Name of the effect.
  34062. */
  34063. name: any;
  34064. /**
  34065. * String container all the define statements that should be set on the shader.
  34066. */
  34067. defines: string;
  34068. /**
  34069. * Callback that will be called when the shader is compiled.
  34070. */
  34071. onCompiled: Nullable<(effect: Effect) => void>;
  34072. /**
  34073. * Callback that will be called if an error occurs during shader compilation.
  34074. */
  34075. onError: Nullable<(effect: Effect, errors: string) => void>;
  34076. /**
  34077. * Callback that will be called when effect is bound.
  34078. */
  34079. onBind: Nullable<(effect: Effect) => void>;
  34080. /**
  34081. * Unique ID of the effect.
  34082. */
  34083. uniqueId: number;
  34084. /**
  34085. * Observable that will be called when the shader is compiled.
  34086. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  34087. */
  34088. onCompileObservable: Observable<Effect>;
  34089. /**
  34090. * Observable that will be called if an error occurs during shader compilation.
  34091. */
  34092. onErrorObservable: Observable<Effect>;
  34093. /** @hidden */
  34094. _onBindObservable: Nullable<Observable<Effect>>;
  34095. /**
  34096. * @hidden
  34097. * Specifies if the effect was previously ready
  34098. */
  34099. _wasPreviouslyReady: boolean;
  34100. /**
  34101. * Observable that will be called when effect is bound.
  34102. */
  34103. get onBindObservable(): Observable<Effect>;
  34104. /** @hidden */
  34105. _bonesComputationForcedToCPU: boolean;
  34106. /** @hidden */
  34107. _multiTarget: boolean;
  34108. private static _uniqueIdSeed;
  34109. private _engine;
  34110. private _uniformBuffersNames;
  34111. private _uniformBuffersNamesList;
  34112. private _uniformsNames;
  34113. private _samplerList;
  34114. private _samplers;
  34115. private _isReady;
  34116. private _compilationError;
  34117. private _allFallbacksProcessed;
  34118. private _attributesNames;
  34119. private _attributes;
  34120. private _attributeLocationByName;
  34121. private _uniforms;
  34122. /**
  34123. * Key for the effect.
  34124. * @hidden
  34125. */
  34126. _key: string;
  34127. private _indexParameters;
  34128. private _fallbacks;
  34129. private _vertexSourceCode;
  34130. private _fragmentSourceCode;
  34131. private _vertexSourceCodeOverride;
  34132. private _fragmentSourceCodeOverride;
  34133. private _transformFeedbackVaryings;
  34134. /**
  34135. * Compiled shader to webGL program.
  34136. * @hidden
  34137. */
  34138. _pipelineContext: Nullable<IPipelineContext>;
  34139. private _valueCache;
  34140. private static _baseCache;
  34141. /**
  34142. * Instantiates an effect.
  34143. * An effect can be used to create/manage/execute vertex and fragment shaders.
  34144. * @param baseName Name of the effect.
  34145. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  34146. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  34147. * @param samplers List of sampler variables that will be passed to the shader.
  34148. * @param engine Engine to be used to render the effect
  34149. * @param defines Define statements to be added to the shader.
  34150. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  34151. * @param onCompiled Callback that will be called when the shader is compiled.
  34152. * @param onError Callback that will be called if an error occurs during shader compilation.
  34153. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34154. */
  34155. 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);
  34156. private _useFinalCode;
  34157. /**
  34158. * Unique key for this effect
  34159. */
  34160. get key(): string;
  34161. /**
  34162. * If the effect has been compiled and prepared.
  34163. * @returns if the effect is compiled and prepared.
  34164. */
  34165. isReady(): boolean;
  34166. private _isReadyInternal;
  34167. /**
  34168. * The engine the effect was initialized with.
  34169. * @returns the engine.
  34170. */
  34171. getEngine(): Engine;
  34172. /**
  34173. * The pipeline context for this effect
  34174. * @returns the associated pipeline context
  34175. */
  34176. getPipelineContext(): Nullable<IPipelineContext>;
  34177. /**
  34178. * The set of names of attribute variables for the shader.
  34179. * @returns An array of attribute names.
  34180. */
  34181. getAttributesNames(): string[];
  34182. /**
  34183. * Returns the attribute at the given index.
  34184. * @param index The index of the attribute.
  34185. * @returns The location of the attribute.
  34186. */
  34187. getAttributeLocation(index: number): number;
  34188. /**
  34189. * Returns the attribute based on the name of the variable.
  34190. * @param name of the attribute to look up.
  34191. * @returns the attribute location.
  34192. */
  34193. getAttributeLocationByName(name: string): number;
  34194. /**
  34195. * The number of attributes.
  34196. * @returns the numnber of attributes.
  34197. */
  34198. getAttributesCount(): number;
  34199. /**
  34200. * Gets the index of a uniform variable.
  34201. * @param uniformName of the uniform to look up.
  34202. * @returns the index.
  34203. */
  34204. getUniformIndex(uniformName: string): number;
  34205. /**
  34206. * Returns the attribute based on the name of the variable.
  34207. * @param uniformName of the uniform to look up.
  34208. * @returns the location of the uniform.
  34209. */
  34210. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  34211. /**
  34212. * Returns an array of sampler variable names
  34213. * @returns The array of sampler variable names.
  34214. */
  34215. getSamplers(): string[];
  34216. /**
  34217. * Returns an array of uniform variable names
  34218. * @returns The array of uniform variable names.
  34219. */
  34220. getUniformNames(): string[];
  34221. /**
  34222. * Returns an array of uniform buffer variable names
  34223. * @returns The array of uniform buffer variable names.
  34224. */
  34225. getUniformBuffersNames(): string[];
  34226. /**
  34227. * Returns the index parameters used to create the effect
  34228. * @returns The index parameters object
  34229. */
  34230. getIndexParameters(): any;
  34231. /**
  34232. * The error from the last compilation.
  34233. * @returns the error string.
  34234. */
  34235. getCompilationError(): string;
  34236. /**
  34237. * Gets a boolean indicating that all fallbacks were used during compilation
  34238. * @returns true if all fallbacks were used
  34239. */
  34240. allFallbacksProcessed(): boolean;
  34241. /**
  34242. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  34243. * @param func The callback to be used.
  34244. */
  34245. executeWhenCompiled(func: (effect: Effect) => void): void;
  34246. private _checkIsReady;
  34247. private _loadShader;
  34248. /**
  34249. * Gets the vertex shader source code of this effect
  34250. */
  34251. get vertexSourceCode(): string;
  34252. /**
  34253. * Gets the fragment shader source code of this effect
  34254. */
  34255. get fragmentSourceCode(): string;
  34256. /**
  34257. * Recompiles the webGL program
  34258. * @param vertexSourceCode The source code for the vertex shader.
  34259. * @param fragmentSourceCode The source code for the fragment shader.
  34260. * @param onCompiled Callback called when completed.
  34261. * @param onError Callback called on error.
  34262. * @hidden
  34263. */
  34264. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  34265. /**
  34266. * Prepares the effect
  34267. * @hidden
  34268. */
  34269. _prepareEffect(): void;
  34270. private _getShaderCodeAndErrorLine;
  34271. private _processCompilationErrors;
  34272. /**
  34273. * Checks if the effect is supported. (Must be called after compilation)
  34274. */
  34275. get isSupported(): boolean;
  34276. /**
  34277. * Binds a texture to the engine to be used as output of the shader.
  34278. * @param channel Name of the output variable.
  34279. * @param texture Texture to bind.
  34280. * @hidden
  34281. */
  34282. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  34283. /**
  34284. * Sets a texture on the engine to be used in the shader.
  34285. * @param channel Name of the sampler variable.
  34286. * @param texture Texture to set.
  34287. */
  34288. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  34289. /**
  34290. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  34291. * @param channel Name of the sampler variable.
  34292. * @param texture Texture to set.
  34293. */
  34294. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  34295. /**
  34296. * Sets an array of textures on the engine to be used in the shader.
  34297. * @param channel Name of the variable.
  34298. * @param textures Textures to set.
  34299. */
  34300. setTextureArray(channel: string, textures: BaseTexture[]): void;
  34301. /**
  34302. * 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)
  34303. * @param channel Name of the sampler variable.
  34304. * @param postProcess Post process to get the input texture from.
  34305. */
  34306. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  34307. /**
  34308. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  34309. * 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)
  34310. * @param channel Name of the sampler variable.
  34311. * @param postProcess Post process to get the output texture from.
  34312. */
  34313. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  34314. /** @hidden */
  34315. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  34316. /** @hidden */
  34317. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  34318. /** @hidden */
  34319. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  34320. /** @hidden */
  34321. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  34322. /**
  34323. * Binds a buffer to a uniform.
  34324. * @param buffer Buffer to bind.
  34325. * @param name Name of the uniform variable to bind to.
  34326. */
  34327. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  34328. /**
  34329. * Binds block to a uniform.
  34330. * @param blockName Name of the block to bind.
  34331. * @param index Index to bind.
  34332. */
  34333. bindUniformBlock(blockName: string, index: number): void;
  34334. /**
  34335. * Sets an interger value on a uniform variable.
  34336. * @param uniformName Name of the variable.
  34337. * @param value Value to be set.
  34338. * @returns this effect.
  34339. */
  34340. setInt(uniformName: string, value: number): Effect;
  34341. /**
  34342. * Sets an int array on a uniform variable.
  34343. * @param uniformName Name of the variable.
  34344. * @param array array to be set.
  34345. * @returns this effect.
  34346. */
  34347. setIntArray(uniformName: string, array: Int32Array): Effect;
  34348. /**
  34349. * 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)
  34350. * @param uniformName Name of the variable.
  34351. * @param array array to be set.
  34352. * @returns this effect.
  34353. */
  34354. setIntArray2(uniformName: string, array: Int32Array): Effect;
  34355. /**
  34356. * 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)
  34357. * @param uniformName Name of the variable.
  34358. * @param array array to be set.
  34359. * @returns this effect.
  34360. */
  34361. setIntArray3(uniformName: string, array: Int32Array): Effect;
  34362. /**
  34363. * 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)
  34364. * @param uniformName Name of the variable.
  34365. * @param array array to be set.
  34366. * @returns this effect.
  34367. */
  34368. setIntArray4(uniformName: string, array: Int32Array): Effect;
  34369. /**
  34370. * Sets an float array on a uniform variable.
  34371. * @param uniformName Name of the variable.
  34372. * @param array array to be set.
  34373. * @returns this effect.
  34374. */
  34375. setFloatArray(uniformName: string, array: Float32Array): Effect;
  34376. /**
  34377. * 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)
  34378. * @param uniformName Name of the variable.
  34379. * @param array array to be set.
  34380. * @returns this effect.
  34381. */
  34382. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  34383. /**
  34384. * 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)
  34385. * @param uniformName Name of the variable.
  34386. * @param array array to be set.
  34387. * @returns this effect.
  34388. */
  34389. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  34390. /**
  34391. * 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)
  34392. * @param uniformName Name of the variable.
  34393. * @param array array to be set.
  34394. * @returns this effect.
  34395. */
  34396. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  34397. /**
  34398. * Sets an array on a uniform variable.
  34399. * @param uniformName Name of the variable.
  34400. * @param array array to be set.
  34401. * @returns this effect.
  34402. */
  34403. setArray(uniformName: string, array: number[]): Effect;
  34404. /**
  34405. * 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)
  34406. * @param uniformName Name of the variable.
  34407. * @param array array to be set.
  34408. * @returns this effect.
  34409. */
  34410. setArray2(uniformName: string, array: number[]): Effect;
  34411. /**
  34412. * 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)
  34413. * @param uniformName Name of the variable.
  34414. * @param array array to be set.
  34415. * @returns this effect.
  34416. */
  34417. setArray3(uniformName: string, array: number[]): Effect;
  34418. /**
  34419. * 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)
  34420. * @param uniformName Name of the variable.
  34421. * @param array array to be set.
  34422. * @returns this effect.
  34423. */
  34424. setArray4(uniformName: string, array: number[]): Effect;
  34425. /**
  34426. * Sets matrices on a uniform variable.
  34427. * @param uniformName Name of the variable.
  34428. * @param matrices matrices to be set.
  34429. * @returns this effect.
  34430. */
  34431. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  34432. /**
  34433. * Sets matrix on a uniform variable.
  34434. * @param uniformName Name of the variable.
  34435. * @param matrix matrix to be set.
  34436. * @returns this effect.
  34437. */
  34438. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  34439. /**
  34440. * 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)
  34441. * @param uniformName Name of the variable.
  34442. * @param matrix matrix to be set.
  34443. * @returns this effect.
  34444. */
  34445. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34446. /**
  34447. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  34448. * @param uniformName Name of the variable.
  34449. * @param matrix matrix to be set.
  34450. * @returns this effect.
  34451. */
  34452. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34453. /**
  34454. * Sets a float on a uniform variable.
  34455. * @param uniformName Name of the variable.
  34456. * @param value value to be set.
  34457. * @returns this effect.
  34458. */
  34459. setFloat(uniformName: string, value: number): Effect;
  34460. /**
  34461. * Sets a boolean on a uniform variable.
  34462. * @param uniformName Name of the variable.
  34463. * @param bool value to be set.
  34464. * @returns this effect.
  34465. */
  34466. setBool(uniformName: string, bool: boolean): Effect;
  34467. /**
  34468. * Sets a Vector2 on a uniform variable.
  34469. * @param uniformName Name of the variable.
  34470. * @param vector2 vector2 to be set.
  34471. * @returns this effect.
  34472. */
  34473. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  34474. /**
  34475. * Sets a float2 on a uniform variable.
  34476. * @param uniformName Name of the variable.
  34477. * @param x First float in float2.
  34478. * @param y Second float in float2.
  34479. * @returns this effect.
  34480. */
  34481. setFloat2(uniformName: string, x: number, y: number): Effect;
  34482. /**
  34483. * Sets a Vector3 on a uniform variable.
  34484. * @param uniformName Name of the variable.
  34485. * @param vector3 Value to be set.
  34486. * @returns this effect.
  34487. */
  34488. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  34489. /**
  34490. * Sets a float3 on a uniform variable.
  34491. * @param uniformName Name of the variable.
  34492. * @param x First float in float3.
  34493. * @param y Second float in float3.
  34494. * @param z Third float in float3.
  34495. * @returns this effect.
  34496. */
  34497. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  34498. /**
  34499. * Sets a Vector4 on a uniform variable.
  34500. * @param uniformName Name of the variable.
  34501. * @param vector4 Value to be set.
  34502. * @returns this effect.
  34503. */
  34504. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  34505. /**
  34506. * Sets a float4 on a uniform variable.
  34507. * @param uniformName Name of the variable.
  34508. * @param x First float in float4.
  34509. * @param y Second float in float4.
  34510. * @param z Third float in float4.
  34511. * @param w Fourth float in float4.
  34512. * @returns this effect.
  34513. */
  34514. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  34515. /**
  34516. * Sets a Color3 on a uniform variable.
  34517. * @param uniformName Name of the variable.
  34518. * @param color3 Value to be set.
  34519. * @returns this effect.
  34520. */
  34521. setColor3(uniformName: string, color3: IColor3Like): Effect;
  34522. /**
  34523. * Sets a Color4 on a uniform variable.
  34524. * @param uniformName Name of the variable.
  34525. * @param color3 Value to be set.
  34526. * @param alpha Alpha value to be set.
  34527. * @returns this effect.
  34528. */
  34529. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  34530. /**
  34531. * Sets a Color4 on a uniform variable
  34532. * @param uniformName defines the name of the variable
  34533. * @param color4 defines the value to be set
  34534. * @returns this effect.
  34535. */
  34536. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  34537. /** Release all associated resources */
  34538. dispose(): void;
  34539. /**
  34540. * This function will add a new shader to the shader store
  34541. * @param name the name of the shader
  34542. * @param pixelShader optional pixel shader content
  34543. * @param vertexShader optional vertex shader content
  34544. */
  34545. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  34546. /**
  34547. * Store of each shader (The can be looked up using effect.key)
  34548. */
  34549. static ShadersStore: {
  34550. [key: string]: string;
  34551. };
  34552. /**
  34553. * Store of each included file for a shader (The can be looked up using effect.key)
  34554. */
  34555. static IncludesShadersStore: {
  34556. [key: string]: string;
  34557. };
  34558. /**
  34559. * Resets the cache of effects.
  34560. */
  34561. static ResetCache(): void;
  34562. }
  34563. }
  34564. declare module BABYLON {
  34565. /**
  34566. * Interface used to describe the capabilities of the engine relatively to the current browser
  34567. */
  34568. export interface EngineCapabilities {
  34569. /** Maximum textures units per fragment shader */
  34570. maxTexturesImageUnits: number;
  34571. /** Maximum texture units per vertex shader */
  34572. maxVertexTextureImageUnits: number;
  34573. /** Maximum textures units in the entire pipeline */
  34574. maxCombinedTexturesImageUnits: number;
  34575. /** Maximum texture size */
  34576. maxTextureSize: number;
  34577. /** Maximum texture samples */
  34578. maxSamples?: number;
  34579. /** Maximum cube texture size */
  34580. maxCubemapTextureSize: number;
  34581. /** Maximum render texture size */
  34582. maxRenderTextureSize: number;
  34583. /** Maximum number of vertex attributes */
  34584. maxVertexAttribs: number;
  34585. /** Maximum number of varyings */
  34586. maxVaryingVectors: number;
  34587. /** Maximum number of uniforms per vertex shader */
  34588. maxVertexUniformVectors: number;
  34589. /** Maximum number of uniforms per fragment shader */
  34590. maxFragmentUniformVectors: number;
  34591. /** Defines if standard derivates (dx/dy) are supported */
  34592. standardDerivatives: boolean;
  34593. /** Defines if s3tc texture compression is supported */
  34594. s3tc?: WEBGL_compressed_texture_s3tc;
  34595. /** Defines if pvrtc texture compression is supported */
  34596. pvrtc: any;
  34597. /** Defines if etc1 texture compression is supported */
  34598. etc1: any;
  34599. /** Defines if etc2 texture compression is supported */
  34600. etc2: any;
  34601. /** Defines if astc texture compression is supported */
  34602. astc: any;
  34603. /** Defines if float textures are supported */
  34604. textureFloat: boolean;
  34605. /** Defines if vertex array objects are supported */
  34606. vertexArrayObject: boolean;
  34607. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  34608. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  34609. /** Gets the maximum level of anisotropy supported */
  34610. maxAnisotropy: number;
  34611. /** Defines if instancing is supported */
  34612. instancedArrays: boolean;
  34613. /** Defines if 32 bits indices are supported */
  34614. uintIndices: boolean;
  34615. /** Defines if high precision shaders are supported */
  34616. highPrecisionShaderSupported: boolean;
  34617. /** Defines if depth reading in the fragment shader is supported */
  34618. fragmentDepthSupported: boolean;
  34619. /** Defines if float texture linear filtering is supported*/
  34620. textureFloatLinearFiltering: boolean;
  34621. /** Defines if rendering to float textures is supported */
  34622. textureFloatRender: boolean;
  34623. /** Defines if half float textures are supported*/
  34624. textureHalfFloat: boolean;
  34625. /** Defines if half float texture linear filtering is supported*/
  34626. textureHalfFloatLinearFiltering: boolean;
  34627. /** Defines if rendering to half float textures is supported */
  34628. textureHalfFloatRender: boolean;
  34629. /** Defines if textureLOD shader command is supported */
  34630. textureLOD: boolean;
  34631. /** Defines if draw buffers extension is supported */
  34632. drawBuffersExtension: boolean;
  34633. /** Defines if depth textures are supported */
  34634. depthTextureExtension: boolean;
  34635. /** Defines if float color buffer are supported */
  34636. colorBufferFloat: boolean;
  34637. /** Gets disjoint timer query extension (null if not supported) */
  34638. timerQuery?: EXT_disjoint_timer_query;
  34639. /** Defines if timestamp can be used with timer query */
  34640. canUseTimestampForTimerQuery: boolean;
  34641. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  34642. multiview?: any;
  34643. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  34644. oculusMultiview?: any;
  34645. /** Function used to let the system compiles shaders in background */
  34646. parallelShaderCompile?: {
  34647. COMPLETION_STATUS_KHR: number;
  34648. };
  34649. /** Max number of texture samples for MSAA */
  34650. maxMSAASamples: number;
  34651. /** Defines if the blend min max extension is supported */
  34652. blendMinMax: boolean;
  34653. }
  34654. }
  34655. declare module BABYLON {
  34656. /**
  34657. * @hidden
  34658. **/
  34659. export class DepthCullingState {
  34660. private _isDepthTestDirty;
  34661. private _isDepthMaskDirty;
  34662. private _isDepthFuncDirty;
  34663. private _isCullFaceDirty;
  34664. private _isCullDirty;
  34665. private _isZOffsetDirty;
  34666. private _isFrontFaceDirty;
  34667. private _depthTest;
  34668. private _depthMask;
  34669. private _depthFunc;
  34670. private _cull;
  34671. private _cullFace;
  34672. private _zOffset;
  34673. private _frontFace;
  34674. /**
  34675. * Initializes the state.
  34676. */
  34677. constructor();
  34678. get isDirty(): boolean;
  34679. get zOffset(): number;
  34680. set zOffset(value: number);
  34681. get cullFace(): Nullable<number>;
  34682. set cullFace(value: Nullable<number>);
  34683. get cull(): Nullable<boolean>;
  34684. set cull(value: Nullable<boolean>);
  34685. get depthFunc(): Nullable<number>;
  34686. set depthFunc(value: Nullable<number>);
  34687. get depthMask(): boolean;
  34688. set depthMask(value: boolean);
  34689. get depthTest(): boolean;
  34690. set depthTest(value: boolean);
  34691. get frontFace(): Nullable<number>;
  34692. set frontFace(value: Nullable<number>);
  34693. reset(): void;
  34694. apply(gl: WebGLRenderingContext): void;
  34695. }
  34696. }
  34697. declare module BABYLON {
  34698. /**
  34699. * @hidden
  34700. **/
  34701. export class StencilState {
  34702. /** 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 */
  34703. static readonly ALWAYS: number;
  34704. /** Passed to stencilOperation to specify that stencil value must be kept */
  34705. static readonly KEEP: number;
  34706. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34707. static readonly REPLACE: number;
  34708. private _isStencilTestDirty;
  34709. private _isStencilMaskDirty;
  34710. private _isStencilFuncDirty;
  34711. private _isStencilOpDirty;
  34712. private _stencilTest;
  34713. private _stencilMask;
  34714. private _stencilFunc;
  34715. private _stencilFuncRef;
  34716. private _stencilFuncMask;
  34717. private _stencilOpStencilFail;
  34718. private _stencilOpDepthFail;
  34719. private _stencilOpStencilDepthPass;
  34720. get isDirty(): boolean;
  34721. get stencilFunc(): number;
  34722. set stencilFunc(value: number);
  34723. get stencilFuncRef(): number;
  34724. set stencilFuncRef(value: number);
  34725. get stencilFuncMask(): number;
  34726. set stencilFuncMask(value: number);
  34727. get stencilOpStencilFail(): number;
  34728. set stencilOpStencilFail(value: number);
  34729. get stencilOpDepthFail(): number;
  34730. set stencilOpDepthFail(value: number);
  34731. get stencilOpStencilDepthPass(): number;
  34732. set stencilOpStencilDepthPass(value: number);
  34733. get stencilMask(): number;
  34734. set stencilMask(value: number);
  34735. get stencilTest(): boolean;
  34736. set stencilTest(value: boolean);
  34737. constructor();
  34738. reset(): void;
  34739. apply(gl: WebGLRenderingContext): void;
  34740. }
  34741. }
  34742. declare module BABYLON {
  34743. /**
  34744. * @hidden
  34745. **/
  34746. export class AlphaState {
  34747. private _isAlphaBlendDirty;
  34748. private _isBlendFunctionParametersDirty;
  34749. private _isBlendEquationParametersDirty;
  34750. private _isBlendConstantsDirty;
  34751. private _alphaBlend;
  34752. private _blendFunctionParameters;
  34753. private _blendEquationParameters;
  34754. private _blendConstants;
  34755. /**
  34756. * Initializes the state.
  34757. */
  34758. constructor();
  34759. get isDirty(): boolean;
  34760. get alphaBlend(): boolean;
  34761. set alphaBlend(value: boolean);
  34762. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  34763. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  34764. setAlphaEquationParameters(rgb: number, alpha: number): void;
  34765. reset(): void;
  34766. apply(gl: WebGLRenderingContext): void;
  34767. }
  34768. }
  34769. declare module BABYLON {
  34770. /** @hidden */
  34771. export class WebGL2ShaderProcessor implements IShaderProcessor {
  34772. attributeProcessor(attribute: string): string;
  34773. varyingProcessor(varying: string, isFragment: boolean): string;
  34774. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  34775. }
  34776. }
  34777. declare module BABYLON {
  34778. /**
  34779. * Interface for attribute information associated with buffer instanciation
  34780. */
  34781. export interface InstancingAttributeInfo {
  34782. /**
  34783. * Name of the GLSL attribute
  34784. * if attribute index is not specified, this is used to retrieve the index from the effect
  34785. */
  34786. attributeName: string;
  34787. /**
  34788. * Index/offset of the attribute in the vertex shader
  34789. * if not specified, this will be computes from the name.
  34790. */
  34791. index?: number;
  34792. /**
  34793. * size of the attribute, 1, 2, 3 or 4
  34794. */
  34795. attributeSize: number;
  34796. /**
  34797. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  34798. */
  34799. offset: number;
  34800. /**
  34801. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  34802. * default to 1
  34803. */
  34804. divisor?: number;
  34805. /**
  34806. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  34807. * default is FLOAT
  34808. */
  34809. attributeType?: number;
  34810. /**
  34811. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  34812. */
  34813. normalized?: boolean;
  34814. }
  34815. }
  34816. declare module BABYLON {
  34817. interface ThinEngine {
  34818. /**
  34819. * Update a video texture
  34820. * @param texture defines the texture to update
  34821. * @param video defines the video element to use
  34822. * @param invertY defines if data must be stored with Y axis inverted
  34823. */
  34824. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  34825. }
  34826. }
  34827. declare module BABYLON {
  34828. interface ThinEngine {
  34829. /**
  34830. * Creates a dynamic texture
  34831. * @param width defines the width of the texture
  34832. * @param height defines the height of the texture
  34833. * @param generateMipMaps defines if the engine should generate the mip levels
  34834. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  34835. * @returns the dynamic texture inside an InternalTexture
  34836. */
  34837. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  34838. /**
  34839. * Update the content of a dynamic texture
  34840. * @param texture defines the texture to update
  34841. * @param canvas defines the canvas containing the source
  34842. * @param invertY defines if data must be stored with Y axis inverted
  34843. * @param premulAlpha defines if alpha is stored as premultiplied
  34844. * @param format defines the format of the data
  34845. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  34846. */
  34847. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  34848. }
  34849. }
  34850. declare module BABYLON {
  34851. /**
  34852. * Settings for finer control over video usage
  34853. */
  34854. export interface VideoTextureSettings {
  34855. /**
  34856. * Applies `autoplay` to video, if specified
  34857. */
  34858. autoPlay?: boolean;
  34859. /**
  34860. * Applies `loop` to video, if specified
  34861. */
  34862. loop?: boolean;
  34863. /**
  34864. * Automatically updates internal texture from video at every frame in the render loop
  34865. */
  34866. autoUpdateTexture: boolean;
  34867. /**
  34868. * Image src displayed during the video loading or until the user interacts with the video.
  34869. */
  34870. poster?: string;
  34871. }
  34872. /**
  34873. * If you want to display a video in your scene, this is the special texture for that.
  34874. * This special texture works similar to other textures, with the exception of a few parameters.
  34875. * @see https://doc.babylonjs.com/how_to/video_texture
  34876. */
  34877. export class VideoTexture extends Texture {
  34878. /**
  34879. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  34880. */
  34881. readonly autoUpdateTexture: boolean;
  34882. /**
  34883. * The video instance used by the texture internally
  34884. */
  34885. readonly video: HTMLVideoElement;
  34886. private _onUserActionRequestedObservable;
  34887. /**
  34888. * Event triggerd when a dom action is required by the user to play the video.
  34889. * This happens due to recent changes in browser policies preventing video to auto start.
  34890. */
  34891. get onUserActionRequestedObservable(): Observable<Texture>;
  34892. private _generateMipMaps;
  34893. private _stillImageCaptured;
  34894. private _displayingPosterTexture;
  34895. private _settings;
  34896. private _createInternalTextureOnEvent;
  34897. private _frameId;
  34898. private _currentSrc;
  34899. /**
  34900. * Creates a video texture.
  34901. * If you want to display a video in your scene, this is the special texture for that.
  34902. * This special texture works similar to other textures, with the exception of a few parameters.
  34903. * @see https://doc.babylonjs.com/how_to/video_texture
  34904. * @param name optional name, will detect from video source, if not defined
  34905. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  34906. * @param scene is obviously the current scene.
  34907. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  34908. * @param invertY is false by default but can be used to invert video on Y axis
  34909. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  34910. * @param settings allows finer control over video usage
  34911. */
  34912. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  34913. private _getName;
  34914. private _getVideo;
  34915. private _createInternalTexture;
  34916. private reset;
  34917. /**
  34918. * @hidden Internal method to initiate `update`.
  34919. */
  34920. _rebuild(): void;
  34921. /**
  34922. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  34923. */
  34924. update(): void;
  34925. /**
  34926. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  34927. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  34928. */
  34929. updateTexture(isVisible: boolean): void;
  34930. protected _updateInternalTexture: () => void;
  34931. /**
  34932. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  34933. * @param url New url.
  34934. */
  34935. updateURL(url: string): void;
  34936. /**
  34937. * Clones the texture.
  34938. * @returns the cloned texture
  34939. */
  34940. clone(): VideoTexture;
  34941. /**
  34942. * Dispose the texture and release its associated resources.
  34943. */
  34944. dispose(): void;
  34945. /**
  34946. * Creates a video texture straight from a stream.
  34947. * @param scene Define the scene the texture should be created in
  34948. * @param stream Define the stream the texture should be created from
  34949. * @returns The created video texture as a promise
  34950. */
  34951. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  34952. /**
  34953. * Creates a video texture straight from your WebCam video feed.
  34954. * @param scene Define the scene the texture should be created in
  34955. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  34956. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  34957. * @returns The created video texture as a promise
  34958. */
  34959. static CreateFromWebCamAsync(scene: Scene, constraints: {
  34960. minWidth: number;
  34961. maxWidth: number;
  34962. minHeight: number;
  34963. maxHeight: number;
  34964. deviceId: string;
  34965. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  34966. /**
  34967. * Creates a video texture straight from your WebCam video feed.
  34968. * @param scene Define the scene the texture should be created in
  34969. * @param onReady Define a callback to triggered once the texture will be ready
  34970. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  34971. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  34972. */
  34973. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  34974. minWidth: number;
  34975. maxWidth: number;
  34976. minHeight: number;
  34977. maxHeight: number;
  34978. deviceId: string;
  34979. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  34980. }
  34981. }
  34982. declare module BABYLON {
  34983. /**
  34984. * Defines the interface used by objects working like Scene
  34985. * @hidden
  34986. */
  34987. export interface ISceneLike {
  34988. _addPendingData(data: any): void;
  34989. _removePendingData(data: any): void;
  34990. offlineProvider: IOfflineProvider;
  34991. }
  34992. /** Interface defining initialization parameters for Engine class */
  34993. export interface EngineOptions extends WebGLContextAttributes {
  34994. /**
  34995. * Defines if the engine should no exceed a specified device ratio
  34996. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  34997. */
  34998. limitDeviceRatio?: number;
  34999. /**
  35000. * Defines if webvr should be enabled automatically
  35001. * @see https://doc.babylonjs.com/how_to/webvr_camera
  35002. */
  35003. autoEnableWebVR?: boolean;
  35004. /**
  35005. * Defines if webgl2 should be turned off even if supported
  35006. * @see https://doc.babylonjs.com/features/webgl2
  35007. */
  35008. disableWebGL2Support?: boolean;
  35009. /**
  35010. * Defines if webaudio should be initialized as well
  35011. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  35012. */
  35013. audioEngine?: boolean;
  35014. /**
  35015. * Defines if animations should run using a deterministic lock step
  35016. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35017. */
  35018. deterministicLockstep?: boolean;
  35019. /** Defines the maximum steps to use with deterministic lock step mode */
  35020. lockstepMaxSteps?: number;
  35021. /** Defines the seconds between each deterministic lock step */
  35022. timeStep?: number;
  35023. /**
  35024. * Defines that engine should ignore context lost events
  35025. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  35026. */
  35027. doNotHandleContextLost?: boolean;
  35028. /**
  35029. * Defines that engine should ignore modifying touch action attribute and style
  35030. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  35031. */
  35032. doNotHandleTouchAction?: boolean;
  35033. /**
  35034. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  35035. */
  35036. useHighPrecisionFloats?: boolean;
  35037. /**
  35038. * Make the canvas XR Compatible for XR sessions
  35039. */
  35040. xrCompatible?: boolean;
  35041. /**
  35042. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  35043. */
  35044. useHighPrecisionMatrix?: boolean;
  35045. }
  35046. /**
  35047. * The base engine class (root of all engines)
  35048. */
  35049. export class ThinEngine {
  35050. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  35051. static ExceptionList: ({
  35052. key: string;
  35053. capture: string;
  35054. captureConstraint: number;
  35055. targets: string[];
  35056. } | {
  35057. key: string;
  35058. capture: null;
  35059. captureConstraint: null;
  35060. targets: string[];
  35061. })[];
  35062. /** @hidden */
  35063. static _TextureLoaders: IInternalTextureLoader[];
  35064. /**
  35065. * Returns the current npm package of the sdk
  35066. */
  35067. static get NpmPackage(): string;
  35068. /**
  35069. * Returns the current version of the framework
  35070. */
  35071. static get Version(): string;
  35072. /**
  35073. * Returns a string describing the current engine
  35074. */
  35075. get description(): string;
  35076. /**
  35077. * Gets or sets the epsilon value used by collision engine
  35078. */
  35079. static CollisionsEpsilon: number;
  35080. /**
  35081. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35082. */
  35083. static get ShadersRepository(): string;
  35084. static set ShadersRepository(value: string);
  35085. /** @hidden */
  35086. _shaderProcessor: IShaderProcessor;
  35087. /**
  35088. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  35089. */
  35090. forcePOTTextures: boolean;
  35091. /**
  35092. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  35093. */
  35094. isFullscreen: boolean;
  35095. /**
  35096. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  35097. */
  35098. cullBackFaces: boolean;
  35099. /**
  35100. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  35101. */
  35102. renderEvenInBackground: boolean;
  35103. /**
  35104. * Gets or sets a boolean indicating that cache can be kept between frames
  35105. */
  35106. preventCacheWipeBetweenFrames: boolean;
  35107. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  35108. validateShaderPrograms: boolean;
  35109. /**
  35110. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  35111. * This can provide greater z depth for distant objects.
  35112. */
  35113. useReverseDepthBuffer: boolean;
  35114. /**
  35115. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  35116. */
  35117. disableUniformBuffers: boolean;
  35118. /** @hidden */
  35119. _uniformBuffers: UniformBuffer[];
  35120. /**
  35121. * Gets a boolean indicating that the engine supports uniform buffers
  35122. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  35123. */
  35124. get supportsUniformBuffers(): boolean;
  35125. /** @hidden */
  35126. _gl: WebGLRenderingContext;
  35127. /** @hidden */
  35128. _webGLVersion: number;
  35129. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  35130. protected _windowIsBackground: boolean;
  35131. protected _creationOptions: EngineOptions;
  35132. protected _highPrecisionShadersAllowed: boolean;
  35133. /** @hidden */
  35134. get _shouldUseHighPrecisionShader(): boolean;
  35135. /**
  35136. * Gets a boolean indicating that only power of 2 textures are supported
  35137. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  35138. */
  35139. get needPOTTextures(): boolean;
  35140. /** @hidden */
  35141. _badOS: boolean;
  35142. /** @hidden */
  35143. _badDesktopOS: boolean;
  35144. private _hardwareScalingLevel;
  35145. /** @hidden */
  35146. _caps: EngineCapabilities;
  35147. private _isStencilEnable;
  35148. private _glVersion;
  35149. private _glRenderer;
  35150. private _glVendor;
  35151. /** @hidden */
  35152. _videoTextureSupported: boolean;
  35153. protected _renderingQueueLaunched: boolean;
  35154. protected _activeRenderLoops: (() => void)[];
  35155. /**
  35156. * Observable signaled when a context lost event is raised
  35157. */
  35158. onContextLostObservable: Observable<ThinEngine>;
  35159. /**
  35160. * Observable signaled when a context restored event is raised
  35161. */
  35162. onContextRestoredObservable: Observable<ThinEngine>;
  35163. private _onContextLost;
  35164. private _onContextRestored;
  35165. protected _contextWasLost: boolean;
  35166. /** @hidden */
  35167. _doNotHandleContextLost: boolean;
  35168. /**
  35169. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  35170. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  35171. */
  35172. get doNotHandleContextLost(): boolean;
  35173. set doNotHandleContextLost(value: boolean);
  35174. /**
  35175. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  35176. */
  35177. disableVertexArrayObjects: boolean;
  35178. /** @hidden */
  35179. protected _colorWrite: boolean;
  35180. /** @hidden */
  35181. protected _colorWriteChanged: boolean;
  35182. /** @hidden */
  35183. protected _depthCullingState: DepthCullingState;
  35184. /** @hidden */
  35185. protected _stencilState: StencilState;
  35186. /** @hidden */
  35187. _alphaState: AlphaState;
  35188. /** @hidden */
  35189. _alphaMode: number;
  35190. /** @hidden */
  35191. _alphaEquation: number;
  35192. /** @hidden */
  35193. _internalTexturesCache: InternalTexture[];
  35194. /** @hidden */
  35195. protected _activeChannel: number;
  35196. private _currentTextureChannel;
  35197. /** @hidden */
  35198. protected _boundTexturesCache: {
  35199. [key: string]: Nullable<InternalTexture>;
  35200. };
  35201. /** @hidden */
  35202. protected _currentEffect: Nullable<Effect>;
  35203. /** @hidden */
  35204. protected _currentProgram: Nullable<WebGLProgram>;
  35205. private _compiledEffects;
  35206. private _vertexAttribArraysEnabled;
  35207. /** @hidden */
  35208. protected _cachedViewport: Nullable<IViewportLike>;
  35209. private _cachedVertexArrayObject;
  35210. /** @hidden */
  35211. protected _cachedVertexBuffers: any;
  35212. /** @hidden */
  35213. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  35214. /** @hidden */
  35215. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  35216. /** @hidden */
  35217. _currentRenderTarget: Nullable<InternalTexture>;
  35218. private _uintIndicesCurrentlySet;
  35219. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  35220. /** @hidden */
  35221. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  35222. /** @hidden */
  35223. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  35224. private _currentBufferPointers;
  35225. private _currentInstanceLocations;
  35226. private _currentInstanceBuffers;
  35227. private _textureUnits;
  35228. /** @hidden */
  35229. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35230. /** @hidden */
  35231. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35232. /** @hidden */
  35233. _boundRenderFunction: any;
  35234. private _vaoRecordInProgress;
  35235. private _mustWipeVertexAttributes;
  35236. private _emptyTexture;
  35237. private _emptyCubeTexture;
  35238. private _emptyTexture3D;
  35239. private _emptyTexture2DArray;
  35240. /** @hidden */
  35241. _frameHandler: number;
  35242. private _nextFreeTextureSlots;
  35243. private _maxSimultaneousTextures;
  35244. private _activeRequests;
  35245. /** @hidden */
  35246. _transformTextureUrl: Nullable<(url: string) => string>;
  35247. protected get _supportsHardwareTextureRescaling(): boolean;
  35248. private _framebufferDimensionsObject;
  35249. /**
  35250. * sets the object from which width and height will be taken from when getting render width and height
  35251. * Will fallback to the gl object
  35252. * @param dimensions the framebuffer width and height that will be used.
  35253. */
  35254. set framebufferDimensionsObject(dimensions: Nullable<{
  35255. framebufferWidth: number;
  35256. framebufferHeight: number;
  35257. }>);
  35258. /**
  35259. * Gets the current viewport
  35260. */
  35261. get currentViewport(): Nullable<IViewportLike>;
  35262. /**
  35263. * Gets the default empty texture
  35264. */
  35265. get emptyTexture(): InternalTexture;
  35266. /**
  35267. * Gets the default empty 3D texture
  35268. */
  35269. get emptyTexture3D(): InternalTexture;
  35270. /**
  35271. * Gets the default empty 2D array texture
  35272. */
  35273. get emptyTexture2DArray(): InternalTexture;
  35274. /**
  35275. * Gets the default empty cube texture
  35276. */
  35277. get emptyCubeTexture(): InternalTexture;
  35278. /**
  35279. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  35280. */
  35281. readonly premultipliedAlpha: boolean;
  35282. /**
  35283. * Observable event triggered before each texture is initialized
  35284. */
  35285. onBeforeTextureInitObservable: Observable<Texture>;
  35286. /**
  35287. * Creates a new engine
  35288. * @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
  35289. * @param antialias defines enable antialiasing (default: false)
  35290. * @param options defines further options to be sent to the getContext() function
  35291. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  35292. */
  35293. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  35294. private _rebuildInternalTextures;
  35295. private _rebuildEffects;
  35296. /**
  35297. * Gets a boolean indicating if all created effects are ready
  35298. * @returns true if all effects are ready
  35299. */
  35300. areAllEffectsReady(): boolean;
  35301. protected _rebuildBuffers(): void;
  35302. protected _initGLContext(): void;
  35303. /**
  35304. * Gets version of the current webGL context
  35305. */
  35306. get webGLVersion(): number;
  35307. /**
  35308. * Gets a string idenfifying the name of the class
  35309. * @returns "Engine" string
  35310. */
  35311. getClassName(): string;
  35312. /**
  35313. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  35314. */
  35315. get isStencilEnable(): boolean;
  35316. /** @hidden */
  35317. _prepareWorkingCanvas(): void;
  35318. /**
  35319. * Reset the texture cache to empty state
  35320. */
  35321. resetTextureCache(): void;
  35322. /**
  35323. * Gets an object containing information about the current webGL context
  35324. * @returns an object containing the vender, the renderer and the version of the current webGL context
  35325. */
  35326. getGlInfo(): {
  35327. vendor: string;
  35328. renderer: string;
  35329. version: string;
  35330. };
  35331. /**
  35332. * Defines the hardware scaling level.
  35333. * By default the hardware scaling level is computed from the window device ratio.
  35334. * 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.
  35335. * @param level defines the level to use
  35336. */
  35337. setHardwareScalingLevel(level: number): void;
  35338. /**
  35339. * Gets the current hardware scaling level.
  35340. * By default the hardware scaling level is computed from the window device ratio.
  35341. * 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.
  35342. * @returns a number indicating the current hardware scaling level
  35343. */
  35344. getHardwareScalingLevel(): number;
  35345. /**
  35346. * Gets the list of loaded textures
  35347. * @returns an array containing all loaded textures
  35348. */
  35349. getLoadedTexturesCache(): InternalTexture[];
  35350. /**
  35351. * Gets the object containing all engine capabilities
  35352. * @returns the EngineCapabilities object
  35353. */
  35354. getCaps(): EngineCapabilities;
  35355. /**
  35356. * stop executing a render loop function and remove it from the execution array
  35357. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  35358. */
  35359. stopRenderLoop(renderFunction?: () => void): void;
  35360. /** @hidden */
  35361. _renderLoop(): void;
  35362. /**
  35363. * Gets the HTML canvas attached with the current webGL context
  35364. * @returns a HTML canvas
  35365. */
  35366. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  35367. /**
  35368. * Gets host window
  35369. * @returns the host window object
  35370. */
  35371. getHostWindow(): Nullable<Window>;
  35372. /**
  35373. * Gets the current render width
  35374. * @param useScreen defines if screen size must be used (or the current render target if any)
  35375. * @returns a number defining the current render width
  35376. */
  35377. getRenderWidth(useScreen?: boolean): number;
  35378. /**
  35379. * Gets the current render height
  35380. * @param useScreen defines if screen size must be used (or the current render target if any)
  35381. * @returns a number defining the current render height
  35382. */
  35383. getRenderHeight(useScreen?: boolean): number;
  35384. /**
  35385. * Can be used to override the current requestAnimationFrame requester.
  35386. * @hidden
  35387. */
  35388. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  35389. /**
  35390. * Register and execute a render loop. The engine can have more than one render function
  35391. * @param renderFunction defines the function to continuously execute
  35392. */
  35393. runRenderLoop(renderFunction: () => void): void;
  35394. /**
  35395. * Clear the current render buffer or the current render target (if any is set up)
  35396. * @param color defines the color to use
  35397. * @param backBuffer defines if the back buffer must be cleared
  35398. * @param depth defines if the depth buffer must be cleared
  35399. * @param stencil defines if the stencil buffer must be cleared
  35400. */
  35401. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  35402. private _viewportCached;
  35403. /** @hidden */
  35404. _viewport(x: number, y: number, width: number, height: number): void;
  35405. /**
  35406. * Set the WebGL's viewport
  35407. * @param viewport defines the viewport element to be used
  35408. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  35409. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  35410. */
  35411. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  35412. /**
  35413. * Begin a new frame
  35414. */
  35415. beginFrame(): void;
  35416. /**
  35417. * Enf the current frame
  35418. */
  35419. endFrame(): void;
  35420. /**
  35421. * Resize the view according to the canvas' size
  35422. */
  35423. resize(): void;
  35424. /**
  35425. * Force a specific size of the canvas
  35426. * @param width defines the new canvas' width
  35427. * @param height defines the new canvas' height
  35428. * @returns true if the size was changed
  35429. */
  35430. setSize(width: number, height: number): boolean;
  35431. /**
  35432. * Binds the frame buffer to the specified texture.
  35433. * @param texture The texture to render to or null for the default canvas
  35434. * @param faceIndex The face of the texture to render to in case of cube texture
  35435. * @param requiredWidth The width of the target to render to
  35436. * @param requiredHeight The height of the target to render to
  35437. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  35438. * @param lodLevel defines the lod level to bind to the frame buffer
  35439. * @param layer defines the 2d array index to bind to frame buffer to
  35440. */
  35441. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  35442. /** @hidden */
  35443. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  35444. /**
  35445. * Unbind the current render target texture from the webGL context
  35446. * @param texture defines the render target texture to unbind
  35447. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  35448. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  35449. */
  35450. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  35451. /**
  35452. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  35453. */
  35454. flushFramebuffer(): void;
  35455. /**
  35456. * Unbind the current render target and bind the default framebuffer
  35457. */
  35458. restoreDefaultFramebuffer(): void;
  35459. /** @hidden */
  35460. protected _resetVertexBufferBinding(): void;
  35461. /**
  35462. * Creates a vertex buffer
  35463. * @param data the data for the vertex buffer
  35464. * @returns the new WebGL static buffer
  35465. */
  35466. createVertexBuffer(data: DataArray): DataBuffer;
  35467. private _createVertexBuffer;
  35468. /**
  35469. * Creates a dynamic vertex buffer
  35470. * @param data the data for the dynamic vertex buffer
  35471. * @returns the new WebGL dynamic buffer
  35472. */
  35473. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  35474. protected _resetIndexBufferBinding(): void;
  35475. /**
  35476. * Creates a new index buffer
  35477. * @param indices defines the content of the index buffer
  35478. * @param updatable defines if the index buffer must be updatable
  35479. * @returns a new webGL buffer
  35480. */
  35481. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  35482. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  35483. /**
  35484. * Bind a webGL buffer to the webGL context
  35485. * @param buffer defines the buffer to bind
  35486. */
  35487. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  35488. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  35489. private bindBuffer;
  35490. /**
  35491. * update the bound buffer with the given data
  35492. * @param data defines the data to update
  35493. */
  35494. updateArrayBuffer(data: Float32Array): void;
  35495. private _vertexAttribPointer;
  35496. /** @hidden */
  35497. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  35498. private _bindVertexBuffersAttributes;
  35499. /**
  35500. * Records a vertex array object
  35501. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35502. * @param vertexBuffers defines the list of vertex buffers to store
  35503. * @param indexBuffer defines the index buffer to store
  35504. * @param effect defines the effect to store
  35505. * @returns the new vertex array object
  35506. */
  35507. recordVertexArrayObject(vertexBuffers: {
  35508. [key: string]: VertexBuffer;
  35509. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  35510. /**
  35511. * Bind a specific vertex array object
  35512. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35513. * @param vertexArrayObject defines the vertex array object to bind
  35514. * @param indexBuffer defines the index buffer to bind
  35515. */
  35516. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  35517. /**
  35518. * Bind webGl buffers directly to the webGL context
  35519. * @param vertexBuffer defines the vertex buffer to bind
  35520. * @param indexBuffer defines the index buffer to bind
  35521. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  35522. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  35523. * @param effect defines the effect associated with the vertex buffer
  35524. */
  35525. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  35526. private _unbindVertexArrayObject;
  35527. /**
  35528. * Bind a list of vertex buffers to the webGL context
  35529. * @param vertexBuffers defines the list of vertex buffers to bind
  35530. * @param indexBuffer defines the index buffer to bind
  35531. * @param effect defines the effect associated with the vertex buffers
  35532. */
  35533. bindBuffers(vertexBuffers: {
  35534. [key: string]: Nullable<VertexBuffer>;
  35535. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  35536. /**
  35537. * Unbind all instance attributes
  35538. */
  35539. unbindInstanceAttributes(): void;
  35540. /**
  35541. * Release and free the memory of a vertex array object
  35542. * @param vao defines the vertex array object to delete
  35543. */
  35544. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  35545. /** @hidden */
  35546. _releaseBuffer(buffer: DataBuffer): boolean;
  35547. protected _deleteBuffer(buffer: DataBuffer): void;
  35548. /**
  35549. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  35550. * @param instancesBuffer defines the webGL buffer to update and bind
  35551. * @param data defines the data to store in the buffer
  35552. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  35553. */
  35554. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  35555. /**
  35556. * Bind the content of a webGL buffer used with instantiation
  35557. * @param instancesBuffer defines the webGL buffer to bind
  35558. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  35559. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  35560. */
  35561. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  35562. /**
  35563. * Disable the instance attribute corresponding to the name in parameter
  35564. * @param name defines the name of the attribute to disable
  35565. */
  35566. disableInstanceAttributeByName(name: string): void;
  35567. /**
  35568. * Disable the instance attribute corresponding to the location in parameter
  35569. * @param attributeLocation defines the attribute location of the attribute to disable
  35570. */
  35571. disableInstanceAttribute(attributeLocation: number): void;
  35572. /**
  35573. * Disable the attribute corresponding to the location in parameter
  35574. * @param attributeLocation defines the attribute location of the attribute to disable
  35575. */
  35576. disableAttributeByIndex(attributeLocation: number): void;
  35577. /**
  35578. * Send a draw order
  35579. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35580. * @param indexStart defines the starting index
  35581. * @param indexCount defines the number of index to draw
  35582. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35583. */
  35584. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  35585. /**
  35586. * Draw a list of points
  35587. * @param verticesStart defines the index of first vertex to draw
  35588. * @param verticesCount defines the count of vertices to draw
  35589. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35590. */
  35591. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35592. /**
  35593. * Draw a list of unindexed primitives
  35594. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35595. * @param verticesStart defines the index of first vertex to draw
  35596. * @param verticesCount defines the count of vertices to draw
  35597. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35598. */
  35599. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35600. /**
  35601. * Draw a list of indexed primitives
  35602. * @param fillMode defines the primitive to use
  35603. * @param indexStart defines the starting index
  35604. * @param indexCount defines the number of index to draw
  35605. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35606. */
  35607. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  35608. /**
  35609. * Draw a list of unindexed primitives
  35610. * @param fillMode defines the primitive to use
  35611. * @param verticesStart defines the index of first vertex to draw
  35612. * @param verticesCount defines the count of vertices to draw
  35613. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  35614. */
  35615. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  35616. private _drawMode;
  35617. /** @hidden */
  35618. protected _reportDrawCall(): void;
  35619. /** @hidden */
  35620. _releaseEffect(effect: Effect): void;
  35621. /** @hidden */
  35622. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  35623. /**
  35624. * Create a new effect (used to store vertex/fragment shaders)
  35625. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  35626. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  35627. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  35628. * @param samplers defines an array of string used to represent textures
  35629. * @param defines defines the string containing the defines to use to compile the shaders
  35630. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  35631. * @param onCompiled defines a function to call when the effect creation is successful
  35632. * @param onError defines a function to call when the effect creation has failed
  35633. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  35634. * @returns the new Effect
  35635. */
  35636. 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;
  35637. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  35638. private _compileShader;
  35639. private _compileRawShader;
  35640. /** @hidden */
  35641. _getShaderSource(shader: WebGLShader): Nullable<string>;
  35642. /**
  35643. * Directly creates a webGL program
  35644. * @param pipelineContext defines the pipeline context to attach to
  35645. * @param vertexCode defines the vertex shader code to use
  35646. * @param fragmentCode defines the fragment shader code to use
  35647. * @param context defines the webGL context to use (if not set, the current one will be used)
  35648. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35649. * @returns the new webGL program
  35650. */
  35651. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35652. /**
  35653. * Creates a webGL program
  35654. * @param pipelineContext defines the pipeline context to attach to
  35655. * @param vertexCode defines the vertex shader code to use
  35656. * @param fragmentCode defines the fragment shader code to use
  35657. * @param defines defines the string containing the defines to use to compile the shaders
  35658. * @param context defines the webGL context to use (if not set, the current one will be used)
  35659. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  35660. * @returns the new webGL program
  35661. */
  35662. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35663. /**
  35664. * Creates a new pipeline context
  35665. * @returns the new pipeline
  35666. */
  35667. createPipelineContext(): IPipelineContext;
  35668. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35669. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  35670. /** @hidden */
  35671. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  35672. /** @hidden */
  35673. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  35674. /** @hidden */
  35675. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  35676. /**
  35677. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  35678. * @param pipelineContext defines the pipeline context to use
  35679. * @param uniformsNames defines the list of uniform names
  35680. * @returns an array of webGL uniform locations
  35681. */
  35682. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  35683. /**
  35684. * Gets the lsit of active attributes for a given webGL program
  35685. * @param pipelineContext defines the pipeline context to use
  35686. * @param attributesNames defines the list of attribute names to get
  35687. * @returns an array of indices indicating the offset of each attribute
  35688. */
  35689. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  35690. /**
  35691. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  35692. * @param effect defines the effect to activate
  35693. */
  35694. enableEffect(effect: Nullable<Effect>): void;
  35695. /**
  35696. * Set the value of an uniform to a number (int)
  35697. * @param uniform defines the webGL uniform location where to store the value
  35698. * @param value defines the int number to store
  35699. */
  35700. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35701. /**
  35702. * Set the value of an uniform to an array of int32
  35703. * @param uniform defines the webGL uniform location where to store the value
  35704. * @param array defines the array of int32 to store
  35705. */
  35706. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35707. /**
  35708. * Set the value of an uniform to an array of int32 (stored as vec2)
  35709. * @param uniform defines the webGL uniform location where to store the value
  35710. * @param array defines the array of int32 to store
  35711. */
  35712. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35713. /**
  35714. * Set the value of an uniform to an array of int32 (stored as vec3)
  35715. * @param uniform defines the webGL uniform location where to store the value
  35716. * @param array defines the array of int32 to store
  35717. */
  35718. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35719. /**
  35720. * Set the value of an uniform to an array of int32 (stored as vec4)
  35721. * @param uniform defines the webGL uniform location where to store the value
  35722. * @param array defines the array of int32 to store
  35723. */
  35724. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  35725. /**
  35726. * Set the value of an uniform to an array of number
  35727. * @param uniform defines the webGL uniform location where to store the value
  35728. * @param array defines the array of number to store
  35729. */
  35730. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35731. /**
  35732. * Set the value of an uniform to an array of number (stored as vec2)
  35733. * @param uniform defines the webGL uniform location where to store the value
  35734. * @param array defines the array of number to store
  35735. */
  35736. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35737. /**
  35738. * Set the value of an uniform to an array of number (stored as vec3)
  35739. * @param uniform defines the webGL uniform location where to store the value
  35740. * @param array defines the array of number to store
  35741. */
  35742. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35743. /**
  35744. * Set the value of an uniform to an array of number (stored as vec4)
  35745. * @param uniform defines the webGL uniform location where to store the value
  35746. * @param array defines the array of number to store
  35747. */
  35748. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  35749. /**
  35750. * Set the value of an uniform to an array of float32 (stored as matrices)
  35751. * @param uniform defines the webGL uniform location where to store the value
  35752. * @param matrices defines the array of float32 to store
  35753. */
  35754. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  35755. /**
  35756. * Set the value of an uniform to a matrix (3x3)
  35757. * @param uniform defines the webGL uniform location where to store the value
  35758. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  35759. */
  35760. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35761. /**
  35762. * Set the value of an uniform to a matrix (2x2)
  35763. * @param uniform defines the webGL uniform location where to store the value
  35764. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  35765. */
  35766. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  35767. /**
  35768. * Set the value of an uniform to a number (float)
  35769. * @param uniform defines the webGL uniform location where to store the value
  35770. * @param value defines the float number to store
  35771. */
  35772. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  35773. /**
  35774. * Set the value of an uniform to a vec2
  35775. * @param uniform defines the webGL uniform location where to store the value
  35776. * @param x defines the 1st component of the value
  35777. * @param y defines the 2nd component of the value
  35778. */
  35779. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  35780. /**
  35781. * Set the value of an uniform to a vec3
  35782. * @param uniform defines the webGL uniform location where to store the value
  35783. * @param x defines the 1st component of the value
  35784. * @param y defines the 2nd component of the value
  35785. * @param z defines the 3rd component of the value
  35786. */
  35787. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  35788. /**
  35789. * Set the value of an uniform to a vec4
  35790. * @param uniform defines the webGL uniform location where to store the value
  35791. * @param x defines the 1st component of the value
  35792. * @param y defines the 2nd component of the value
  35793. * @param z defines the 3rd component of the value
  35794. * @param w defines the 4th component of the value
  35795. */
  35796. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  35797. /**
  35798. * Apply all cached states (depth, culling, stencil and alpha)
  35799. */
  35800. applyStates(): void;
  35801. /**
  35802. * Enable or disable color writing
  35803. * @param enable defines the state to set
  35804. */
  35805. setColorWrite(enable: boolean): void;
  35806. /**
  35807. * Gets a boolean indicating if color writing is enabled
  35808. * @returns the current color writing state
  35809. */
  35810. getColorWrite(): boolean;
  35811. /**
  35812. * Gets the depth culling state manager
  35813. */
  35814. get depthCullingState(): DepthCullingState;
  35815. /**
  35816. * Gets the alpha state manager
  35817. */
  35818. get alphaState(): AlphaState;
  35819. /**
  35820. * Gets the stencil state manager
  35821. */
  35822. get stencilState(): StencilState;
  35823. /**
  35824. * Clears the list of texture accessible through engine.
  35825. * This can help preventing texture load conflict due to name collision.
  35826. */
  35827. clearInternalTexturesCache(): void;
  35828. /**
  35829. * Force the entire cache to be cleared
  35830. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  35831. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  35832. */
  35833. wipeCaches(bruteForce?: boolean): void;
  35834. /** @hidden */
  35835. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  35836. min: number;
  35837. mag: number;
  35838. };
  35839. /** @hidden */
  35840. _createTexture(): WebGLTexture;
  35841. /**
  35842. * Usually called from Texture.ts.
  35843. * Passed information to create a WebGLTexture
  35844. * @param url defines a value which contains one of the following:
  35845. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  35846. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  35847. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  35848. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  35849. * @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)
  35850. * @param scene needed for loading to the correct scene
  35851. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  35852. * @param onLoad optional callback to be called upon successful completion
  35853. * @param onError optional callback to be called upon failure
  35854. * @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
  35855. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  35856. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  35857. * @param forcedExtension defines the extension to use to pick the right loader
  35858. * @param mimeType defines an optional mime type
  35859. * @returns a InternalTexture for assignment back into BABYLON.Texture
  35860. */
  35861. 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;
  35862. /**
  35863. * Loads an image as an HTMLImageElement.
  35864. * @param input url string, ArrayBuffer, or Blob to load
  35865. * @param onLoad callback called when the image successfully loads
  35866. * @param onError callback called when the image fails to load
  35867. * @param offlineProvider offline provider for caching
  35868. * @param mimeType optional mime type
  35869. * @returns the HTMLImageElement of the loaded image
  35870. * @hidden
  35871. */
  35872. 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>;
  35873. /**
  35874. * @hidden
  35875. */
  35876. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  35877. private _unpackFlipYCached;
  35878. /**
  35879. * In case you are sharing the context with other applications, it might
  35880. * be interested to not cache the unpack flip y state to ensure a consistent
  35881. * value would be set.
  35882. */
  35883. enableUnpackFlipYCached: boolean;
  35884. /** @hidden */
  35885. _unpackFlipY(value: boolean): void;
  35886. /** @hidden */
  35887. _getUnpackAlignement(): number;
  35888. private _getTextureTarget;
  35889. /**
  35890. * Update the sampling mode of a given texture
  35891. * @param samplingMode defines the required sampling mode
  35892. * @param texture defines the texture to update
  35893. * @param generateMipMaps defines whether to generate mipmaps for the texture
  35894. */
  35895. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  35896. /**
  35897. * Update the sampling mode of a given texture
  35898. * @param texture defines the texture to update
  35899. * @param wrapU defines the texture wrap mode of the u coordinates
  35900. * @param wrapV defines the texture wrap mode of the v coordinates
  35901. * @param wrapR defines the texture wrap mode of the r coordinates
  35902. */
  35903. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  35904. /** @hidden */
  35905. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  35906. width: number;
  35907. height: number;
  35908. layers?: number;
  35909. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  35910. /** @hidden */
  35911. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  35912. /** @hidden */
  35913. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  35914. /**
  35915. * Update a portion of an internal texture
  35916. * @param texture defines the texture to update
  35917. * @param imageData defines the data to store into the texture
  35918. * @param xOffset defines the x coordinates of the update rectangle
  35919. * @param yOffset defines the y coordinates of the update rectangle
  35920. * @param width defines the width of the update rectangle
  35921. * @param height defines the height of the update rectangle
  35922. * @param faceIndex defines the face index if texture is a cube (0 by default)
  35923. * @param lod defines the lod level to update (0 by default)
  35924. */
  35925. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  35926. /** @hidden */
  35927. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  35928. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  35929. private _prepareWebGLTexture;
  35930. /** @hidden */
  35931. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  35932. private _getDepthStencilBuffer;
  35933. /** @hidden */
  35934. _releaseFramebufferObjects(texture: InternalTexture): void;
  35935. /** @hidden */
  35936. _releaseTexture(texture: InternalTexture): void;
  35937. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  35938. protected _setProgram(program: WebGLProgram): void;
  35939. protected _boundUniforms: {
  35940. [key: number]: WebGLUniformLocation;
  35941. };
  35942. /**
  35943. * Binds an effect to the webGL context
  35944. * @param effect defines the effect to bind
  35945. */
  35946. bindSamplers(effect: Effect): void;
  35947. private _activateCurrentTexture;
  35948. /** @hidden */
  35949. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  35950. /** @hidden */
  35951. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  35952. /**
  35953. * Unbind all textures from the webGL context
  35954. */
  35955. unbindAllTextures(): void;
  35956. /**
  35957. * Sets a texture to the according uniform.
  35958. * @param channel The texture channel
  35959. * @param uniform The uniform to set
  35960. * @param texture The texture to apply
  35961. */
  35962. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  35963. private _bindSamplerUniformToChannel;
  35964. private _getTextureWrapMode;
  35965. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  35966. /**
  35967. * Sets an array of texture to the webGL context
  35968. * @param channel defines the channel where the texture array must be set
  35969. * @param uniform defines the associated uniform location
  35970. * @param textures defines the array of textures to bind
  35971. */
  35972. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  35973. /** @hidden */
  35974. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  35975. private _setTextureParameterFloat;
  35976. private _setTextureParameterInteger;
  35977. /**
  35978. * Unbind all vertex attributes from the webGL context
  35979. */
  35980. unbindAllAttributes(): void;
  35981. /**
  35982. * 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
  35983. */
  35984. releaseEffects(): void;
  35985. /**
  35986. * Dispose and release all associated resources
  35987. */
  35988. dispose(): void;
  35989. /**
  35990. * Attach a new callback raised when context lost event is fired
  35991. * @param callback defines the callback to call
  35992. */
  35993. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  35994. /**
  35995. * Attach a new callback raised when context restored event is fired
  35996. * @param callback defines the callback to call
  35997. */
  35998. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  35999. /**
  36000. * Get the current error code of the webGL context
  36001. * @returns the error code
  36002. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  36003. */
  36004. getError(): number;
  36005. private _canRenderToFloatFramebuffer;
  36006. private _canRenderToHalfFloatFramebuffer;
  36007. private _canRenderToFramebuffer;
  36008. /** @hidden */
  36009. _getWebGLTextureType(type: number): number;
  36010. /** @hidden */
  36011. _getInternalFormat(format: number): number;
  36012. /** @hidden */
  36013. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  36014. /** @hidden */
  36015. _getRGBAMultiSampleBufferFormat(type: number): number;
  36016. /** @hidden */
  36017. _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;
  36018. /**
  36019. * Loads a file from a url
  36020. * @param url url to load
  36021. * @param onSuccess callback called when the file successfully loads
  36022. * @param onProgress callback called while file is loading (if the server supports this mode)
  36023. * @param offlineProvider defines the offline provider for caching
  36024. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  36025. * @param onError callback called when the file fails to load
  36026. * @returns a file request object
  36027. * @hidden
  36028. */
  36029. 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;
  36030. /**
  36031. * Reads pixels from the current frame buffer. Please note that this function can be slow
  36032. * @param x defines the x coordinate of the rectangle where pixels must be read
  36033. * @param y defines the y coordinate of the rectangle where pixels must be read
  36034. * @param width defines the width of the rectangle where pixels must be read
  36035. * @param height defines the height of the rectangle where pixels must be read
  36036. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  36037. * @returns a Uint8Array containing RGBA colors
  36038. */
  36039. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  36040. private static _isSupported;
  36041. /**
  36042. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  36043. * @returns true if the engine can be created
  36044. * @ignorenaming
  36045. */
  36046. static isSupported(): boolean;
  36047. /**
  36048. * Find the next highest power of two.
  36049. * @param x Number to start search from.
  36050. * @return Next highest power of two.
  36051. */
  36052. static CeilingPOT(x: number): number;
  36053. /**
  36054. * Find the next lowest power of two.
  36055. * @param x Number to start search from.
  36056. * @return Next lowest power of two.
  36057. */
  36058. static FloorPOT(x: number): number;
  36059. /**
  36060. * Find the nearest power of two.
  36061. * @param x Number to start search from.
  36062. * @return Next nearest power of two.
  36063. */
  36064. static NearestPOT(x: number): number;
  36065. /**
  36066. * Get the closest exponent of two
  36067. * @param value defines the value to approximate
  36068. * @param max defines the maximum value to return
  36069. * @param mode defines how to define the closest value
  36070. * @returns closest exponent of two of the given value
  36071. */
  36072. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  36073. /**
  36074. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  36075. * @param func - the function to be called
  36076. * @param requester - the object that will request the next frame. Falls back to window.
  36077. * @returns frame number
  36078. */
  36079. static QueueNewFrame(func: () => void, requester?: any): number;
  36080. /**
  36081. * Gets host document
  36082. * @returns the host document object
  36083. */
  36084. getHostDocument(): Nullable<Document>;
  36085. }
  36086. }
  36087. declare module BABYLON {
  36088. /**
  36089. * Class representing spherical harmonics coefficients to the 3rd degree
  36090. */
  36091. export class SphericalHarmonics {
  36092. /**
  36093. * Defines whether or not the harmonics have been prescaled for rendering.
  36094. */
  36095. preScaled: boolean;
  36096. /**
  36097. * The l0,0 coefficients of the spherical harmonics
  36098. */
  36099. l00: Vector3;
  36100. /**
  36101. * The l1,-1 coefficients of the spherical harmonics
  36102. */
  36103. l1_1: Vector3;
  36104. /**
  36105. * The l1,0 coefficients of the spherical harmonics
  36106. */
  36107. l10: Vector3;
  36108. /**
  36109. * The l1,1 coefficients of the spherical harmonics
  36110. */
  36111. l11: Vector3;
  36112. /**
  36113. * The l2,-2 coefficients of the spherical harmonics
  36114. */
  36115. l2_2: Vector3;
  36116. /**
  36117. * The l2,-1 coefficients of the spherical harmonics
  36118. */
  36119. l2_1: Vector3;
  36120. /**
  36121. * The l2,0 coefficients of the spherical harmonics
  36122. */
  36123. l20: Vector3;
  36124. /**
  36125. * The l2,1 coefficients of the spherical harmonics
  36126. */
  36127. l21: Vector3;
  36128. /**
  36129. * The l2,2 coefficients of the spherical harmonics
  36130. */
  36131. l22: Vector3;
  36132. /**
  36133. * Adds a light to the spherical harmonics
  36134. * @param direction the direction of the light
  36135. * @param color the color of the light
  36136. * @param deltaSolidAngle the delta solid angle of the light
  36137. */
  36138. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  36139. /**
  36140. * Scales the spherical harmonics by the given amount
  36141. * @param scale the amount to scale
  36142. */
  36143. scaleInPlace(scale: number): void;
  36144. /**
  36145. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  36146. *
  36147. * ```
  36148. * E_lm = A_l * L_lm
  36149. * ```
  36150. *
  36151. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  36152. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  36153. * the scaling factors are given in equation 9.
  36154. */
  36155. convertIncidentRadianceToIrradiance(): void;
  36156. /**
  36157. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  36158. *
  36159. * ```
  36160. * L = (1/pi) * E * rho
  36161. * ```
  36162. *
  36163. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  36164. */
  36165. convertIrradianceToLambertianRadiance(): void;
  36166. /**
  36167. * Integrates the reconstruction coefficients directly in to the SH preventing further
  36168. * required operations at run time.
  36169. *
  36170. * This is simply done by scaling back the SH with Ylm constants parameter.
  36171. * The trigonometric part being applied by the shader at run time.
  36172. */
  36173. preScaleForRendering(): void;
  36174. /**
  36175. * Constructs a spherical harmonics from an array.
  36176. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  36177. * @returns the spherical harmonics
  36178. */
  36179. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  36180. /**
  36181. * Gets the spherical harmonics from polynomial
  36182. * @param polynomial the spherical polynomial
  36183. * @returns the spherical harmonics
  36184. */
  36185. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  36186. }
  36187. /**
  36188. * Class representing spherical polynomial coefficients to the 3rd degree
  36189. */
  36190. export class SphericalPolynomial {
  36191. private _harmonics;
  36192. /**
  36193. * The spherical harmonics used to create the polynomials.
  36194. */
  36195. get preScaledHarmonics(): SphericalHarmonics;
  36196. /**
  36197. * The x coefficients of the spherical polynomial
  36198. */
  36199. x: Vector3;
  36200. /**
  36201. * The y coefficients of the spherical polynomial
  36202. */
  36203. y: Vector3;
  36204. /**
  36205. * The z coefficients of the spherical polynomial
  36206. */
  36207. z: Vector3;
  36208. /**
  36209. * The xx coefficients of the spherical polynomial
  36210. */
  36211. xx: Vector3;
  36212. /**
  36213. * The yy coefficients of the spherical polynomial
  36214. */
  36215. yy: Vector3;
  36216. /**
  36217. * The zz coefficients of the spherical polynomial
  36218. */
  36219. zz: Vector3;
  36220. /**
  36221. * The xy coefficients of the spherical polynomial
  36222. */
  36223. xy: Vector3;
  36224. /**
  36225. * The yz coefficients of the spherical polynomial
  36226. */
  36227. yz: Vector3;
  36228. /**
  36229. * The zx coefficients of the spherical polynomial
  36230. */
  36231. zx: Vector3;
  36232. /**
  36233. * Adds an ambient color to the spherical polynomial
  36234. * @param color the color to add
  36235. */
  36236. addAmbient(color: Color3): void;
  36237. /**
  36238. * Scales the spherical polynomial by the given amount
  36239. * @param scale the amount to scale
  36240. */
  36241. scaleInPlace(scale: number): void;
  36242. /**
  36243. * Gets the spherical polynomial from harmonics
  36244. * @param harmonics the spherical harmonics
  36245. * @returns the spherical polynomial
  36246. */
  36247. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  36248. /**
  36249. * Constructs a spherical polynomial from an array.
  36250. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  36251. * @returns the spherical polynomial
  36252. */
  36253. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  36254. }
  36255. }
  36256. declare module BABYLON {
  36257. /**
  36258. * Defines the source of the internal texture
  36259. */
  36260. export enum InternalTextureSource {
  36261. /**
  36262. * The source of the texture data is unknown
  36263. */
  36264. Unknown = 0,
  36265. /**
  36266. * Texture data comes from an URL
  36267. */
  36268. Url = 1,
  36269. /**
  36270. * Texture data is only used for temporary storage
  36271. */
  36272. Temp = 2,
  36273. /**
  36274. * Texture data comes from raw data (ArrayBuffer)
  36275. */
  36276. Raw = 3,
  36277. /**
  36278. * Texture content is dynamic (video or dynamic texture)
  36279. */
  36280. Dynamic = 4,
  36281. /**
  36282. * Texture content is generated by rendering to it
  36283. */
  36284. RenderTarget = 5,
  36285. /**
  36286. * Texture content is part of a multi render target process
  36287. */
  36288. MultiRenderTarget = 6,
  36289. /**
  36290. * Texture data comes from a cube data file
  36291. */
  36292. Cube = 7,
  36293. /**
  36294. * Texture data comes from a raw cube data
  36295. */
  36296. CubeRaw = 8,
  36297. /**
  36298. * Texture data come from a prefiltered cube data file
  36299. */
  36300. CubePrefiltered = 9,
  36301. /**
  36302. * Texture content is raw 3D data
  36303. */
  36304. Raw3D = 10,
  36305. /**
  36306. * Texture content is raw 2D array data
  36307. */
  36308. Raw2DArray = 11,
  36309. /**
  36310. * Texture content is a depth texture
  36311. */
  36312. Depth = 12,
  36313. /**
  36314. * Texture data comes from a raw cube data encoded with RGBD
  36315. */
  36316. CubeRawRGBD = 13
  36317. }
  36318. /**
  36319. * Class used to store data associated with WebGL texture data for the engine
  36320. * This class should not be used directly
  36321. */
  36322. export class InternalTexture {
  36323. /** @hidden */
  36324. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  36325. /**
  36326. * Defines if the texture is ready
  36327. */
  36328. isReady: boolean;
  36329. /**
  36330. * Defines if the texture is a cube texture
  36331. */
  36332. isCube: boolean;
  36333. /**
  36334. * Defines if the texture contains 3D data
  36335. */
  36336. is3D: boolean;
  36337. /**
  36338. * Defines if the texture contains 2D array data
  36339. */
  36340. is2DArray: boolean;
  36341. /**
  36342. * Defines if the texture contains multiview data
  36343. */
  36344. isMultiview: boolean;
  36345. /**
  36346. * Gets the URL used to load this texture
  36347. */
  36348. url: string;
  36349. /**
  36350. * Gets the sampling mode of the texture
  36351. */
  36352. samplingMode: number;
  36353. /**
  36354. * Gets a boolean indicating if the texture needs mipmaps generation
  36355. */
  36356. generateMipMaps: boolean;
  36357. /**
  36358. * Gets the number of samples used by the texture (WebGL2+ only)
  36359. */
  36360. samples: number;
  36361. /**
  36362. * Gets the type of the texture (int, float...)
  36363. */
  36364. type: number;
  36365. /**
  36366. * Gets the format of the texture (RGB, RGBA...)
  36367. */
  36368. format: number;
  36369. /**
  36370. * Observable called when the texture is loaded
  36371. */
  36372. onLoadedObservable: Observable<InternalTexture>;
  36373. /**
  36374. * Gets the width of the texture
  36375. */
  36376. width: number;
  36377. /**
  36378. * Gets the height of the texture
  36379. */
  36380. height: number;
  36381. /**
  36382. * Gets the depth of the texture
  36383. */
  36384. depth: number;
  36385. /**
  36386. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  36387. */
  36388. baseWidth: number;
  36389. /**
  36390. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  36391. */
  36392. baseHeight: number;
  36393. /**
  36394. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  36395. */
  36396. baseDepth: number;
  36397. /**
  36398. * Gets a boolean indicating if the texture is inverted on Y axis
  36399. */
  36400. invertY: boolean;
  36401. /** @hidden */
  36402. _invertVScale: boolean;
  36403. /** @hidden */
  36404. _associatedChannel: number;
  36405. /** @hidden */
  36406. _source: InternalTextureSource;
  36407. /** @hidden */
  36408. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  36409. /** @hidden */
  36410. _bufferView: Nullable<ArrayBufferView>;
  36411. /** @hidden */
  36412. _bufferViewArray: Nullable<ArrayBufferView[]>;
  36413. /** @hidden */
  36414. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  36415. /** @hidden */
  36416. _size: number;
  36417. /** @hidden */
  36418. _extension: string;
  36419. /** @hidden */
  36420. _files: Nullable<string[]>;
  36421. /** @hidden */
  36422. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36423. /** @hidden */
  36424. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36425. /** @hidden */
  36426. _framebuffer: Nullable<WebGLFramebuffer>;
  36427. /** @hidden */
  36428. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  36429. /** @hidden */
  36430. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  36431. /** @hidden */
  36432. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  36433. /** @hidden */
  36434. _attachments: Nullable<number[]>;
  36435. /** @hidden */
  36436. _textureArray: Nullable<InternalTexture[]>;
  36437. /** @hidden */
  36438. _cachedCoordinatesMode: Nullable<number>;
  36439. /** @hidden */
  36440. _cachedWrapU: Nullable<number>;
  36441. /** @hidden */
  36442. _cachedWrapV: Nullable<number>;
  36443. /** @hidden */
  36444. _cachedWrapR: Nullable<number>;
  36445. /** @hidden */
  36446. _cachedAnisotropicFilteringLevel: Nullable<number>;
  36447. /** @hidden */
  36448. _isDisabled: boolean;
  36449. /** @hidden */
  36450. _compression: Nullable<string>;
  36451. /** @hidden */
  36452. _generateStencilBuffer: boolean;
  36453. /** @hidden */
  36454. _generateDepthBuffer: boolean;
  36455. /** @hidden */
  36456. _comparisonFunction: number;
  36457. /** @hidden */
  36458. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  36459. /** @hidden */
  36460. _lodGenerationScale: number;
  36461. /** @hidden */
  36462. _lodGenerationOffset: number;
  36463. /** @hidden */
  36464. _depthStencilTexture: Nullable<InternalTexture>;
  36465. /** @hidden */
  36466. _colorTextureArray: Nullable<WebGLTexture>;
  36467. /** @hidden */
  36468. _depthStencilTextureArray: Nullable<WebGLTexture>;
  36469. /** @hidden */
  36470. _lodTextureHigh: Nullable<BaseTexture>;
  36471. /** @hidden */
  36472. _lodTextureMid: Nullable<BaseTexture>;
  36473. /** @hidden */
  36474. _lodTextureLow: Nullable<BaseTexture>;
  36475. /** @hidden */
  36476. _isRGBD: boolean;
  36477. /** @hidden */
  36478. _linearSpecularLOD: boolean;
  36479. /** @hidden */
  36480. _irradianceTexture: Nullable<BaseTexture>;
  36481. /** @hidden */
  36482. _webGLTexture: Nullable<WebGLTexture>;
  36483. /** @hidden */
  36484. _references: number;
  36485. private _engine;
  36486. /**
  36487. * Gets the Engine the texture belongs to.
  36488. * @returns The babylon engine
  36489. */
  36490. getEngine(): ThinEngine;
  36491. /**
  36492. * Gets the data source type of the texture
  36493. */
  36494. get source(): InternalTextureSource;
  36495. /**
  36496. * Creates a new InternalTexture
  36497. * @param engine defines the engine to use
  36498. * @param source defines the type of data that will be used
  36499. * @param delayAllocation if the texture allocation should be delayed (default: false)
  36500. */
  36501. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  36502. /**
  36503. * Increments the number of references (ie. the number of Texture that point to it)
  36504. */
  36505. incrementReferences(): void;
  36506. /**
  36507. * Change the size of the texture (not the size of the content)
  36508. * @param width defines the new width
  36509. * @param height defines the new height
  36510. * @param depth defines the new depth (1 by default)
  36511. */
  36512. updateSize(width: int, height: int, depth?: int): void;
  36513. /** @hidden */
  36514. _rebuild(): void;
  36515. /** @hidden */
  36516. _swapAndDie(target: InternalTexture): void;
  36517. /**
  36518. * Dispose the current allocated resources
  36519. */
  36520. dispose(): void;
  36521. }
  36522. }
  36523. declare module BABYLON {
  36524. /**
  36525. * Class used to work with sound analyzer using fast fourier transform (FFT)
  36526. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36527. */
  36528. export class Analyser {
  36529. /**
  36530. * Gets or sets the smoothing
  36531. * @ignorenaming
  36532. */
  36533. SMOOTHING: number;
  36534. /**
  36535. * Gets or sets the FFT table size
  36536. * @ignorenaming
  36537. */
  36538. FFT_SIZE: number;
  36539. /**
  36540. * Gets or sets the bar graph amplitude
  36541. * @ignorenaming
  36542. */
  36543. BARGRAPHAMPLITUDE: number;
  36544. /**
  36545. * Gets or sets the position of the debug canvas
  36546. * @ignorenaming
  36547. */
  36548. DEBUGCANVASPOS: {
  36549. x: number;
  36550. y: number;
  36551. };
  36552. /**
  36553. * Gets or sets the debug canvas size
  36554. * @ignorenaming
  36555. */
  36556. DEBUGCANVASSIZE: {
  36557. width: number;
  36558. height: number;
  36559. };
  36560. private _byteFreqs;
  36561. private _byteTime;
  36562. private _floatFreqs;
  36563. private _webAudioAnalyser;
  36564. private _debugCanvas;
  36565. private _debugCanvasContext;
  36566. private _scene;
  36567. private _registerFunc;
  36568. private _audioEngine;
  36569. /**
  36570. * Creates a new analyser
  36571. * @param scene defines hosting scene
  36572. */
  36573. constructor(scene: Scene);
  36574. /**
  36575. * Get the number of data values you will have to play with for the visualization
  36576. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  36577. * @returns a number
  36578. */
  36579. getFrequencyBinCount(): number;
  36580. /**
  36581. * Gets the current frequency data as a byte array
  36582. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36583. * @returns a Uint8Array
  36584. */
  36585. getByteFrequencyData(): Uint8Array;
  36586. /**
  36587. * Gets the current waveform as a byte array
  36588. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  36589. * @returns a Uint8Array
  36590. */
  36591. getByteTimeDomainData(): Uint8Array;
  36592. /**
  36593. * Gets the current frequency data as a float array
  36594. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  36595. * @returns a Float32Array
  36596. */
  36597. getFloatFrequencyData(): Float32Array;
  36598. /**
  36599. * Renders the debug canvas
  36600. */
  36601. drawDebugCanvas(): void;
  36602. /**
  36603. * Stops rendering the debug canvas and removes it
  36604. */
  36605. stopDebugCanvas(): void;
  36606. /**
  36607. * Connects two audio nodes
  36608. * @param inputAudioNode defines first node to connect
  36609. * @param outputAudioNode defines second node to connect
  36610. */
  36611. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  36612. /**
  36613. * Releases all associated resources
  36614. */
  36615. dispose(): void;
  36616. }
  36617. }
  36618. declare module BABYLON {
  36619. /**
  36620. * This represents an audio engine and it is responsible
  36621. * to play, synchronize and analyse sounds throughout the application.
  36622. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36623. */
  36624. export interface IAudioEngine extends IDisposable {
  36625. /**
  36626. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36627. */
  36628. readonly canUseWebAudio: boolean;
  36629. /**
  36630. * Gets the current AudioContext if available.
  36631. */
  36632. readonly audioContext: Nullable<AudioContext>;
  36633. /**
  36634. * The master gain node defines the global audio volume of your audio engine.
  36635. */
  36636. readonly masterGain: GainNode;
  36637. /**
  36638. * Gets whether or not mp3 are supported by your browser.
  36639. */
  36640. readonly isMP3supported: boolean;
  36641. /**
  36642. * Gets whether or not ogg are supported by your browser.
  36643. */
  36644. readonly isOGGsupported: boolean;
  36645. /**
  36646. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36647. * @ignoreNaming
  36648. */
  36649. WarnedWebAudioUnsupported: boolean;
  36650. /**
  36651. * Defines if the audio engine relies on a custom unlocked button.
  36652. * In this case, the embedded button will not be displayed.
  36653. */
  36654. useCustomUnlockedButton: boolean;
  36655. /**
  36656. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  36657. */
  36658. readonly unlocked: boolean;
  36659. /**
  36660. * Event raised when audio has been unlocked on the browser.
  36661. */
  36662. onAudioUnlockedObservable: Observable<AudioEngine>;
  36663. /**
  36664. * Event raised when audio has been locked on the browser.
  36665. */
  36666. onAudioLockedObservable: Observable<AudioEngine>;
  36667. /**
  36668. * Flags the audio engine in Locked state.
  36669. * This happens due to new browser policies preventing audio to autoplay.
  36670. */
  36671. lock(): void;
  36672. /**
  36673. * Unlocks the audio engine once a user action has been done on the dom.
  36674. * This is helpful to resume play once browser policies have been satisfied.
  36675. */
  36676. unlock(): void;
  36677. /**
  36678. * Gets the global volume sets on the master gain.
  36679. * @returns the global volume if set or -1 otherwise
  36680. */
  36681. getGlobalVolume(): number;
  36682. /**
  36683. * Sets the global volume of your experience (sets on the master gain).
  36684. * @param newVolume Defines the new global volume of the application
  36685. */
  36686. setGlobalVolume(newVolume: number): void;
  36687. /**
  36688. * Connect the audio engine to an audio analyser allowing some amazing
  36689. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36690. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36691. * @param analyser The analyser to connect to the engine
  36692. */
  36693. connectToAnalyser(analyser: Analyser): void;
  36694. }
  36695. /**
  36696. * This represents the default audio engine used in babylon.
  36697. * It is responsible to play, synchronize and analyse sounds throughout the application.
  36698. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36699. */
  36700. export class AudioEngine implements IAudioEngine {
  36701. private _audioContext;
  36702. private _audioContextInitialized;
  36703. private _muteButton;
  36704. private _hostElement;
  36705. /**
  36706. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  36707. */
  36708. canUseWebAudio: boolean;
  36709. /**
  36710. * The master gain node defines the global audio volume of your audio engine.
  36711. */
  36712. masterGain: GainNode;
  36713. /**
  36714. * Defines if Babylon should emit a warning if WebAudio is not supported.
  36715. * @ignoreNaming
  36716. */
  36717. WarnedWebAudioUnsupported: boolean;
  36718. /**
  36719. * Gets whether or not mp3 are supported by your browser.
  36720. */
  36721. isMP3supported: boolean;
  36722. /**
  36723. * Gets whether or not ogg are supported by your browser.
  36724. */
  36725. isOGGsupported: boolean;
  36726. /**
  36727. * Gets whether audio has been unlocked on the device.
  36728. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  36729. * a user interaction has happened.
  36730. */
  36731. unlocked: boolean;
  36732. /**
  36733. * Defines if the audio engine relies on a custom unlocked button.
  36734. * In this case, the embedded button will not be displayed.
  36735. */
  36736. useCustomUnlockedButton: boolean;
  36737. /**
  36738. * Event raised when audio has been unlocked on the browser.
  36739. */
  36740. onAudioUnlockedObservable: Observable<AudioEngine>;
  36741. /**
  36742. * Event raised when audio has been locked on the browser.
  36743. */
  36744. onAudioLockedObservable: Observable<AudioEngine>;
  36745. /**
  36746. * Gets the current AudioContext if available.
  36747. */
  36748. get audioContext(): Nullable<AudioContext>;
  36749. private _connectedAnalyser;
  36750. /**
  36751. * Instantiates a new audio engine.
  36752. *
  36753. * There should be only one per page as some browsers restrict the number
  36754. * of audio contexts you can create.
  36755. * @param hostElement defines the host element where to display the mute icon if necessary
  36756. */
  36757. constructor(hostElement?: Nullable<HTMLElement>);
  36758. /**
  36759. * Flags the audio engine in Locked state.
  36760. * This happens due to new browser policies preventing audio to autoplay.
  36761. */
  36762. lock(): void;
  36763. /**
  36764. * Unlocks the audio engine once a user action has been done on the dom.
  36765. * This is helpful to resume play once browser policies have been satisfied.
  36766. */
  36767. unlock(): void;
  36768. private _resumeAudioContext;
  36769. private _initializeAudioContext;
  36770. private _tryToRun;
  36771. private _triggerRunningState;
  36772. private _triggerSuspendedState;
  36773. private _displayMuteButton;
  36774. private _moveButtonToTopLeft;
  36775. private _onResize;
  36776. private _hideMuteButton;
  36777. /**
  36778. * Destroy and release the resources associated with the audio ccontext.
  36779. */
  36780. dispose(): void;
  36781. /**
  36782. * Gets the global volume sets on the master gain.
  36783. * @returns the global volume if set or -1 otherwise
  36784. */
  36785. getGlobalVolume(): number;
  36786. /**
  36787. * Sets the global volume of your experience (sets on the master gain).
  36788. * @param newVolume Defines the new global volume of the application
  36789. */
  36790. setGlobalVolume(newVolume: number): void;
  36791. /**
  36792. * Connect the audio engine to an audio analyser allowing some amazing
  36793. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36794. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36795. * @param analyser The analyser to connect to the engine
  36796. */
  36797. connectToAnalyser(analyser: Analyser): void;
  36798. }
  36799. }
  36800. declare module BABYLON {
  36801. /**
  36802. * Interface used to present a loading screen while loading a scene
  36803. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36804. */
  36805. export interface ILoadingScreen {
  36806. /**
  36807. * Function called to display the loading screen
  36808. */
  36809. displayLoadingUI: () => void;
  36810. /**
  36811. * Function called to hide the loading screen
  36812. */
  36813. hideLoadingUI: () => void;
  36814. /**
  36815. * Gets or sets the color to use for the background
  36816. */
  36817. loadingUIBackgroundColor: string;
  36818. /**
  36819. * Gets or sets the text to display while loading
  36820. */
  36821. loadingUIText: string;
  36822. }
  36823. /**
  36824. * Class used for the default loading screen
  36825. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  36826. */
  36827. export class DefaultLoadingScreen implements ILoadingScreen {
  36828. private _renderingCanvas;
  36829. private _loadingText;
  36830. private _loadingDivBackgroundColor;
  36831. private _loadingDiv;
  36832. private _loadingTextDiv;
  36833. /** Gets or sets the logo url to use for the default loading screen */
  36834. static DefaultLogoUrl: string;
  36835. /** Gets or sets the spinner url to use for the default loading screen */
  36836. static DefaultSpinnerUrl: string;
  36837. /**
  36838. * Creates a new default loading screen
  36839. * @param _renderingCanvas defines the canvas used to render the scene
  36840. * @param _loadingText defines the default text to display
  36841. * @param _loadingDivBackgroundColor defines the default background color
  36842. */
  36843. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  36844. /**
  36845. * Function called to display the loading screen
  36846. */
  36847. displayLoadingUI(): void;
  36848. /**
  36849. * Function called to hide the loading screen
  36850. */
  36851. hideLoadingUI(): void;
  36852. /**
  36853. * Gets or sets the text to display while loading
  36854. */
  36855. set loadingUIText(text: string);
  36856. get loadingUIText(): string;
  36857. /**
  36858. * Gets or sets the color to use for the background
  36859. */
  36860. get loadingUIBackgroundColor(): string;
  36861. set loadingUIBackgroundColor(color: string);
  36862. private _resizeLoadingUI;
  36863. }
  36864. }
  36865. declare module BABYLON {
  36866. /**
  36867. * Interface for any object that can request an animation frame
  36868. */
  36869. export interface ICustomAnimationFrameRequester {
  36870. /**
  36871. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  36872. */
  36873. renderFunction?: Function;
  36874. /**
  36875. * Called to request the next frame to render to
  36876. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  36877. */
  36878. requestAnimationFrame: Function;
  36879. /**
  36880. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  36881. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  36882. */
  36883. requestID?: number;
  36884. }
  36885. }
  36886. declare module BABYLON {
  36887. /**
  36888. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  36889. */
  36890. export class PerformanceMonitor {
  36891. private _enabled;
  36892. private _rollingFrameTime;
  36893. private _lastFrameTimeMs;
  36894. /**
  36895. * constructor
  36896. * @param frameSampleSize The number of samples required to saturate the sliding window
  36897. */
  36898. constructor(frameSampleSize?: number);
  36899. /**
  36900. * Samples current frame
  36901. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  36902. */
  36903. sampleFrame(timeMs?: number): void;
  36904. /**
  36905. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  36906. */
  36907. get averageFrameTime(): number;
  36908. /**
  36909. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  36910. */
  36911. get averageFrameTimeVariance(): number;
  36912. /**
  36913. * Returns the frame time of the most recent frame
  36914. */
  36915. get instantaneousFrameTime(): number;
  36916. /**
  36917. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  36918. */
  36919. get averageFPS(): number;
  36920. /**
  36921. * Returns the average framerate in frames per second using the most recent frame time
  36922. */
  36923. get instantaneousFPS(): number;
  36924. /**
  36925. * Returns true if enough samples have been taken to completely fill the sliding window
  36926. */
  36927. get isSaturated(): boolean;
  36928. /**
  36929. * Enables contributions to the sliding window sample set
  36930. */
  36931. enable(): void;
  36932. /**
  36933. * Disables contributions to the sliding window sample set
  36934. * Samples will not be interpolated over the disabled period
  36935. */
  36936. disable(): void;
  36937. /**
  36938. * Returns true if sampling is enabled
  36939. */
  36940. get isEnabled(): boolean;
  36941. /**
  36942. * Resets performance monitor
  36943. */
  36944. reset(): void;
  36945. }
  36946. /**
  36947. * RollingAverage
  36948. *
  36949. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  36950. */
  36951. export class RollingAverage {
  36952. /**
  36953. * Current average
  36954. */
  36955. average: number;
  36956. /**
  36957. * Current variance
  36958. */
  36959. variance: number;
  36960. protected _samples: Array<number>;
  36961. protected _sampleCount: number;
  36962. protected _pos: number;
  36963. protected _m2: number;
  36964. /**
  36965. * constructor
  36966. * @param length The number of samples required to saturate the sliding window
  36967. */
  36968. constructor(length: number);
  36969. /**
  36970. * Adds a sample to the sample set
  36971. * @param v The sample value
  36972. */
  36973. add(v: number): void;
  36974. /**
  36975. * Returns previously added values or null if outside of history or outside the sliding window domain
  36976. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  36977. * @return Value previously recorded with add() or null if outside of range
  36978. */
  36979. history(i: number): number;
  36980. /**
  36981. * Returns true if enough samples have been taken to completely fill the sliding window
  36982. * @return true if sample-set saturated
  36983. */
  36984. isSaturated(): boolean;
  36985. /**
  36986. * Resets the rolling average (equivalent to 0 samples taken so far)
  36987. */
  36988. reset(): void;
  36989. /**
  36990. * Wraps a value around the sample range boundaries
  36991. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  36992. * @return Wrapped position in sample range
  36993. */
  36994. protected _wrapPosition(i: number): number;
  36995. }
  36996. }
  36997. declare module BABYLON {
  36998. /**
  36999. * This class is used to track a performance counter which is number based.
  37000. * The user has access to many properties which give statistics of different nature.
  37001. *
  37002. * The implementer can track two kinds of Performance Counter: time and count.
  37003. * 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.
  37004. * 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.
  37005. */
  37006. export class PerfCounter {
  37007. /**
  37008. * Gets or sets a global boolean to turn on and off all the counters
  37009. */
  37010. static Enabled: boolean;
  37011. /**
  37012. * Returns the smallest value ever
  37013. */
  37014. get min(): number;
  37015. /**
  37016. * Returns the biggest value ever
  37017. */
  37018. get max(): number;
  37019. /**
  37020. * Returns the average value since the performance counter is running
  37021. */
  37022. get average(): number;
  37023. /**
  37024. * Returns the average value of the last second the counter was monitored
  37025. */
  37026. get lastSecAverage(): number;
  37027. /**
  37028. * Returns the current value
  37029. */
  37030. get current(): number;
  37031. /**
  37032. * Gets the accumulated total
  37033. */
  37034. get total(): number;
  37035. /**
  37036. * Gets the total value count
  37037. */
  37038. get count(): number;
  37039. /**
  37040. * Creates a new counter
  37041. */
  37042. constructor();
  37043. /**
  37044. * Call this method to start monitoring a new frame.
  37045. * 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.
  37046. */
  37047. fetchNewFrame(): void;
  37048. /**
  37049. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  37050. * @param newCount the count value to add to the monitored count
  37051. * @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.
  37052. */
  37053. addCount(newCount: number, fetchResult: boolean): void;
  37054. /**
  37055. * Start monitoring this performance counter
  37056. */
  37057. beginMonitoring(): void;
  37058. /**
  37059. * Compute the time lapsed since the previous beginMonitoring() call.
  37060. * @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
  37061. */
  37062. endMonitoring(newFrame?: boolean): void;
  37063. private _fetchResult;
  37064. private _startMonitoringTime;
  37065. private _min;
  37066. private _max;
  37067. private _average;
  37068. private _current;
  37069. private _totalValueCount;
  37070. private _totalAccumulated;
  37071. private _lastSecAverage;
  37072. private _lastSecAccumulated;
  37073. private _lastSecTime;
  37074. private _lastSecValueCount;
  37075. }
  37076. }
  37077. declare module BABYLON {
  37078. interface ThinEngine {
  37079. /**
  37080. * Sets alpha constants used by some alpha blending modes
  37081. * @param r defines the red component
  37082. * @param g defines the green component
  37083. * @param b defines the blue component
  37084. * @param a defines the alpha component
  37085. */
  37086. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  37087. /**
  37088. * Sets the current alpha mode
  37089. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  37090. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  37091. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37092. */
  37093. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  37094. /**
  37095. * Gets the current alpha mode
  37096. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37097. * @returns the current alpha mode
  37098. */
  37099. getAlphaMode(): number;
  37100. /**
  37101. * Sets the current alpha equation
  37102. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  37103. */
  37104. setAlphaEquation(equation: number): void;
  37105. /**
  37106. * Gets the current alpha equation.
  37107. * @returns the current alpha equation
  37108. */
  37109. getAlphaEquation(): number;
  37110. }
  37111. }
  37112. declare module BABYLON {
  37113. interface ThinEngine {
  37114. /** @hidden */
  37115. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  37116. }
  37117. }
  37118. declare module BABYLON {
  37119. /**
  37120. * Defines the interface used by display changed events
  37121. */
  37122. export interface IDisplayChangedEventArgs {
  37123. /** Gets the vrDisplay object (if any) */
  37124. vrDisplay: Nullable<any>;
  37125. /** Gets a boolean indicating if webVR is supported */
  37126. vrSupported: boolean;
  37127. }
  37128. /**
  37129. * Defines the interface used by objects containing a viewport (like a camera)
  37130. */
  37131. interface IViewportOwnerLike {
  37132. /**
  37133. * Gets or sets the viewport
  37134. */
  37135. viewport: IViewportLike;
  37136. }
  37137. /**
  37138. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  37139. */
  37140. export class Engine extends ThinEngine {
  37141. /** Defines that alpha blending is disabled */
  37142. static readonly ALPHA_DISABLE: number;
  37143. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  37144. static readonly ALPHA_ADD: number;
  37145. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  37146. static readonly ALPHA_COMBINE: number;
  37147. /** Defines that alpha blending to DEST - SRC * DEST */
  37148. static readonly ALPHA_SUBTRACT: number;
  37149. /** Defines that alpha blending to SRC * DEST */
  37150. static readonly ALPHA_MULTIPLY: number;
  37151. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  37152. static readonly ALPHA_MAXIMIZED: number;
  37153. /** Defines that alpha blending to SRC + DEST */
  37154. static readonly ALPHA_ONEONE: number;
  37155. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  37156. static readonly ALPHA_PREMULTIPLIED: number;
  37157. /**
  37158. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  37159. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  37160. */
  37161. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  37162. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  37163. static readonly ALPHA_INTERPOLATE: number;
  37164. /**
  37165. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  37166. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  37167. */
  37168. static readonly ALPHA_SCREENMODE: number;
  37169. /** Defines that the ressource is not delayed*/
  37170. static readonly DELAYLOADSTATE_NONE: number;
  37171. /** Defines that the ressource was successfully delay loaded */
  37172. static readonly DELAYLOADSTATE_LOADED: number;
  37173. /** Defines that the ressource is currently delay loading */
  37174. static readonly DELAYLOADSTATE_LOADING: number;
  37175. /** Defines that the ressource is delayed and has not started loading */
  37176. static readonly DELAYLOADSTATE_NOTLOADED: number;
  37177. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  37178. static readonly NEVER: number;
  37179. /** 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 */
  37180. static readonly ALWAYS: number;
  37181. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  37182. static readonly LESS: number;
  37183. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  37184. static readonly EQUAL: number;
  37185. /** 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 */
  37186. static readonly LEQUAL: number;
  37187. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  37188. static readonly GREATER: number;
  37189. /** 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 */
  37190. static readonly GEQUAL: number;
  37191. /** 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 */
  37192. static readonly NOTEQUAL: number;
  37193. /** Passed to stencilOperation to specify that stencil value must be kept */
  37194. static readonly KEEP: number;
  37195. /** Passed to stencilOperation to specify that stencil value must be replaced */
  37196. static readonly REPLACE: number;
  37197. /** Passed to stencilOperation to specify that stencil value must be incremented */
  37198. static readonly INCR: number;
  37199. /** Passed to stencilOperation to specify that stencil value must be decremented */
  37200. static readonly DECR: number;
  37201. /** Passed to stencilOperation to specify that stencil value must be inverted */
  37202. static readonly INVERT: number;
  37203. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  37204. static readonly INCR_WRAP: number;
  37205. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  37206. static readonly DECR_WRAP: number;
  37207. /** Texture is not repeating outside of 0..1 UVs */
  37208. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  37209. /** Texture is repeating outside of 0..1 UVs */
  37210. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  37211. /** Texture is repeating and mirrored */
  37212. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  37213. /** ALPHA */
  37214. static readonly TEXTUREFORMAT_ALPHA: number;
  37215. /** LUMINANCE */
  37216. static readonly TEXTUREFORMAT_LUMINANCE: number;
  37217. /** LUMINANCE_ALPHA */
  37218. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  37219. /** RGB */
  37220. static readonly TEXTUREFORMAT_RGB: number;
  37221. /** RGBA */
  37222. static readonly TEXTUREFORMAT_RGBA: number;
  37223. /** RED */
  37224. static readonly TEXTUREFORMAT_RED: number;
  37225. /** RED (2nd reference) */
  37226. static readonly TEXTUREFORMAT_R: number;
  37227. /** RG */
  37228. static readonly TEXTUREFORMAT_RG: number;
  37229. /** RED_INTEGER */
  37230. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  37231. /** RED_INTEGER (2nd reference) */
  37232. static readonly TEXTUREFORMAT_R_INTEGER: number;
  37233. /** RG_INTEGER */
  37234. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  37235. /** RGB_INTEGER */
  37236. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  37237. /** RGBA_INTEGER */
  37238. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  37239. /** UNSIGNED_BYTE */
  37240. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  37241. /** UNSIGNED_BYTE (2nd reference) */
  37242. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  37243. /** FLOAT */
  37244. static readonly TEXTURETYPE_FLOAT: number;
  37245. /** HALF_FLOAT */
  37246. static readonly TEXTURETYPE_HALF_FLOAT: number;
  37247. /** BYTE */
  37248. static readonly TEXTURETYPE_BYTE: number;
  37249. /** SHORT */
  37250. static readonly TEXTURETYPE_SHORT: number;
  37251. /** UNSIGNED_SHORT */
  37252. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  37253. /** INT */
  37254. static readonly TEXTURETYPE_INT: number;
  37255. /** UNSIGNED_INT */
  37256. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  37257. /** UNSIGNED_SHORT_4_4_4_4 */
  37258. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  37259. /** UNSIGNED_SHORT_5_5_5_1 */
  37260. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  37261. /** UNSIGNED_SHORT_5_6_5 */
  37262. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  37263. /** UNSIGNED_INT_2_10_10_10_REV */
  37264. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  37265. /** UNSIGNED_INT_24_8 */
  37266. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  37267. /** UNSIGNED_INT_10F_11F_11F_REV */
  37268. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  37269. /** UNSIGNED_INT_5_9_9_9_REV */
  37270. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  37271. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  37272. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  37273. /** nearest is mag = nearest and min = nearest and mip = linear */
  37274. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  37275. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37276. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  37277. /** Trilinear is mag = linear and min = linear and mip = linear */
  37278. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  37279. /** nearest is mag = nearest and min = nearest and mip = linear */
  37280. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  37281. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37282. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  37283. /** Trilinear is mag = linear and min = linear and mip = linear */
  37284. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  37285. /** mag = nearest and min = nearest and mip = nearest */
  37286. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  37287. /** mag = nearest and min = linear and mip = nearest */
  37288. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  37289. /** mag = nearest and min = linear and mip = linear */
  37290. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  37291. /** mag = nearest and min = linear and mip = none */
  37292. static readonly TEXTURE_NEAREST_LINEAR: number;
  37293. /** mag = nearest and min = nearest and mip = none */
  37294. static readonly TEXTURE_NEAREST_NEAREST: number;
  37295. /** mag = linear and min = nearest and mip = nearest */
  37296. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  37297. /** mag = linear and min = nearest and mip = linear */
  37298. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  37299. /** mag = linear and min = linear and mip = none */
  37300. static readonly TEXTURE_LINEAR_LINEAR: number;
  37301. /** mag = linear and min = nearest and mip = none */
  37302. static readonly TEXTURE_LINEAR_NEAREST: number;
  37303. /** Explicit coordinates mode */
  37304. static readonly TEXTURE_EXPLICIT_MODE: number;
  37305. /** Spherical coordinates mode */
  37306. static readonly TEXTURE_SPHERICAL_MODE: number;
  37307. /** Planar coordinates mode */
  37308. static readonly TEXTURE_PLANAR_MODE: number;
  37309. /** Cubic coordinates mode */
  37310. static readonly TEXTURE_CUBIC_MODE: number;
  37311. /** Projection coordinates mode */
  37312. static readonly TEXTURE_PROJECTION_MODE: number;
  37313. /** Skybox coordinates mode */
  37314. static readonly TEXTURE_SKYBOX_MODE: number;
  37315. /** Inverse Cubic coordinates mode */
  37316. static readonly TEXTURE_INVCUBIC_MODE: number;
  37317. /** Equirectangular coordinates mode */
  37318. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  37319. /** Equirectangular Fixed coordinates mode */
  37320. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  37321. /** Equirectangular Fixed Mirrored coordinates mode */
  37322. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  37323. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  37324. static readonly SCALEMODE_FLOOR: number;
  37325. /** Defines that texture rescaling will look for the nearest power of 2 size */
  37326. static readonly SCALEMODE_NEAREST: number;
  37327. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  37328. static readonly SCALEMODE_CEILING: number;
  37329. /**
  37330. * Returns the current npm package of the sdk
  37331. */
  37332. static get NpmPackage(): string;
  37333. /**
  37334. * Returns the current version of the framework
  37335. */
  37336. static get Version(): string;
  37337. /** Gets the list of created engines */
  37338. static get Instances(): Engine[];
  37339. /**
  37340. * Gets the latest created engine
  37341. */
  37342. static get LastCreatedEngine(): Nullable<Engine>;
  37343. /**
  37344. * Gets the latest created scene
  37345. */
  37346. static get LastCreatedScene(): Nullable<Scene>;
  37347. /**
  37348. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  37349. * @param flag defines which part of the materials must be marked as dirty
  37350. * @param predicate defines a predicate used to filter which materials should be affected
  37351. */
  37352. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37353. /**
  37354. * Method called to create the default loading screen.
  37355. * This can be overriden in your own app.
  37356. * @param canvas The rendering canvas element
  37357. * @returns The loading screen
  37358. */
  37359. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  37360. /**
  37361. * Method called to create the default rescale post process on each engine.
  37362. */
  37363. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  37364. /**
  37365. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  37366. **/
  37367. enableOfflineSupport: boolean;
  37368. /**
  37369. * 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)
  37370. **/
  37371. disableManifestCheck: boolean;
  37372. /**
  37373. * Gets the list of created scenes
  37374. */
  37375. scenes: Scene[];
  37376. /**
  37377. * Event raised when a new scene is created
  37378. */
  37379. onNewSceneAddedObservable: Observable<Scene>;
  37380. /**
  37381. * Gets the list of created postprocesses
  37382. */
  37383. postProcesses: PostProcess[];
  37384. /**
  37385. * Gets a boolean indicating if the pointer is currently locked
  37386. */
  37387. isPointerLock: boolean;
  37388. /**
  37389. * Observable event triggered each time the rendering canvas is resized
  37390. */
  37391. onResizeObservable: Observable<Engine>;
  37392. /**
  37393. * Observable event triggered each time the canvas loses focus
  37394. */
  37395. onCanvasBlurObservable: Observable<Engine>;
  37396. /**
  37397. * Observable event triggered each time the canvas gains focus
  37398. */
  37399. onCanvasFocusObservable: Observable<Engine>;
  37400. /**
  37401. * Observable event triggered each time the canvas receives pointerout event
  37402. */
  37403. onCanvasPointerOutObservable: Observable<PointerEvent>;
  37404. /**
  37405. * Observable raised when the engine begins a new frame
  37406. */
  37407. onBeginFrameObservable: Observable<Engine>;
  37408. /**
  37409. * If set, will be used to request the next animation frame for the render loop
  37410. */
  37411. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  37412. /**
  37413. * Observable raised when the engine ends the current frame
  37414. */
  37415. onEndFrameObservable: Observable<Engine>;
  37416. /**
  37417. * Observable raised when the engine is about to compile a shader
  37418. */
  37419. onBeforeShaderCompilationObservable: Observable<Engine>;
  37420. /**
  37421. * Observable raised when the engine has jsut compiled a shader
  37422. */
  37423. onAfterShaderCompilationObservable: Observable<Engine>;
  37424. /**
  37425. * Gets the audio engine
  37426. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37427. * @ignorenaming
  37428. */
  37429. static audioEngine: IAudioEngine;
  37430. /**
  37431. * Default AudioEngine factory responsible of creating the Audio Engine.
  37432. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  37433. */
  37434. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  37435. /**
  37436. * Default offline support factory responsible of creating a tool used to store data locally.
  37437. * By default, this will create a Database object if the workload has been embedded.
  37438. */
  37439. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  37440. private _loadingScreen;
  37441. private _pointerLockRequested;
  37442. private _rescalePostProcess;
  37443. private _deterministicLockstep;
  37444. private _lockstepMaxSteps;
  37445. private _timeStep;
  37446. protected get _supportsHardwareTextureRescaling(): boolean;
  37447. private _fps;
  37448. private _deltaTime;
  37449. /** @hidden */
  37450. _drawCalls: PerfCounter;
  37451. /** 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 */
  37452. canvasTabIndex: number;
  37453. /**
  37454. * Turn this value on if you want to pause FPS computation when in background
  37455. */
  37456. disablePerformanceMonitorInBackground: boolean;
  37457. private _performanceMonitor;
  37458. /**
  37459. * Gets the performance monitor attached to this engine
  37460. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  37461. */
  37462. get performanceMonitor(): PerformanceMonitor;
  37463. private _onFocus;
  37464. private _onBlur;
  37465. private _onCanvasPointerOut;
  37466. private _onCanvasBlur;
  37467. private _onCanvasFocus;
  37468. private _onFullscreenChange;
  37469. private _onPointerLockChange;
  37470. /**
  37471. * Gets the HTML element used to attach event listeners
  37472. * @returns a HTML element
  37473. */
  37474. getInputElement(): Nullable<HTMLElement>;
  37475. /**
  37476. * Creates a new engine
  37477. * @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
  37478. * @param antialias defines enable antialiasing (default: false)
  37479. * @param options defines further options to be sent to the getContext() function
  37480. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  37481. */
  37482. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  37483. /**
  37484. * Gets current aspect ratio
  37485. * @param viewportOwner defines the camera to use to get the aspect ratio
  37486. * @param useScreen defines if screen size must be used (or the current render target if any)
  37487. * @returns a number defining the aspect ratio
  37488. */
  37489. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  37490. /**
  37491. * Gets current screen aspect ratio
  37492. * @returns a number defining the aspect ratio
  37493. */
  37494. getScreenAspectRatio(): number;
  37495. /**
  37496. * Gets the client rect of the HTML canvas attached with the current webGL context
  37497. * @returns a client rectanglee
  37498. */
  37499. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  37500. /**
  37501. * Gets the client rect of the HTML element used for events
  37502. * @returns a client rectanglee
  37503. */
  37504. getInputElementClientRect(): Nullable<ClientRect>;
  37505. /**
  37506. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  37507. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37508. * @returns true if engine is in deterministic lock step mode
  37509. */
  37510. isDeterministicLockStep(): boolean;
  37511. /**
  37512. * Gets the max steps when engine is running in deterministic lock step
  37513. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37514. * @returns the max steps
  37515. */
  37516. getLockstepMaxSteps(): number;
  37517. /**
  37518. * Returns the time in ms between steps when using deterministic lock step.
  37519. * @returns time step in (ms)
  37520. */
  37521. getTimeStep(): number;
  37522. /**
  37523. * Force the mipmap generation for the given render target texture
  37524. * @param texture defines the render target texture to use
  37525. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  37526. */
  37527. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  37528. /** States */
  37529. /**
  37530. * Set various states to the webGL context
  37531. * @param culling defines backface culling state
  37532. * @param zOffset defines the value to apply to zOffset (0 by default)
  37533. * @param force defines if states must be applied even if cache is up to date
  37534. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  37535. */
  37536. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  37537. /**
  37538. * Set the z offset to apply to current rendering
  37539. * @param value defines the offset to apply
  37540. */
  37541. setZOffset(value: number): void;
  37542. /**
  37543. * Gets the current value of the zOffset
  37544. * @returns the current zOffset state
  37545. */
  37546. getZOffset(): number;
  37547. /**
  37548. * Enable or disable depth buffering
  37549. * @param enable defines the state to set
  37550. */
  37551. setDepthBuffer(enable: boolean): void;
  37552. /**
  37553. * Gets a boolean indicating if depth writing is enabled
  37554. * @returns the current depth writing state
  37555. */
  37556. getDepthWrite(): boolean;
  37557. /**
  37558. * Enable or disable depth writing
  37559. * @param enable defines the state to set
  37560. */
  37561. setDepthWrite(enable: boolean): void;
  37562. /**
  37563. * Gets a boolean indicating if stencil buffer is enabled
  37564. * @returns the current stencil buffer state
  37565. */
  37566. getStencilBuffer(): boolean;
  37567. /**
  37568. * Enable or disable the stencil buffer
  37569. * @param enable defines if the stencil buffer must be enabled or disabled
  37570. */
  37571. setStencilBuffer(enable: boolean): void;
  37572. /**
  37573. * Gets the current stencil mask
  37574. * @returns a number defining the new stencil mask to use
  37575. */
  37576. getStencilMask(): number;
  37577. /**
  37578. * Sets the current stencil mask
  37579. * @param mask defines the new stencil mask to use
  37580. */
  37581. setStencilMask(mask: number): void;
  37582. /**
  37583. * Gets the current stencil function
  37584. * @returns a number defining the stencil function to use
  37585. */
  37586. getStencilFunction(): number;
  37587. /**
  37588. * Gets the current stencil reference value
  37589. * @returns a number defining the stencil reference value to use
  37590. */
  37591. getStencilFunctionReference(): number;
  37592. /**
  37593. * Gets the current stencil mask
  37594. * @returns a number defining the stencil mask to use
  37595. */
  37596. getStencilFunctionMask(): number;
  37597. /**
  37598. * Sets the current stencil function
  37599. * @param stencilFunc defines the new stencil function to use
  37600. */
  37601. setStencilFunction(stencilFunc: number): void;
  37602. /**
  37603. * Sets the current stencil reference
  37604. * @param reference defines the new stencil reference to use
  37605. */
  37606. setStencilFunctionReference(reference: number): void;
  37607. /**
  37608. * Sets the current stencil mask
  37609. * @param mask defines the new stencil mask to use
  37610. */
  37611. setStencilFunctionMask(mask: number): void;
  37612. /**
  37613. * Gets the current stencil operation when stencil fails
  37614. * @returns a number defining stencil operation to use when stencil fails
  37615. */
  37616. getStencilOperationFail(): number;
  37617. /**
  37618. * Gets the current stencil operation when depth fails
  37619. * @returns a number defining stencil operation to use when depth fails
  37620. */
  37621. getStencilOperationDepthFail(): number;
  37622. /**
  37623. * Gets the current stencil operation when stencil passes
  37624. * @returns a number defining stencil operation to use when stencil passes
  37625. */
  37626. getStencilOperationPass(): number;
  37627. /**
  37628. * Sets the stencil operation to use when stencil fails
  37629. * @param operation defines the stencil operation to use when stencil fails
  37630. */
  37631. setStencilOperationFail(operation: number): void;
  37632. /**
  37633. * Sets the stencil operation to use when depth fails
  37634. * @param operation defines the stencil operation to use when depth fails
  37635. */
  37636. setStencilOperationDepthFail(operation: number): void;
  37637. /**
  37638. * Sets the stencil operation to use when stencil passes
  37639. * @param operation defines the stencil operation to use when stencil passes
  37640. */
  37641. setStencilOperationPass(operation: number): void;
  37642. /**
  37643. * Sets a boolean indicating if the dithering state is enabled or disabled
  37644. * @param value defines the dithering state
  37645. */
  37646. setDitheringState(value: boolean): void;
  37647. /**
  37648. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  37649. * @param value defines the rasterizer state
  37650. */
  37651. setRasterizerState(value: boolean): void;
  37652. /**
  37653. * Gets the current depth function
  37654. * @returns a number defining the depth function
  37655. */
  37656. getDepthFunction(): Nullable<number>;
  37657. /**
  37658. * Sets the current depth function
  37659. * @param depthFunc defines the function to use
  37660. */
  37661. setDepthFunction(depthFunc: number): void;
  37662. /**
  37663. * Sets the current depth function to GREATER
  37664. */
  37665. setDepthFunctionToGreater(): void;
  37666. /**
  37667. * Sets the current depth function to GEQUAL
  37668. */
  37669. setDepthFunctionToGreaterOrEqual(): void;
  37670. /**
  37671. * Sets the current depth function to LESS
  37672. */
  37673. setDepthFunctionToLess(): void;
  37674. /**
  37675. * Sets the current depth function to LEQUAL
  37676. */
  37677. setDepthFunctionToLessOrEqual(): void;
  37678. private _cachedStencilBuffer;
  37679. private _cachedStencilFunction;
  37680. private _cachedStencilMask;
  37681. private _cachedStencilOperationPass;
  37682. private _cachedStencilOperationFail;
  37683. private _cachedStencilOperationDepthFail;
  37684. private _cachedStencilReference;
  37685. /**
  37686. * Caches the the state of the stencil buffer
  37687. */
  37688. cacheStencilState(): void;
  37689. /**
  37690. * Restores the state of the stencil buffer
  37691. */
  37692. restoreStencilState(): void;
  37693. /**
  37694. * Directly set the WebGL Viewport
  37695. * @param x defines the x coordinate of the viewport (in screen space)
  37696. * @param y defines the y coordinate of the viewport (in screen space)
  37697. * @param width defines the width of the viewport (in screen space)
  37698. * @param height defines the height of the viewport (in screen space)
  37699. * @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
  37700. */
  37701. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  37702. /**
  37703. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  37704. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  37705. * @param y defines the y-coordinate of the corner of the clear rectangle
  37706. * @param width defines the width of the clear rectangle
  37707. * @param height defines the height of the clear rectangle
  37708. * @param clearColor defines the clear color
  37709. */
  37710. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  37711. /**
  37712. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  37713. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  37714. * @param y defines the y-coordinate of the corner of the clear rectangle
  37715. * @param width defines the width of the clear rectangle
  37716. * @param height defines the height of the clear rectangle
  37717. */
  37718. enableScissor(x: number, y: number, width: number, height: number): void;
  37719. /**
  37720. * Disable previously set scissor test rectangle
  37721. */
  37722. disableScissor(): void;
  37723. protected _reportDrawCall(): void;
  37724. /**
  37725. * Initializes a webVR display and starts listening to display change events
  37726. * The onVRDisplayChangedObservable will be notified upon these changes
  37727. * @returns The onVRDisplayChangedObservable
  37728. */
  37729. initWebVR(): Observable<IDisplayChangedEventArgs>;
  37730. /** @hidden */
  37731. _prepareVRComponent(): void;
  37732. /** @hidden */
  37733. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  37734. /** @hidden */
  37735. _submitVRFrame(): void;
  37736. /**
  37737. * Call this function to leave webVR mode
  37738. * Will do nothing if webVR is not supported or if there is no webVR device
  37739. * @see https://doc.babylonjs.com/how_to/webvr_camera
  37740. */
  37741. disableVR(): void;
  37742. /**
  37743. * Gets a boolean indicating that the system is in VR mode and is presenting
  37744. * @returns true if VR mode is engaged
  37745. */
  37746. isVRPresenting(): boolean;
  37747. /** @hidden */
  37748. _requestVRFrame(): void;
  37749. /** @hidden */
  37750. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37751. /**
  37752. * Gets the source code of the vertex shader associated with a specific webGL program
  37753. * @param program defines the program to use
  37754. * @returns a string containing the source code of the vertex shader associated with the program
  37755. */
  37756. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  37757. /**
  37758. * Gets the source code of the fragment shader associated with a specific webGL program
  37759. * @param program defines the program to use
  37760. * @returns a string containing the source code of the fragment shader associated with the program
  37761. */
  37762. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  37763. /**
  37764. * Sets a depth stencil texture from a render target to the according uniform.
  37765. * @param channel The texture channel
  37766. * @param uniform The uniform to set
  37767. * @param texture The render target texture containing the depth stencil texture to apply
  37768. */
  37769. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  37770. /**
  37771. * Sets a texture to the webGL context from a postprocess
  37772. * @param channel defines the channel to use
  37773. * @param postProcess defines the source postprocess
  37774. */
  37775. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  37776. /**
  37777. * Binds the output of the passed in post process to the texture channel specified
  37778. * @param channel The channel the texture should be bound to
  37779. * @param postProcess The post process which's output should be bound
  37780. */
  37781. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  37782. protected _rebuildBuffers(): void;
  37783. /** @hidden */
  37784. _renderFrame(): void;
  37785. _renderLoop(): void;
  37786. /** @hidden */
  37787. _renderViews(): boolean;
  37788. /**
  37789. * Toggle full screen mode
  37790. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37791. */
  37792. switchFullscreen(requestPointerLock: boolean): void;
  37793. /**
  37794. * Enters full screen mode
  37795. * @param requestPointerLock defines if a pointer lock should be requested from the user
  37796. */
  37797. enterFullscreen(requestPointerLock: boolean): void;
  37798. /**
  37799. * Exits full screen mode
  37800. */
  37801. exitFullscreen(): void;
  37802. /**
  37803. * Enters Pointerlock mode
  37804. */
  37805. enterPointerlock(): void;
  37806. /**
  37807. * Exits Pointerlock mode
  37808. */
  37809. exitPointerlock(): void;
  37810. /**
  37811. * Begin a new frame
  37812. */
  37813. beginFrame(): void;
  37814. /**
  37815. * Enf the current frame
  37816. */
  37817. endFrame(): void;
  37818. resize(): void;
  37819. /**
  37820. * Force a specific size of the canvas
  37821. * @param width defines the new canvas' width
  37822. * @param height defines the new canvas' height
  37823. * @returns true if the size was changed
  37824. */
  37825. setSize(width: number, height: number): boolean;
  37826. /**
  37827. * Updates a dynamic vertex buffer.
  37828. * @param vertexBuffer the vertex buffer to update
  37829. * @param data the data used to update the vertex buffer
  37830. * @param byteOffset the byte offset of the data
  37831. * @param byteLength the byte length of the data
  37832. */
  37833. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  37834. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  37835. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37836. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37837. _releaseTexture(texture: InternalTexture): void;
  37838. /**
  37839. * @hidden
  37840. * Rescales a texture
  37841. * @param source input texutre
  37842. * @param destination destination texture
  37843. * @param scene scene to use to render the resize
  37844. * @param internalFormat format to use when resizing
  37845. * @param onComplete callback to be called when resize has completed
  37846. */
  37847. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  37848. /**
  37849. * Gets the current framerate
  37850. * @returns a number representing the framerate
  37851. */
  37852. getFps(): number;
  37853. /**
  37854. * Gets the time spent between current and previous frame
  37855. * @returns a number representing the delta time in ms
  37856. */
  37857. getDeltaTime(): number;
  37858. private _measureFps;
  37859. /** @hidden */
  37860. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  37861. /**
  37862. * Update a dynamic index buffer
  37863. * @param indexBuffer defines the target index buffer
  37864. * @param indices defines the data to update
  37865. * @param offset defines the offset in the target index buffer where update should start
  37866. */
  37867. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  37868. /**
  37869. * Updates the sample count of a render target texture
  37870. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  37871. * @param texture defines the texture to update
  37872. * @param samples defines the sample count to set
  37873. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  37874. */
  37875. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  37876. /**
  37877. * Updates a depth texture Comparison Mode and Function.
  37878. * If the comparison Function is equal to 0, the mode will be set to none.
  37879. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  37880. * @param texture The texture to set the comparison function for
  37881. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  37882. */
  37883. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  37884. /**
  37885. * Creates a webGL buffer to use with instanciation
  37886. * @param capacity defines the size of the buffer
  37887. * @returns the webGL buffer
  37888. */
  37889. createInstancesBuffer(capacity: number): DataBuffer;
  37890. /**
  37891. * Delete a webGL buffer used with instanciation
  37892. * @param buffer defines the webGL buffer to delete
  37893. */
  37894. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  37895. private _clientWaitAsync;
  37896. /** @hidden */
  37897. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  37898. dispose(): void;
  37899. private _disableTouchAction;
  37900. /**
  37901. * Display the loading screen
  37902. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37903. */
  37904. displayLoadingUI(): void;
  37905. /**
  37906. * Hide the loading screen
  37907. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37908. */
  37909. hideLoadingUI(): void;
  37910. /**
  37911. * Gets the current loading screen object
  37912. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37913. */
  37914. get loadingScreen(): ILoadingScreen;
  37915. /**
  37916. * Sets the current loading screen object
  37917. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37918. */
  37919. set loadingScreen(loadingScreen: ILoadingScreen);
  37920. /**
  37921. * Sets the current loading screen text
  37922. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37923. */
  37924. set loadingUIText(text: string);
  37925. /**
  37926. * Sets the current loading screen background color
  37927. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37928. */
  37929. set loadingUIBackgroundColor(color: string);
  37930. /** Pointerlock and fullscreen */
  37931. /**
  37932. * Ask the browser to promote the current element to pointerlock mode
  37933. * @param element defines the DOM element to promote
  37934. */
  37935. static _RequestPointerlock(element: HTMLElement): void;
  37936. /**
  37937. * Asks the browser to exit pointerlock mode
  37938. */
  37939. static _ExitPointerlock(): void;
  37940. /**
  37941. * Ask the browser to promote the current element to fullscreen rendering mode
  37942. * @param element defines the DOM element to promote
  37943. */
  37944. static _RequestFullscreen(element: HTMLElement): void;
  37945. /**
  37946. * Asks the browser to exit fullscreen mode
  37947. */
  37948. static _ExitFullscreen(): void;
  37949. }
  37950. }
  37951. declare module BABYLON {
  37952. /**
  37953. * The engine store class is responsible to hold all the instances of Engine and Scene created
  37954. * during the life time of the application.
  37955. */
  37956. export class EngineStore {
  37957. /** Gets the list of created engines */
  37958. static Instances: Engine[];
  37959. /** @hidden */
  37960. static _LastCreatedScene: Nullable<Scene>;
  37961. /**
  37962. * Gets the latest created engine
  37963. */
  37964. static get LastCreatedEngine(): Nullable<Engine>;
  37965. /**
  37966. * Gets the latest created scene
  37967. */
  37968. static get LastCreatedScene(): Nullable<Scene>;
  37969. /**
  37970. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  37971. * @ignorenaming
  37972. */
  37973. static UseFallbackTexture: boolean;
  37974. /**
  37975. * Texture content used if a texture cannot loaded
  37976. * @ignorenaming
  37977. */
  37978. static FallbackTexture: string;
  37979. }
  37980. }
  37981. declare module BABYLON {
  37982. /**
  37983. * Helper class that provides a small promise polyfill
  37984. */
  37985. export class PromisePolyfill {
  37986. /**
  37987. * Static function used to check if the polyfill is required
  37988. * If this is the case then the function will inject the polyfill to window.Promise
  37989. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  37990. */
  37991. static Apply(force?: boolean): void;
  37992. }
  37993. }
  37994. declare module BABYLON {
  37995. /**
  37996. * Interface for screenshot methods with describe argument called `size` as object with options
  37997. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  37998. */
  37999. export interface IScreenshotSize {
  38000. /**
  38001. * number in pixels for canvas height
  38002. */
  38003. height?: number;
  38004. /**
  38005. * multiplier allowing render at a higher or lower resolution
  38006. * If value is defined then height and width will be ignored and taken from camera
  38007. */
  38008. precision?: number;
  38009. /**
  38010. * number in pixels for canvas width
  38011. */
  38012. width?: number;
  38013. }
  38014. }
  38015. declare module BABYLON {
  38016. interface IColor4Like {
  38017. r: float;
  38018. g: float;
  38019. b: float;
  38020. a: float;
  38021. }
  38022. /**
  38023. * Class containing a set of static utilities functions
  38024. */
  38025. export class Tools {
  38026. /**
  38027. * Gets or sets the base URL to use to load assets
  38028. */
  38029. static get BaseUrl(): string;
  38030. static set BaseUrl(value: string);
  38031. /**
  38032. * Enable/Disable Custom HTTP Request Headers globally.
  38033. * default = false
  38034. * @see CustomRequestHeaders
  38035. */
  38036. static UseCustomRequestHeaders: boolean;
  38037. /**
  38038. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  38039. * i.e. when loading files, where the server/service expects an Authorization header
  38040. */
  38041. static CustomRequestHeaders: {
  38042. [key: string]: string;
  38043. };
  38044. /**
  38045. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  38046. */
  38047. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  38048. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  38049. /**
  38050. * Default behaviour for cors in the application.
  38051. * It can be a string if the expected behavior is identical in the entire app.
  38052. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  38053. */
  38054. static get CorsBehavior(): string | ((url: string | string[]) => string);
  38055. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  38056. /**
  38057. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38058. * @ignorenaming
  38059. */
  38060. static get UseFallbackTexture(): boolean;
  38061. static set UseFallbackTexture(value: boolean);
  38062. /**
  38063. * Use this object to register external classes like custom textures or material
  38064. * to allow the laoders to instantiate them
  38065. */
  38066. static get RegisteredExternalClasses(): {
  38067. [key: string]: Object;
  38068. };
  38069. static set RegisteredExternalClasses(classes: {
  38070. [key: string]: Object;
  38071. });
  38072. /**
  38073. * Texture content used if a texture cannot loaded
  38074. * @ignorenaming
  38075. */
  38076. static get fallbackTexture(): string;
  38077. static set fallbackTexture(value: string);
  38078. /**
  38079. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  38080. * @param u defines the coordinate on X axis
  38081. * @param v defines the coordinate on Y axis
  38082. * @param width defines the width of the source data
  38083. * @param height defines the height of the source data
  38084. * @param pixels defines the source byte array
  38085. * @param color defines the output color
  38086. */
  38087. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  38088. /**
  38089. * Interpolates between a and b via alpha
  38090. * @param a The lower value (returned when alpha = 0)
  38091. * @param b The upper value (returned when alpha = 1)
  38092. * @param alpha The interpolation-factor
  38093. * @return The mixed value
  38094. */
  38095. static Mix(a: number, b: number, alpha: number): number;
  38096. /**
  38097. * Tries to instantiate a new object from a given class name
  38098. * @param className defines the class name to instantiate
  38099. * @returns the new object or null if the system was not able to do the instantiation
  38100. */
  38101. static Instantiate(className: string): any;
  38102. /**
  38103. * Provides a slice function that will work even on IE
  38104. * @param data defines the array to slice
  38105. * @param start defines the start of the data (optional)
  38106. * @param end defines the end of the data (optional)
  38107. * @returns the new sliced array
  38108. */
  38109. static Slice<T>(data: T, start?: number, end?: number): T;
  38110. /**
  38111. * Polyfill for setImmediate
  38112. * @param action defines the action to execute after the current execution block
  38113. */
  38114. static SetImmediate(action: () => void): void;
  38115. /**
  38116. * Function indicating if a number is an exponent of 2
  38117. * @param value defines the value to test
  38118. * @returns true if the value is an exponent of 2
  38119. */
  38120. static IsExponentOfTwo(value: number): boolean;
  38121. private static _tmpFloatArray;
  38122. /**
  38123. * Returns the nearest 32-bit single precision float representation of a Number
  38124. * @param value A Number. If the parameter is of a different type, it will get converted
  38125. * to a number or to NaN if it cannot be converted
  38126. * @returns number
  38127. */
  38128. static FloatRound(value: number): number;
  38129. /**
  38130. * Extracts the filename from a path
  38131. * @param path defines the path to use
  38132. * @returns the filename
  38133. */
  38134. static GetFilename(path: string): string;
  38135. /**
  38136. * Extracts the "folder" part of a path (everything before the filename).
  38137. * @param uri The URI to extract the info from
  38138. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  38139. * @returns The "folder" part of the path
  38140. */
  38141. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  38142. /**
  38143. * Extracts text content from a DOM element hierarchy
  38144. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  38145. */
  38146. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  38147. /**
  38148. * Convert an angle in radians to degrees
  38149. * @param angle defines the angle to convert
  38150. * @returns the angle in degrees
  38151. */
  38152. static ToDegrees(angle: number): number;
  38153. /**
  38154. * Convert an angle in degrees to radians
  38155. * @param angle defines the angle to convert
  38156. * @returns the angle in radians
  38157. */
  38158. static ToRadians(angle: number): number;
  38159. /**
  38160. * Returns an array if obj is not an array
  38161. * @param obj defines the object to evaluate as an array
  38162. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  38163. * @returns either obj directly if obj is an array or a new array containing obj
  38164. */
  38165. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  38166. /**
  38167. * Gets the pointer prefix to use
  38168. * @param engine defines the engine we are finding the prefix for
  38169. * @returns "pointer" if touch is enabled. Else returns "mouse"
  38170. */
  38171. static GetPointerPrefix(engine: Engine): string;
  38172. /**
  38173. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  38174. * @param url define the url we are trying
  38175. * @param element define the dom element where to configure the cors policy
  38176. */
  38177. static SetCorsBehavior(url: string | string[], element: {
  38178. crossOrigin: string | null;
  38179. }): void;
  38180. /**
  38181. * Removes unwanted characters from an url
  38182. * @param url defines the url to clean
  38183. * @returns the cleaned url
  38184. */
  38185. static CleanUrl(url: string): string;
  38186. /**
  38187. * Gets or sets a function used to pre-process url before using them to load assets
  38188. */
  38189. static get PreprocessUrl(): (url: string) => string;
  38190. static set PreprocessUrl(processor: (url: string) => string);
  38191. /**
  38192. * Loads an image as an HTMLImageElement.
  38193. * @param input url string, ArrayBuffer, or Blob to load
  38194. * @param onLoad callback called when the image successfully loads
  38195. * @param onError callback called when the image fails to load
  38196. * @param offlineProvider offline provider for caching
  38197. * @param mimeType optional mime type
  38198. * @returns the HTMLImageElement of the loaded image
  38199. */
  38200. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  38201. /**
  38202. * Loads a file from a url
  38203. * @param url url string, ArrayBuffer, or Blob to load
  38204. * @param onSuccess callback called when the file successfully loads
  38205. * @param onProgress callback called while file is loading (if the server supports this mode)
  38206. * @param offlineProvider defines the offline provider for caching
  38207. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38208. * @param onError callback called when the file fails to load
  38209. * @returns a file request object
  38210. */
  38211. 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;
  38212. /**
  38213. * Loads a file from a url
  38214. * @param url the file url to load
  38215. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38216. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  38217. */
  38218. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  38219. /**
  38220. * Load a script (identified by an url). When the url returns, the
  38221. * content of this file is added into a new script element, attached to the DOM (body element)
  38222. * @param scriptUrl defines the url of the script to laod
  38223. * @param onSuccess defines the callback called when the script is loaded
  38224. * @param onError defines the callback to call if an error occurs
  38225. * @param scriptId defines the id of the script element
  38226. */
  38227. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  38228. /**
  38229. * Load an asynchronous script (identified by an url). When the url returns, the
  38230. * content of this file is added into a new script element, attached to the DOM (body element)
  38231. * @param scriptUrl defines the url of the script to laod
  38232. * @param scriptId defines the id of the script element
  38233. * @returns a promise request object
  38234. */
  38235. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  38236. /**
  38237. * Loads a file from a blob
  38238. * @param fileToLoad defines the blob to use
  38239. * @param callback defines the callback to call when data is loaded
  38240. * @param progressCallback defines the callback to call during loading process
  38241. * @returns a file request object
  38242. */
  38243. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  38244. /**
  38245. * Reads a file from a File object
  38246. * @param file defines the file to load
  38247. * @param onSuccess defines the callback to call when data is loaded
  38248. * @param onProgress defines the callback to call during loading process
  38249. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  38250. * @param onError defines the callback to call when an error occurs
  38251. * @returns a file request object
  38252. */
  38253. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38254. /**
  38255. * Creates a data url from a given string content
  38256. * @param content defines the content to convert
  38257. * @returns the new data url link
  38258. */
  38259. static FileAsURL(content: string): string;
  38260. /**
  38261. * Format the given number to a specific decimal format
  38262. * @param value defines the number to format
  38263. * @param decimals defines the number of decimals to use
  38264. * @returns the formatted string
  38265. */
  38266. static Format(value: number, decimals?: number): string;
  38267. /**
  38268. * Tries to copy an object by duplicating every property
  38269. * @param source defines the source object
  38270. * @param destination defines the target object
  38271. * @param doNotCopyList defines a list of properties to avoid
  38272. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  38273. */
  38274. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  38275. /**
  38276. * Gets a boolean indicating if the given object has no own property
  38277. * @param obj defines the object to test
  38278. * @returns true if object has no own property
  38279. */
  38280. static IsEmpty(obj: any): boolean;
  38281. /**
  38282. * Function used to register events at window level
  38283. * @param windowElement defines the Window object to use
  38284. * @param events defines the events to register
  38285. */
  38286. static RegisterTopRootEvents(windowElement: Window, events: {
  38287. name: string;
  38288. handler: Nullable<(e: FocusEvent) => any>;
  38289. }[]): void;
  38290. /**
  38291. * Function used to unregister events from window level
  38292. * @param windowElement defines the Window object to use
  38293. * @param events defines the events to unregister
  38294. */
  38295. static UnregisterTopRootEvents(windowElement: Window, events: {
  38296. name: string;
  38297. handler: Nullable<(e: FocusEvent) => any>;
  38298. }[]): void;
  38299. /**
  38300. * @ignore
  38301. */
  38302. static _ScreenshotCanvas: HTMLCanvasElement;
  38303. /**
  38304. * Dumps the current bound framebuffer
  38305. * @param width defines the rendering width
  38306. * @param height defines the rendering height
  38307. * @param engine defines the hosting engine
  38308. * @param successCallback defines the callback triggered once the data are available
  38309. * @param mimeType defines the mime type of the result
  38310. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  38311. */
  38312. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38313. /**
  38314. * Converts the canvas data to blob.
  38315. * This acts as a polyfill for browsers not supporting the to blob function.
  38316. * @param canvas Defines the canvas to extract the data from
  38317. * @param successCallback Defines the callback triggered once the data are available
  38318. * @param mimeType Defines the mime type of the result
  38319. */
  38320. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  38321. /**
  38322. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  38323. * @param successCallback defines the callback triggered once the data are available
  38324. * @param mimeType defines the mime type of the result
  38325. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  38326. */
  38327. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38328. /**
  38329. * Downloads a blob in the browser
  38330. * @param blob defines the blob to download
  38331. * @param fileName defines the name of the downloaded file
  38332. */
  38333. static Download(blob: Blob, fileName: string): void;
  38334. /**
  38335. * Captures a screenshot of the current rendering
  38336. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38337. * @param engine defines the rendering engine
  38338. * @param camera defines the source camera
  38339. * @param size This parameter can be set to a single number or to an object with the
  38340. * following (optional) properties: precision, width, height. If a single number is passed,
  38341. * it will be used for both width and height. If an object is passed, the screenshot size
  38342. * will be derived from the parameters. The precision property is a multiplier allowing
  38343. * rendering at a higher or lower resolution
  38344. * @param successCallback defines the callback receives a single parameter which contains the
  38345. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38346. * src parameter of an <img> to display it
  38347. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38348. * Check your browser for supported MIME types
  38349. */
  38350. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  38351. /**
  38352. * Captures a screenshot of the current rendering
  38353. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38354. * @param engine defines the rendering engine
  38355. * @param camera defines the source camera
  38356. * @param size This parameter can be set to a single number or to an object with the
  38357. * following (optional) properties: precision, width, height. If a single number is passed,
  38358. * it will be used for both width and height. If an object is passed, the screenshot size
  38359. * will be derived from the parameters. The precision property is a multiplier allowing
  38360. * rendering at a higher or lower resolution
  38361. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38362. * Check your browser for supported MIME types
  38363. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38364. * to the src parameter of an <img> to display it
  38365. */
  38366. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  38367. /**
  38368. * Generates an image screenshot from the specified camera.
  38369. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38370. * @param engine The engine to use for rendering
  38371. * @param camera The camera to use for rendering
  38372. * @param size This parameter can be set to a single number or to an object with the
  38373. * following (optional) properties: precision, width, height. If a single number is passed,
  38374. * it will be used for both width and height. If an object is passed, the screenshot size
  38375. * will be derived from the parameters. The precision property is a multiplier allowing
  38376. * rendering at a higher or lower resolution
  38377. * @param successCallback The callback receives a single parameter which contains the
  38378. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38379. * src parameter of an <img> to display it
  38380. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38381. * Check your browser for supported MIME types
  38382. * @param samples Texture samples (default: 1)
  38383. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38384. * @param fileName A name for for the downloaded file.
  38385. */
  38386. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  38387. /**
  38388. * Generates an image screenshot from the specified camera.
  38389. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38390. * @param engine The engine to use for rendering
  38391. * @param camera The camera to use for rendering
  38392. * @param size This parameter can be set to a single number or to an object with the
  38393. * following (optional) properties: precision, width, height. If a single number is passed,
  38394. * it will be used for both width and height. If an object is passed, the screenshot size
  38395. * will be derived from the parameters. The precision property is a multiplier allowing
  38396. * rendering at a higher or lower resolution
  38397. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38398. * Check your browser for supported MIME types
  38399. * @param samples Texture samples (default: 1)
  38400. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38401. * @param fileName A name for for the downloaded file.
  38402. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38403. * to the src parameter of an <img> to display it
  38404. */
  38405. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  38406. /**
  38407. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  38408. * Be aware Math.random() could cause collisions, but:
  38409. * "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"
  38410. * @returns a pseudo random id
  38411. */
  38412. static RandomId(): string;
  38413. /**
  38414. * Test if the given uri is a base64 string
  38415. * @param uri The uri to test
  38416. * @return True if the uri is a base64 string or false otherwise
  38417. */
  38418. static IsBase64(uri: string): boolean;
  38419. /**
  38420. * Decode the given base64 uri.
  38421. * @param uri The uri to decode
  38422. * @return The decoded base64 data.
  38423. */
  38424. static DecodeBase64(uri: string): ArrayBuffer;
  38425. /**
  38426. * Gets the absolute url.
  38427. * @param url the input url
  38428. * @return the absolute url
  38429. */
  38430. static GetAbsoluteUrl(url: string): string;
  38431. /**
  38432. * No log
  38433. */
  38434. static readonly NoneLogLevel: number;
  38435. /**
  38436. * Only message logs
  38437. */
  38438. static readonly MessageLogLevel: number;
  38439. /**
  38440. * Only warning logs
  38441. */
  38442. static readonly WarningLogLevel: number;
  38443. /**
  38444. * Only error logs
  38445. */
  38446. static readonly ErrorLogLevel: number;
  38447. /**
  38448. * All logs
  38449. */
  38450. static readonly AllLogLevel: number;
  38451. /**
  38452. * Gets a value indicating the number of loading errors
  38453. * @ignorenaming
  38454. */
  38455. static get errorsCount(): number;
  38456. /**
  38457. * Callback called when a new log is added
  38458. */
  38459. static OnNewCacheEntry: (entry: string) => void;
  38460. /**
  38461. * Log a message to the console
  38462. * @param message defines the message to log
  38463. */
  38464. static Log(message: string): void;
  38465. /**
  38466. * Write a warning message to the console
  38467. * @param message defines the message to log
  38468. */
  38469. static Warn(message: string): void;
  38470. /**
  38471. * Write an error message to the console
  38472. * @param message defines the message to log
  38473. */
  38474. static Error(message: string): void;
  38475. /**
  38476. * Gets current log cache (list of logs)
  38477. */
  38478. static get LogCache(): string;
  38479. /**
  38480. * Clears the log cache
  38481. */
  38482. static ClearLogCache(): void;
  38483. /**
  38484. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  38485. */
  38486. static set LogLevels(level: number);
  38487. /**
  38488. * Checks if the window object exists
  38489. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  38490. */
  38491. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  38492. /**
  38493. * No performance log
  38494. */
  38495. static readonly PerformanceNoneLogLevel: number;
  38496. /**
  38497. * Use user marks to log performance
  38498. */
  38499. static readonly PerformanceUserMarkLogLevel: number;
  38500. /**
  38501. * Log performance to the console
  38502. */
  38503. static readonly PerformanceConsoleLogLevel: number;
  38504. private static _performance;
  38505. /**
  38506. * Sets the current performance log level
  38507. */
  38508. static set PerformanceLogLevel(level: number);
  38509. private static _StartPerformanceCounterDisabled;
  38510. private static _EndPerformanceCounterDisabled;
  38511. private static _StartUserMark;
  38512. private static _EndUserMark;
  38513. private static _StartPerformanceConsole;
  38514. private static _EndPerformanceConsole;
  38515. /**
  38516. * Starts a performance counter
  38517. */
  38518. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38519. /**
  38520. * Ends a specific performance coutner
  38521. */
  38522. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38523. /**
  38524. * Gets either window.performance.now() if supported or Date.now() else
  38525. */
  38526. static get Now(): number;
  38527. /**
  38528. * This method will return the name of the class used to create the instance of the given object.
  38529. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  38530. * @param object the object to get the class name from
  38531. * @param isType defines if the object is actually a type
  38532. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  38533. */
  38534. static GetClassName(object: any, isType?: boolean): string;
  38535. /**
  38536. * Gets the first element of an array satisfying a given predicate
  38537. * @param array defines the array to browse
  38538. * @param predicate defines the predicate to use
  38539. * @returns null if not found or the element
  38540. */
  38541. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  38542. /**
  38543. * This method will return the name of the full name of the class, including its owning module (if any).
  38544. * 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).
  38545. * @param object the object to get the class name from
  38546. * @param isType defines if the object is actually a type
  38547. * @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.
  38548. * @ignorenaming
  38549. */
  38550. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  38551. /**
  38552. * Returns a promise that resolves after the given amount of time.
  38553. * @param delay Number of milliseconds to delay
  38554. * @returns Promise that resolves after the given amount of time
  38555. */
  38556. static DelayAsync(delay: number): Promise<void>;
  38557. /**
  38558. * Utility function to detect if the current user agent is Safari
  38559. * @returns whether or not the current user agent is safari
  38560. */
  38561. static IsSafari(): boolean;
  38562. }
  38563. /**
  38564. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  38565. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  38566. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  38567. * @param name The name of the class, case should be preserved
  38568. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  38569. */
  38570. export function className(name: string, module?: string): (target: Object) => void;
  38571. /**
  38572. * An implementation of a loop for asynchronous functions.
  38573. */
  38574. export class AsyncLoop {
  38575. /**
  38576. * Defines the number of iterations for the loop
  38577. */
  38578. iterations: number;
  38579. /**
  38580. * Defines the current index of the loop.
  38581. */
  38582. index: number;
  38583. private _done;
  38584. private _fn;
  38585. private _successCallback;
  38586. /**
  38587. * Constructor.
  38588. * @param iterations the number of iterations.
  38589. * @param func the function to run each iteration
  38590. * @param successCallback the callback that will be called upon succesful execution
  38591. * @param offset starting offset.
  38592. */
  38593. constructor(
  38594. /**
  38595. * Defines the number of iterations for the loop
  38596. */
  38597. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  38598. /**
  38599. * Execute the next iteration. Must be called after the last iteration was finished.
  38600. */
  38601. executeNext(): void;
  38602. /**
  38603. * Break the loop and run the success callback.
  38604. */
  38605. breakLoop(): void;
  38606. /**
  38607. * Create and run an async loop.
  38608. * @param iterations the number of iterations.
  38609. * @param fn the function to run each iteration
  38610. * @param successCallback the callback that will be called upon succesful execution
  38611. * @param offset starting offset.
  38612. * @returns the created async loop object
  38613. */
  38614. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  38615. /**
  38616. * A for-loop that will run a given number of iterations synchronous and the rest async.
  38617. * @param iterations total number of iterations
  38618. * @param syncedIterations number of synchronous iterations in each async iteration.
  38619. * @param fn the function to call each iteration.
  38620. * @param callback a success call back that will be called when iterating stops.
  38621. * @param breakFunction a break condition (optional)
  38622. * @param timeout timeout settings for the setTimeout function. default - 0.
  38623. * @returns the created async loop object
  38624. */
  38625. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  38626. }
  38627. }
  38628. declare module BABYLON {
  38629. /**
  38630. * This class implement a typical dictionary using a string as key and the generic type T as value.
  38631. * The underlying implementation relies on an associative array to ensure the best performances.
  38632. * The value can be anything including 'null' but except 'undefined'
  38633. */
  38634. export class StringDictionary<T> {
  38635. /**
  38636. * This will clear this dictionary and copy the content from the 'source' one.
  38637. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  38638. * @param source the dictionary to take the content from and copy to this dictionary
  38639. */
  38640. copyFrom(source: StringDictionary<T>): void;
  38641. /**
  38642. * Get a value based from its key
  38643. * @param key the given key to get the matching value from
  38644. * @return the value if found, otherwise undefined is returned
  38645. */
  38646. get(key: string): T | undefined;
  38647. /**
  38648. * Get a value from its key or add it if it doesn't exist.
  38649. * This method will ensure you that a given key/data will be present in the dictionary.
  38650. * @param key the given key to get the matching value from
  38651. * @param factory the factory that will create the value if the key is not present in the dictionary.
  38652. * The factory will only be invoked if there's no data for the given key.
  38653. * @return the value corresponding to the key.
  38654. */
  38655. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  38656. /**
  38657. * Get a value from its key if present in the dictionary otherwise add it
  38658. * @param key the key to get the value from
  38659. * @param val if there's no such key/value pair in the dictionary add it with this value
  38660. * @return the value corresponding to the key
  38661. */
  38662. getOrAdd(key: string, val: T): T;
  38663. /**
  38664. * Check if there's a given key in the dictionary
  38665. * @param key the key to check for
  38666. * @return true if the key is present, false otherwise
  38667. */
  38668. contains(key: string): boolean;
  38669. /**
  38670. * Add a new key and its corresponding value
  38671. * @param key the key to add
  38672. * @param value the value corresponding to the key
  38673. * @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
  38674. */
  38675. add(key: string, value: T): boolean;
  38676. /**
  38677. * Update a specific value associated to a key
  38678. * @param key defines the key to use
  38679. * @param value defines the value to store
  38680. * @returns true if the value was updated (or false if the key was not found)
  38681. */
  38682. set(key: string, value: T): boolean;
  38683. /**
  38684. * Get the element of the given key and remove it from the dictionary
  38685. * @param key defines the key to search
  38686. * @returns the value associated with the key or null if not found
  38687. */
  38688. getAndRemove(key: string): Nullable<T>;
  38689. /**
  38690. * Remove a key/value from the dictionary.
  38691. * @param key the key to remove
  38692. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  38693. */
  38694. remove(key: string): boolean;
  38695. /**
  38696. * Clear the whole content of the dictionary
  38697. */
  38698. clear(): void;
  38699. /**
  38700. * Gets the current count
  38701. */
  38702. get count(): number;
  38703. /**
  38704. * Execute a callback on each key/val of the dictionary.
  38705. * Note that you can remove any element in this dictionary in the callback implementation
  38706. * @param callback the callback to execute on a given key/value pair
  38707. */
  38708. forEach(callback: (key: string, val: T) => void): void;
  38709. /**
  38710. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  38711. * If the callback returns null or undefined the method will iterate to the next key/value pair
  38712. * Note that you can remove any element in this dictionary in the callback implementation
  38713. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  38714. * @returns the first item
  38715. */
  38716. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  38717. private _count;
  38718. private _data;
  38719. }
  38720. }
  38721. declare module BABYLON {
  38722. /** @hidden */
  38723. export interface ICollisionCoordinator {
  38724. createCollider(): Collider;
  38725. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  38726. init(scene: Scene): void;
  38727. }
  38728. /** @hidden */
  38729. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  38730. private _scene;
  38731. private _scaledPosition;
  38732. private _scaledVelocity;
  38733. private _finalPosition;
  38734. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  38735. createCollider(): Collider;
  38736. init(scene: Scene): void;
  38737. private _collideWithWorld;
  38738. }
  38739. }
  38740. declare module BABYLON {
  38741. /**
  38742. * Class used to manage all inputs for the scene.
  38743. */
  38744. export class InputManager {
  38745. /** The distance in pixel that you have to move to prevent some events */
  38746. static DragMovementThreshold: number;
  38747. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  38748. static LongPressDelay: number;
  38749. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  38750. static DoubleClickDelay: number;
  38751. /** If you need to check double click without raising a single click at first click, enable this flag */
  38752. static ExclusiveDoubleClickMode: boolean;
  38753. /** 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. */
  38754. private _alreadyAttached;
  38755. private _wheelEventName;
  38756. private _onPointerMove;
  38757. private _onPointerDown;
  38758. private _onPointerUp;
  38759. private _initClickEvent;
  38760. private _initActionManager;
  38761. private _delayedSimpleClick;
  38762. private _delayedSimpleClickTimeout;
  38763. private _previousDelayedSimpleClickTimeout;
  38764. private _meshPickProceed;
  38765. private _previousButtonPressed;
  38766. private _currentPickResult;
  38767. private _previousPickResult;
  38768. private _totalPointersPressed;
  38769. private _doubleClickOccured;
  38770. private _pointerOverMesh;
  38771. private _pickedDownMesh;
  38772. private _pickedUpMesh;
  38773. private _pointerX;
  38774. private _pointerY;
  38775. private _unTranslatedPointerX;
  38776. private _unTranslatedPointerY;
  38777. private _startingPointerPosition;
  38778. private _previousStartingPointerPosition;
  38779. private _startingPointerTime;
  38780. private _previousStartingPointerTime;
  38781. private _pointerCaptures;
  38782. private _onKeyDown;
  38783. private _onKeyUp;
  38784. private _onCanvasFocusObserver;
  38785. private _onCanvasBlurObserver;
  38786. private _scene;
  38787. /**
  38788. * Creates a new InputManager
  38789. * @param scene defines the hosting scene
  38790. */
  38791. constructor(scene: Scene);
  38792. /**
  38793. * Gets the mesh that is currently under the pointer
  38794. */
  38795. get meshUnderPointer(): Nullable<AbstractMesh>;
  38796. /**
  38797. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  38798. */
  38799. get unTranslatedPointer(): Vector2;
  38800. /**
  38801. * Gets or sets the current on-screen X position of the pointer
  38802. */
  38803. get pointerX(): number;
  38804. set pointerX(value: number);
  38805. /**
  38806. * Gets or sets the current on-screen Y position of the pointer
  38807. */
  38808. get pointerY(): number;
  38809. set pointerY(value: number);
  38810. private _updatePointerPosition;
  38811. private _processPointerMove;
  38812. private _setRayOnPointerInfo;
  38813. private _checkPrePointerObservable;
  38814. /**
  38815. * Use this method to simulate a pointer move on a mesh
  38816. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38817. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38818. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38819. */
  38820. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38821. /**
  38822. * Use this method to simulate a pointer down on a mesh
  38823. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38824. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38825. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38826. */
  38827. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  38828. private _processPointerDown;
  38829. /** @hidden */
  38830. _isPointerSwiping(): boolean;
  38831. /**
  38832. * Use this method to simulate a pointer up on a mesh
  38833. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  38834. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  38835. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  38836. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  38837. */
  38838. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  38839. private _processPointerUp;
  38840. /**
  38841. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  38842. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  38843. * @returns true if the pointer was captured
  38844. */
  38845. isPointerCaptured(pointerId?: number): boolean;
  38846. /**
  38847. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  38848. * @param attachUp defines if you want to attach events to pointerup
  38849. * @param attachDown defines if you want to attach events to pointerdown
  38850. * @param attachMove defines if you want to attach events to pointermove
  38851. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  38852. */
  38853. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  38854. /**
  38855. * Detaches all event handlers
  38856. */
  38857. detachControl(): void;
  38858. /**
  38859. * Force the value of meshUnderPointer
  38860. * @param mesh defines the mesh to use
  38861. */
  38862. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  38863. /**
  38864. * Gets the mesh under the pointer
  38865. * @returns a Mesh or null if no mesh is under the pointer
  38866. */
  38867. getPointerOverMesh(): Nullable<AbstractMesh>;
  38868. }
  38869. }
  38870. declare module BABYLON {
  38871. /**
  38872. * This class defines the direct association between an animation and a target
  38873. */
  38874. export class TargetedAnimation {
  38875. /**
  38876. * Animation to perform
  38877. */
  38878. animation: Animation;
  38879. /**
  38880. * Target to animate
  38881. */
  38882. target: any;
  38883. /**
  38884. * Returns the string "TargetedAnimation"
  38885. * @returns "TargetedAnimation"
  38886. */
  38887. getClassName(): string;
  38888. /**
  38889. * Serialize the object
  38890. * @returns the JSON object representing the current entity
  38891. */
  38892. serialize(): any;
  38893. }
  38894. /**
  38895. * Use this class to create coordinated animations on multiple targets
  38896. */
  38897. export class AnimationGroup implements IDisposable {
  38898. /** The name of the animation group */
  38899. name: string;
  38900. private _scene;
  38901. private _targetedAnimations;
  38902. private _animatables;
  38903. private _from;
  38904. private _to;
  38905. private _isStarted;
  38906. private _isPaused;
  38907. private _speedRatio;
  38908. private _loopAnimation;
  38909. private _isAdditive;
  38910. /**
  38911. * Gets or sets the unique id of the node
  38912. */
  38913. uniqueId: number;
  38914. /**
  38915. * This observable will notify when one animation have ended
  38916. */
  38917. onAnimationEndObservable: Observable<TargetedAnimation>;
  38918. /**
  38919. * Observer raised when one animation loops
  38920. */
  38921. onAnimationLoopObservable: Observable<TargetedAnimation>;
  38922. /**
  38923. * Observer raised when all animations have looped
  38924. */
  38925. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  38926. /**
  38927. * This observable will notify when all animations have ended.
  38928. */
  38929. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  38930. /**
  38931. * This observable will notify when all animations have paused.
  38932. */
  38933. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  38934. /**
  38935. * This observable will notify when all animations are playing.
  38936. */
  38937. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  38938. /**
  38939. * Gets the first frame
  38940. */
  38941. get from(): number;
  38942. /**
  38943. * Gets the last frame
  38944. */
  38945. get to(): number;
  38946. /**
  38947. * Define if the animations are started
  38948. */
  38949. get isStarted(): boolean;
  38950. /**
  38951. * Gets a value indicating that the current group is playing
  38952. */
  38953. get isPlaying(): boolean;
  38954. /**
  38955. * Gets or sets the speed ratio to use for all animations
  38956. */
  38957. get speedRatio(): number;
  38958. /**
  38959. * Gets or sets the speed ratio to use for all animations
  38960. */
  38961. set speedRatio(value: number);
  38962. /**
  38963. * Gets or sets if all animations should loop or not
  38964. */
  38965. get loopAnimation(): boolean;
  38966. set loopAnimation(value: boolean);
  38967. /**
  38968. * Gets or sets if all animations should be evaluated additively
  38969. */
  38970. get isAdditive(): boolean;
  38971. set isAdditive(value: boolean);
  38972. /**
  38973. * Gets the targeted animations for this animation group
  38974. */
  38975. get targetedAnimations(): Array<TargetedAnimation>;
  38976. /**
  38977. * returning the list of animatables controlled by this animation group.
  38978. */
  38979. get animatables(): Array<Animatable>;
  38980. /**
  38981. * Gets the list of target animations
  38982. */
  38983. get children(): TargetedAnimation[];
  38984. /**
  38985. * Instantiates a new Animation Group.
  38986. * This helps managing several animations at once.
  38987. * @see https://doc.babylonjs.com/how_to/group
  38988. * @param name Defines the name of the group
  38989. * @param scene Defines the scene the group belongs to
  38990. */
  38991. constructor(
  38992. /** The name of the animation group */
  38993. name: string, scene?: Nullable<Scene>);
  38994. /**
  38995. * Add an animation (with its target) in the group
  38996. * @param animation defines the animation we want to add
  38997. * @param target defines the target of the animation
  38998. * @returns the TargetedAnimation object
  38999. */
  39000. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  39001. /**
  39002. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  39003. * It can add constant keys at begin or end
  39004. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  39005. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  39006. * @returns the animation group
  39007. */
  39008. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  39009. private _animationLoopCount;
  39010. private _animationLoopFlags;
  39011. private _processLoop;
  39012. /**
  39013. * Start all animations on given targets
  39014. * @param loop defines if animations must loop
  39015. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  39016. * @param from defines the from key (optional)
  39017. * @param to defines the to key (optional)
  39018. * @param isAdditive defines the additive state for the resulting animatables (optional)
  39019. * @returns the current animation group
  39020. */
  39021. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  39022. /**
  39023. * Pause all animations
  39024. * @returns the animation group
  39025. */
  39026. pause(): AnimationGroup;
  39027. /**
  39028. * Play all animations to initial state
  39029. * This function will start() the animations if they were not started or will restart() them if they were paused
  39030. * @param loop defines if animations must loop
  39031. * @returns the animation group
  39032. */
  39033. play(loop?: boolean): AnimationGroup;
  39034. /**
  39035. * Reset all animations to initial state
  39036. * @returns the animation group
  39037. */
  39038. reset(): AnimationGroup;
  39039. /**
  39040. * Restart animations from key 0
  39041. * @returns the animation group
  39042. */
  39043. restart(): AnimationGroup;
  39044. /**
  39045. * Stop all animations
  39046. * @returns the animation group
  39047. */
  39048. stop(): AnimationGroup;
  39049. /**
  39050. * Set animation weight for all animatables
  39051. * @param weight defines the weight to use
  39052. * @return the animationGroup
  39053. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39054. */
  39055. setWeightForAllAnimatables(weight: number): AnimationGroup;
  39056. /**
  39057. * Synchronize and normalize all animatables with a source animatable
  39058. * @param root defines the root animatable to synchronize with
  39059. * @return the animationGroup
  39060. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39061. */
  39062. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  39063. /**
  39064. * Goes to a specific frame in this animation group
  39065. * @param frame the frame number to go to
  39066. * @return the animationGroup
  39067. */
  39068. goToFrame(frame: number): AnimationGroup;
  39069. /**
  39070. * Dispose all associated resources
  39071. */
  39072. dispose(): void;
  39073. private _checkAnimationGroupEnded;
  39074. /**
  39075. * Clone the current animation group and returns a copy
  39076. * @param newName defines the name of the new group
  39077. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  39078. * @returns the new aniamtion group
  39079. */
  39080. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  39081. /**
  39082. * Serializes the animationGroup to an object
  39083. * @returns Serialized object
  39084. */
  39085. serialize(): any;
  39086. /**
  39087. * Returns a new AnimationGroup object parsed from the source provided.
  39088. * @param parsedAnimationGroup defines the source
  39089. * @param scene defines the scene that will receive the animationGroup
  39090. * @returns a new AnimationGroup
  39091. */
  39092. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  39093. /**
  39094. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  39095. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  39096. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  39097. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  39098. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  39099. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  39100. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  39101. */
  39102. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  39103. /**
  39104. * Returns the string "AnimationGroup"
  39105. * @returns "AnimationGroup"
  39106. */
  39107. getClassName(): string;
  39108. /**
  39109. * Creates a detailled string about the object
  39110. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  39111. * @returns a string representing the object
  39112. */
  39113. toString(fullDetails?: boolean): string;
  39114. }
  39115. }
  39116. declare module BABYLON {
  39117. /**
  39118. * Define an interface for all classes that will hold resources
  39119. */
  39120. export interface IDisposable {
  39121. /**
  39122. * Releases all held resources
  39123. */
  39124. dispose(): void;
  39125. }
  39126. /** Interface defining initialization parameters for Scene class */
  39127. export interface SceneOptions {
  39128. /**
  39129. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  39130. * It will improve performance when the number of geometries becomes important.
  39131. */
  39132. useGeometryUniqueIdsMap?: boolean;
  39133. /**
  39134. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  39135. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39136. */
  39137. useMaterialMeshMap?: boolean;
  39138. /**
  39139. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  39140. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39141. */
  39142. useClonedMeshMap?: boolean;
  39143. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  39144. virtual?: boolean;
  39145. }
  39146. /**
  39147. * Represents a scene to be rendered by the engine.
  39148. * @see https://doc.babylonjs.com/features/scene
  39149. */
  39150. export class Scene extends AbstractScene implements IAnimatable {
  39151. /** The fog is deactivated */
  39152. static readonly FOGMODE_NONE: number;
  39153. /** The fog density is following an exponential function */
  39154. static readonly FOGMODE_EXP: number;
  39155. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  39156. static readonly FOGMODE_EXP2: number;
  39157. /** The fog density is following a linear function. */
  39158. static readonly FOGMODE_LINEAR: number;
  39159. /**
  39160. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  39161. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39162. */
  39163. static MinDeltaTime: number;
  39164. /**
  39165. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  39166. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39167. */
  39168. static MaxDeltaTime: number;
  39169. /**
  39170. * Factory used to create the default material.
  39171. * @param name The name of the material to create
  39172. * @param scene The scene to create the material for
  39173. * @returns The default material
  39174. */
  39175. static DefaultMaterialFactory(scene: Scene): Material;
  39176. /**
  39177. * Factory used to create the a collision coordinator.
  39178. * @returns The collision coordinator
  39179. */
  39180. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  39181. /** @hidden */
  39182. _inputManager: InputManager;
  39183. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  39184. cameraToUseForPointers: Nullable<Camera>;
  39185. /** @hidden */
  39186. readonly _isScene: boolean;
  39187. /** @hidden */
  39188. _blockEntityCollection: boolean;
  39189. /**
  39190. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  39191. */
  39192. autoClear: boolean;
  39193. /**
  39194. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  39195. */
  39196. autoClearDepthAndStencil: boolean;
  39197. /**
  39198. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  39199. */
  39200. clearColor: Color4;
  39201. /**
  39202. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  39203. */
  39204. ambientColor: Color3;
  39205. /**
  39206. * This is use to store the default BRDF lookup for PBR materials in your scene.
  39207. * It should only be one of the following (if not the default embedded one):
  39208. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  39209. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  39210. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  39211. * The material properties need to be setup according to the type of texture in use.
  39212. */
  39213. environmentBRDFTexture: BaseTexture;
  39214. /** @hidden */
  39215. protected _environmentTexture: Nullable<BaseTexture>;
  39216. /**
  39217. * Texture used in all pbr material as the reflection texture.
  39218. * As in the majority of the scene they are the same (exception for multi room and so on),
  39219. * this is easier to reference from here than from all the materials.
  39220. */
  39221. get environmentTexture(): Nullable<BaseTexture>;
  39222. /**
  39223. * Texture used in all pbr material as the reflection texture.
  39224. * As in the majority of the scene they are the same (exception for multi room and so on),
  39225. * this is easier to set here than in all the materials.
  39226. */
  39227. set environmentTexture(value: Nullable<BaseTexture>);
  39228. /** @hidden */
  39229. protected _environmentIntensity: number;
  39230. /**
  39231. * Intensity of the environment in all pbr material.
  39232. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39233. * As in the majority of the scene they are the same (exception for multi room and so on),
  39234. * this is easier to reference from here than from all the materials.
  39235. */
  39236. get environmentIntensity(): number;
  39237. /**
  39238. * Intensity of the environment in all pbr material.
  39239. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39240. * As in the majority of the scene they are the same (exception for multi room and so on),
  39241. * this is easier to set here than in all the materials.
  39242. */
  39243. set environmentIntensity(value: number);
  39244. /** @hidden */
  39245. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39246. /**
  39247. * Default image processing configuration used either in the rendering
  39248. * Forward main pass or through the imageProcessingPostProcess if present.
  39249. * As in the majority of the scene they are the same (exception for multi camera),
  39250. * this is easier to reference from here than from all the materials and post process.
  39251. *
  39252. * No setter as we it is a shared configuration, you can set the values instead.
  39253. */
  39254. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  39255. private _forceWireframe;
  39256. /**
  39257. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  39258. */
  39259. set forceWireframe(value: boolean);
  39260. get forceWireframe(): boolean;
  39261. private _skipFrustumClipping;
  39262. /**
  39263. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  39264. */
  39265. set skipFrustumClipping(value: boolean);
  39266. get skipFrustumClipping(): boolean;
  39267. private _forcePointsCloud;
  39268. /**
  39269. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  39270. */
  39271. set forcePointsCloud(value: boolean);
  39272. get forcePointsCloud(): boolean;
  39273. /**
  39274. * Gets or sets the active clipplane 1
  39275. */
  39276. clipPlane: Nullable<Plane>;
  39277. /**
  39278. * Gets or sets the active clipplane 2
  39279. */
  39280. clipPlane2: Nullable<Plane>;
  39281. /**
  39282. * Gets or sets the active clipplane 3
  39283. */
  39284. clipPlane3: Nullable<Plane>;
  39285. /**
  39286. * Gets or sets the active clipplane 4
  39287. */
  39288. clipPlane4: Nullable<Plane>;
  39289. /**
  39290. * Gets or sets the active clipplane 5
  39291. */
  39292. clipPlane5: Nullable<Plane>;
  39293. /**
  39294. * Gets or sets the active clipplane 6
  39295. */
  39296. clipPlane6: Nullable<Plane>;
  39297. /**
  39298. * Gets or sets a boolean indicating if animations are enabled
  39299. */
  39300. animationsEnabled: boolean;
  39301. private _animationPropertiesOverride;
  39302. /**
  39303. * Gets or sets the animation properties override
  39304. */
  39305. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  39306. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  39307. /**
  39308. * Gets or sets a boolean indicating if a constant deltatime has to be used
  39309. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  39310. */
  39311. useConstantAnimationDeltaTime: boolean;
  39312. /**
  39313. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  39314. * Please note that it requires to run a ray cast through the scene on every frame
  39315. */
  39316. constantlyUpdateMeshUnderPointer: boolean;
  39317. /**
  39318. * Defines the HTML cursor to use when hovering over interactive elements
  39319. */
  39320. hoverCursor: string;
  39321. /**
  39322. * Defines the HTML default cursor to use (empty by default)
  39323. */
  39324. defaultCursor: string;
  39325. /**
  39326. * Defines whether cursors are handled by the scene.
  39327. */
  39328. doNotHandleCursors: boolean;
  39329. /**
  39330. * This is used to call preventDefault() on pointer down
  39331. * in order to block unwanted artifacts like system double clicks
  39332. */
  39333. preventDefaultOnPointerDown: boolean;
  39334. /**
  39335. * This is used to call preventDefault() on pointer up
  39336. * in order to block unwanted artifacts like system double clicks
  39337. */
  39338. preventDefaultOnPointerUp: boolean;
  39339. /**
  39340. * Gets or sets user defined metadata
  39341. */
  39342. metadata: any;
  39343. /**
  39344. * For internal use only. Please do not use.
  39345. */
  39346. reservedDataStore: any;
  39347. /**
  39348. * Gets the name of the plugin used to load this scene (null by default)
  39349. */
  39350. loadingPluginName: string;
  39351. /**
  39352. * Use this array to add regular expressions used to disable offline support for specific urls
  39353. */
  39354. disableOfflineSupportExceptionRules: RegExp[];
  39355. /**
  39356. * An event triggered when the scene is disposed.
  39357. */
  39358. onDisposeObservable: Observable<Scene>;
  39359. private _onDisposeObserver;
  39360. /** Sets a function to be executed when this scene is disposed. */
  39361. set onDispose(callback: () => void);
  39362. /**
  39363. * An event triggered before rendering the scene (right after animations and physics)
  39364. */
  39365. onBeforeRenderObservable: Observable<Scene>;
  39366. private _onBeforeRenderObserver;
  39367. /** Sets a function to be executed before rendering this scene */
  39368. set beforeRender(callback: Nullable<() => void>);
  39369. /**
  39370. * An event triggered after rendering the scene
  39371. */
  39372. onAfterRenderObservable: Observable<Scene>;
  39373. /**
  39374. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  39375. */
  39376. onAfterRenderCameraObservable: Observable<Camera>;
  39377. private _onAfterRenderObserver;
  39378. /** Sets a function to be executed after rendering this scene */
  39379. set afterRender(callback: Nullable<() => void>);
  39380. /**
  39381. * An event triggered before animating the scene
  39382. */
  39383. onBeforeAnimationsObservable: Observable<Scene>;
  39384. /**
  39385. * An event triggered after animations processing
  39386. */
  39387. onAfterAnimationsObservable: Observable<Scene>;
  39388. /**
  39389. * An event triggered before draw calls are ready to be sent
  39390. */
  39391. onBeforeDrawPhaseObservable: Observable<Scene>;
  39392. /**
  39393. * An event triggered after draw calls have been sent
  39394. */
  39395. onAfterDrawPhaseObservable: Observable<Scene>;
  39396. /**
  39397. * An event triggered when the scene is ready
  39398. */
  39399. onReadyObservable: Observable<Scene>;
  39400. /**
  39401. * An event triggered before rendering a camera
  39402. */
  39403. onBeforeCameraRenderObservable: Observable<Camera>;
  39404. private _onBeforeCameraRenderObserver;
  39405. /** Sets a function to be executed before rendering a camera*/
  39406. set beforeCameraRender(callback: () => void);
  39407. /**
  39408. * An event triggered after rendering a camera
  39409. */
  39410. onAfterCameraRenderObservable: Observable<Camera>;
  39411. private _onAfterCameraRenderObserver;
  39412. /** Sets a function to be executed after rendering a camera*/
  39413. set afterCameraRender(callback: () => void);
  39414. /**
  39415. * An event triggered when active meshes evaluation is about to start
  39416. */
  39417. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  39418. /**
  39419. * An event triggered when active meshes evaluation is done
  39420. */
  39421. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  39422. /**
  39423. * An event triggered when particles rendering is about to start
  39424. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39425. */
  39426. onBeforeParticlesRenderingObservable: Observable<Scene>;
  39427. /**
  39428. * An event triggered when particles rendering is done
  39429. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39430. */
  39431. onAfterParticlesRenderingObservable: Observable<Scene>;
  39432. /**
  39433. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  39434. */
  39435. onDataLoadedObservable: Observable<Scene>;
  39436. /**
  39437. * An event triggered when a camera is created
  39438. */
  39439. onNewCameraAddedObservable: Observable<Camera>;
  39440. /**
  39441. * An event triggered when a camera is removed
  39442. */
  39443. onCameraRemovedObservable: Observable<Camera>;
  39444. /**
  39445. * An event triggered when a light is created
  39446. */
  39447. onNewLightAddedObservable: Observable<Light>;
  39448. /**
  39449. * An event triggered when a light is removed
  39450. */
  39451. onLightRemovedObservable: Observable<Light>;
  39452. /**
  39453. * An event triggered when a geometry is created
  39454. */
  39455. onNewGeometryAddedObservable: Observable<Geometry>;
  39456. /**
  39457. * An event triggered when a geometry is removed
  39458. */
  39459. onGeometryRemovedObservable: Observable<Geometry>;
  39460. /**
  39461. * An event triggered when a transform node is created
  39462. */
  39463. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  39464. /**
  39465. * An event triggered when a transform node is removed
  39466. */
  39467. onTransformNodeRemovedObservable: Observable<TransformNode>;
  39468. /**
  39469. * An event triggered when a mesh is created
  39470. */
  39471. onNewMeshAddedObservable: Observable<AbstractMesh>;
  39472. /**
  39473. * An event triggered when a mesh is removed
  39474. */
  39475. onMeshRemovedObservable: Observable<AbstractMesh>;
  39476. /**
  39477. * An event triggered when a skeleton is created
  39478. */
  39479. onNewSkeletonAddedObservable: Observable<Skeleton>;
  39480. /**
  39481. * An event triggered when a skeleton is removed
  39482. */
  39483. onSkeletonRemovedObservable: Observable<Skeleton>;
  39484. /**
  39485. * An event triggered when a material is created
  39486. */
  39487. onNewMaterialAddedObservable: Observable<Material>;
  39488. /**
  39489. * An event triggered when a material is removed
  39490. */
  39491. onMaterialRemovedObservable: Observable<Material>;
  39492. /**
  39493. * An event triggered when a texture is created
  39494. */
  39495. onNewTextureAddedObservable: Observable<BaseTexture>;
  39496. /**
  39497. * An event triggered when a texture is removed
  39498. */
  39499. onTextureRemovedObservable: Observable<BaseTexture>;
  39500. /**
  39501. * An event triggered when render targets are about to be rendered
  39502. * Can happen multiple times per frame.
  39503. */
  39504. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  39505. /**
  39506. * An event triggered when render targets were rendered.
  39507. * Can happen multiple times per frame.
  39508. */
  39509. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  39510. /**
  39511. * An event triggered before calculating deterministic simulation step
  39512. */
  39513. onBeforeStepObservable: Observable<Scene>;
  39514. /**
  39515. * An event triggered after calculating deterministic simulation step
  39516. */
  39517. onAfterStepObservable: Observable<Scene>;
  39518. /**
  39519. * An event triggered when the activeCamera property is updated
  39520. */
  39521. onActiveCameraChanged: Observable<Scene>;
  39522. /**
  39523. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  39524. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39525. * 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)
  39526. */
  39527. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39528. /**
  39529. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  39530. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39531. * 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)
  39532. */
  39533. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39534. /**
  39535. * This Observable will when a mesh has been imported into the scene.
  39536. */
  39537. onMeshImportedObservable: Observable<AbstractMesh>;
  39538. /**
  39539. * This Observable will when an animation file has been imported into the scene.
  39540. */
  39541. onAnimationFileImportedObservable: Observable<Scene>;
  39542. /**
  39543. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  39544. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  39545. */
  39546. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  39547. /** @hidden */
  39548. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  39549. /**
  39550. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  39551. */
  39552. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  39553. /**
  39554. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  39555. */
  39556. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  39557. /**
  39558. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  39559. */
  39560. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  39561. /** Callback called when a pointer move is detected */
  39562. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39563. /** Callback called when a pointer down is detected */
  39564. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39565. /** Callback called when a pointer up is detected */
  39566. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  39567. /** Callback called when a pointer pick is detected */
  39568. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  39569. /**
  39570. * 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).
  39571. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  39572. */
  39573. onPrePointerObservable: Observable<PointerInfoPre>;
  39574. /**
  39575. * Observable event triggered each time an input event is received from the rendering canvas
  39576. */
  39577. onPointerObservable: Observable<PointerInfo>;
  39578. /**
  39579. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  39580. */
  39581. get unTranslatedPointer(): Vector2;
  39582. /**
  39583. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  39584. */
  39585. static get DragMovementThreshold(): number;
  39586. static set DragMovementThreshold(value: number);
  39587. /**
  39588. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  39589. */
  39590. static get LongPressDelay(): number;
  39591. static set LongPressDelay(value: number);
  39592. /**
  39593. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  39594. */
  39595. static get DoubleClickDelay(): number;
  39596. static set DoubleClickDelay(value: number);
  39597. /** If you need to check double click without raising a single click at first click, enable this flag */
  39598. static get ExclusiveDoubleClickMode(): boolean;
  39599. static set ExclusiveDoubleClickMode(value: boolean);
  39600. /** @hidden */
  39601. _mirroredCameraPosition: Nullable<Vector3>;
  39602. /**
  39603. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  39604. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  39605. */
  39606. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  39607. /**
  39608. * Observable event triggered each time an keyboard event is received from the hosting window
  39609. */
  39610. onKeyboardObservable: Observable<KeyboardInfo>;
  39611. private _useRightHandedSystem;
  39612. /**
  39613. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  39614. */
  39615. set useRightHandedSystem(value: boolean);
  39616. get useRightHandedSystem(): boolean;
  39617. private _timeAccumulator;
  39618. private _currentStepId;
  39619. private _currentInternalStep;
  39620. /**
  39621. * Sets the step Id used by deterministic lock step
  39622. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39623. * @param newStepId defines the step Id
  39624. */
  39625. setStepId(newStepId: number): void;
  39626. /**
  39627. * Gets the step Id used by deterministic lock step
  39628. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39629. * @returns the step Id
  39630. */
  39631. getStepId(): number;
  39632. /**
  39633. * Gets the internal step used by deterministic lock step
  39634. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39635. * @returns the internal step
  39636. */
  39637. getInternalStep(): number;
  39638. private _fogEnabled;
  39639. /**
  39640. * Gets or sets a boolean indicating if fog is enabled on this scene
  39641. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39642. * (Default is true)
  39643. */
  39644. set fogEnabled(value: boolean);
  39645. get fogEnabled(): boolean;
  39646. private _fogMode;
  39647. /**
  39648. * Gets or sets the fog mode to use
  39649. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39650. * | mode | value |
  39651. * | --- | --- |
  39652. * | FOGMODE_NONE | 0 |
  39653. * | FOGMODE_EXP | 1 |
  39654. * | FOGMODE_EXP2 | 2 |
  39655. * | FOGMODE_LINEAR | 3 |
  39656. */
  39657. set fogMode(value: number);
  39658. get fogMode(): number;
  39659. /**
  39660. * Gets or sets the fog color to use
  39661. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39662. * (Default is Color3(0.2, 0.2, 0.3))
  39663. */
  39664. fogColor: Color3;
  39665. /**
  39666. * Gets or sets the fog density to use
  39667. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39668. * (Default is 0.1)
  39669. */
  39670. fogDensity: number;
  39671. /**
  39672. * Gets or sets the fog start distance to use
  39673. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39674. * (Default is 0)
  39675. */
  39676. fogStart: number;
  39677. /**
  39678. * Gets or sets the fog end distance to use
  39679. * @see https://doc.babylonjs.com/babylon101/environment#fog
  39680. * (Default is 1000)
  39681. */
  39682. fogEnd: number;
  39683. /**
  39684. * Flag indicating that the frame buffer binding is handled by another component
  39685. */
  39686. prePass: boolean;
  39687. private _shadowsEnabled;
  39688. /**
  39689. * Gets or sets a boolean indicating if shadows are enabled on this scene
  39690. */
  39691. set shadowsEnabled(value: boolean);
  39692. get shadowsEnabled(): boolean;
  39693. private _lightsEnabled;
  39694. /**
  39695. * Gets or sets a boolean indicating if lights are enabled on this scene
  39696. */
  39697. set lightsEnabled(value: boolean);
  39698. get lightsEnabled(): boolean;
  39699. /** All of the active cameras added to this scene. */
  39700. activeCameras: Camera[];
  39701. /** @hidden */
  39702. _activeCamera: Nullable<Camera>;
  39703. /** Gets or sets the current active camera */
  39704. get activeCamera(): Nullable<Camera>;
  39705. set activeCamera(value: Nullable<Camera>);
  39706. private _defaultMaterial;
  39707. /** The default material used on meshes when no material is affected */
  39708. get defaultMaterial(): Material;
  39709. /** The default material used on meshes when no material is affected */
  39710. set defaultMaterial(value: Material);
  39711. private _texturesEnabled;
  39712. /**
  39713. * Gets or sets a boolean indicating if textures are enabled on this scene
  39714. */
  39715. set texturesEnabled(value: boolean);
  39716. get texturesEnabled(): boolean;
  39717. /**
  39718. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  39719. */
  39720. physicsEnabled: boolean;
  39721. /**
  39722. * Gets or sets a boolean indicating if particles are enabled on this scene
  39723. */
  39724. particlesEnabled: boolean;
  39725. /**
  39726. * Gets or sets a boolean indicating if sprites are enabled on this scene
  39727. */
  39728. spritesEnabled: boolean;
  39729. private _skeletonsEnabled;
  39730. /**
  39731. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  39732. */
  39733. set skeletonsEnabled(value: boolean);
  39734. get skeletonsEnabled(): boolean;
  39735. /**
  39736. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  39737. */
  39738. lensFlaresEnabled: boolean;
  39739. /**
  39740. * Gets or sets a boolean indicating if collisions are enabled on this scene
  39741. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  39742. */
  39743. collisionsEnabled: boolean;
  39744. private _collisionCoordinator;
  39745. /** @hidden */
  39746. get collisionCoordinator(): ICollisionCoordinator;
  39747. /**
  39748. * Defines the gravity applied to this scene (used only for collisions)
  39749. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  39750. */
  39751. gravity: Vector3;
  39752. /**
  39753. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  39754. */
  39755. postProcessesEnabled: boolean;
  39756. /**
  39757. * The list of postprocesses added to the scene
  39758. */
  39759. postProcesses: PostProcess[];
  39760. /**
  39761. * Gets the current postprocess manager
  39762. */
  39763. postProcessManager: PostProcessManager;
  39764. /**
  39765. * Gets or sets a boolean indicating if render targets are enabled on this scene
  39766. */
  39767. renderTargetsEnabled: boolean;
  39768. /**
  39769. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  39770. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  39771. */
  39772. dumpNextRenderTargets: boolean;
  39773. /**
  39774. * The list of user defined render targets added to the scene
  39775. */
  39776. customRenderTargets: RenderTargetTexture[];
  39777. /**
  39778. * Defines if texture loading must be delayed
  39779. * If true, textures will only be loaded when they need to be rendered
  39780. */
  39781. useDelayedTextureLoading: boolean;
  39782. /**
  39783. * Gets the list of meshes imported to the scene through SceneLoader
  39784. */
  39785. importedMeshesFiles: String[];
  39786. /**
  39787. * Gets or sets a boolean indicating if probes are enabled on this scene
  39788. */
  39789. probesEnabled: boolean;
  39790. /**
  39791. * Gets or sets the current offline provider to use to store scene data
  39792. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  39793. */
  39794. offlineProvider: IOfflineProvider;
  39795. /**
  39796. * Gets or sets the action manager associated with the scene
  39797. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  39798. */
  39799. actionManager: AbstractActionManager;
  39800. private _meshesForIntersections;
  39801. /**
  39802. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  39803. */
  39804. proceduralTexturesEnabled: boolean;
  39805. private _engine;
  39806. private _totalVertices;
  39807. /** @hidden */
  39808. _activeIndices: PerfCounter;
  39809. /** @hidden */
  39810. _activeParticles: PerfCounter;
  39811. /** @hidden */
  39812. _activeBones: PerfCounter;
  39813. private _animationRatio;
  39814. /** @hidden */
  39815. _animationTimeLast: number;
  39816. /** @hidden */
  39817. _animationTime: number;
  39818. /**
  39819. * Gets or sets a general scale for animation speed
  39820. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  39821. */
  39822. animationTimeScale: number;
  39823. /** @hidden */
  39824. _cachedMaterial: Nullable<Material>;
  39825. /** @hidden */
  39826. _cachedEffect: Nullable<Effect>;
  39827. /** @hidden */
  39828. _cachedVisibility: Nullable<number>;
  39829. private _renderId;
  39830. private _frameId;
  39831. private _executeWhenReadyTimeoutId;
  39832. private _intermediateRendering;
  39833. private _viewUpdateFlag;
  39834. private _projectionUpdateFlag;
  39835. /** @hidden */
  39836. _toBeDisposed: Nullable<IDisposable>[];
  39837. private _activeRequests;
  39838. /** @hidden */
  39839. _pendingData: any[];
  39840. private _isDisposed;
  39841. /**
  39842. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  39843. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  39844. */
  39845. dispatchAllSubMeshesOfActiveMeshes: boolean;
  39846. private _activeMeshes;
  39847. private _processedMaterials;
  39848. private _renderTargets;
  39849. /** @hidden */
  39850. _activeParticleSystems: SmartArray<IParticleSystem>;
  39851. private _activeSkeletons;
  39852. private _softwareSkinnedMeshes;
  39853. private _renderingManager;
  39854. /** @hidden */
  39855. _activeAnimatables: Animatable[];
  39856. private _transformMatrix;
  39857. private _sceneUbo;
  39858. /** @hidden */
  39859. _viewMatrix: Matrix;
  39860. private _projectionMatrix;
  39861. /** @hidden */
  39862. _forcedViewPosition: Nullable<Vector3>;
  39863. /** @hidden */
  39864. _frustumPlanes: Plane[];
  39865. /**
  39866. * Gets the list of frustum planes (built from the active camera)
  39867. */
  39868. get frustumPlanes(): Plane[];
  39869. /**
  39870. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  39871. * This is useful if there are more lights that the maximum simulteanous authorized
  39872. */
  39873. requireLightSorting: boolean;
  39874. /** @hidden */
  39875. readonly useMaterialMeshMap: boolean;
  39876. /** @hidden */
  39877. readonly useClonedMeshMap: boolean;
  39878. private _externalData;
  39879. private _uid;
  39880. /**
  39881. * @hidden
  39882. * Backing store of defined scene components.
  39883. */
  39884. _components: ISceneComponent[];
  39885. /**
  39886. * @hidden
  39887. * Backing store of defined scene components.
  39888. */
  39889. _serializableComponents: ISceneSerializableComponent[];
  39890. /**
  39891. * List of components to register on the next registration step.
  39892. */
  39893. private _transientComponents;
  39894. /**
  39895. * Registers the transient components if needed.
  39896. */
  39897. private _registerTransientComponents;
  39898. /**
  39899. * @hidden
  39900. * Add a component to the scene.
  39901. * Note that the ccomponent could be registered on th next frame if this is called after
  39902. * the register component stage.
  39903. * @param component Defines the component to add to the scene
  39904. */
  39905. _addComponent(component: ISceneComponent): void;
  39906. /**
  39907. * @hidden
  39908. * Gets a component from the scene.
  39909. * @param name defines the name of the component to retrieve
  39910. * @returns the component or null if not present
  39911. */
  39912. _getComponent(name: string): Nullable<ISceneComponent>;
  39913. /**
  39914. * @hidden
  39915. * Defines the actions happening before camera updates.
  39916. */
  39917. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  39918. /**
  39919. * @hidden
  39920. * Defines the actions happening before clear the canvas.
  39921. */
  39922. _beforeClearStage: Stage<SimpleStageAction>;
  39923. /**
  39924. * @hidden
  39925. * Defines the actions when collecting render targets for the frame.
  39926. */
  39927. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  39928. /**
  39929. * @hidden
  39930. * Defines the actions happening for one camera in the frame.
  39931. */
  39932. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  39933. /**
  39934. * @hidden
  39935. * Defines the actions happening during the per mesh ready checks.
  39936. */
  39937. _isReadyForMeshStage: Stage<MeshStageAction>;
  39938. /**
  39939. * @hidden
  39940. * Defines the actions happening before evaluate active mesh checks.
  39941. */
  39942. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  39943. /**
  39944. * @hidden
  39945. * Defines the actions happening during the evaluate sub mesh checks.
  39946. */
  39947. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  39948. /**
  39949. * @hidden
  39950. * Defines the actions happening during the active mesh stage.
  39951. */
  39952. _activeMeshStage: Stage<ActiveMeshStageAction>;
  39953. /**
  39954. * @hidden
  39955. * Defines the actions happening during the per camera render target step.
  39956. */
  39957. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  39958. /**
  39959. * @hidden
  39960. * Defines the actions happening just before the active camera is drawing.
  39961. */
  39962. _beforeCameraDrawStage: Stage<CameraStageAction>;
  39963. /**
  39964. * @hidden
  39965. * Defines the actions happening just before a render target is drawing.
  39966. */
  39967. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  39968. /**
  39969. * @hidden
  39970. * Defines the actions happening just before a rendering group is drawing.
  39971. */
  39972. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  39973. /**
  39974. * @hidden
  39975. * Defines the actions happening just before a mesh is drawing.
  39976. */
  39977. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  39978. /**
  39979. * @hidden
  39980. * Defines the actions happening just after a mesh has been drawn.
  39981. */
  39982. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  39983. /**
  39984. * @hidden
  39985. * Defines the actions happening just after a rendering group has been drawn.
  39986. */
  39987. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  39988. /**
  39989. * @hidden
  39990. * Defines the actions happening just after the active camera has been drawn.
  39991. */
  39992. _afterCameraDrawStage: Stage<CameraStageAction>;
  39993. /**
  39994. * @hidden
  39995. * Defines the actions happening just after a render target has been drawn.
  39996. */
  39997. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  39998. /**
  39999. * @hidden
  40000. * Defines the actions happening just after rendering all cameras and computing intersections.
  40001. */
  40002. _afterRenderStage: Stage<SimpleStageAction>;
  40003. /**
  40004. * @hidden
  40005. * Defines the actions happening when a pointer move event happens.
  40006. */
  40007. _pointerMoveStage: Stage<PointerMoveStageAction>;
  40008. /**
  40009. * @hidden
  40010. * Defines the actions happening when a pointer down event happens.
  40011. */
  40012. _pointerDownStage: Stage<PointerUpDownStageAction>;
  40013. /**
  40014. * @hidden
  40015. * Defines the actions happening when a pointer up event happens.
  40016. */
  40017. _pointerUpStage: Stage<PointerUpDownStageAction>;
  40018. /**
  40019. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  40020. */
  40021. private geometriesByUniqueId;
  40022. /**
  40023. * Creates a new Scene
  40024. * @param engine defines the engine to use to render this scene
  40025. * @param options defines the scene options
  40026. */
  40027. constructor(engine: Engine, options?: SceneOptions);
  40028. /**
  40029. * Gets a string idenfifying the name of the class
  40030. * @returns "Scene" string
  40031. */
  40032. getClassName(): string;
  40033. private _defaultMeshCandidates;
  40034. /**
  40035. * @hidden
  40036. */
  40037. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40038. private _defaultSubMeshCandidates;
  40039. /**
  40040. * @hidden
  40041. */
  40042. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40043. /**
  40044. * Sets the default candidate providers for the scene.
  40045. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  40046. * and getCollidingSubMeshCandidates to their default function
  40047. */
  40048. setDefaultCandidateProviders(): void;
  40049. /**
  40050. * Gets the mesh that is currently under the pointer
  40051. */
  40052. get meshUnderPointer(): Nullable<AbstractMesh>;
  40053. /**
  40054. * Gets or sets the current on-screen X position of the pointer
  40055. */
  40056. get pointerX(): number;
  40057. set pointerX(value: number);
  40058. /**
  40059. * Gets or sets the current on-screen Y position of the pointer
  40060. */
  40061. get pointerY(): number;
  40062. set pointerY(value: number);
  40063. /**
  40064. * Gets the cached material (ie. the latest rendered one)
  40065. * @returns the cached material
  40066. */
  40067. getCachedMaterial(): Nullable<Material>;
  40068. /**
  40069. * Gets the cached effect (ie. the latest rendered one)
  40070. * @returns the cached effect
  40071. */
  40072. getCachedEffect(): Nullable<Effect>;
  40073. /**
  40074. * Gets the cached visibility state (ie. the latest rendered one)
  40075. * @returns the cached visibility state
  40076. */
  40077. getCachedVisibility(): Nullable<number>;
  40078. /**
  40079. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  40080. * @param material defines the current material
  40081. * @param effect defines the current effect
  40082. * @param visibility defines the current visibility state
  40083. * @returns true if one parameter is not cached
  40084. */
  40085. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  40086. /**
  40087. * Gets the engine associated with the scene
  40088. * @returns an Engine
  40089. */
  40090. getEngine(): Engine;
  40091. /**
  40092. * Gets the total number of vertices rendered per frame
  40093. * @returns the total number of vertices rendered per frame
  40094. */
  40095. getTotalVertices(): number;
  40096. /**
  40097. * Gets the performance counter for total vertices
  40098. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40099. */
  40100. get totalVerticesPerfCounter(): PerfCounter;
  40101. /**
  40102. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  40103. * @returns the total number of active indices rendered per frame
  40104. */
  40105. getActiveIndices(): number;
  40106. /**
  40107. * Gets the performance counter for active indices
  40108. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40109. */
  40110. get totalActiveIndicesPerfCounter(): PerfCounter;
  40111. /**
  40112. * Gets the total number of active particles rendered per frame
  40113. * @returns the total number of active particles rendered per frame
  40114. */
  40115. getActiveParticles(): number;
  40116. /**
  40117. * Gets the performance counter for active particles
  40118. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40119. */
  40120. get activeParticlesPerfCounter(): PerfCounter;
  40121. /**
  40122. * Gets the total number of active bones rendered per frame
  40123. * @returns the total number of active bones rendered per frame
  40124. */
  40125. getActiveBones(): number;
  40126. /**
  40127. * Gets the performance counter for active bones
  40128. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40129. */
  40130. get activeBonesPerfCounter(): PerfCounter;
  40131. /**
  40132. * Gets the array of active meshes
  40133. * @returns an array of AbstractMesh
  40134. */
  40135. getActiveMeshes(): SmartArray<AbstractMesh>;
  40136. /**
  40137. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  40138. * @returns a number
  40139. */
  40140. getAnimationRatio(): number;
  40141. /**
  40142. * Gets an unique Id for the current render phase
  40143. * @returns a number
  40144. */
  40145. getRenderId(): number;
  40146. /**
  40147. * Gets an unique Id for the current frame
  40148. * @returns a number
  40149. */
  40150. getFrameId(): number;
  40151. /** Call this function if you want to manually increment the render Id*/
  40152. incrementRenderId(): void;
  40153. private _createUbo;
  40154. /**
  40155. * Use this method to simulate a pointer move on a mesh
  40156. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40157. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40158. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40159. * @returns the current scene
  40160. */
  40161. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40162. /**
  40163. * Use this method to simulate a pointer down on a mesh
  40164. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40165. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40166. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40167. * @returns the current scene
  40168. */
  40169. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40170. /**
  40171. * Use this method to simulate a pointer up on a mesh
  40172. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40173. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40174. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40175. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40176. * @returns the current scene
  40177. */
  40178. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  40179. /**
  40180. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40181. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40182. * @returns true if the pointer was captured
  40183. */
  40184. isPointerCaptured(pointerId?: number): boolean;
  40185. /**
  40186. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40187. * @param attachUp defines if you want to attach events to pointerup
  40188. * @param attachDown defines if you want to attach events to pointerdown
  40189. * @param attachMove defines if you want to attach events to pointermove
  40190. */
  40191. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  40192. /** Detaches all event handlers*/
  40193. detachControl(): void;
  40194. /**
  40195. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  40196. * Delay loaded resources are not taking in account
  40197. * @return true if all required resources are ready
  40198. */
  40199. isReady(): boolean;
  40200. /** Resets all cached information relative to material (including effect and visibility) */
  40201. resetCachedMaterial(): void;
  40202. /**
  40203. * Registers a function to be called before every frame render
  40204. * @param func defines the function to register
  40205. */
  40206. registerBeforeRender(func: () => void): void;
  40207. /**
  40208. * Unregisters a function called before every frame render
  40209. * @param func defines the function to unregister
  40210. */
  40211. unregisterBeforeRender(func: () => void): void;
  40212. /**
  40213. * Registers a function to be called after every frame render
  40214. * @param func defines the function to register
  40215. */
  40216. registerAfterRender(func: () => void): void;
  40217. /**
  40218. * Unregisters a function called after every frame render
  40219. * @param func defines the function to unregister
  40220. */
  40221. unregisterAfterRender(func: () => void): void;
  40222. private _executeOnceBeforeRender;
  40223. /**
  40224. * The provided function will run before render once and will be disposed afterwards.
  40225. * A timeout delay can be provided so that the function will be executed in N ms.
  40226. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  40227. * @param func The function to be executed.
  40228. * @param timeout optional delay in ms
  40229. */
  40230. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  40231. /** @hidden */
  40232. _addPendingData(data: any): void;
  40233. /** @hidden */
  40234. _removePendingData(data: any): void;
  40235. /**
  40236. * Returns the number of items waiting to be loaded
  40237. * @returns the number of items waiting to be loaded
  40238. */
  40239. getWaitingItemsCount(): number;
  40240. /**
  40241. * Returns a boolean indicating if the scene is still loading data
  40242. */
  40243. get isLoading(): boolean;
  40244. /**
  40245. * Registers a function to be executed when the scene is ready
  40246. * @param {Function} func - the function to be executed
  40247. */
  40248. executeWhenReady(func: () => void): void;
  40249. /**
  40250. * Returns a promise that resolves when the scene is ready
  40251. * @returns A promise that resolves when the scene is ready
  40252. */
  40253. whenReadyAsync(): Promise<void>;
  40254. /** @hidden */
  40255. _checkIsReady(): void;
  40256. /**
  40257. * Gets all animatable attached to the scene
  40258. */
  40259. get animatables(): Animatable[];
  40260. /**
  40261. * Resets the last animation time frame.
  40262. * Useful to override when animations start running when loading a scene for the first time.
  40263. */
  40264. resetLastAnimationTimeFrame(): void;
  40265. /**
  40266. * Gets the current view matrix
  40267. * @returns a Matrix
  40268. */
  40269. getViewMatrix(): Matrix;
  40270. /**
  40271. * Gets the current projection matrix
  40272. * @returns a Matrix
  40273. */
  40274. getProjectionMatrix(): Matrix;
  40275. /**
  40276. * Gets the current transform matrix
  40277. * @returns a Matrix made of View * Projection
  40278. */
  40279. getTransformMatrix(): Matrix;
  40280. /**
  40281. * Sets the current transform matrix
  40282. * @param viewL defines the View matrix to use
  40283. * @param projectionL defines the Projection matrix to use
  40284. * @param viewR defines the right View matrix to use (if provided)
  40285. * @param projectionR defines the right Projection matrix to use (if provided)
  40286. */
  40287. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  40288. /**
  40289. * Gets the uniform buffer used to store scene data
  40290. * @returns a UniformBuffer
  40291. */
  40292. getSceneUniformBuffer(): UniformBuffer;
  40293. /**
  40294. * Gets an unique (relatively to the current scene) Id
  40295. * @returns an unique number for the scene
  40296. */
  40297. getUniqueId(): number;
  40298. /**
  40299. * Add a mesh to the list of scene's meshes
  40300. * @param newMesh defines the mesh to add
  40301. * @param recursive if all child meshes should also be added to the scene
  40302. */
  40303. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  40304. /**
  40305. * Remove a mesh for the list of scene's meshes
  40306. * @param toRemove defines the mesh to remove
  40307. * @param recursive if all child meshes should also be removed from the scene
  40308. * @returns the index where the mesh was in the mesh list
  40309. */
  40310. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  40311. /**
  40312. * Add a transform node to the list of scene's transform nodes
  40313. * @param newTransformNode defines the transform node to add
  40314. */
  40315. addTransformNode(newTransformNode: TransformNode): void;
  40316. /**
  40317. * Remove a transform node for the list of scene's transform nodes
  40318. * @param toRemove defines the transform node to remove
  40319. * @returns the index where the transform node was in the transform node list
  40320. */
  40321. removeTransformNode(toRemove: TransformNode): number;
  40322. /**
  40323. * Remove a skeleton for the list of scene's skeletons
  40324. * @param toRemove defines the skeleton to remove
  40325. * @returns the index where the skeleton was in the skeleton list
  40326. */
  40327. removeSkeleton(toRemove: Skeleton): number;
  40328. /**
  40329. * Remove a morph target for the list of scene's morph targets
  40330. * @param toRemove defines the morph target to remove
  40331. * @returns the index where the morph target was in the morph target list
  40332. */
  40333. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  40334. /**
  40335. * Remove a light for the list of scene's lights
  40336. * @param toRemove defines the light to remove
  40337. * @returns the index where the light was in the light list
  40338. */
  40339. removeLight(toRemove: Light): number;
  40340. /**
  40341. * Remove a camera for the list of scene's cameras
  40342. * @param toRemove defines the camera to remove
  40343. * @returns the index where the camera was in the camera list
  40344. */
  40345. removeCamera(toRemove: Camera): number;
  40346. /**
  40347. * Remove a particle system for the list of scene's particle systems
  40348. * @param toRemove defines the particle system to remove
  40349. * @returns the index where the particle system was in the particle system list
  40350. */
  40351. removeParticleSystem(toRemove: IParticleSystem): number;
  40352. /**
  40353. * Remove a animation for the list of scene's animations
  40354. * @param toRemove defines the animation to remove
  40355. * @returns the index where the animation was in the animation list
  40356. */
  40357. removeAnimation(toRemove: Animation): number;
  40358. /**
  40359. * Will stop the animation of the given target
  40360. * @param target - the target
  40361. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  40362. * @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)
  40363. */
  40364. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  40365. /**
  40366. * Removes the given animation group from this scene.
  40367. * @param toRemove The animation group to remove
  40368. * @returns The index of the removed animation group
  40369. */
  40370. removeAnimationGroup(toRemove: AnimationGroup): number;
  40371. /**
  40372. * Removes the given multi-material from this scene.
  40373. * @param toRemove The multi-material to remove
  40374. * @returns The index of the removed multi-material
  40375. */
  40376. removeMultiMaterial(toRemove: MultiMaterial): number;
  40377. /**
  40378. * Removes the given material from this scene.
  40379. * @param toRemove The material to remove
  40380. * @returns The index of the removed material
  40381. */
  40382. removeMaterial(toRemove: Material): number;
  40383. /**
  40384. * Removes the given action manager from this scene.
  40385. * @param toRemove The action manager to remove
  40386. * @returns The index of the removed action manager
  40387. */
  40388. removeActionManager(toRemove: AbstractActionManager): number;
  40389. /**
  40390. * Removes the given texture from this scene.
  40391. * @param toRemove The texture to remove
  40392. * @returns The index of the removed texture
  40393. */
  40394. removeTexture(toRemove: BaseTexture): number;
  40395. /**
  40396. * Adds the given light to this scene
  40397. * @param newLight The light to add
  40398. */
  40399. addLight(newLight: Light): void;
  40400. /**
  40401. * Sorts the list list based on light priorities
  40402. */
  40403. sortLightsByPriority(): void;
  40404. /**
  40405. * Adds the given camera to this scene
  40406. * @param newCamera The camera to add
  40407. */
  40408. addCamera(newCamera: Camera): void;
  40409. /**
  40410. * Adds the given skeleton to this scene
  40411. * @param newSkeleton The skeleton to add
  40412. */
  40413. addSkeleton(newSkeleton: Skeleton): void;
  40414. /**
  40415. * Adds the given particle system to this scene
  40416. * @param newParticleSystem The particle system to add
  40417. */
  40418. addParticleSystem(newParticleSystem: IParticleSystem): void;
  40419. /**
  40420. * Adds the given animation to this scene
  40421. * @param newAnimation The animation to add
  40422. */
  40423. addAnimation(newAnimation: Animation): void;
  40424. /**
  40425. * Adds the given animation group to this scene.
  40426. * @param newAnimationGroup The animation group to add
  40427. */
  40428. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  40429. /**
  40430. * Adds the given multi-material to this scene
  40431. * @param newMultiMaterial The multi-material to add
  40432. */
  40433. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  40434. /**
  40435. * Adds the given material to this scene
  40436. * @param newMaterial The material to add
  40437. */
  40438. addMaterial(newMaterial: Material): void;
  40439. /**
  40440. * Adds the given morph target to this scene
  40441. * @param newMorphTargetManager The morph target to add
  40442. */
  40443. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  40444. /**
  40445. * Adds the given geometry to this scene
  40446. * @param newGeometry The geometry to add
  40447. */
  40448. addGeometry(newGeometry: Geometry): void;
  40449. /**
  40450. * Adds the given action manager to this scene
  40451. * @param newActionManager The action manager to add
  40452. */
  40453. addActionManager(newActionManager: AbstractActionManager): void;
  40454. /**
  40455. * Adds the given texture to this scene.
  40456. * @param newTexture The texture to add
  40457. */
  40458. addTexture(newTexture: BaseTexture): void;
  40459. /**
  40460. * Switch active camera
  40461. * @param newCamera defines the new active camera
  40462. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  40463. */
  40464. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  40465. /**
  40466. * sets the active camera of the scene using its ID
  40467. * @param id defines the camera's ID
  40468. * @return the new active camera or null if none found.
  40469. */
  40470. setActiveCameraByID(id: string): Nullable<Camera>;
  40471. /**
  40472. * sets the active camera of the scene using its name
  40473. * @param name defines the camera's name
  40474. * @returns the new active camera or null if none found.
  40475. */
  40476. setActiveCameraByName(name: string): Nullable<Camera>;
  40477. /**
  40478. * get an animation group using its name
  40479. * @param name defines the material's name
  40480. * @return the animation group or null if none found.
  40481. */
  40482. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  40483. /**
  40484. * Get a material using its unique id
  40485. * @param uniqueId defines the material's unique id
  40486. * @return the material or null if none found.
  40487. */
  40488. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  40489. /**
  40490. * get a material using its id
  40491. * @param id defines the material's ID
  40492. * @return the material or null if none found.
  40493. */
  40494. getMaterialByID(id: string): Nullable<Material>;
  40495. /**
  40496. * Gets a the last added material using a given id
  40497. * @param id defines the material's ID
  40498. * @return the last material with the given id or null if none found.
  40499. */
  40500. getLastMaterialByID(id: string): Nullable<Material>;
  40501. /**
  40502. * Gets a material using its name
  40503. * @param name defines the material's name
  40504. * @return the material or null if none found.
  40505. */
  40506. getMaterialByName(name: string): Nullable<Material>;
  40507. /**
  40508. * Get a texture using its unique id
  40509. * @param uniqueId defines the texture's unique id
  40510. * @return the texture or null if none found.
  40511. */
  40512. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  40513. /**
  40514. * Gets a camera using its id
  40515. * @param id defines the id to look for
  40516. * @returns the camera or null if not found
  40517. */
  40518. getCameraByID(id: string): Nullable<Camera>;
  40519. /**
  40520. * Gets a camera using its unique id
  40521. * @param uniqueId defines the unique id to look for
  40522. * @returns the camera or null if not found
  40523. */
  40524. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  40525. /**
  40526. * Gets a camera using its name
  40527. * @param name defines the camera's name
  40528. * @return the camera or null if none found.
  40529. */
  40530. getCameraByName(name: string): Nullable<Camera>;
  40531. /**
  40532. * Gets a bone using its id
  40533. * @param id defines the bone's id
  40534. * @return the bone or null if not found
  40535. */
  40536. getBoneByID(id: string): Nullable<Bone>;
  40537. /**
  40538. * Gets a bone using its id
  40539. * @param name defines the bone's name
  40540. * @return the bone or null if not found
  40541. */
  40542. getBoneByName(name: string): Nullable<Bone>;
  40543. /**
  40544. * Gets a light node using its name
  40545. * @param name defines the the light's name
  40546. * @return the light or null if none found.
  40547. */
  40548. getLightByName(name: string): Nullable<Light>;
  40549. /**
  40550. * Gets a light node using its id
  40551. * @param id defines the light's id
  40552. * @return the light or null if none found.
  40553. */
  40554. getLightByID(id: string): Nullable<Light>;
  40555. /**
  40556. * Gets a light node using its scene-generated unique ID
  40557. * @param uniqueId defines the light's unique id
  40558. * @return the light or null if none found.
  40559. */
  40560. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  40561. /**
  40562. * Gets a particle system by id
  40563. * @param id defines the particle system id
  40564. * @return the corresponding system or null if none found
  40565. */
  40566. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  40567. /**
  40568. * Gets a geometry using its ID
  40569. * @param id defines the geometry's id
  40570. * @return the geometry or null if none found.
  40571. */
  40572. getGeometryByID(id: string): Nullable<Geometry>;
  40573. private _getGeometryByUniqueID;
  40574. /**
  40575. * Add a new geometry to this scene
  40576. * @param geometry defines the geometry to be added to the scene.
  40577. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  40578. * @return a boolean defining if the geometry was added or not
  40579. */
  40580. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  40581. /**
  40582. * Removes an existing geometry
  40583. * @param geometry defines the geometry to be removed from the scene
  40584. * @return a boolean defining if the geometry was removed or not
  40585. */
  40586. removeGeometry(geometry: Geometry): boolean;
  40587. /**
  40588. * Gets the list of geometries attached to the scene
  40589. * @returns an array of Geometry
  40590. */
  40591. getGeometries(): Geometry[];
  40592. /**
  40593. * Gets the first added mesh found of a given ID
  40594. * @param id defines the id to search for
  40595. * @return the mesh found or null if not found at all
  40596. */
  40597. getMeshByID(id: string): Nullable<AbstractMesh>;
  40598. /**
  40599. * Gets a list of meshes using their id
  40600. * @param id defines the id to search for
  40601. * @returns a list of meshes
  40602. */
  40603. getMeshesByID(id: string): Array<AbstractMesh>;
  40604. /**
  40605. * Gets the first added transform node found of a given ID
  40606. * @param id defines the id to search for
  40607. * @return the found transform node or null if not found at all.
  40608. */
  40609. getTransformNodeByID(id: string): Nullable<TransformNode>;
  40610. /**
  40611. * Gets a transform node with its auto-generated unique id
  40612. * @param uniqueId efines the unique id to search for
  40613. * @return the found transform node or null if not found at all.
  40614. */
  40615. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  40616. /**
  40617. * Gets a list of transform nodes using their id
  40618. * @param id defines the id to search for
  40619. * @returns a list of transform nodes
  40620. */
  40621. getTransformNodesByID(id: string): Array<TransformNode>;
  40622. /**
  40623. * Gets a mesh with its auto-generated unique id
  40624. * @param uniqueId defines the unique id to search for
  40625. * @return the found mesh or null if not found at all.
  40626. */
  40627. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  40628. /**
  40629. * Gets a the last added mesh using a given id
  40630. * @param id defines the id to search for
  40631. * @return the found mesh or null if not found at all.
  40632. */
  40633. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  40634. /**
  40635. * Gets a the last added node (Mesh, Camera, Light) using a given id
  40636. * @param id defines the id to search for
  40637. * @return the found node or null if not found at all
  40638. */
  40639. getLastEntryByID(id: string): Nullable<Node>;
  40640. /**
  40641. * Gets a node (Mesh, Camera, Light) using a given id
  40642. * @param id defines the id to search for
  40643. * @return the found node or null if not found at all
  40644. */
  40645. getNodeByID(id: string): Nullable<Node>;
  40646. /**
  40647. * Gets a node (Mesh, Camera, Light) using a given name
  40648. * @param name defines the name to search for
  40649. * @return the found node or null if not found at all.
  40650. */
  40651. getNodeByName(name: string): Nullable<Node>;
  40652. /**
  40653. * Gets a mesh using a given name
  40654. * @param name defines the name to search for
  40655. * @return the found mesh or null if not found at all.
  40656. */
  40657. getMeshByName(name: string): Nullable<AbstractMesh>;
  40658. /**
  40659. * Gets a transform node using a given name
  40660. * @param name defines the name to search for
  40661. * @return the found transform node or null if not found at all.
  40662. */
  40663. getTransformNodeByName(name: string): Nullable<TransformNode>;
  40664. /**
  40665. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  40666. * @param id defines the id to search for
  40667. * @return the found skeleton or null if not found at all.
  40668. */
  40669. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  40670. /**
  40671. * Gets a skeleton using a given auto generated unique id
  40672. * @param uniqueId defines the unique id to search for
  40673. * @return the found skeleton or null if not found at all.
  40674. */
  40675. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  40676. /**
  40677. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  40678. * @param id defines the id to search for
  40679. * @return the found skeleton or null if not found at all.
  40680. */
  40681. getSkeletonById(id: string): Nullable<Skeleton>;
  40682. /**
  40683. * Gets a skeleton using a given name
  40684. * @param name defines the name to search for
  40685. * @return the found skeleton or null if not found at all.
  40686. */
  40687. getSkeletonByName(name: string): Nullable<Skeleton>;
  40688. /**
  40689. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  40690. * @param id defines the id to search for
  40691. * @return the found morph target manager or null if not found at all.
  40692. */
  40693. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  40694. /**
  40695. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  40696. * @param id defines the id to search for
  40697. * @return the found morph target or null if not found at all.
  40698. */
  40699. getMorphTargetById(id: string): Nullable<MorphTarget>;
  40700. /**
  40701. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  40702. * @param name defines the name to search for
  40703. * @return the found morph target or null if not found at all.
  40704. */
  40705. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  40706. /**
  40707. * Gets a boolean indicating if the given mesh is active
  40708. * @param mesh defines the mesh to look for
  40709. * @returns true if the mesh is in the active list
  40710. */
  40711. isActiveMesh(mesh: AbstractMesh): boolean;
  40712. /**
  40713. * Return a unique id as a string which can serve as an identifier for the scene
  40714. */
  40715. get uid(): string;
  40716. /**
  40717. * Add an externaly attached data from its key.
  40718. * This method call will fail and return false, if such key already exists.
  40719. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  40720. * @param key the unique key that identifies the data
  40721. * @param data the data object to associate to the key for this Engine instance
  40722. * @return true if no such key were already present and the data was added successfully, false otherwise
  40723. */
  40724. addExternalData<T>(key: string, data: T): boolean;
  40725. /**
  40726. * Get an externaly attached data from its key
  40727. * @param key the unique key that identifies the data
  40728. * @return the associated data, if present (can be null), or undefined if not present
  40729. */
  40730. getExternalData<T>(key: string): Nullable<T>;
  40731. /**
  40732. * Get an externaly attached data from its key, create it using a factory if it's not already present
  40733. * @param key the unique key that identifies the data
  40734. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  40735. * @return the associated data, can be null if the factory returned null.
  40736. */
  40737. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  40738. /**
  40739. * Remove an externaly attached data from the Engine instance
  40740. * @param key the unique key that identifies the data
  40741. * @return true if the data was successfully removed, false if it doesn't exist
  40742. */
  40743. removeExternalData(key: string): boolean;
  40744. private _evaluateSubMesh;
  40745. /**
  40746. * Clear the processed materials smart array preventing retention point in material dispose.
  40747. */
  40748. freeProcessedMaterials(): void;
  40749. private _preventFreeActiveMeshesAndRenderingGroups;
  40750. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  40751. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  40752. * when disposing several meshes in a row or a hierarchy of meshes.
  40753. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  40754. */
  40755. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  40756. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  40757. /**
  40758. * Clear the active meshes smart array preventing retention point in mesh dispose.
  40759. */
  40760. freeActiveMeshes(): void;
  40761. /**
  40762. * Clear the info related to rendering groups preventing retention points during dispose.
  40763. */
  40764. freeRenderingGroups(): void;
  40765. /** @hidden */
  40766. _isInIntermediateRendering(): boolean;
  40767. /**
  40768. * Lambda returning the list of potentially active meshes.
  40769. */
  40770. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  40771. /**
  40772. * Lambda returning the list of potentially active sub meshes.
  40773. */
  40774. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  40775. /**
  40776. * Lambda returning the list of potentially intersecting sub meshes.
  40777. */
  40778. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  40779. /**
  40780. * Lambda returning the list of potentially colliding sub meshes.
  40781. */
  40782. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  40783. private _activeMeshesFrozen;
  40784. private _skipEvaluateActiveMeshesCompletely;
  40785. /**
  40786. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  40787. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  40788. * @returns the current scene
  40789. */
  40790. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  40791. /**
  40792. * Use this function to restart evaluating active meshes on every frame
  40793. * @returns the current scene
  40794. */
  40795. unfreezeActiveMeshes(): Scene;
  40796. private _evaluateActiveMeshes;
  40797. private _activeMesh;
  40798. /**
  40799. * Update the transform matrix to update from the current active camera
  40800. * @param force defines a boolean used to force the update even if cache is up to date
  40801. */
  40802. updateTransformMatrix(force?: boolean): void;
  40803. private _bindFrameBuffer;
  40804. /** @hidden */
  40805. _allowPostProcessClearColor: boolean;
  40806. /** @hidden */
  40807. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  40808. private _processSubCameras;
  40809. private _checkIntersections;
  40810. /** @hidden */
  40811. _advancePhysicsEngineStep(step: number): void;
  40812. /**
  40813. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  40814. */
  40815. getDeterministicFrameTime: () => number;
  40816. /** @hidden */
  40817. _animate(): void;
  40818. /** Execute all animations (for a frame) */
  40819. animate(): void;
  40820. /**
  40821. * Render the scene
  40822. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  40823. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  40824. */
  40825. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  40826. /**
  40827. * Freeze all materials
  40828. * A frozen material will not be updatable but should be faster to render
  40829. */
  40830. freezeMaterials(): void;
  40831. /**
  40832. * Unfreeze all materials
  40833. * A frozen material will not be updatable but should be faster to render
  40834. */
  40835. unfreezeMaterials(): void;
  40836. /**
  40837. * Releases all held ressources
  40838. */
  40839. dispose(): void;
  40840. /**
  40841. * Gets if the scene is already disposed
  40842. */
  40843. get isDisposed(): boolean;
  40844. /**
  40845. * Call this function to reduce memory footprint of the scene.
  40846. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  40847. */
  40848. clearCachedVertexData(): void;
  40849. /**
  40850. * This function will remove the local cached buffer data from texture.
  40851. * It will save memory but will prevent the texture from being rebuilt
  40852. */
  40853. cleanCachedTextureBuffer(): void;
  40854. /**
  40855. * Get the world extend vectors with an optional filter
  40856. *
  40857. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  40858. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  40859. */
  40860. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  40861. min: Vector3;
  40862. max: Vector3;
  40863. };
  40864. /**
  40865. * Creates a ray that can be used to pick in the scene
  40866. * @param x defines the x coordinate of the origin (on-screen)
  40867. * @param y defines the y coordinate of the origin (on-screen)
  40868. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  40869. * @param camera defines the camera to use for the picking
  40870. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  40871. * @returns a Ray
  40872. */
  40873. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  40874. /**
  40875. * Creates a ray that can be used to pick in the scene
  40876. * @param x defines the x coordinate of the origin (on-screen)
  40877. * @param y defines the y coordinate of the origin (on-screen)
  40878. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  40879. * @param result defines the ray where to store the picking ray
  40880. * @param camera defines the camera to use for the picking
  40881. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  40882. * @returns the current scene
  40883. */
  40884. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  40885. /**
  40886. * Creates a ray that can be used to pick in the scene
  40887. * @param x defines the x coordinate of the origin (on-screen)
  40888. * @param y defines the y coordinate of the origin (on-screen)
  40889. * @param camera defines the camera to use for the picking
  40890. * @returns a Ray
  40891. */
  40892. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  40893. /**
  40894. * Creates a ray that can be used to pick in the scene
  40895. * @param x defines the x coordinate of the origin (on-screen)
  40896. * @param y defines the y coordinate of the origin (on-screen)
  40897. * @param result defines the ray where to store the picking ray
  40898. * @param camera defines the camera to use for the picking
  40899. * @returns the current scene
  40900. */
  40901. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  40902. /** Launch a ray to try to pick a mesh in the scene
  40903. * @param x position on screen
  40904. * @param y position on screen
  40905. * @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
  40906. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40907. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40908. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40909. * @returns a PickingInfo
  40910. */
  40911. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  40912. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  40913. * @param x position on screen
  40914. * @param y position on screen
  40915. * @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
  40916. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40917. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40918. * @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)
  40919. */
  40920. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  40921. /** Use the given ray to pick a mesh in the scene
  40922. * @param ray The ray to use to pick meshes
  40923. * @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
  40924. * @param fastCheck defines if the first intersection will be used (and not the closest)
  40925. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40926. * @returns a PickingInfo
  40927. */
  40928. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  40929. /**
  40930. * Launch a ray to try to pick a mesh in the scene
  40931. * @param x X position on screen
  40932. * @param y Y position on screen
  40933. * @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
  40934. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  40935. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40936. * @returns an array of PickingInfo
  40937. */
  40938. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  40939. /**
  40940. * Launch a ray to try to pick a mesh in the scene
  40941. * @param ray Ray to use
  40942. * @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
  40943. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  40944. * @returns an array of PickingInfo
  40945. */
  40946. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  40947. /**
  40948. * Force the value of meshUnderPointer
  40949. * @param mesh defines the mesh to use
  40950. */
  40951. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  40952. /**
  40953. * Gets the mesh under the pointer
  40954. * @returns a Mesh or null if no mesh is under the pointer
  40955. */
  40956. getPointerOverMesh(): Nullable<AbstractMesh>;
  40957. /** @hidden */
  40958. _rebuildGeometries(): void;
  40959. /** @hidden */
  40960. _rebuildTextures(): void;
  40961. private _getByTags;
  40962. /**
  40963. * Get a list of meshes by tags
  40964. * @param tagsQuery defines the tags query to use
  40965. * @param forEach defines a predicate used to filter results
  40966. * @returns an array of Mesh
  40967. */
  40968. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  40969. /**
  40970. * Get a list of cameras by tags
  40971. * @param tagsQuery defines the tags query to use
  40972. * @param forEach defines a predicate used to filter results
  40973. * @returns an array of Camera
  40974. */
  40975. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  40976. /**
  40977. * Get a list of lights by tags
  40978. * @param tagsQuery defines the tags query to use
  40979. * @param forEach defines a predicate used to filter results
  40980. * @returns an array of Light
  40981. */
  40982. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  40983. /**
  40984. * Get a list of materials by tags
  40985. * @param tagsQuery defines the tags query to use
  40986. * @param forEach defines a predicate used to filter results
  40987. * @returns an array of Material
  40988. */
  40989. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  40990. /**
  40991. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  40992. * This allowed control for front to back rendering or reversly depending of the special needs.
  40993. *
  40994. * @param renderingGroupId The rendering group id corresponding to its index
  40995. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  40996. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  40997. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  40998. */
  40999. 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;
  41000. /**
  41001. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  41002. *
  41003. * @param renderingGroupId The rendering group id corresponding to its index
  41004. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  41005. * @param depth Automatically clears depth between groups if true and autoClear is true.
  41006. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  41007. */
  41008. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  41009. /**
  41010. * Gets the current auto clear configuration for one rendering group of the rendering
  41011. * manager.
  41012. * @param index the rendering group index to get the information for
  41013. * @returns The auto clear setup for the requested rendering group
  41014. */
  41015. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  41016. private _blockMaterialDirtyMechanism;
  41017. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  41018. get blockMaterialDirtyMechanism(): boolean;
  41019. set blockMaterialDirtyMechanism(value: boolean);
  41020. /**
  41021. * Will flag all materials as dirty to trigger new shader compilation
  41022. * @param flag defines the flag used to specify which material part must be marked as dirty
  41023. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  41024. */
  41025. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41026. /** @hidden */
  41027. _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;
  41028. /** @hidden */
  41029. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41030. /** @hidden */
  41031. _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;
  41032. /** @hidden */
  41033. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  41034. /** @hidden */
  41035. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41036. /** @hidden */
  41037. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41038. }
  41039. }
  41040. declare module BABYLON {
  41041. /**
  41042. * Set of assets to keep when moving a scene into an asset container.
  41043. */
  41044. export class KeepAssets extends AbstractScene {
  41045. }
  41046. /**
  41047. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  41048. */
  41049. export class InstantiatedEntries {
  41050. /**
  41051. * List of new root nodes (eg. nodes with no parent)
  41052. */
  41053. rootNodes: TransformNode[];
  41054. /**
  41055. * List of new skeletons
  41056. */
  41057. skeletons: Skeleton[];
  41058. /**
  41059. * List of new animation groups
  41060. */
  41061. animationGroups: AnimationGroup[];
  41062. }
  41063. /**
  41064. * Container with a set of assets that can be added or removed from a scene.
  41065. */
  41066. export class AssetContainer extends AbstractScene {
  41067. private _wasAddedToScene;
  41068. /**
  41069. * The scene the AssetContainer belongs to.
  41070. */
  41071. scene: Scene;
  41072. /**
  41073. * Instantiates an AssetContainer.
  41074. * @param scene The scene the AssetContainer belongs to.
  41075. */
  41076. constructor(scene: Scene);
  41077. /**
  41078. * Instantiate or clone all meshes and add the new ones to the scene.
  41079. * Skeletons and animation groups will all be cloned
  41080. * @param nameFunction defines an optional function used to get new names for clones
  41081. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  41082. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  41083. */
  41084. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  41085. /**
  41086. * Adds all the assets from the container to the scene.
  41087. */
  41088. addAllToScene(): void;
  41089. /**
  41090. * Removes all the assets in the container from the scene
  41091. */
  41092. removeAllFromScene(): void;
  41093. /**
  41094. * Disposes all the assets in the container
  41095. */
  41096. dispose(): void;
  41097. private _moveAssets;
  41098. /**
  41099. * Removes all the assets contained in the scene and adds them to the container.
  41100. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  41101. */
  41102. moveAllFromScene(keepAssets?: KeepAssets): void;
  41103. /**
  41104. * 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.
  41105. * @returns the root mesh
  41106. */
  41107. createRootMesh(): Mesh;
  41108. /**
  41109. * Merge animations (direct and animation groups) from this asset container into a scene
  41110. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41111. * @param animatables set of animatables to retarget to a node from the scene
  41112. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  41113. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  41114. */
  41115. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  41116. }
  41117. }
  41118. declare module BABYLON {
  41119. /**
  41120. * Defines how the parser contract is defined.
  41121. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  41122. */
  41123. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  41124. /**
  41125. * Defines how the individual parser contract is defined.
  41126. * These parser can parse an individual asset
  41127. */
  41128. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  41129. /**
  41130. * Base class of the scene acting as a container for the different elements composing a scene.
  41131. * This class is dynamically extended by the different components of the scene increasing
  41132. * flexibility and reducing coupling
  41133. */
  41134. export abstract class AbstractScene {
  41135. /**
  41136. * Stores the list of available parsers in the application.
  41137. */
  41138. private static _BabylonFileParsers;
  41139. /**
  41140. * Stores the list of available individual parsers in the application.
  41141. */
  41142. private static _IndividualBabylonFileParsers;
  41143. /**
  41144. * Adds a parser in the list of available ones
  41145. * @param name Defines the name of the parser
  41146. * @param parser Defines the parser to add
  41147. */
  41148. static AddParser(name: string, parser: BabylonFileParser): void;
  41149. /**
  41150. * Gets a general parser from the list of avaialble ones
  41151. * @param name Defines the name of the parser
  41152. * @returns the requested parser or null
  41153. */
  41154. static GetParser(name: string): Nullable<BabylonFileParser>;
  41155. /**
  41156. * Adds n individual parser in the list of available ones
  41157. * @param name Defines the name of the parser
  41158. * @param parser Defines the parser to add
  41159. */
  41160. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  41161. /**
  41162. * Gets an individual parser from the list of avaialble ones
  41163. * @param name Defines the name of the parser
  41164. * @returns the requested parser or null
  41165. */
  41166. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  41167. /**
  41168. * Parser json data and populate both a scene and its associated container object
  41169. * @param jsonData Defines the data to parse
  41170. * @param scene Defines the scene to parse the data for
  41171. * @param container Defines the container attached to the parsing sequence
  41172. * @param rootUrl Defines the root url of the data
  41173. */
  41174. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  41175. /**
  41176. * Gets the list of root nodes (ie. nodes with no parent)
  41177. */
  41178. rootNodes: Node[];
  41179. /** All of the cameras added to this scene
  41180. * @see https://doc.babylonjs.com/babylon101/cameras
  41181. */
  41182. cameras: Camera[];
  41183. /**
  41184. * All of the lights added to this scene
  41185. * @see https://doc.babylonjs.com/babylon101/lights
  41186. */
  41187. lights: Light[];
  41188. /**
  41189. * All of the (abstract) meshes added to this scene
  41190. */
  41191. meshes: AbstractMesh[];
  41192. /**
  41193. * The list of skeletons added to the scene
  41194. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  41195. */
  41196. skeletons: Skeleton[];
  41197. /**
  41198. * All of the particle systems added to this scene
  41199. * @see https://doc.babylonjs.com/babylon101/particles
  41200. */
  41201. particleSystems: IParticleSystem[];
  41202. /**
  41203. * Gets a list of Animations associated with the scene
  41204. */
  41205. animations: Animation[];
  41206. /**
  41207. * All of the animation groups added to this scene
  41208. * @see https://doc.babylonjs.com/how_to/group
  41209. */
  41210. animationGroups: AnimationGroup[];
  41211. /**
  41212. * All of the multi-materials added to this scene
  41213. * @see https://doc.babylonjs.com/how_to/multi_materials
  41214. */
  41215. multiMaterials: MultiMaterial[];
  41216. /**
  41217. * All of the materials added to this scene
  41218. * In the context of a Scene, it is not supposed to be modified manually.
  41219. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  41220. * Note also that the order of the Material within the array is not significant and might change.
  41221. * @see https://doc.babylonjs.com/babylon101/materials
  41222. */
  41223. materials: Material[];
  41224. /**
  41225. * The list of morph target managers added to the scene
  41226. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  41227. */
  41228. morphTargetManagers: MorphTargetManager[];
  41229. /**
  41230. * The list of geometries used in the scene.
  41231. */
  41232. geometries: Geometry[];
  41233. /**
  41234. * All of the tranform nodes added to this scene
  41235. * In the context of a Scene, it is not supposed to be modified manually.
  41236. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  41237. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  41238. * @see https://doc.babylonjs.com/how_to/transformnode
  41239. */
  41240. transformNodes: TransformNode[];
  41241. /**
  41242. * ActionManagers available on the scene.
  41243. */
  41244. actionManagers: AbstractActionManager[];
  41245. /**
  41246. * Textures to keep.
  41247. */
  41248. textures: BaseTexture[];
  41249. /**
  41250. * Environment texture for the scene
  41251. */
  41252. environmentTexture: Nullable<BaseTexture>;
  41253. /**
  41254. * @returns all meshes, lights, cameras, transformNodes and bones
  41255. */
  41256. getNodes(): Array<Node>;
  41257. }
  41258. }
  41259. declare module BABYLON {
  41260. /**
  41261. * Interface used to define options for Sound class
  41262. */
  41263. export interface ISoundOptions {
  41264. /**
  41265. * Does the sound autoplay once loaded.
  41266. */
  41267. autoplay?: boolean;
  41268. /**
  41269. * Does the sound loop after it finishes playing once.
  41270. */
  41271. loop?: boolean;
  41272. /**
  41273. * Sound's volume
  41274. */
  41275. volume?: number;
  41276. /**
  41277. * Is it a spatial sound?
  41278. */
  41279. spatialSound?: boolean;
  41280. /**
  41281. * Maximum distance to hear that sound
  41282. */
  41283. maxDistance?: number;
  41284. /**
  41285. * Uses user defined attenuation function
  41286. */
  41287. useCustomAttenuation?: boolean;
  41288. /**
  41289. * Define the roll off factor of spatial sounds.
  41290. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41291. */
  41292. rolloffFactor?: number;
  41293. /**
  41294. * Define the reference distance the sound should be heard perfectly.
  41295. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41296. */
  41297. refDistance?: number;
  41298. /**
  41299. * Define the distance attenuation model the sound will follow.
  41300. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41301. */
  41302. distanceModel?: string;
  41303. /**
  41304. * Defines the playback speed (1 by default)
  41305. */
  41306. playbackRate?: number;
  41307. /**
  41308. * Defines if the sound is from a streaming source
  41309. */
  41310. streaming?: boolean;
  41311. /**
  41312. * Defines an optional length (in seconds) inside the sound file
  41313. */
  41314. length?: number;
  41315. /**
  41316. * Defines an optional offset (in seconds) inside the sound file
  41317. */
  41318. offset?: number;
  41319. /**
  41320. * If true, URLs will not be required to state the audio file codec to use.
  41321. */
  41322. skipCodecCheck?: boolean;
  41323. }
  41324. /**
  41325. * Defines a sound that can be played in the application.
  41326. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  41327. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41328. */
  41329. export class Sound {
  41330. /**
  41331. * The name of the sound in the scene.
  41332. */
  41333. name: string;
  41334. /**
  41335. * Does the sound autoplay once loaded.
  41336. */
  41337. autoplay: boolean;
  41338. /**
  41339. * Does the sound loop after it finishes playing once.
  41340. */
  41341. loop: boolean;
  41342. /**
  41343. * Does the sound use a custom attenuation curve to simulate the falloff
  41344. * happening when the source gets further away from the camera.
  41345. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41346. */
  41347. useCustomAttenuation: boolean;
  41348. /**
  41349. * The sound track id this sound belongs to.
  41350. */
  41351. soundTrackId: number;
  41352. /**
  41353. * Is this sound currently played.
  41354. */
  41355. isPlaying: boolean;
  41356. /**
  41357. * Is this sound currently paused.
  41358. */
  41359. isPaused: boolean;
  41360. /**
  41361. * Does this sound enables spatial sound.
  41362. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41363. */
  41364. spatialSound: boolean;
  41365. /**
  41366. * Define the reference distance the sound should be heard perfectly.
  41367. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41368. */
  41369. refDistance: number;
  41370. /**
  41371. * Define the roll off factor of spatial sounds.
  41372. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41373. */
  41374. rolloffFactor: number;
  41375. /**
  41376. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  41377. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41378. */
  41379. maxDistance: number;
  41380. /**
  41381. * Define the distance attenuation model the sound will follow.
  41382. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41383. */
  41384. distanceModel: string;
  41385. /**
  41386. * @hidden
  41387. * Back Compat
  41388. **/
  41389. onended: () => any;
  41390. /**
  41391. * Gets or sets an object used to store user defined information for the sound.
  41392. */
  41393. metadata: any;
  41394. /**
  41395. * Observable event when the current playing sound finishes.
  41396. */
  41397. onEndedObservable: Observable<Sound>;
  41398. private _panningModel;
  41399. private _playbackRate;
  41400. private _streaming;
  41401. private _startTime;
  41402. private _startOffset;
  41403. private _position;
  41404. /** @hidden */
  41405. _positionInEmitterSpace: boolean;
  41406. private _localDirection;
  41407. private _volume;
  41408. private _isReadyToPlay;
  41409. private _isDirectional;
  41410. private _readyToPlayCallback;
  41411. private _audioBuffer;
  41412. private _soundSource;
  41413. private _streamingSource;
  41414. private _soundPanner;
  41415. private _soundGain;
  41416. private _inputAudioNode;
  41417. private _outputAudioNode;
  41418. private _coneInnerAngle;
  41419. private _coneOuterAngle;
  41420. private _coneOuterGain;
  41421. private _scene;
  41422. private _connectedTransformNode;
  41423. private _customAttenuationFunction;
  41424. private _registerFunc;
  41425. private _isOutputConnected;
  41426. private _htmlAudioElement;
  41427. private _urlType;
  41428. private _length?;
  41429. private _offset?;
  41430. /** @hidden */
  41431. static _SceneComponentInitialization: (scene: Scene) => void;
  41432. /**
  41433. * Create a sound and attach it to a scene
  41434. * @param name Name of your sound
  41435. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  41436. * @param scene defines the scene the sound belongs to
  41437. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  41438. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  41439. */
  41440. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  41441. /**
  41442. * Release the sound and its associated resources
  41443. */
  41444. dispose(): void;
  41445. /**
  41446. * Gets if the sounds is ready to be played or not.
  41447. * @returns true if ready, otherwise false
  41448. */
  41449. isReady(): boolean;
  41450. private _soundLoaded;
  41451. /**
  41452. * Sets the data of the sound from an audiobuffer
  41453. * @param audioBuffer The audioBuffer containing the data
  41454. */
  41455. setAudioBuffer(audioBuffer: AudioBuffer): void;
  41456. /**
  41457. * Updates the current sounds options such as maxdistance, loop...
  41458. * @param options A JSON object containing values named as the object properties
  41459. */
  41460. updateOptions(options: ISoundOptions): void;
  41461. private _createSpatialParameters;
  41462. private _updateSpatialParameters;
  41463. /**
  41464. * Switch the panning model to HRTF:
  41465. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41466. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41467. */
  41468. switchPanningModelToHRTF(): void;
  41469. /**
  41470. * Switch the panning model to Equal Power:
  41471. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41472. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41473. */
  41474. switchPanningModelToEqualPower(): void;
  41475. private _switchPanningModel;
  41476. /**
  41477. * Connect this sound to a sound track audio node like gain...
  41478. * @param soundTrackAudioNode the sound track audio node to connect to
  41479. */
  41480. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  41481. /**
  41482. * Transform this sound into a directional source
  41483. * @param coneInnerAngle Size of the inner cone in degree
  41484. * @param coneOuterAngle Size of the outer cone in degree
  41485. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  41486. */
  41487. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  41488. /**
  41489. * Gets or sets the inner angle for the directional cone.
  41490. */
  41491. get directionalConeInnerAngle(): number;
  41492. /**
  41493. * Gets or sets the inner angle for the directional cone.
  41494. */
  41495. set directionalConeInnerAngle(value: number);
  41496. /**
  41497. * Gets or sets the outer angle for the directional cone.
  41498. */
  41499. get directionalConeOuterAngle(): number;
  41500. /**
  41501. * Gets or sets the outer angle for the directional cone.
  41502. */
  41503. set directionalConeOuterAngle(value: number);
  41504. /**
  41505. * Sets the position of the emitter if spatial sound is enabled
  41506. * @param newPosition Defines the new posisiton
  41507. */
  41508. setPosition(newPosition: Vector3): void;
  41509. /**
  41510. * Sets the local direction of the emitter if spatial sound is enabled
  41511. * @param newLocalDirection Defines the new local direction
  41512. */
  41513. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  41514. private _updateDirection;
  41515. /** @hidden */
  41516. updateDistanceFromListener(): void;
  41517. /**
  41518. * Sets a new custom attenuation function for the sound.
  41519. * @param callback Defines the function used for the attenuation
  41520. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41521. */
  41522. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  41523. /**
  41524. * Play the sound
  41525. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  41526. * @param offset (optional) Start the sound at a specific time in seconds
  41527. * @param length (optional) Sound duration (in seconds)
  41528. */
  41529. play(time?: number, offset?: number, length?: number): void;
  41530. private _onended;
  41531. /**
  41532. * Stop the sound
  41533. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  41534. */
  41535. stop(time?: number): void;
  41536. /**
  41537. * Put the sound in pause
  41538. */
  41539. pause(): void;
  41540. /**
  41541. * Sets a dedicated volume for this sounds
  41542. * @param newVolume Define the new volume of the sound
  41543. * @param time Define time for gradual change to new volume
  41544. */
  41545. setVolume(newVolume: number, time?: number): void;
  41546. /**
  41547. * Set the sound play back rate
  41548. * @param newPlaybackRate Define the playback rate the sound should be played at
  41549. */
  41550. setPlaybackRate(newPlaybackRate: number): void;
  41551. /**
  41552. * Gets the volume of the sound.
  41553. * @returns the volume of the sound
  41554. */
  41555. getVolume(): number;
  41556. /**
  41557. * Attach the sound to a dedicated mesh
  41558. * @param transformNode The transform node to connect the sound with
  41559. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41560. */
  41561. attachToMesh(transformNode: TransformNode): void;
  41562. /**
  41563. * Detach the sound from the previously attached mesh
  41564. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41565. */
  41566. detachFromMesh(): void;
  41567. private _onRegisterAfterWorldMatrixUpdate;
  41568. /**
  41569. * Clone the current sound in the scene.
  41570. * @returns the new sound clone
  41571. */
  41572. clone(): Nullable<Sound>;
  41573. /**
  41574. * Gets the current underlying audio buffer containing the data
  41575. * @returns the audio buffer
  41576. */
  41577. getAudioBuffer(): Nullable<AudioBuffer>;
  41578. /**
  41579. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  41580. * @returns the source node
  41581. */
  41582. getSoundSource(): Nullable<AudioBufferSourceNode>;
  41583. /**
  41584. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  41585. * @returns the gain node
  41586. */
  41587. getSoundGain(): Nullable<GainNode>;
  41588. /**
  41589. * Serializes the Sound in a JSON representation
  41590. * @returns the JSON representation of the sound
  41591. */
  41592. serialize(): any;
  41593. /**
  41594. * Parse a JSON representation of a sound to innstantiate in a given scene
  41595. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  41596. * @param scene Define the scene the new parsed sound should be created in
  41597. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  41598. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  41599. * @returns the newly parsed sound
  41600. */
  41601. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  41602. }
  41603. }
  41604. declare module BABYLON {
  41605. /**
  41606. * This defines an action helpful to play a defined sound on a triggered action.
  41607. */
  41608. export class PlaySoundAction extends Action {
  41609. private _sound;
  41610. /**
  41611. * Instantiate the action
  41612. * @param triggerOptions defines the trigger options
  41613. * @param sound defines the sound to play
  41614. * @param condition defines the trigger related conditions
  41615. */
  41616. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41617. /** @hidden */
  41618. _prepare(): void;
  41619. /**
  41620. * Execute the action and play the sound.
  41621. */
  41622. execute(): void;
  41623. /**
  41624. * Serializes the actions and its related information.
  41625. * @param parent defines the object to serialize in
  41626. * @returns the serialized object
  41627. */
  41628. serialize(parent: any): any;
  41629. }
  41630. /**
  41631. * This defines an action helpful to stop a defined sound on a triggered action.
  41632. */
  41633. export class StopSoundAction extends Action {
  41634. private _sound;
  41635. /**
  41636. * Instantiate the action
  41637. * @param triggerOptions defines the trigger options
  41638. * @param sound defines the sound to stop
  41639. * @param condition defines the trigger related conditions
  41640. */
  41641. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  41642. /** @hidden */
  41643. _prepare(): void;
  41644. /**
  41645. * Execute the action and stop the sound.
  41646. */
  41647. execute(): void;
  41648. /**
  41649. * Serializes the actions and its related information.
  41650. * @param parent defines the object to serialize in
  41651. * @returns the serialized object
  41652. */
  41653. serialize(parent: any): any;
  41654. }
  41655. }
  41656. declare module BABYLON {
  41657. /**
  41658. * This defines an action responsible to change the value of a property
  41659. * by interpolating between its current value and the newly set one once triggered.
  41660. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  41661. */
  41662. export class InterpolateValueAction extends Action {
  41663. /**
  41664. * Defines the path of the property where the value should be interpolated
  41665. */
  41666. propertyPath: string;
  41667. /**
  41668. * Defines the target value at the end of the interpolation.
  41669. */
  41670. value: any;
  41671. /**
  41672. * Defines the time it will take for the property to interpolate to the value.
  41673. */
  41674. duration: number;
  41675. /**
  41676. * Defines if the other scene animations should be stopped when the action has been triggered
  41677. */
  41678. stopOtherAnimations?: boolean;
  41679. /**
  41680. * Defines a callback raised once the interpolation animation has been done.
  41681. */
  41682. onInterpolationDone?: () => void;
  41683. /**
  41684. * Observable triggered once the interpolation animation has been done.
  41685. */
  41686. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  41687. private _target;
  41688. private _effectiveTarget;
  41689. private _property;
  41690. /**
  41691. * Instantiate the action
  41692. * @param triggerOptions defines the trigger options
  41693. * @param target defines the object containing the value to interpolate
  41694. * @param propertyPath defines the path to the property in the target object
  41695. * @param value defines the target value at the end of the interpolation
  41696. * @param duration deines the time it will take for the property to interpolate to the value.
  41697. * @param condition defines the trigger related conditions
  41698. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  41699. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  41700. */
  41701. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  41702. /** @hidden */
  41703. _prepare(): void;
  41704. /**
  41705. * Execute the action starts the value interpolation.
  41706. */
  41707. execute(): void;
  41708. /**
  41709. * Serializes the actions and its related information.
  41710. * @param parent defines the object to serialize in
  41711. * @returns the serialized object
  41712. */
  41713. serialize(parent: any): any;
  41714. }
  41715. }
  41716. declare module BABYLON {
  41717. /**
  41718. * Options allowed during the creation of a sound track.
  41719. */
  41720. export interface ISoundTrackOptions {
  41721. /**
  41722. * The volume the sound track should take during creation
  41723. */
  41724. volume?: number;
  41725. /**
  41726. * Define if the sound track is the main sound track of the scene
  41727. */
  41728. mainTrack?: boolean;
  41729. }
  41730. /**
  41731. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  41732. * It will be also used in a future release to apply effects on a specific track.
  41733. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  41734. */
  41735. export class SoundTrack {
  41736. /**
  41737. * The unique identifier of the sound track in the scene.
  41738. */
  41739. id: number;
  41740. /**
  41741. * The list of sounds included in the sound track.
  41742. */
  41743. soundCollection: Array<Sound>;
  41744. private _outputAudioNode;
  41745. private _scene;
  41746. private _connectedAnalyser;
  41747. private _options;
  41748. private _isInitialized;
  41749. /**
  41750. * Creates a new sound track.
  41751. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  41752. * @param scene Define the scene the sound track belongs to
  41753. * @param options
  41754. */
  41755. constructor(scene: Scene, options?: ISoundTrackOptions);
  41756. private _initializeSoundTrackAudioGraph;
  41757. /**
  41758. * Release the sound track and its associated resources
  41759. */
  41760. dispose(): void;
  41761. /**
  41762. * Adds a sound to this sound track
  41763. * @param sound define the cound to add
  41764. * @ignoreNaming
  41765. */
  41766. AddSound(sound: Sound): void;
  41767. /**
  41768. * Removes a sound to this sound track
  41769. * @param sound define the cound to remove
  41770. * @ignoreNaming
  41771. */
  41772. RemoveSound(sound: Sound): void;
  41773. /**
  41774. * Set a global volume for the full sound track.
  41775. * @param newVolume Define the new volume of the sound track
  41776. */
  41777. setVolume(newVolume: number): void;
  41778. /**
  41779. * Switch the panning model to HRTF:
  41780. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41781. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41782. */
  41783. switchPanningModelToHRTF(): void;
  41784. /**
  41785. * Switch the panning model to Equal Power:
  41786. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41787. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41788. */
  41789. switchPanningModelToEqualPower(): void;
  41790. /**
  41791. * Connect the sound track to an audio analyser allowing some amazing
  41792. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41793. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41794. * @param analyser The analyser to connect to the engine
  41795. */
  41796. connectToAnalyser(analyser: Analyser): void;
  41797. }
  41798. }
  41799. declare module BABYLON {
  41800. interface AbstractScene {
  41801. /**
  41802. * The list of sounds used in the scene.
  41803. */
  41804. sounds: Nullable<Array<Sound>>;
  41805. }
  41806. interface Scene {
  41807. /**
  41808. * @hidden
  41809. * Backing field
  41810. */
  41811. _mainSoundTrack: SoundTrack;
  41812. /**
  41813. * The main sound track played by the scene.
  41814. * It cotains your primary collection of sounds.
  41815. */
  41816. mainSoundTrack: SoundTrack;
  41817. /**
  41818. * The list of sound tracks added to the scene
  41819. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41820. */
  41821. soundTracks: Nullable<Array<SoundTrack>>;
  41822. /**
  41823. * Gets a sound using a given name
  41824. * @param name defines the name to search for
  41825. * @return the found sound or null if not found at all.
  41826. */
  41827. getSoundByName(name: string): Nullable<Sound>;
  41828. /**
  41829. * Gets or sets if audio support is enabled
  41830. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41831. */
  41832. audioEnabled: boolean;
  41833. /**
  41834. * Gets or sets if audio will be output to headphones
  41835. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41836. */
  41837. headphone: boolean;
  41838. /**
  41839. * Gets or sets custom audio listener position provider
  41840. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41841. */
  41842. audioListenerPositionProvider: Nullable<() => Vector3>;
  41843. /**
  41844. * Gets or sets a refresh rate when using 3D audio positioning
  41845. */
  41846. audioPositioningRefreshRate: number;
  41847. }
  41848. /**
  41849. * Defines the sound scene component responsible to manage any sounds
  41850. * in a given scene.
  41851. */
  41852. export class AudioSceneComponent implements ISceneSerializableComponent {
  41853. /**
  41854. * The component name helpfull to identify the component in the list of scene components.
  41855. */
  41856. readonly name: string;
  41857. /**
  41858. * The scene the component belongs to.
  41859. */
  41860. scene: Scene;
  41861. private _audioEnabled;
  41862. /**
  41863. * Gets whether audio is enabled or not.
  41864. * Please use related enable/disable method to switch state.
  41865. */
  41866. get audioEnabled(): boolean;
  41867. private _headphone;
  41868. /**
  41869. * Gets whether audio is outputing to headphone or not.
  41870. * Please use the according Switch methods to change output.
  41871. */
  41872. get headphone(): boolean;
  41873. /**
  41874. * Gets or sets a refresh rate when using 3D audio positioning
  41875. */
  41876. audioPositioningRefreshRate: number;
  41877. private _audioListenerPositionProvider;
  41878. /**
  41879. * Gets the current audio listener position provider
  41880. */
  41881. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  41882. /**
  41883. * Sets a custom listener position for all sounds in the scene
  41884. * By default, this is the position of the first active camera
  41885. */
  41886. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  41887. /**
  41888. * Creates a new instance of the component for the given scene
  41889. * @param scene Defines the scene to register the component in
  41890. */
  41891. constructor(scene: Scene);
  41892. /**
  41893. * Registers the component in a given scene
  41894. */
  41895. register(): void;
  41896. /**
  41897. * Rebuilds the elements related to this component in case of
  41898. * context lost for instance.
  41899. */
  41900. rebuild(): void;
  41901. /**
  41902. * Serializes the component data to the specified json object
  41903. * @param serializationObject The object to serialize to
  41904. */
  41905. serialize(serializationObject: any): void;
  41906. /**
  41907. * Adds all the elements from the container to the scene
  41908. * @param container the container holding the elements
  41909. */
  41910. addFromContainer(container: AbstractScene): void;
  41911. /**
  41912. * Removes all the elements in the container from the scene
  41913. * @param container contains the elements to remove
  41914. * @param dispose if the removed element should be disposed (default: false)
  41915. */
  41916. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  41917. /**
  41918. * Disposes the component and the associated ressources.
  41919. */
  41920. dispose(): void;
  41921. /**
  41922. * Disables audio in the associated scene.
  41923. */
  41924. disableAudio(): void;
  41925. /**
  41926. * Enables audio in the associated scene.
  41927. */
  41928. enableAudio(): void;
  41929. /**
  41930. * Switch audio to headphone output.
  41931. */
  41932. switchAudioModeForHeadphones(): void;
  41933. /**
  41934. * Switch audio to normal speakers.
  41935. */
  41936. switchAudioModeForNormalSpeakers(): void;
  41937. private _cachedCameraDirection;
  41938. private _cachedCameraPosition;
  41939. private _lastCheck;
  41940. private _afterRender;
  41941. }
  41942. }
  41943. declare module BABYLON {
  41944. /**
  41945. * Wraps one or more Sound objects and selects one with random weight for playback.
  41946. */
  41947. export class WeightedSound {
  41948. /** When true a Sound will be selected and played when the current playing Sound completes. */
  41949. loop: boolean;
  41950. private _coneInnerAngle;
  41951. private _coneOuterAngle;
  41952. private _volume;
  41953. /** A Sound is currently playing. */
  41954. isPlaying: boolean;
  41955. /** A Sound is currently paused. */
  41956. isPaused: boolean;
  41957. private _sounds;
  41958. private _weights;
  41959. private _currentIndex?;
  41960. /**
  41961. * Creates a new WeightedSound from the list of sounds given.
  41962. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  41963. * @param sounds Array of Sounds that will be selected from.
  41964. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  41965. */
  41966. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  41967. /**
  41968. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  41969. */
  41970. get directionalConeInnerAngle(): number;
  41971. /**
  41972. * The size of cone in degress for a directional sound in which there will be no attenuation.
  41973. */
  41974. set directionalConeInnerAngle(value: number);
  41975. /**
  41976. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  41977. * Listener angles between innerAngle and outerAngle will falloff linearly.
  41978. */
  41979. get directionalConeOuterAngle(): number;
  41980. /**
  41981. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  41982. * Listener angles between innerAngle and outerAngle will falloff linearly.
  41983. */
  41984. set directionalConeOuterAngle(value: number);
  41985. /**
  41986. * Playback volume.
  41987. */
  41988. get volume(): number;
  41989. /**
  41990. * Playback volume.
  41991. */
  41992. set volume(value: number);
  41993. private _onended;
  41994. /**
  41995. * Suspend playback
  41996. */
  41997. pause(): void;
  41998. /**
  41999. * Stop playback
  42000. */
  42001. stop(): void;
  42002. /**
  42003. * Start playback.
  42004. * @param startOffset Position the clip head at a specific time in seconds.
  42005. */
  42006. play(startOffset?: number): void;
  42007. }
  42008. }
  42009. declare module BABYLON {
  42010. /**
  42011. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  42012. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42013. */
  42014. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  42015. /**
  42016. * Gets the name of the behavior.
  42017. */
  42018. get name(): string;
  42019. /**
  42020. * The easing function used by animations
  42021. */
  42022. static EasingFunction: BackEase;
  42023. /**
  42024. * The easing mode used by animations
  42025. */
  42026. static EasingMode: number;
  42027. /**
  42028. * The duration of the animation, in milliseconds
  42029. */
  42030. transitionDuration: number;
  42031. /**
  42032. * Length of the distance animated by the transition when lower radius is reached
  42033. */
  42034. lowerRadiusTransitionRange: number;
  42035. /**
  42036. * Length of the distance animated by the transition when upper radius is reached
  42037. */
  42038. upperRadiusTransitionRange: number;
  42039. private _autoTransitionRange;
  42040. /**
  42041. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42042. */
  42043. get autoTransitionRange(): boolean;
  42044. /**
  42045. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42046. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  42047. */
  42048. set autoTransitionRange(value: boolean);
  42049. private _attachedCamera;
  42050. private _onAfterCheckInputsObserver;
  42051. private _onMeshTargetChangedObserver;
  42052. /**
  42053. * Initializes the behavior.
  42054. */
  42055. init(): void;
  42056. /**
  42057. * Attaches the behavior to its arc rotate camera.
  42058. * @param camera Defines the camera to attach the behavior to
  42059. */
  42060. attach(camera: ArcRotateCamera): void;
  42061. /**
  42062. * Detaches the behavior from its current arc rotate camera.
  42063. */
  42064. detach(): void;
  42065. private _radiusIsAnimating;
  42066. private _radiusBounceTransition;
  42067. private _animatables;
  42068. private _cachedWheelPrecision;
  42069. /**
  42070. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  42071. * @param radiusLimit The limit to check against.
  42072. * @return Bool to indicate if at limit.
  42073. */
  42074. private _isRadiusAtLimit;
  42075. /**
  42076. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  42077. * @param radiusDelta The delta by which to animate to. Can be negative.
  42078. */
  42079. private _applyBoundRadiusAnimation;
  42080. /**
  42081. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  42082. */
  42083. protected _clearAnimationLocks(): void;
  42084. /**
  42085. * Stops and removes all animations that have been applied to the camera
  42086. */
  42087. stopAllAnimations(): void;
  42088. }
  42089. }
  42090. declare module BABYLON {
  42091. /**
  42092. * 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.
  42093. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42094. */
  42095. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  42096. /**
  42097. * Gets the name of the behavior.
  42098. */
  42099. get name(): string;
  42100. private _mode;
  42101. private _radiusScale;
  42102. private _positionScale;
  42103. private _defaultElevation;
  42104. private _elevationReturnTime;
  42105. private _elevationReturnWaitTime;
  42106. private _zoomStopsAnimation;
  42107. private _framingTime;
  42108. /**
  42109. * The easing function used by animations
  42110. */
  42111. static EasingFunction: ExponentialEase;
  42112. /**
  42113. * The easing mode used by animations
  42114. */
  42115. static EasingMode: number;
  42116. /**
  42117. * Sets the current mode used by the behavior
  42118. */
  42119. set mode(mode: number);
  42120. /**
  42121. * Gets current mode used by the behavior.
  42122. */
  42123. get mode(): number;
  42124. /**
  42125. * Sets the scale applied to the radius (1 by default)
  42126. */
  42127. set radiusScale(radius: number);
  42128. /**
  42129. * Gets the scale applied to the radius
  42130. */
  42131. get radiusScale(): number;
  42132. /**
  42133. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42134. */
  42135. set positionScale(scale: number);
  42136. /**
  42137. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42138. */
  42139. get positionScale(): number;
  42140. /**
  42141. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42142. * behaviour is triggered, in radians.
  42143. */
  42144. set defaultElevation(elevation: number);
  42145. /**
  42146. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42147. * behaviour is triggered, in radians.
  42148. */
  42149. get defaultElevation(): number;
  42150. /**
  42151. * Sets the time (in milliseconds) taken to return to the default beta position.
  42152. * Negative value indicates camera should not return to default.
  42153. */
  42154. set elevationReturnTime(speed: number);
  42155. /**
  42156. * Gets the time (in milliseconds) taken to return to the default beta position.
  42157. * Negative value indicates camera should not return to default.
  42158. */
  42159. get elevationReturnTime(): number;
  42160. /**
  42161. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42162. */
  42163. set elevationReturnWaitTime(time: number);
  42164. /**
  42165. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42166. */
  42167. get elevationReturnWaitTime(): number;
  42168. /**
  42169. * Sets the flag that indicates if user zooming should stop animation.
  42170. */
  42171. set zoomStopsAnimation(flag: boolean);
  42172. /**
  42173. * Gets the flag that indicates if user zooming should stop animation.
  42174. */
  42175. get zoomStopsAnimation(): boolean;
  42176. /**
  42177. * Sets the transition time when framing the mesh, in milliseconds
  42178. */
  42179. set framingTime(time: number);
  42180. /**
  42181. * Gets the transition time when framing the mesh, in milliseconds
  42182. */
  42183. get framingTime(): number;
  42184. /**
  42185. * Define if the behavior should automatically change the configured
  42186. * camera limits and sensibilities.
  42187. */
  42188. autoCorrectCameraLimitsAndSensibility: boolean;
  42189. private _onPrePointerObservableObserver;
  42190. private _onAfterCheckInputsObserver;
  42191. private _onMeshTargetChangedObserver;
  42192. private _attachedCamera;
  42193. private _isPointerDown;
  42194. private _lastInteractionTime;
  42195. /**
  42196. * Initializes the behavior.
  42197. */
  42198. init(): void;
  42199. /**
  42200. * Attaches the behavior to its arc rotate camera.
  42201. * @param camera Defines the camera to attach the behavior to
  42202. */
  42203. attach(camera: ArcRotateCamera): void;
  42204. /**
  42205. * Detaches the behavior from its current arc rotate camera.
  42206. */
  42207. detach(): void;
  42208. private _animatables;
  42209. private _betaIsAnimating;
  42210. private _betaTransition;
  42211. private _radiusTransition;
  42212. private _vectorTransition;
  42213. /**
  42214. * Targets the given mesh and updates zoom level accordingly.
  42215. * @param mesh The mesh to target.
  42216. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42217. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42218. */
  42219. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42220. /**
  42221. * Targets the given mesh with its children and updates zoom level accordingly.
  42222. * @param mesh The mesh to target.
  42223. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42224. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42225. */
  42226. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42227. /**
  42228. * Targets the given meshes with their children and updates zoom level accordingly.
  42229. * @param meshes The mesh to target.
  42230. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42231. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42232. */
  42233. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42234. /**
  42235. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  42236. * @param minimumWorld Determines the smaller position of the bounding box extend
  42237. * @param maximumWorld Determines the bigger position of the bounding box extend
  42238. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42239. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42240. */
  42241. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42242. /**
  42243. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  42244. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  42245. * frustum width.
  42246. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  42247. * to fully enclose the mesh in the viewing frustum.
  42248. */
  42249. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  42250. /**
  42251. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  42252. * is automatically returned to its default position (expected to be above ground plane).
  42253. */
  42254. private _maintainCameraAboveGround;
  42255. /**
  42256. * Returns the frustum slope based on the canvas ratio and camera FOV
  42257. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  42258. */
  42259. private _getFrustumSlope;
  42260. /**
  42261. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  42262. */
  42263. private _clearAnimationLocks;
  42264. /**
  42265. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42266. */
  42267. private _applyUserInteraction;
  42268. /**
  42269. * Stops and removes all animations that have been applied to the camera
  42270. */
  42271. stopAllAnimations(): void;
  42272. /**
  42273. * Gets a value indicating if the user is moving the camera
  42274. */
  42275. get isUserIsMoving(): boolean;
  42276. /**
  42277. * The camera can move all the way towards the mesh.
  42278. */
  42279. static IgnoreBoundsSizeMode: number;
  42280. /**
  42281. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  42282. */
  42283. static FitFrustumSidesMode: number;
  42284. }
  42285. }
  42286. declare module BABYLON {
  42287. /**
  42288. * Base class for Camera Pointer Inputs.
  42289. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  42290. * for example usage.
  42291. */
  42292. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  42293. /**
  42294. * Defines the camera the input is attached to.
  42295. */
  42296. abstract camera: Camera;
  42297. /**
  42298. * Whether keyboard modifier keys are pressed at time of last mouse event.
  42299. */
  42300. protected _altKey: boolean;
  42301. protected _ctrlKey: boolean;
  42302. protected _metaKey: boolean;
  42303. protected _shiftKey: boolean;
  42304. /**
  42305. * Which mouse buttons were pressed at time of last mouse event.
  42306. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  42307. */
  42308. protected _buttonsPressed: number;
  42309. /**
  42310. * Defines the buttons associated with the input to handle camera move.
  42311. */
  42312. buttons: number[];
  42313. /**
  42314. * Attach the input controls to a specific dom element to get the input from.
  42315. * @param element Defines the element the controls should be listened from
  42316. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42317. */
  42318. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42319. /**
  42320. * Detach the current controls from the specified dom element.
  42321. * @param element Defines the element to stop listening the inputs from
  42322. */
  42323. detachControl(element: Nullable<HTMLElement>): void;
  42324. /**
  42325. * Gets the class name of the current input.
  42326. * @returns the class name
  42327. */
  42328. getClassName(): string;
  42329. /**
  42330. * Get the friendly name associated with the input class.
  42331. * @returns the input friendly name
  42332. */
  42333. getSimpleName(): string;
  42334. /**
  42335. * Called on pointer POINTERDOUBLETAP event.
  42336. * Override this method to provide functionality on POINTERDOUBLETAP event.
  42337. */
  42338. protected onDoubleTap(type: string): void;
  42339. /**
  42340. * Called on pointer POINTERMOVE event if only a single touch is active.
  42341. * Override this method to provide functionality.
  42342. */
  42343. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42344. /**
  42345. * Called on pointer POINTERMOVE event if multiple touches are active.
  42346. * Override this method to provide functionality.
  42347. */
  42348. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42349. /**
  42350. * Called on JS contextmenu event.
  42351. * Override this method to provide functionality.
  42352. */
  42353. protected onContextMenu(evt: PointerEvent): void;
  42354. /**
  42355. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42356. * press.
  42357. * Override this method to provide functionality.
  42358. */
  42359. protected onButtonDown(evt: PointerEvent): void;
  42360. /**
  42361. * Called each time a new POINTERUP event occurs. Ie, for each button
  42362. * release.
  42363. * Override this method to provide functionality.
  42364. */
  42365. protected onButtonUp(evt: PointerEvent): void;
  42366. /**
  42367. * Called when window becomes inactive.
  42368. * Override this method to provide functionality.
  42369. */
  42370. protected onLostFocus(): void;
  42371. private _pointerInput;
  42372. private _observer;
  42373. private _onLostFocus;
  42374. private pointA;
  42375. private pointB;
  42376. }
  42377. }
  42378. declare module BABYLON {
  42379. /**
  42380. * Manage the pointers inputs to control an arc rotate camera.
  42381. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42382. */
  42383. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  42384. /**
  42385. * Defines the camera the input is attached to.
  42386. */
  42387. camera: ArcRotateCamera;
  42388. /**
  42389. * Gets the class name of the current input.
  42390. * @returns the class name
  42391. */
  42392. getClassName(): string;
  42393. /**
  42394. * Defines the buttons associated with the input to handle camera move.
  42395. */
  42396. buttons: number[];
  42397. /**
  42398. * Defines the pointer angular sensibility along the X axis or how fast is
  42399. * the camera rotating.
  42400. */
  42401. angularSensibilityX: number;
  42402. /**
  42403. * Defines the pointer angular sensibility along the Y axis or how fast is
  42404. * the camera rotating.
  42405. */
  42406. angularSensibilityY: number;
  42407. /**
  42408. * Defines the pointer pinch precision or how fast is the camera zooming.
  42409. */
  42410. pinchPrecision: number;
  42411. /**
  42412. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  42413. * from 0.
  42414. * It defines the percentage of current camera.radius to use as delta when
  42415. * pinch zoom is used.
  42416. */
  42417. pinchDeltaPercentage: number;
  42418. /**
  42419. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42420. * that any object in the plane at the camera's target point will scale
  42421. * perfectly with finger motion.
  42422. * Overrides pinchDeltaPercentage and pinchPrecision.
  42423. */
  42424. useNaturalPinchZoom: boolean;
  42425. /**
  42426. * Defines the pointer panning sensibility or how fast is the camera moving.
  42427. */
  42428. panningSensibility: number;
  42429. /**
  42430. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  42431. */
  42432. multiTouchPanning: boolean;
  42433. /**
  42434. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  42435. * zoom (pinch) through multitouch.
  42436. */
  42437. multiTouchPanAndZoom: boolean;
  42438. /**
  42439. * Revers pinch action direction.
  42440. */
  42441. pinchInwards: boolean;
  42442. private _isPanClick;
  42443. private _twoFingerActivityCount;
  42444. private _isPinching;
  42445. /**
  42446. * Called on pointer POINTERMOVE event if only a single touch is active.
  42447. */
  42448. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42449. /**
  42450. * Called on pointer POINTERDOUBLETAP event.
  42451. */
  42452. protected onDoubleTap(type: string): void;
  42453. /**
  42454. * Called on pointer POINTERMOVE event if multiple touches are active.
  42455. */
  42456. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42457. /**
  42458. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42459. * press.
  42460. */
  42461. protected onButtonDown(evt: PointerEvent): void;
  42462. /**
  42463. * Called each time a new POINTERUP event occurs. Ie, for each button
  42464. * release.
  42465. */
  42466. protected onButtonUp(evt: PointerEvent): void;
  42467. /**
  42468. * Called when window becomes inactive.
  42469. */
  42470. protected onLostFocus(): void;
  42471. }
  42472. }
  42473. declare module BABYLON {
  42474. /**
  42475. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  42476. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42477. */
  42478. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  42479. /**
  42480. * Defines the camera the input is attached to.
  42481. */
  42482. camera: ArcRotateCamera;
  42483. /**
  42484. * Defines the list of key codes associated with the up action (increase alpha)
  42485. */
  42486. keysUp: number[];
  42487. /**
  42488. * Defines the list of key codes associated with the down action (decrease alpha)
  42489. */
  42490. keysDown: number[];
  42491. /**
  42492. * Defines the list of key codes associated with the left action (increase beta)
  42493. */
  42494. keysLeft: number[];
  42495. /**
  42496. * Defines the list of key codes associated with the right action (decrease beta)
  42497. */
  42498. keysRight: number[];
  42499. /**
  42500. * Defines the list of key codes associated with the reset action.
  42501. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  42502. */
  42503. keysReset: number[];
  42504. /**
  42505. * Defines the panning sensibility of the inputs.
  42506. * (How fast is the camera panning)
  42507. */
  42508. panningSensibility: number;
  42509. /**
  42510. * Defines the zooming sensibility of the inputs.
  42511. * (How fast is the camera zooming)
  42512. */
  42513. zoomingSensibility: number;
  42514. /**
  42515. * Defines whether maintaining the alt key down switch the movement mode from
  42516. * orientation to zoom.
  42517. */
  42518. useAltToZoom: boolean;
  42519. /**
  42520. * Rotation speed of the camera
  42521. */
  42522. angularSpeed: number;
  42523. private _keys;
  42524. private _ctrlPressed;
  42525. private _altPressed;
  42526. private _onCanvasBlurObserver;
  42527. private _onKeyboardObserver;
  42528. private _engine;
  42529. private _scene;
  42530. /**
  42531. * Attach the input controls to a specific dom element to get the input from.
  42532. * @param element Defines the element the controls should be listened from
  42533. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42534. */
  42535. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42536. /**
  42537. * Detach the current controls from the specified dom element.
  42538. * @param element Defines the element to stop listening the inputs from
  42539. */
  42540. detachControl(element: Nullable<HTMLElement>): void;
  42541. /**
  42542. * Update the current camera state depending on the inputs that have been used this frame.
  42543. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42544. */
  42545. checkInputs(): void;
  42546. /**
  42547. * Gets the class name of the current intput.
  42548. * @returns the class name
  42549. */
  42550. getClassName(): string;
  42551. /**
  42552. * Get the friendly name associated with the input class.
  42553. * @returns the input friendly name
  42554. */
  42555. getSimpleName(): string;
  42556. }
  42557. }
  42558. declare module BABYLON {
  42559. /**
  42560. * Manage the mouse wheel inputs to control an arc rotate camera.
  42561. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42562. */
  42563. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  42564. /**
  42565. * Defines the camera the input is attached to.
  42566. */
  42567. camera: ArcRotateCamera;
  42568. /**
  42569. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42570. */
  42571. wheelPrecision: number;
  42572. /**
  42573. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  42574. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  42575. */
  42576. wheelDeltaPercentage: number;
  42577. private _wheel;
  42578. private _observer;
  42579. private computeDeltaFromMouseWheelLegacyEvent;
  42580. /**
  42581. * Attach the input controls to a specific dom element to get the input from.
  42582. * @param element Defines the element the controls should be listened from
  42583. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42584. */
  42585. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42586. /**
  42587. * Detach the current controls from the specified dom element.
  42588. * @param element Defines the element to stop listening the inputs from
  42589. */
  42590. detachControl(element: Nullable<HTMLElement>): void;
  42591. /**
  42592. * Gets the class name of the current intput.
  42593. * @returns the class name
  42594. */
  42595. getClassName(): string;
  42596. /**
  42597. * Get the friendly name associated with the input class.
  42598. * @returns the input friendly name
  42599. */
  42600. getSimpleName(): string;
  42601. }
  42602. }
  42603. declare module BABYLON {
  42604. /**
  42605. * Default Inputs manager for the ArcRotateCamera.
  42606. * It groups all the default supported inputs for ease of use.
  42607. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42608. */
  42609. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  42610. /**
  42611. * Instantiates a new ArcRotateCameraInputsManager.
  42612. * @param camera Defines the camera the inputs belong to
  42613. */
  42614. constructor(camera: ArcRotateCamera);
  42615. /**
  42616. * Add mouse wheel input support to the input manager.
  42617. * @returns the current input manager
  42618. */
  42619. addMouseWheel(): ArcRotateCameraInputsManager;
  42620. /**
  42621. * Add pointers input support to the input manager.
  42622. * @returns the current input manager
  42623. */
  42624. addPointers(): ArcRotateCameraInputsManager;
  42625. /**
  42626. * Add keyboard input support to the input manager.
  42627. * @returns the current input manager
  42628. */
  42629. addKeyboard(): ArcRotateCameraInputsManager;
  42630. }
  42631. }
  42632. declare module BABYLON {
  42633. /**
  42634. * This represents an orbital type of camera.
  42635. *
  42636. * 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.
  42637. * 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.
  42638. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  42639. */
  42640. export class ArcRotateCamera extends TargetCamera {
  42641. /**
  42642. * Defines the rotation angle of the camera along the longitudinal axis.
  42643. */
  42644. alpha: number;
  42645. /**
  42646. * Defines the rotation angle of the camera along the latitudinal axis.
  42647. */
  42648. beta: number;
  42649. /**
  42650. * Defines the radius of the camera from it s target point.
  42651. */
  42652. radius: number;
  42653. protected _target: Vector3;
  42654. protected _targetHost: Nullable<AbstractMesh>;
  42655. /**
  42656. * Defines the target point of the camera.
  42657. * The camera looks towards it form the radius distance.
  42658. */
  42659. get target(): Vector3;
  42660. set target(value: Vector3);
  42661. /**
  42662. * Define the current local position of the camera in the scene
  42663. */
  42664. get position(): Vector3;
  42665. set position(newPosition: Vector3);
  42666. protected _upVector: Vector3;
  42667. protected _upToYMatrix: Matrix;
  42668. protected _YToUpMatrix: Matrix;
  42669. /**
  42670. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  42671. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  42672. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  42673. */
  42674. set upVector(vec: Vector3);
  42675. get upVector(): Vector3;
  42676. /**
  42677. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  42678. */
  42679. setMatUp(): void;
  42680. /**
  42681. * Current inertia value on the longitudinal axis.
  42682. * The bigger this number the longer it will take for the camera to stop.
  42683. */
  42684. inertialAlphaOffset: number;
  42685. /**
  42686. * Current inertia value on the latitudinal axis.
  42687. * The bigger this number the longer it will take for the camera to stop.
  42688. */
  42689. inertialBetaOffset: number;
  42690. /**
  42691. * Current inertia value on the radius axis.
  42692. * The bigger this number the longer it will take for the camera to stop.
  42693. */
  42694. inertialRadiusOffset: number;
  42695. /**
  42696. * Minimum allowed angle on the longitudinal axis.
  42697. * This can help limiting how the Camera is able to move in the scene.
  42698. */
  42699. lowerAlphaLimit: Nullable<number>;
  42700. /**
  42701. * Maximum allowed angle on the longitudinal axis.
  42702. * This can help limiting how the Camera is able to move in the scene.
  42703. */
  42704. upperAlphaLimit: Nullable<number>;
  42705. /**
  42706. * Minimum allowed angle on the latitudinal axis.
  42707. * This can help limiting how the Camera is able to move in the scene.
  42708. */
  42709. lowerBetaLimit: number;
  42710. /**
  42711. * Maximum allowed angle on the latitudinal axis.
  42712. * This can help limiting how the Camera is able to move in the scene.
  42713. */
  42714. upperBetaLimit: number;
  42715. /**
  42716. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  42717. * This can help limiting how the Camera is able to move in the scene.
  42718. */
  42719. lowerRadiusLimit: Nullable<number>;
  42720. /**
  42721. * Maximum allowed distance of the camera to the target (The camera can not get further).
  42722. * This can help limiting how the Camera is able to move in the scene.
  42723. */
  42724. upperRadiusLimit: Nullable<number>;
  42725. /**
  42726. * Defines the current inertia value used during panning of the camera along the X axis.
  42727. */
  42728. inertialPanningX: number;
  42729. /**
  42730. * Defines the current inertia value used during panning of the camera along the Y axis.
  42731. */
  42732. inertialPanningY: number;
  42733. /**
  42734. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  42735. * Basically if your fingers moves away from more than this distance you will be considered
  42736. * in pinch mode.
  42737. */
  42738. pinchToPanMaxDistance: number;
  42739. /**
  42740. * Defines the maximum distance the camera can pan.
  42741. * This could help keeping the cammera always in your scene.
  42742. */
  42743. panningDistanceLimit: Nullable<number>;
  42744. /**
  42745. * Defines the target of the camera before paning.
  42746. */
  42747. panningOriginTarget: Vector3;
  42748. /**
  42749. * Defines the value of the inertia used during panning.
  42750. * 0 would mean stop inertia and one would mean no decelleration at all.
  42751. */
  42752. panningInertia: number;
  42753. /**
  42754. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  42755. */
  42756. get angularSensibilityX(): number;
  42757. set angularSensibilityX(value: number);
  42758. /**
  42759. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  42760. */
  42761. get angularSensibilityY(): number;
  42762. set angularSensibilityY(value: number);
  42763. /**
  42764. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  42765. */
  42766. get pinchPrecision(): number;
  42767. set pinchPrecision(value: number);
  42768. /**
  42769. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  42770. * It will be used instead of pinchDeltaPrecision if different from 0.
  42771. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  42772. */
  42773. get pinchDeltaPercentage(): number;
  42774. set pinchDeltaPercentage(value: number);
  42775. /**
  42776. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  42777. * and pinch delta percentage.
  42778. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42779. * that any object in the plane at the camera's target point will scale
  42780. * perfectly with finger motion.
  42781. */
  42782. get useNaturalPinchZoom(): boolean;
  42783. set useNaturalPinchZoom(value: boolean);
  42784. /**
  42785. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  42786. */
  42787. get panningSensibility(): number;
  42788. set panningSensibility(value: number);
  42789. /**
  42790. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  42791. */
  42792. get keysUp(): number[];
  42793. set keysUp(value: number[]);
  42794. /**
  42795. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  42796. */
  42797. get keysDown(): number[];
  42798. set keysDown(value: number[]);
  42799. /**
  42800. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  42801. */
  42802. get keysLeft(): number[];
  42803. set keysLeft(value: number[]);
  42804. /**
  42805. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  42806. */
  42807. get keysRight(): number[];
  42808. set keysRight(value: number[]);
  42809. /**
  42810. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42811. */
  42812. get wheelPrecision(): number;
  42813. set wheelPrecision(value: number);
  42814. /**
  42815. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  42816. * It will be used instead of pinchDeltaPrecision if different from 0.
  42817. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  42818. */
  42819. get wheelDeltaPercentage(): number;
  42820. set wheelDeltaPercentage(value: number);
  42821. /**
  42822. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  42823. */
  42824. zoomOnFactor: number;
  42825. /**
  42826. * Defines a screen offset for the camera position.
  42827. */
  42828. targetScreenOffset: Vector2;
  42829. /**
  42830. * Allows the camera to be completely reversed.
  42831. * If false the camera can not arrive upside down.
  42832. */
  42833. allowUpsideDown: boolean;
  42834. /**
  42835. * Define if double tap/click is used to restore the previously saved state of the camera.
  42836. */
  42837. useInputToRestoreState: boolean;
  42838. /** @hidden */
  42839. _viewMatrix: Matrix;
  42840. /** @hidden */
  42841. _useCtrlForPanning: boolean;
  42842. /** @hidden */
  42843. _panningMouseButton: number;
  42844. /**
  42845. * Defines the input associated to the camera.
  42846. */
  42847. inputs: ArcRotateCameraInputsManager;
  42848. /** @hidden */
  42849. _reset: () => void;
  42850. /**
  42851. * Defines the allowed panning axis.
  42852. */
  42853. panningAxis: Vector3;
  42854. protected _localDirection: Vector3;
  42855. protected _transformedDirection: Vector3;
  42856. private _bouncingBehavior;
  42857. /**
  42858. * Gets the bouncing behavior of the camera if it has been enabled.
  42859. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42860. */
  42861. get bouncingBehavior(): Nullable<BouncingBehavior>;
  42862. /**
  42863. * Defines if the bouncing behavior of the camera is enabled on the camera.
  42864. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42865. */
  42866. get useBouncingBehavior(): boolean;
  42867. set useBouncingBehavior(value: boolean);
  42868. private _framingBehavior;
  42869. /**
  42870. * Gets the framing behavior of the camera if it has been enabled.
  42871. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42872. */
  42873. get framingBehavior(): Nullable<FramingBehavior>;
  42874. /**
  42875. * Defines if the framing behavior of the camera is enabled on the camera.
  42876. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42877. */
  42878. get useFramingBehavior(): boolean;
  42879. set useFramingBehavior(value: boolean);
  42880. private _autoRotationBehavior;
  42881. /**
  42882. * Gets the auto rotation behavior of the camera if it has been enabled.
  42883. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42884. */
  42885. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  42886. /**
  42887. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  42888. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  42889. */
  42890. get useAutoRotationBehavior(): boolean;
  42891. set useAutoRotationBehavior(value: boolean);
  42892. /**
  42893. * Observable triggered when the mesh target has been changed on the camera.
  42894. */
  42895. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  42896. /**
  42897. * Event raised when the camera is colliding with a mesh.
  42898. */
  42899. onCollide: (collidedMesh: AbstractMesh) => void;
  42900. /**
  42901. * Defines whether the camera should check collision with the objects oh the scene.
  42902. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  42903. */
  42904. checkCollisions: boolean;
  42905. /**
  42906. * Defines the collision radius of the camera.
  42907. * This simulates a sphere around the camera.
  42908. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  42909. */
  42910. collisionRadius: Vector3;
  42911. protected _collider: Collider;
  42912. protected _previousPosition: Vector3;
  42913. protected _collisionVelocity: Vector3;
  42914. protected _newPosition: Vector3;
  42915. protected _previousAlpha: number;
  42916. protected _previousBeta: number;
  42917. protected _previousRadius: number;
  42918. protected _collisionTriggered: boolean;
  42919. protected _targetBoundingCenter: Nullable<Vector3>;
  42920. private _computationVector;
  42921. /**
  42922. * Instantiates a new ArcRotateCamera in a given scene
  42923. * @param name Defines the name of the camera
  42924. * @param alpha Defines the camera rotation along the logitudinal axis
  42925. * @param beta Defines the camera rotation along the latitudinal axis
  42926. * @param radius Defines the camera distance from its target
  42927. * @param target Defines the camera target
  42928. * @param scene Defines the scene the camera belongs to
  42929. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  42930. */
  42931. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  42932. /** @hidden */
  42933. _initCache(): void;
  42934. /** @hidden */
  42935. _updateCache(ignoreParentClass?: boolean): void;
  42936. protected _getTargetPosition(): Vector3;
  42937. private _storedAlpha;
  42938. private _storedBeta;
  42939. private _storedRadius;
  42940. private _storedTarget;
  42941. private _storedTargetScreenOffset;
  42942. /**
  42943. * Stores the current state of the camera (alpha, beta, radius and target)
  42944. * @returns the camera itself
  42945. */
  42946. storeState(): Camera;
  42947. /**
  42948. * @hidden
  42949. * Restored camera state. You must call storeState() first
  42950. */
  42951. _restoreStateValues(): boolean;
  42952. /** @hidden */
  42953. _isSynchronizedViewMatrix(): boolean;
  42954. /**
  42955. * Attached controls to the current camera.
  42956. * @param element Defines the element the controls should be listened from
  42957. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42958. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  42959. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  42960. */
  42961. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  42962. /**
  42963. * Detach the current controls from the camera.
  42964. * The camera will stop reacting to inputs.
  42965. * @param element Defines the element to stop listening the inputs from
  42966. */
  42967. detachControl(element: HTMLElement): void;
  42968. /** @hidden */
  42969. _checkInputs(): void;
  42970. protected _checkLimits(): void;
  42971. /**
  42972. * Rebuilds angles (alpha, beta) and radius from the give position and target
  42973. */
  42974. rebuildAnglesAndRadius(): void;
  42975. /**
  42976. * Use a position to define the current camera related information like alpha, beta and radius
  42977. * @param position Defines the position to set the camera at
  42978. */
  42979. setPosition(position: Vector3): void;
  42980. /**
  42981. * Defines the target the camera should look at.
  42982. * This will automatically adapt alpha beta and radius to fit within the new target.
  42983. * @param target Defines the new target as a Vector or a mesh
  42984. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  42985. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  42986. */
  42987. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  42988. /** @hidden */
  42989. _getViewMatrix(): Matrix;
  42990. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  42991. /**
  42992. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  42993. * @param meshes Defines the mesh to zoom on
  42994. * @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)
  42995. */
  42996. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  42997. /**
  42998. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  42999. * The target will be changed but the radius
  43000. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  43001. * @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)
  43002. */
  43003. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  43004. min: Vector3;
  43005. max: Vector3;
  43006. distance: number;
  43007. }, doNotUpdateMaxZ?: boolean): void;
  43008. /**
  43009. * @override
  43010. * Override Camera.createRigCamera
  43011. */
  43012. createRigCamera(name: string, cameraIndex: number): Camera;
  43013. /**
  43014. * @hidden
  43015. * @override
  43016. * Override Camera._updateRigCameras
  43017. */
  43018. _updateRigCameras(): void;
  43019. /**
  43020. * Destroy the camera and release the current resources hold by it.
  43021. */
  43022. dispose(): void;
  43023. /**
  43024. * Gets the current object class name.
  43025. * @return the class name
  43026. */
  43027. getClassName(): string;
  43028. }
  43029. }
  43030. declare module BABYLON {
  43031. /**
  43032. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  43033. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43034. */
  43035. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  43036. /**
  43037. * Gets the name of the behavior.
  43038. */
  43039. get name(): string;
  43040. private _zoomStopsAnimation;
  43041. private _idleRotationSpeed;
  43042. private _idleRotationWaitTime;
  43043. private _idleRotationSpinupTime;
  43044. /**
  43045. * Sets the flag that indicates if user zooming should stop animation.
  43046. */
  43047. set zoomStopsAnimation(flag: boolean);
  43048. /**
  43049. * Gets the flag that indicates if user zooming should stop animation.
  43050. */
  43051. get zoomStopsAnimation(): boolean;
  43052. /**
  43053. * Sets the default speed at which the camera rotates around the model.
  43054. */
  43055. set idleRotationSpeed(speed: number);
  43056. /**
  43057. * Gets the default speed at which the camera rotates around the model.
  43058. */
  43059. get idleRotationSpeed(): number;
  43060. /**
  43061. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  43062. */
  43063. set idleRotationWaitTime(time: number);
  43064. /**
  43065. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  43066. */
  43067. get idleRotationWaitTime(): number;
  43068. /**
  43069. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43070. */
  43071. set idleRotationSpinupTime(time: number);
  43072. /**
  43073. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43074. */
  43075. get idleRotationSpinupTime(): number;
  43076. /**
  43077. * Gets a value indicating if the camera is currently rotating because of this behavior
  43078. */
  43079. get rotationInProgress(): boolean;
  43080. private _onPrePointerObservableObserver;
  43081. private _onAfterCheckInputsObserver;
  43082. private _attachedCamera;
  43083. private _isPointerDown;
  43084. private _lastFrameTime;
  43085. private _lastInteractionTime;
  43086. private _cameraRotationSpeed;
  43087. /**
  43088. * Initializes the behavior.
  43089. */
  43090. init(): void;
  43091. /**
  43092. * Attaches the behavior to its arc rotate camera.
  43093. * @param camera Defines the camera to attach the behavior to
  43094. */
  43095. attach(camera: ArcRotateCamera): void;
  43096. /**
  43097. * Detaches the behavior from its current arc rotate camera.
  43098. */
  43099. detach(): void;
  43100. /**
  43101. * Returns true if user is scrolling.
  43102. * @return true if user is scrolling.
  43103. */
  43104. private _userIsZooming;
  43105. private _lastFrameRadius;
  43106. private _shouldAnimationStopForInteraction;
  43107. /**
  43108. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43109. */
  43110. private _applyUserInteraction;
  43111. private _userIsMoving;
  43112. }
  43113. }
  43114. declare module BABYLON {
  43115. /**
  43116. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  43117. */
  43118. export class AttachToBoxBehavior implements Behavior<Mesh> {
  43119. private ui;
  43120. /**
  43121. * The name of the behavior
  43122. */
  43123. name: string;
  43124. /**
  43125. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  43126. */
  43127. distanceAwayFromFace: number;
  43128. /**
  43129. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  43130. */
  43131. distanceAwayFromBottomOfFace: number;
  43132. private _faceVectors;
  43133. private _target;
  43134. private _scene;
  43135. private _onRenderObserver;
  43136. private _tmpMatrix;
  43137. private _tmpVector;
  43138. /**
  43139. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  43140. * @param ui The transform node that should be attched to the mesh
  43141. */
  43142. constructor(ui: TransformNode);
  43143. /**
  43144. * Initializes the behavior
  43145. */
  43146. init(): void;
  43147. private _closestFace;
  43148. private _zeroVector;
  43149. private _lookAtTmpMatrix;
  43150. private _lookAtToRef;
  43151. /**
  43152. * Attaches the AttachToBoxBehavior to the passed in mesh
  43153. * @param target The mesh that the specified node will be attached to
  43154. */
  43155. attach(target: Mesh): void;
  43156. /**
  43157. * Detaches the behavior from the mesh
  43158. */
  43159. detach(): void;
  43160. }
  43161. }
  43162. declare module BABYLON {
  43163. /**
  43164. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  43165. */
  43166. export class FadeInOutBehavior implements Behavior<Mesh> {
  43167. /**
  43168. * Time in milliseconds to delay before fading in (Default: 0)
  43169. */
  43170. delay: number;
  43171. /**
  43172. * Time in milliseconds for the mesh to fade in (Default: 300)
  43173. */
  43174. fadeInTime: number;
  43175. private _millisecondsPerFrame;
  43176. private _hovered;
  43177. private _hoverValue;
  43178. private _ownerNode;
  43179. /**
  43180. * Instatiates the FadeInOutBehavior
  43181. */
  43182. constructor();
  43183. /**
  43184. * The name of the behavior
  43185. */
  43186. get name(): string;
  43187. /**
  43188. * Initializes the behavior
  43189. */
  43190. init(): void;
  43191. /**
  43192. * Attaches the fade behavior on the passed in mesh
  43193. * @param ownerNode The mesh that will be faded in/out once attached
  43194. */
  43195. attach(ownerNode: Mesh): void;
  43196. /**
  43197. * Detaches the behavior from the mesh
  43198. */
  43199. detach(): void;
  43200. /**
  43201. * Triggers the mesh to begin fading in or out
  43202. * @param value if the object should fade in or out (true to fade in)
  43203. */
  43204. fadeIn(value: boolean): void;
  43205. private _update;
  43206. private _setAllVisibility;
  43207. }
  43208. }
  43209. declare module BABYLON {
  43210. /**
  43211. * Class containing a set of static utilities functions for managing Pivots
  43212. * @hidden
  43213. */
  43214. export class PivotTools {
  43215. private static _PivotCached;
  43216. private static _OldPivotPoint;
  43217. private static _PivotTranslation;
  43218. private static _PivotTmpVector;
  43219. /** @hidden */
  43220. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  43221. /** @hidden */
  43222. static _RestorePivotPoint(mesh: AbstractMesh): void;
  43223. }
  43224. }
  43225. declare module BABYLON {
  43226. /**
  43227. * Class containing static functions to help procedurally build meshes
  43228. */
  43229. export class PlaneBuilder {
  43230. /**
  43231. * Creates a plane mesh
  43232. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  43233. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  43234. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  43235. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43236. * * 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
  43237. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43238. * @param name defines the name of the mesh
  43239. * @param options defines the options used to create the mesh
  43240. * @param scene defines the hosting scene
  43241. * @returns the plane mesh
  43242. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  43243. */
  43244. static CreatePlane(name: string, options: {
  43245. size?: number;
  43246. width?: number;
  43247. height?: number;
  43248. sideOrientation?: number;
  43249. frontUVs?: Vector4;
  43250. backUVs?: Vector4;
  43251. updatable?: boolean;
  43252. sourcePlane?: Plane;
  43253. }, scene?: Nullable<Scene>): Mesh;
  43254. }
  43255. }
  43256. declare module BABYLON {
  43257. /**
  43258. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  43259. */
  43260. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  43261. private static _AnyMouseID;
  43262. /**
  43263. * Abstract mesh the behavior is set on
  43264. */
  43265. attachedNode: AbstractMesh;
  43266. private _dragPlane;
  43267. private _scene;
  43268. private _pointerObserver;
  43269. private _beforeRenderObserver;
  43270. private static _planeScene;
  43271. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  43272. /**
  43273. * 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)
  43274. */
  43275. maxDragAngle: number;
  43276. /**
  43277. * @hidden
  43278. */
  43279. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  43280. /**
  43281. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43282. */
  43283. currentDraggingPointerID: number;
  43284. /**
  43285. * The last position where the pointer hit the drag plane in world space
  43286. */
  43287. lastDragPosition: Vector3;
  43288. /**
  43289. * If the behavior is currently in a dragging state
  43290. */
  43291. dragging: boolean;
  43292. /**
  43293. * 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)
  43294. */
  43295. dragDeltaRatio: number;
  43296. /**
  43297. * If the drag plane orientation should be updated during the dragging (Default: true)
  43298. */
  43299. updateDragPlane: boolean;
  43300. private _debugMode;
  43301. private _moving;
  43302. /**
  43303. * Fires each time the attached mesh is dragged with the pointer
  43304. * * delta between last drag position and current drag position in world space
  43305. * * dragDistance along the drag axis
  43306. * * dragPlaneNormal normal of the current drag plane used during the drag
  43307. * * dragPlanePoint in world space where the drag intersects the drag plane
  43308. */
  43309. onDragObservable: Observable<{
  43310. delta: Vector3;
  43311. dragPlanePoint: Vector3;
  43312. dragPlaneNormal: Vector3;
  43313. dragDistance: number;
  43314. pointerId: number;
  43315. }>;
  43316. /**
  43317. * Fires each time a drag begins (eg. mouse down on mesh)
  43318. */
  43319. onDragStartObservable: Observable<{
  43320. dragPlanePoint: Vector3;
  43321. pointerId: number;
  43322. }>;
  43323. /**
  43324. * Fires each time a drag ends (eg. mouse release after drag)
  43325. */
  43326. onDragEndObservable: Observable<{
  43327. dragPlanePoint: Vector3;
  43328. pointerId: number;
  43329. }>;
  43330. /**
  43331. * If the attached mesh should be moved when dragged
  43332. */
  43333. moveAttached: boolean;
  43334. /**
  43335. * If the drag behavior will react to drag events (Default: true)
  43336. */
  43337. enabled: boolean;
  43338. /**
  43339. * If pointer events should start and release the drag (Default: true)
  43340. */
  43341. startAndReleaseDragOnPointerEvents: boolean;
  43342. /**
  43343. * If camera controls should be detached during the drag
  43344. */
  43345. detachCameraControls: boolean;
  43346. /**
  43347. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  43348. */
  43349. useObjectOrientationForDragging: boolean;
  43350. private _options;
  43351. /**
  43352. * Gets the options used by the behavior
  43353. */
  43354. get options(): {
  43355. dragAxis?: Vector3;
  43356. dragPlaneNormal?: Vector3;
  43357. };
  43358. /**
  43359. * Sets the options used by the behavior
  43360. */
  43361. set options(options: {
  43362. dragAxis?: Vector3;
  43363. dragPlaneNormal?: Vector3;
  43364. });
  43365. /**
  43366. * Creates a pointer drag behavior that can be attached to a mesh
  43367. * @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)
  43368. */
  43369. constructor(options?: {
  43370. dragAxis?: Vector3;
  43371. dragPlaneNormal?: Vector3;
  43372. });
  43373. /**
  43374. * Predicate to determine if it is valid to move the object to a new position when it is moved
  43375. */
  43376. validateDrag: (targetPosition: Vector3) => boolean;
  43377. /**
  43378. * The name of the behavior
  43379. */
  43380. get name(): string;
  43381. /**
  43382. * Initializes the behavior
  43383. */
  43384. init(): void;
  43385. private _tmpVector;
  43386. private _alternatePickedPoint;
  43387. private _worldDragAxis;
  43388. private _targetPosition;
  43389. private _attachedElement;
  43390. /**
  43391. * Attaches the drag behavior the passed in mesh
  43392. * @param ownerNode The mesh that will be dragged around once attached
  43393. * @param predicate Predicate to use for pick filtering
  43394. */
  43395. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  43396. /**
  43397. * Force relase the drag action by code.
  43398. */
  43399. releaseDrag(): void;
  43400. private _startDragRay;
  43401. private _lastPointerRay;
  43402. /**
  43403. * Simulates the start of a pointer drag event on the behavior
  43404. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  43405. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  43406. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  43407. */
  43408. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  43409. private _startDrag;
  43410. private _dragDelta;
  43411. private _moveDrag;
  43412. private _pickWithRayOnDragPlane;
  43413. private _pointA;
  43414. private _pointC;
  43415. private _localAxis;
  43416. private _lookAt;
  43417. private _updateDragPlanePosition;
  43418. /**
  43419. * Detaches the behavior from the mesh
  43420. */
  43421. detach(): void;
  43422. }
  43423. }
  43424. declare module BABYLON {
  43425. /**
  43426. * A behavior that when attached to a mesh will allow the mesh to be scaled
  43427. */
  43428. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  43429. private _dragBehaviorA;
  43430. private _dragBehaviorB;
  43431. private _startDistance;
  43432. private _initialScale;
  43433. private _targetScale;
  43434. private _ownerNode;
  43435. private _sceneRenderObserver;
  43436. /**
  43437. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  43438. */
  43439. constructor();
  43440. /**
  43441. * The name of the behavior
  43442. */
  43443. get name(): string;
  43444. /**
  43445. * Initializes the behavior
  43446. */
  43447. init(): void;
  43448. private _getCurrentDistance;
  43449. /**
  43450. * Attaches the scale behavior the passed in mesh
  43451. * @param ownerNode The mesh that will be scaled around once attached
  43452. */
  43453. attach(ownerNode: Mesh): void;
  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 dragged around based on directions and origin of the pointer's ray
  43463. */
  43464. export class SixDofDragBehavior implements Behavior<Mesh> {
  43465. private static _virtualScene;
  43466. private _ownerNode;
  43467. private _sceneRenderObserver;
  43468. private _scene;
  43469. private _targetPosition;
  43470. private _virtualOriginMesh;
  43471. private _virtualDragMesh;
  43472. private _pointerObserver;
  43473. private _moving;
  43474. private _startingOrientation;
  43475. private _attachedElement;
  43476. /**
  43477. * 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)
  43478. */
  43479. private zDragFactor;
  43480. /**
  43481. * If the object should rotate to face the drag origin
  43482. */
  43483. rotateDraggedObject: boolean;
  43484. /**
  43485. * If the behavior is currently in a dragging state
  43486. */
  43487. dragging: boolean;
  43488. /**
  43489. * 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)
  43490. */
  43491. dragDeltaRatio: number;
  43492. /**
  43493. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43494. */
  43495. currentDraggingPointerID: number;
  43496. /**
  43497. * If camera controls should be detached during the drag
  43498. */
  43499. detachCameraControls: boolean;
  43500. /**
  43501. * Fires each time a drag starts
  43502. */
  43503. onDragStartObservable: Observable<{}>;
  43504. /**
  43505. * Fires each time a drag ends (eg. mouse release after drag)
  43506. */
  43507. onDragEndObservable: Observable<{}>;
  43508. /**
  43509. * 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
  43510. */
  43511. constructor();
  43512. /**
  43513. * The name of the behavior
  43514. */
  43515. get name(): string;
  43516. /**
  43517. * Initializes the behavior
  43518. */
  43519. init(): void;
  43520. /**
  43521. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  43522. */
  43523. private get _pointerCamera();
  43524. /**
  43525. * Attaches the scale behavior the passed in mesh
  43526. * @param ownerNode The mesh that will be scaled around once attached
  43527. */
  43528. attach(ownerNode: Mesh): void;
  43529. /**
  43530. * Detaches the behavior from the mesh
  43531. */
  43532. detach(): void;
  43533. }
  43534. }
  43535. declare module BABYLON {
  43536. /**
  43537. * Class used to apply inverse kinematics to bones
  43538. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  43539. */
  43540. export class BoneIKController {
  43541. private static _tmpVecs;
  43542. private static _tmpQuat;
  43543. private static _tmpMats;
  43544. /**
  43545. * Gets or sets the target mesh
  43546. */
  43547. targetMesh: AbstractMesh;
  43548. /** Gets or sets the mesh used as pole */
  43549. poleTargetMesh: AbstractMesh;
  43550. /**
  43551. * Gets or sets the bone used as pole
  43552. */
  43553. poleTargetBone: Nullable<Bone>;
  43554. /**
  43555. * Gets or sets the target position
  43556. */
  43557. targetPosition: Vector3;
  43558. /**
  43559. * Gets or sets the pole target position
  43560. */
  43561. poleTargetPosition: Vector3;
  43562. /**
  43563. * Gets or sets the pole target local offset
  43564. */
  43565. poleTargetLocalOffset: Vector3;
  43566. /**
  43567. * Gets or sets the pole angle
  43568. */
  43569. poleAngle: number;
  43570. /**
  43571. * Gets or sets the mesh associated with the controller
  43572. */
  43573. mesh: AbstractMesh;
  43574. /**
  43575. * 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)
  43576. */
  43577. slerpAmount: number;
  43578. private _bone1Quat;
  43579. private _bone1Mat;
  43580. private _bone2Ang;
  43581. private _bone1;
  43582. private _bone2;
  43583. private _bone1Length;
  43584. private _bone2Length;
  43585. private _maxAngle;
  43586. private _maxReach;
  43587. private _rightHandedSystem;
  43588. private _bendAxis;
  43589. private _slerping;
  43590. private _adjustRoll;
  43591. /**
  43592. * Gets or sets maximum allowed angle
  43593. */
  43594. get maxAngle(): number;
  43595. set maxAngle(value: number);
  43596. /**
  43597. * Creates a new BoneIKController
  43598. * @param mesh defines the mesh to control
  43599. * @param bone defines the bone to control
  43600. * @param options defines options to set up the controller
  43601. */
  43602. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  43603. targetMesh?: AbstractMesh;
  43604. poleTargetMesh?: AbstractMesh;
  43605. poleTargetBone?: Bone;
  43606. poleTargetLocalOffset?: Vector3;
  43607. poleAngle?: number;
  43608. bendAxis?: Vector3;
  43609. maxAngle?: number;
  43610. slerpAmount?: number;
  43611. });
  43612. private _setMaxAngle;
  43613. /**
  43614. * Force the controller to update the bones
  43615. */
  43616. update(): void;
  43617. }
  43618. }
  43619. declare module BABYLON {
  43620. /**
  43621. * Class used to make a bone look toward a point in space
  43622. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  43623. */
  43624. export class BoneLookController {
  43625. private static _tmpVecs;
  43626. private static _tmpQuat;
  43627. private static _tmpMats;
  43628. /**
  43629. * The target Vector3 that the bone will look at
  43630. */
  43631. target: Vector3;
  43632. /**
  43633. * The mesh that the bone is attached to
  43634. */
  43635. mesh: AbstractMesh;
  43636. /**
  43637. * The bone that will be looking to the target
  43638. */
  43639. bone: Bone;
  43640. /**
  43641. * The up axis of the coordinate system that is used when the bone is rotated
  43642. */
  43643. upAxis: Vector3;
  43644. /**
  43645. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  43646. */
  43647. upAxisSpace: Space;
  43648. /**
  43649. * Used to make an adjustment to the yaw of the bone
  43650. */
  43651. adjustYaw: number;
  43652. /**
  43653. * Used to make an adjustment to the pitch of the bone
  43654. */
  43655. adjustPitch: number;
  43656. /**
  43657. * Used to make an adjustment to the roll of the bone
  43658. */
  43659. adjustRoll: number;
  43660. /**
  43661. * 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)
  43662. */
  43663. slerpAmount: number;
  43664. private _minYaw;
  43665. private _maxYaw;
  43666. private _minPitch;
  43667. private _maxPitch;
  43668. private _minYawSin;
  43669. private _minYawCos;
  43670. private _maxYawSin;
  43671. private _maxYawCos;
  43672. private _midYawConstraint;
  43673. private _minPitchTan;
  43674. private _maxPitchTan;
  43675. private _boneQuat;
  43676. private _slerping;
  43677. private _transformYawPitch;
  43678. private _transformYawPitchInv;
  43679. private _firstFrameSkipped;
  43680. private _yawRange;
  43681. private _fowardAxis;
  43682. /**
  43683. * Gets or sets the minimum yaw angle that the bone can look to
  43684. */
  43685. get minYaw(): number;
  43686. set minYaw(value: number);
  43687. /**
  43688. * Gets or sets the maximum yaw angle that the bone can look to
  43689. */
  43690. get maxYaw(): number;
  43691. set maxYaw(value: number);
  43692. /**
  43693. * Gets or sets the minimum pitch angle that the bone can look to
  43694. */
  43695. get minPitch(): number;
  43696. set minPitch(value: number);
  43697. /**
  43698. * Gets or sets the maximum pitch angle that the bone can look to
  43699. */
  43700. get maxPitch(): number;
  43701. set maxPitch(value: number);
  43702. /**
  43703. * Create a BoneLookController
  43704. * @param mesh the mesh that the bone belongs to
  43705. * @param bone the bone that will be looking to the target
  43706. * @param target the target Vector3 to look at
  43707. * @param options optional settings:
  43708. * * maxYaw: the maximum angle the bone will yaw to
  43709. * * minYaw: the minimum angle the bone will yaw to
  43710. * * maxPitch: the maximum angle the bone will pitch to
  43711. * * minPitch: the minimum angle the bone will yaw to
  43712. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  43713. * * upAxis: the up axis of the coordinate system
  43714. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  43715. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  43716. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  43717. * * adjustYaw: used to make an adjustment to the yaw of the bone
  43718. * * adjustPitch: used to make an adjustment to the pitch of the bone
  43719. * * adjustRoll: used to make an adjustment to the roll of the bone
  43720. **/
  43721. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  43722. maxYaw?: number;
  43723. minYaw?: number;
  43724. maxPitch?: number;
  43725. minPitch?: number;
  43726. slerpAmount?: number;
  43727. upAxis?: Vector3;
  43728. upAxisSpace?: Space;
  43729. yawAxis?: Vector3;
  43730. pitchAxis?: Vector3;
  43731. adjustYaw?: number;
  43732. adjustPitch?: number;
  43733. adjustRoll?: number;
  43734. });
  43735. /**
  43736. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  43737. */
  43738. update(): void;
  43739. private _getAngleDiff;
  43740. private _getAngleBetween;
  43741. private _isAngleBetween;
  43742. }
  43743. }
  43744. declare module BABYLON {
  43745. /**
  43746. * Manage the gamepad inputs to control an arc rotate camera.
  43747. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43748. */
  43749. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  43750. /**
  43751. * Defines the camera the input is attached to.
  43752. */
  43753. camera: ArcRotateCamera;
  43754. /**
  43755. * Defines the gamepad the input is gathering event from.
  43756. */
  43757. gamepad: Nullable<Gamepad>;
  43758. /**
  43759. * Defines the gamepad rotation sensiblity.
  43760. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43761. */
  43762. gamepadRotationSensibility: number;
  43763. /**
  43764. * Defines the gamepad move sensiblity.
  43765. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43766. */
  43767. gamepadMoveSensibility: number;
  43768. private _yAxisScale;
  43769. /**
  43770. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  43771. */
  43772. get invertYAxis(): boolean;
  43773. set invertYAxis(value: boolean);
  43774. private _onGamepadConnectedObserver;
  43775. private _onGamepadDisconnectedObserver;
  43776. /**
  43777. * Attach the input controls to a specific dom element to get the input from.
  43778. * @param element Defines the element the controls should be listened from
  43779. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43780. */
  43781. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43782. /**
  43783. * Detach the current controls from the specified dom element.
  43784. * @param element Defines the element to stop listening the inputs from
  43785. */
  43786. detachControl(element: Nullable<HTMLElement>): void;
  43787. /**
  43788. * Update the current camera state depending on the inputs that have been used this frame.
  43789. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43790. */
  43791. checkInputs(): void;
  43792. /**
  43793. * Gets the class name of the current intput.
  43794. * @returns the class name
  43795. */
  43796. getClassName(): string;
  43797. /**
  43798. * Get the friendly name associated with the input class.
  43799. * @returns the input friendly name
  43800. */
  43801. getSimpleName(): string;
  43802. }
  43803. }
  43804. declare module BABYLON {
  43805. interface ArcRotateCameraInputsManager {
  43806. /**
  43807. * Add orientation input support to the input manager.
  43808. * @returns the current input manager
  43809. */
  43810. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  43811. }
  43812. /**
  43813. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  43814. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43815. */
  43816. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  43817. /**
  43818. * Defines the camera the input is attached to.
  43819. */
  43820. camera: ArcRotateCamera;
  43821. /**
  43822. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  43823. */
  43824. alphaCorrection: number;
  43825. /**
  43826. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  43827. */
  43828. gammaCorrection: number;
  43829. private _alpha;
  43830. private _gamma;
  43831. private _dirty;
  43832. private _deviceOrientationHandler;
  43833. /**
  43834. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  43835. */
  43836. constructor();
  43837. /**
  43838. * Attach the input controls to a specific dom element to get the input from.
  43839. * @param element Defines the element the controls should be listened from
  43840. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43841. */
  43842. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43843. /** @hidden */
  43844. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  43845. /**
  43846. * Update the current camera state depending on the inputs that have been used this frame.
  43847. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43848. */
  43849. checkInputs(): void;
  43850. /**
  43851. * Detach the current controls from the specified dom element.
  43852. * @param element Defines the element to stop listening the inputs from
  43853. */
  43854. detachControl(element: Nullable<HTMLElement>): void;
  43855. /**
  43856. * Gets the class name of the current intput.
  43857. * @returns the class name
  43858. */
  43859. getClassName(): string;
  43860. /**
  43861. * Get the friendly name associated with the input class.
  43862. * @returns the input friendly name
  43863. */
  43864. getSimpleName(): string;
  43865. }
  43866. }
  43867. declare module BABYLON {
  43868. /**
  43869. * Listen to mouse events to control the camera.
  43870. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43871. */
  43872. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  43873. /**
  43874. * Defines the camera the input is attached to.
  43875. */
  43876. camera: FlyCamera;
  43877. /**
  43878. * Defines if touch is enabled. (Default is true.)
  43879. */
  43880. touchEnabled: boolean;
  43881. /**
  43882. * Defines the buttons associated with the input to handle camera rotation.
  43883. */
  43884. buttons: number[];
  43885. /**
  43886. * Assign buttons for Yaw control.
  43887. */
  43888. buttonsYaw: number[];
  43889. /**
  43890. * Assign buttons for Pitch control.
  43891. */
  43892. buttonsPitch: number[];
  43893. /**
  43894. * Assign buttons for Roll control.
  43895. */
  43896. buttonsRoll: number[];
  43897. /**
  43898. * Detect if any button is being pressed while mouse is moved.
  43899. * -1 = Mouse locked.
  43900. * 0 = Left button.
  43901. * 1 = Middle Button.
  43902. * 2 = Right Button.
  43903. */
  43904. activeButton: number;
  43905. /**
  43906. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  43907. * Higher values reduce its sensitivity.
  43908. */
  43909. angularSensibility: number;
  43910. private _mousemoveCallback;
  43911. private _observer;
  43912. private _rollObserver;
  43913. private previousPosition;
  43914. private noPreventDefault;
  43915. private element;
  43916. /**
  43917. * Listen to mouse events to control the camera.
  43918. * @param touchEnabled Define if touch is enabled. (Default is true.)
  43919. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43920. */
  43921. constructor(touchEnabled?: boolean);
  43922. /**
  43923. * Attach the mouse control to the HTML DOM element.
  43924. * @param element Defines the element that listens to the input events.
  43925. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  43926. */
  43927. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43928. /**
  43929. * Detach the current controls from the specified dom element.
  43930. * @param element Defines the element to stop listening the inputs from
  43931. */
  43932. detachControl(element: Nullable<HTMLElement>): void;
  43933. /**
  43934. * Gets the class name of the current input.
  43935. * @returns the class name.
  43936. */
  43937. getClassName(): string;
  43938. /**
  43939. * Get the friendly name associated with the input class.
  43940. * @returns the input's friendly name.
  43941. */
  43942. getSimpleName(): string;
  43943. private _pointerInput;
  43944. private _onMouseMove;
  43945. /**
  43946. * Rotate camera by mouse offset.
  43947. */
  43948. private rotateCamera;
  43949. }
  43950. }
  43951. declare module BABYLON {
  43952. /**
  43953. * Default Inputs manager for the FlyCamera.
  43954. * It groups all the default supported inputs for ease of use.
  43955. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43956. */
  43957. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  43958. /**
  43959. * Instantiates a new FlyCameraInputsManager.
  43960. * @param camera Defines the camera the inputs belong to.
  43961. */
  43962. constructor(camera: FlyCamera);
  43963. /**
  43964. * Add keyboard input support to the input manager.
  43965. * @returns the new FlyCameraKeyboardMoveInput().
  43966. */
  43967. addKeyboard(): FlyCameraInputsManager;
  43968. /**
  43969. * Add mouse input support to the input manager.
  43970. * @param touchEnabled Enable touch screen support.
  43971. * @returns the new FlyCameraMouseInput().
  43972. */
  43973. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  43974. }
  43975. }
  43976. declare module BABYLON {
  43977. /**
  43978. * This is a flying camera, designed for 3D movement and rotation in all directions,
  43979. * such as in a 3D Space Shooter or a Flight Simulator.
  43980. */
  43981. export class FlyCamera extends TargetCamera {
  43982. /**
  43983. * Define the collision ellipsoid of the camera.
  43984. * This is helpful for simulating a camera body, like a player's body.
  43985. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43986. */
  43987. ellipsoid: Vector3;
  43988. /**
  43989. * Define an offset for the position of the ellipsoid around the camera.
  43990. * This can be helpful if the camera is attached away from the player's body center,
  43991. * such as at its head.
  43992. */
  43993. ellipsoidOffset: Vector3;
  43994. /**
  43995. * Enable or disable collisions of the camera with the rest of the scene objects.
  43996. */
  43997. checkCollisions: boolean;
  43998. /**
  43999. * Enable or disable gravity on the camera.
  44000. */
  44001. applyGravity: boolean;
  44002. /**
  44003. * Define the current direction the camera is moving to.
  44004. */
  44005. cameraDirection: Vector3;
  44006. /**
  44007. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  44008. * This overrides and empties cameraRotation.
  44009. */
  44010. rotationQuaternion: Quaternion;
  44011. /**
  44012. * Track Roll to maintain the wanted Rolling when looking around.
  44013. */
  44014. _trackRoll: number;
  44015. /**
  44016. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  44017. */
  44018. rollCorrect: number;
  44019. /**
  44020. * Mimic a banked turn, Rolling the camera when Yawing.
  44021. * It's recommended to use rollCorrect = 10 for faster banking correction.
  44022. */
  44023. bankedTurn: boolean;
  44024. /**
  44025. * Limit in radians for how much Roll banking will add. (Default: 90°)
  44026. */
  44027. bankedTurnLimit: number;
  44028. /**
  44029. * Value of 0 disables the banked Roll.
  44030. * Value of 1 is equal to the Yaw angle in radians.
  44031. */
  44032. bankedTurnMultiplier: number;
  44033. /**
  44034. * The inputs manager loads all the input sources, such as keyboard and mouse.
  44035. */
  44036. inputs: FlyCameraInputsManager;
  44037. /**
  44038. * Gets the input sensibility for mouse input.
  44039. * Higher values reduce sensitivity.
  44040. */
  44041. get angularSensibility(): number;
  44042. /**
  44043. * Sets the input sensibility for a mouse input.
  44044. * Higher values reduce sensitivity.
  44045. */
  44046. set angularSensibility(value: number);
  44047. /**
  44048. * Get the keys for camera movement forward.
  44049. */
  44050. get keysForward(): number[];
  44051. /**
  44052. * Set the keys for camera movement forward.
  44053. */
  44054. set keysForward(value: number[]);
  44055. /**
  44056. * Get the keys for camera movement backward.
  44057. */
  44058. get keysBackward(): number[];
  44059. set keysBackward(value: number[]);
  44060. /**
  44061. * Get the keys for camera movement up.
  44062. */
  44063. get keysUp(): number[];
  44064. /**
  44065. * Set the keys for camera movement up.
  44066. */
  44067. set keysUp(value: number[]);
  44068. /**
  44069. * Get the keys for camera movement down.
  44070. */
  44071. get keysDown(): number[];
  44072. /**
  44073. * Set the keys for camera movement down.
  44074. */
  44075. set keysDown(value: number[]);
  44076. /**
  44077. * Get the keys for camera movement left.
  44078. */
  44079. get keysLeft(): number[];
  44080. /**
  44081. * Set the keys for camera movement left.
  44082. */
  44083. set keysLeft(value: number[]);
  44084. /**
  44085. * Set the keys for camera movement right.
  44086. */
  44087. get keysRight(): number[];
  44088. /**
  44089. * Set the keys for camera movement right.
  44090. */
  44091. set keysRight(value: number[]);
  44092. /**
  44093. * Event raised when the camera collides with a mesh in the scene.
  44094. */
  44095. onCollide: (collidedMesh: AbstractMesh) => void;
  44096. private _collider;
  44097. private _needMoveForGravity;
  44098. private _oldPosition;
  44099. private _diffPosition;
  44100. private _newPosition;
  44101. /** @hidden */
  44102. _localDirection: Vector3;
  44103. /** @hidden */
  44104. _transformedDirection: Vector3;
  44105. /**
  44106. * Instantiates a FlyCamera.
  44107. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44108. * such as in a 3D Space Shooter or a Flight Simulator.
  44109. * @param name Define the name of the camera in the scene.
  44110. * @param position Define the starting position of the camera in the scene.
  44111. * @param scene Define the scene the camera belongs to.
  44112. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  44113. */
  44114. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44115. /**
  44116. * Attach a control to the HTML DOM element.
  44117. * @param element Defines the element that listens to the input events.
  44118. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  44119. */
  44120. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44121. /**
  44122. * Detach a control from the HTML DOM element.
  44123. * The camera will stop reacting to that input.
  44124. * @param element Defines the element that listens to the input events.
  44125. */
  44126. detachControl(element: HTMLElement): void;
  44127. private _collisionMask;
  44128. /**
  44129. * Get the mask that the camera ignores in collision events.
  44130. */
  44131. get collisionMask(): number;
  44132. /**
  44133. * Set the mask that the camera ignores in collision events.
  44134. */
  44135. set collisionMask(mask: number);
  44136. /** @hidden */
  44137. _collideWithWorld(displacement: Vector3): void;
  44138. /** @hidden */
  44139. private _onCollisionPositionChange;
  44140. /** @hidden */
  44141. _checkInputs(): void;
  44142. /** @hidden */
  44143. _decideIfNeedsToMove(): boolean;
  44144. /** @hidden */
  44145. _updatePosition(): void;
  44146. /**
  44147. * Restore the Roll to its target value at the rate specified.
  44148. * @param rate - Higher means slower restoring.
  44149. * @hidden
  44150. */
  44151. restoreRoll(rate: number): void;
  44152. /**
  44153. * Destroy the camera and release the current resources held by it.
  44154. */
  44155. dispose(): void;
  44156. /**
  44157. * Get the current object class name.
  44158. * @returns the class name.
  44159. */
  44160. getClassName(): string;
  44161. }
  44162. }
  44163. declare module BABYLON {
  44164. /**
  44165. * Listen to keyboard events to control the camera.
  44166. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44167. */
  44168. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  44169. /**
  44170. * Defines the camera the input is attached to.
  44171. */
  44172. camera: FlyCamera;
  44173. /**
  44174. * The list of keyboard keys used to control the forward move of the camera.
  44175. */
  44176. keysForward: number[];
  44177. /**
  44178. * The list of keyboard keys used to control the backward move of the camera.
  44179. */
  44180. keysBackward: number[];
  44181. /**
  44182. * The list of keyboard keys used to control the forward move of the camera.
  44183. */
  44184. keysUp: number[];
  44185. /**
  44186. * The list of keyboard keys used to control the backward move of the camera.
  44187. */
  44188. keysDown: number[];
  44189. /**
  44190. * The list of keyboard keys used to control the right strafe move of the camera.
  44191. */
  44192. keysRight: number[];
  44193. /**
  44194. * The list of keyboard keys used to control the left strafe move of the camera.
  44195. */
  44196. keysLeft: number[];
  44197. private _keys;
  44198. private _onCanvasBlurObserver;
  44199. private _onKeyboardObserver;
  44200. private _engine;
  44201. private _scene;
  44202. /**
  44203. * Attach the input controls to a specific dom element to get the input from.
  44204. * @param element Defines the element the controls should be listened from
  44205. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44206. */
  44207. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44208. /**
  44209. * Detach the current controls from the specified dom element.
  44210. * @param element Defines the element to stop listening the inputs from
  44211. */
  44212. detachControl(element: Nullable<HTMLElement>): void;
  44213. /**
  44214. * Gets the class name of the current intput.
  44215. * @returns the class name
  44216. */
  44217. getClassName(): string;
  44218. /** @hidden */
  44219. _onLostFocus(e: FocusEvent): void;
  44220. /**
  44221. * Get the friendly name associated with the input class.
  44222. * @returns the input friendly name
  44223. */
  44224. getSimpleName(): string;
  44225. /**
  44226. * Update the current camera state depending on the inputs that have been used this frame.
  44227. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44228. */
  44229. checkInputs(): void;
  44230. }
  44231. }
  44232. declare module BABYLON {
  44233. /**
  44234. * Manage the mouse wheel inputs to control a follow camera.
  44235. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44236. */
  44237. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  44238. /**
  44239. * Defines the camera the input is attached to.
  44240. */
  44241. camera: FollowCamera;
  44242. /**
  44243. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  44244. */
  44245. axisControlRadius: boolean;
  44246. /**
  44247. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  44248. */
  44249. axisControlHeight: boolean;
  44250. /**
  44251. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  44252. */
  44253. axisControlRotation: boolean;
  44254. /**
  44255. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  44256. * relation to mouseWheel events.
  44257. */
  44258. wheelPrecision: number;
  44259. /**
  44260. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44261. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44262. */
  44263. wheelDeltaPercentage: number;
  44264. private _wheel;
  44265. private _observer;
  44266. /**
  44267. * Attach the input controls to a specific dom element to get the input from.
  44268. * @param element Defines the element the controls should be listened from
  44269. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44270. */
  44271. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44272. /**
  44273. * Detach the current controls from the specified dom element.
  44274. * @param element Defines the element to stop listening the inputs from
  44275. */
  44276. detachControl(element: Nullable<HTMLElement>): void;
  44277. /**
  44278. * Gets the class name of the current intput.
  44279. * @returns the class name
  44280. */
  44281. getClassName(): string;
  44282. /**
  44283. * Get the friendly name associated with the input class.
  44284. * @returns the input friendly name
  44285. */
  44286. getSimpleName(): string;
  44287. }
  44288. }
  44289. declare module BABYLON {
  44290. /**
  44291. * Manage the pointers inputs to control an follow camera.
  44292. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44293. */
  44294. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  44295. /**
  44296. * Defines the camera the input is attached to.
  44297. */
  44298. camera: FollowCamera;
  44299. /**
  44300. * Gets the class name of the current input.
  44301. * @returns the class name
  44302. */
  44303. getClassName(): string;
  44304. /**
  44305. * Defines the pointer angular sensibility along the X axis or how fast is
  44306. * the camera rotating.
  44307. * A negative number will reverse the axis direction.
  44308. */
  44309. angularSensibilityX: number;
  44310. /**
  44311. * Defines the pointer angular sensibility along the Y axis or how fast is
  44312. * the camera rotating.
  44313. * A negative number will reverse the axis direction.
  44314. */
  44315. angularSensibilityY: number;
  44316. /**
  44317. * Defines the pointer pinch precision or how fast is the camera zooming.
  44318. * A negative number will reverse the axis direction.
  44319. */
  44320. pinchPrecision: number;
  44321. /**
  44322. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44323. * from 0.
  44324. * It defines the percentage of current camera.radius to use as delta when
  44325. * pinch zoom is used.
  44326. */
  44327. pinchDeltaPercentage: number;
  44328. /**
  44329. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  44330. */
  44331. axisXControlRadius: boolean;
  44332. /**
  44333. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  44334. */
  44335. axisXControlHeight: boolean;
  44336. /**
  44337. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  44338. */
  44339. axisXControlRotation: boolean;
  44340. /**
  44341. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  44342. */
  44343. axisYControlRadius: boolean;
  44344. /**
  44345. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  44346. */
  44347. axisYControlHeight: boolean;
  44348. /**
  44349. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  44350. */
  44351. axisYControlRotation: boolean;
  44352. /**
  44353. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  44354. */
  44355. axisPinchControlRadius: boolean;
  44356. /**
  44357. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  44358. */
  44359. axisPinchControlHeight: boolean;
  44360. /**
  44361. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  44362. */
  44363. axisPinchControlRotation: boolean;
  44364. /**
  44365. * Log error messages if basic misconfiguration has occurred.
  44366. */
  44367. warningEnable: boolean;
  44368. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44369. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44370. private _warningCounter;
  44371. private _warning;
  44372. }
  44373. }
  44374. declare module BABYLON {
  44375. /**
  44376. * Default Inputs manager for the FollowCamera.
  44377. * It groups all the default supported inputs for ease of use.
  44378. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44379. */
  44380. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  44381. /**
  44382. * Instantiates a new FollowCameraInputsManager.
  44383. * @param camera Defines the camera the inputs belong to
  44384. */
  44385. constructor(camera: FollowCamera);
  44386. /**
  44387. * Add keyboard input support to the input manager.
  44388. * @returns the current input manager
  44389. */
  44390. addKeyboard(): FollowCameraInputsManager;
  44391. /**
  44392. * Add mouse wheel input support to the input manager.
  44393. * @returns the current input manager
  44394. */
  44395. addMouseWheel(): FollowCameraInputsManager;
  44396. /**
  44397. * Add pointers input support to the input manager.
  44398. * @returns the current input manager
  44399. */
  44400. addPointers(): FollowCameraInputsManager;
  44401. /**
  44402. * Add orientation input support to the input manager.
  44403. * @returns the current input manager
  44404. */
  44405. addVRDeviceOrientation(): FollowCameraInputsManager;
  44406. }
  44407. }
  44408. declare module BABYLON {
  44409. /**
  44410. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  44411. * an arc rotate version arcFollowCamera are available.
  44412. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44413. */
  44414. export class FollowCamera extends TargetCamera {
  44415. /**
  44416. * Distance the follow camera should follow an object at
  44417. */
  44418. radius: number;
  44419. /**
  44420. * Minimum allowed distance of the camera to the axis of rotation
  44421. * (The camera can not get closer).
  44422. * This can help limiting how the Camera is able to move in the scene.
  44423. */
  44424. lowerRadiusLimit: Nullable<number>;
  44425. /**
  44426. * Maximum allowed distance of the camera to the axis of rotation
  44427. * (The camera can not get further).
  44428. * This can help limiting how the Camera is able to move in the scene.
  44429. */
  44430. upperRadiusLimit: Nullable<number>;
  44431. /**
  44432. * Define a rotation offset between the camera and the object it follows
  44433. */
  44434. rotationOffset: number;
  44435. /**
  44436. * Minimum allowed angle to camera position relative to target object.
  44437. * This can help limiting how the Camera is able to move in the scene.
  44438. */
  44439. lowerRotationOffsetLimit: Nullable<number>;
  44440. /**
  44441. * Maximum allowed angle to camera position relative to target object.
  44442. * This can help limiting how the Camera is able to move in the scene.
  44443. */
  44444. upperRotationOffsetLimit: Nullable<number>;
  44445. /**
  44446. * Define a height offset between the camera and the object it follows.
  44447. * It can help following an object from the top (like a car chaing a plane)
  44448. */
  44449. heightOffset: number;
  44450. /**
  44451. * Minimum allowed height of camera position relative to target object.
  44452. * This can help limiting how the Camera is able to move in the scene.
  44453. */
  44454. lowerHeightOffsetLimit: Nullable<number>;
  44455. /**
  44456. * Maximum allowed height of camera position relative to target object.
  44457. * This can help limiting how the Camera is able to move in the scene.
  44458. */
  44459. upperHeightOffsetLimit: Nullable<number>;
  44460. /**
  44461. * Define how fast the camera can accelerate to follow it s target.
  44462. */
  44463. cameraAcceleration: number;
  44464. /**
  44465. * Define the speed limit of the camera following an object.
  44466. */
  44467. maxCameraSpeed: number;
  44468. /**
  44469. * Define the target of the camera.
  44470. */
  44471. lockedTarget: Nullable<AbstractMesh>;
  44472. /**
  44473. * Defines the input associated with the camera.
  44474. */
  44475. inputs: FollowCameraInputsManager;
  44476. /**
  44477. * Instantiates the follow camera.
  44478. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44479. * @param name Define the name of the camera in the scene
  44480. * @param position Define the position of the camera
  44481. * @param scene Define the scene the camera belong to
  44482. * @param lockedTarget Define the target of the camera
  44483. */
  44484. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  44485. private _follow;
  44486. /**
  44487. * Attached controls to the current camera.
  44488. * @param element Defines the element the controls should be listened from
  44489. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44490. */
  44491. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44492. /**
  44493. * Detach the current controls from the camera.
  44494. * The camera will stop reacting to inputs.
  44495. * @param element Defines the element to stop listening the inputs from
  44496. */
  44497. detachControl(element: HTMLElement): void;
  44498. /** @hidden */
  44499. _checkInputs(): void;
  44500. private _checkLimits;
  44501. /**
  44502. * Gets the camera class name.
  44503. * @returns the class name
  44504. */
  44505. getClassName(): string;
  44506. }
  44507. /**
  44508. * Arc Rotate version of the follow camera.
  44509. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  44510. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44511. */
  44512. export class ArcFollowCamera extends TargetCamera {
  44513. /** The longitudinal angle of the camera */
  44514. alpha: number;
  44515. /** The latitudinal angle of the camera */
  44516. beta: number;
  44517. /** The radius of the camera from its target */
  44518. radius: number;
  44519. /** Define the camera target (the mesh it should follow) */
  44520. target: Nullable<AbstractMesh>;
  44521. private _cartesianCoordinates;
  44522. /**
  44523. * Instantiates a new ArcFollowCamera
  44524. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44525. * @param name Define the name of the camera
  44526. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  44527. * @param beta Define the rotation angle of the camera around the elevation axis
  44528. * @param radius Define the radius of the camera from its target point
  44529. * @param target Define the target of the camera
  44530. * @param scene Define the scene the camera belongs to
  44531. */
  44532. constructor(name: string,
  44533. /** The longitudinal angle of the camera */
  44534. alpha: number,
  44535. /** The latitudinal angle of the camera */
  44536. beta: number,
  44537. /** The radius of the camera from its target */
  44538. radius: number,
  44539. /** Define the camera target (the mesh it should follow) */
  44540. target: Nullable<AbstractMesh>, scene: Scene);
  44541. private _follow;
  44542. /** @hidden */
  44543. _checkInputs(): void;
  44544. /**
  44545. * Returns the class name of the object.
  44546. * It is mostly used internally for serialization purposes.
  44547. */
  44548. getClassName(): string;
  44549. }
  44550. }
  44551. declare module BABYLON {
  44552. /**
  44553. * Manage the keyboard inputs to control the movement of a follow camera.
  44554. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44555. */
  44556. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  44557. /**
  44558. * Defines the camera the input is attached to.
  44559. */
  44560. camera: FollowCamera;
  44561. /**
  44562. * Defines the list of key codes associated with the up action (increase heightOffset)
  44563. */
  44564. keysHeightOffsetIncr: number[];
  44565. /**
  44566. * Defines the list of key codes associated with the down action (decrease heightOffset)
  44567. */
  44568. keysHeightOffsetDecr: number[];
  44569. /**
  44570. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  44571. */
  44572. keysHeightOffsetModifierAlt: boolean;
  44573. /**
  44574. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  44575. */
  44576. keysHeightOffsetModifierCtrl: boolean;
  44577. /**
  44578. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  44579. */
  44580. keysHeightOffsetModifierShift: boolean;
  44581. /**
  44582. * Defines the list of key codes associated with the left action (increase rotationOffset)
  44583. */
  44584. keysRotationOffsetIncr: number[];
  44585. /**
  44586. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  44587. */
  44588. keysRotationOffsetDecr: number[];
  44589. /**
  44590. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  44591. */
  44592. keysRotationOffsetModifierAlt: boolean;
  44593. /**
  44594. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  44595. */
  44596. keysRotationOffsetModifierCtrl: boolean;
  44597. /**
  44598. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  44599. */
  44600. keysRotationOffsetModifierShift: boolean;
  44601. /**
  44602. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  44603. */
  44604. keysRadiusIncr: number[];
  44605. /**
  44606. * Defines the list of key codes associated with the zoom-out action (increase radius)
  44607. */
  44608. keysRadiusDecr: number[];
  44609. /**
  44610. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  44611. */
  44612. keysRadiusModifierAlt: boolean;
  44613. /**
  44614. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  44615. */
  44616. keysRadiusModifierCtrl: boolean;
  44617. /**
  44618. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  44619. */
  44620. keysRadiusModifierShift: boolean;
  44621. /**
  44622. * Defines the rate of change of heightOffset.
  44623. */
  44624. heightSensibility: number;
  44625. /**
  44626. * Defines the rate of change of rotationOffset.
  44627. */
  44628. rotationSensibility: number;
  44629. /**
  44630. * Defines the rate of change of radius.
  44631. */
  44632. radiusSensibility: number;
  44633. private _keys;
  44634. private _ctrlPressed;
  44635. private _altPressed;
  44636. private _shiftPressed;
  44637. private _onCanvasBlurObserver;
  44638. private _onKeyboardObserver;
  44639. private _engine;
  44640. private _scene;
  44641. /**
  44642. * Attach the input controls to a specific dom element to get the input from.
  44643. * @param element Defines the element the controls should be listened from
  44644. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44645. */
  44646. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44647. /**
  44648. * Detach the current controls from the specified dom element.
  44649. * @param element Defines the element to stop listening the inputs from
  44650. */
  44651. detachControl(element: Nullable<HTMLElement>): void;
  44652. /**
  44653. * Update the current camera state depending on the inputs that have been used this frame.
  44654. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44655. */
  44656. checkInputs(): void;
  44657. /**
  44658. * Gets the class name of the current input.
  44659. * @returns the class name
  44660. */
  44661. getClassName(): string;
  44662. /**
  44663. * Get the friendly name associated with the input class.
  44664. * @returns the input friendly name
  44665. */
  44666. getSimpleName(): string;
  44667. /**
  44668. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44669. * allow modification of the heightOffset value.
  44670. */
  44671. private _modifierHeightOffset;
  44672. /**
  44673. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44674. * allow modification of the rotationOffset value.
  44675. */
  44676. private _modifierRotationOffset;
  44677. /**
  44678. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  44679. * allow modification of the radius value.
  44680. */
  44681. private _modifierRadius;
  44682. }
  44683. }
  44684. declare module BABYLON {
  44685. interface FreeCameraInputsManager {
  44686. /**
  44687. * @hidden
  44688. */
  44689. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  44690. /**
  44691. * Add orientation input support to the input manager.
  44692. * @returns the current input manager
  44693. */
  44694. addDeviceOrientation(): FreeCameraInputsManager;
  44695. }
  44696. /**
  44697. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  44698. * Screen rotation is taken into account.
  44699. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44700. */
  44701. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  44702. private _camera;
  44703. private _screenOrientationAngle;
  44704. private _constantTranform;
  44705. private _screenQuaternion;
  44706. private _alpha;
  44707. private _beta;
  44708. private _gamma;
  44709. /**
  44710. * Can be used to detect if a device orientation sensor is available on a device
  44711. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  44712. * @returns a promise that will resolve on orientation change
  44713. */
  44714. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  44715. /**
  44716. * @hidden
  44717. */
  44718. _onDeviceOrientationChangedObservable: Observable<void>;
  44719. /**
  44720. * Instantiates a new input
  44721. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44722. */
  44723. constructor();
  44724. /**
  44725. * Define the camera controlled by the input.
  44726. */
  44727. get camera(): FreeCamera;
  44728. set camera(camera: FreeCamera);
  44729. /**
  44730. * Attach the input controls to a specific dom element to get the input from.
  44731. * @param element Defines the element the controls should be listened from
  44732. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44733. */
  44734. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44735. private _orientationChanged;
  44736. private _deviceOrientation;
  44737. /**
  44738. * Detach the current controls from the specified dom element.
  44739. * @param element Defines the element to stop listening the inputs from
  44740. */
  44741. detachControl(element: Nullable<HTMLElement>): void;
  44742. /**
  44743. * Update the current camera state depending on the inputs that have been used this frame.
  44744. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44745. */
  44746. checkInputs(): void;
  44747. /**
  44748. * Gets the class name of the current intput.
  44749. * @returns the class name
  44750. */
  44751. getClassName(): string;
  44752. /**
  44753. * Get the friendly name associated with the input class.
  44754. * @returns the input friendly name
  44755. */
  44756. getSimpleName(): string;
  44757. }
  44758. }
  44759. declare module BABYLON {
  44760. /**
  44761. * Manage the gamepad inputs to control a free camera.
  44762. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44763. */
  44764. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  44765. /**
  44766. * Define the camera the input is attached to.
  44767. */
  44768. camera: FreeCamera;
  44769. /**
  44770. * Define the Gamepad controlling the input
  44771. */
  44772. gamepad: Nullable<Gamepad>;
  44773. /**
  44774. * Defines the gamepad rotation sensiblity.
  44775. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44776. */
  44777. gamepadAngularSensibility: number;
  44778. /**
  44779. * Defines the gamepad move sensiblity.
  44780. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44781. */
  44782. gamepadMoveSensibility: number;
  44783. private _yAxisScale;
  44784. /**
  44785. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44786. */
  44787. get invertYAxis(): boolean;
  44788. set invertYAxis(value: boolean);
  44789. private _onGamepadConnectedObserver;
  44790. private _onGamepadDisconnectedObserver;
  44791. private _cameraTransform;
  44792. private _deltaTransform;
  44793. private _vector3;
  44794. private _vector2;
  44795. /**
  44796. * Attach the input controls to a specific dom element to get the input from.
  44797. * @param element Defines the element the controls should be listened from
  44798. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44799. */
  44800. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44801. /**
  44802. * Detach the current controls from the specified dom element.
  44803. * @param element Defines the element to stop listening the inputs from
  44804. */
  44805. detachControl(element: Nullable<HTMLElement>): void;
  44806. /**
  44807. * Update the current camera state depending on the inputs that have been used this frame.
  44808. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44809. */
  44810. checkInputs(): void;
  44811. /**
  44812. * Gets the class name of the current intput.
  44813. * @returns the class name
  44814. */
  44815. getClassName(): string;
  44816. /**
  44817. * Get the friendly name associated with the input class.
  44818. * @returns the input friendly name
  44819. */
  44820. getSimpleName(): string;
  44821. }
  44822. }
  44823. declare module BABYLON {
  44824. /**
  44825. * Defines the potential axis of a Joystick
  44826. */
  44827. export enum JoystickAxis {
  44828. /** X axis */
  44829. X = 0,
  44830. /** Y axis */
  44831. Y = 1,
  44832. /** Z axis */
  44833. Z = 2
  44834. }
  44835. /**
  44836. * Represents the different customization options available
  44837. * for VirtualJoystick
  44838. */
  44839. interface VirtualJoystickCustomizations {
  44840. /**
  44841. * Size of the joystick's puck
  44842. */
  44843. puckSize: number;
  44844. /**
  44845. * Size of the joystick's container
  44846. */
  44847. containerSize: number;
  44848. /**
  44849. * Color of the joystick && puck
  44850. */
  44851. color: string;
  44852. /**
  44853. * Image URL for the joystick's puck
  44854. */
  44855. puckImage?: string;
  44856. /**
  44857. * Image URL for the joystick's container
  44858. */
  44859. containerImage?: string;
  44860. /**
  44861. * Defines the unmoving position of the joystick container
  44862. */
  44863. position?: {
  44864. x: number;
  44865. y: number;
  44866. };
  44867. /**
  44868. * Defines whether or not the joystick container is always visible
  44869. */
  44870. alwaysVisible: boolean;
  44871. /**
  44872. * Defines whether or not to limit the movement of the puck to the joystick's container
  44873. */
  44874. limitToContainer: boolean;
  44875. }
  44876. /**
  44877. * Class used to define virtual joystick (used in touch mode)
  44878. */
  44879. export class VirtualJoystick {
  44880. /**
  44881. * Gets or sets a boolean indicating that left and right values must be inverted
  44882. */
  44883. reverseLeftRight: boolean;
  44884. /**
  44885. * Gets or sets a boolean indicating that up and down values must be inverted
  44886. */
  44887. reverseUpDown: boolean;
  44888. /**
  44889. * Gets the offset value for the position (ie. the change of the position value)
  44890. */
  44891. deltaPosition: Vector3;
  44892. /**
  44893. * Gets a boolean indicating if the virtual joystick was pressed
  44894. */
  44895. pressed: boolean;
  44896. /**
  44897. * Canvas the virtual joystick will render onto, default z-index of this is 5
  44898. */
  44899. static Canvas: Nullable<HTMLCanvasElement>;
  44900. /**
  44901. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  44902. */
  44903. limitToContainer: boolean;
  44904. private static _globalJoystickIndex;
  44905. private static _alwaysVisibleSticks;
  44906. private static vjCanvasContext;
  44907. private static vjCanvasWidth;
  44908. private static vjCanvasHeight;
  44909. private static halfWidth;
  44910. private static _GetDefaultOptions;
  44911. private _action;
  44912. private _axisTargetedByLeftAndRight;
  44913. private _axisTargetedByUpAndDown;
  44914. private _joystickSensibility;
  44915. private _inversedSensibility;
  44916. private _joystickPointerID;
  44917. private _joystickColor;
  44918. private _joystickPointerPos;
  44919. private _joystickPreviousPointerPos;
  44920. private _joystickPointerStartPos;
  44921. private _deltaJoystickVector;
  44922. private _leftJoystick;
  44923. private _touches;
  44924. private _joystickPosition;
  44925. private _alwaysVisible;
  44926. private _puckImage;
  44927. private _containerImage;
  44928. private _joystickPuckSize;
  44929. private _joystickContainerSize;
  44930. private _clearPuckSize;
  44931. private _clearContainerSize;
  44932. private _clearPuckSizeOffset;
  44933. private _clearContainerSizeOffset;
  44934. private _onPointerDownHandlerRef;
  44935. private _onPointerMoveHandlerRef;
  44936. private _onPointerUpHandlerRef;
  44937. private _onResize;
  44938. /**
  44939. * Creates a new virtual joystick
  44940. * @param leftJoystick defines that the joystick is for left hand (false by default)
  44941. * @param customizations Defines the options we want to customize the VirtualJoystick
  44942. */
  44943. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  44944. /**
  44945. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  44946. * @param newJoystickSensibility defines the new sensibility
  44947. */
  44948. setJoystickSensibility(newJoystickSensibility: number): void;
  44949. private _onPointerDown;
  44950. private _onPointerMove;
  44951. private _onPointerUp;
  44952. /**
  44953. * Change the color of the virtual joystick
  44954. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  44955. */
  44956. setJoystickColor(newColor: string): void;
  44957. /**
  44958. * Size of the joystick's container
  44959. */
  44960. set containerSize(newSize: number);
  44961. get containerSize(): number;
  44962. /**
  44963. * Size of the joystick's puck
  44964. */
  44965. set puckSize(newSize: number);
  44966. get puckSize(): number;
  44967. /**
  44968. * Clears the set position of the joystick
  44969. */
  44970. clearPosition(): void;
  44971. /**
  44972. * Defines whether or not the joystick container is always visible
  44973. */
  44974. set alwaysVisible(value: boolean);
  44975. get alwaysVisible(): boolean;
  44976. /**
  44977. * Sets the constant position of the Joystick container
  44978. * @param x X axis coordinate
  44979. * @param y Y axis coordinate
  44980. */
  44981. setPosition(x: number, y: number): void;
  44982. /**
  44983. * Defines a callback to call when the joystick is touched
  44984. * @param action defines the callback
  44985. */
  44986. setActionOnTouch(action: () => any): void;
  44987. /**
  44988. * Defines which axis you'd like to control for left & right
  44989. * @param axis defines the axis to use
  44990. */
  44991. setAxisForLeftRight(axis: JoystickAxis): void;
  44992. /**
  44993. * Defines which axis you'd like to control for up & down
  44994. * @param axis defines the axis to use
  44995. */
  44996. setAxisForUpDown(axis: JoystickAxis): void;
  44997. /**
  44998. * Clears the canvas from the previous puck / container draw
  44999. */
  45000. private _clearPreviousDraw;
  45001. /**
  45002. * Loads `urlPath` to be used for the container's image
  45003. * @param urlPath defines the urlPath of an image to use
  45004. */
  45005. setContainerImage(urlPath: string): void;
  45006. /**
  45007. * Loads `urlPath` to be used for the puck's image
  45008. * @param urlPath defines the urlPath of an image to use
  45009. */
  45010. setPuckImage(urlPath: string): void;
  45011. /**
  45012. * Draws the Virtual Joystick's container
  45013. */
  45014. private _drawContainer;
  45015. /**
  45016. * Draws the Virtual Joystick's puck
  45017. */
  45018. private _drawPuck;
  45019. private _drawVirtualJoystick;
  45020. /**
  45021. * Release internal HTML canvas
  45022. */
  45023. releaseCanvas(): void;
  45024. }
  45025. }
  45026. declare module BABYLON {
  45027. interface FreeCameraInputsManager {
  45028. /**
  45029. * Add virtual joystick input support to the input manager.
  45030. * @returns the current input manager
  45031. */
  45032. addVirtualJoystick(): FreeCameraInputsManager;
  45033. }
  45034. /**
  45035. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  45036. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45037. */
  45038. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  45039. /**
  45040. * Defines the camera the input is attached to.
  45041. */
  45042. camera: FreeCamera;
  45043. private _leftjoystick;
  45044. private _rightjoystick;
  45045. /**
  45046. * Gets the left stick of the virtual joystick.
  45047. * @returns The virtual Joystick
  45048. */
  45049. getLeftJoystick(): VirtualJoystick;
  45050. /**
  45051. * Gets the right stick of the virtual joystick.
  45052. * @returns The virtual Joystick
  45053. */
  45054. getRightJoystick(): VirtualJoystick;
  45055. /**
  45056. * Update the current camera state depending on the inputs that have been used this frame.
  45057. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45058. */
  45059. checkInputs(): void;
  45060. /**
  45061. * Attach the input controls to a specific dom element to get the input from.
  45062. * @param element Defines the element the controls should be listened from
  45063. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45064. */
  45065. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45066. /**
  45067. * Detach the current controls from the specified dom element.
  45068. * @param element Defines the element to stop listening the inputs from
  45069. */
  45070. detachControl(element: Nullable<HTMLElement>): void;
  45071. /**
  45072. * Gets the class name of the current intput.
  45073. * @returns the class name
  45074. */
  45075. getClassName(): string;
  45076. /**
  45077. * Get the friendly name associated with the input class.
  45078. * @returns the input friendly name
  45079. */
  45080. getSimpleName(): string;
  45081. }
  45082. }
  45083. declare module BABYLON {
  45084. /**
  45085. * This represents a FPS type of camera controlled by touch.
  45086. * This is like a universal camera minus the Gamepad controls.
  45087. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45088. */
  45089. export class TouchCamera extends FreeCamera {
  45090. /**
  45091. * Defines the touch sensibility for rotation.
  45092. * The higher the faster.
  45093. */
  45094. get touchAngularSensibility(): number;
  45095. set touchAngularSensibility(value: number);
  45096. /**
  45097. * Defines the touch sensibility for move.
  45098. * The higher the faster.
  45099. */
  45100. get touchMoveSensibility(): number;
  45101. set touchMoveSensibility(value: number);
  45102. /**
  45103. * Instantiates a new touch camera.
  45104. * This represents a FPS type of camera controlled by touch.
  45105. * This is like a universal camera minus the Gamepad controls.
  45106. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45107. * @param name Define the name of the camera in the scene
  45108. * @param position Define the start position of the camera in the scene
  45109. * @param scene Define the scene the camera belongs to
  45110. */
  45111. constructor(name: string, position: Vector3, scene: Scene);
  45112. /**
  45113. * Gets the current object class name.
  45114. * @return the class name
  45115. */
  45116. getClassName(): string;
  45117. /** @hidden */
  45118. _setupInputs(): void;
  45119. }
  45120. }
  45121. declare module BABYLON {
  45122. /**
  45123. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  45124. * being tilted forward or back and left or right.
  45125. */
  45126. export class DeviceOrientationCamera extends FreeCamera {
  45127. private _initialQuaternion;
  45128. private _quaternionCache;
  45129. private _tmpDragQuaternion;
  45130. private _disablePointerInputWhenUsingDeviceOrientation;
  45131. /**
  45132. * Creates a new device orientation camera
  45133. * @param name The name of the camera
  45134. * @param position The start position camera
  45135. * @param scene The scene the camera belongs to
  45136. */
  45137. constructor(name: string, position: Vector3, scene: Scene);
  45138. /**
  45139. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  45140. */
  45141. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  45142. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  45143. private _dragFactor;
  45144. /**
  45145. * Enabled turning on the y axis when the orientation sensor is active
  45146. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  45147. */
  45148. enableHorizontalDragging(dragFactor?: number): void;
  45149. /**
  45150. * Gets the current instance class name ("DeviceOrientationCamera").
  45151. * This helps avoiding instanceof at run time.
  45152. * @returns the class name
  45153. */
  45154. getClassName(): string;
  45155. /**
  45156. * @hidden
  45157. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  45158. */
  45159. _checkInputs(): void;
  45160. /**
  45161. * Reset the camera to its default orientation on the specified axis only.
  45162. * @param axis The axis to reset
  45163. */
  45164. resetToCurrentRotation(axis?: Axis): void;
  45165. }
  45166. }
  45167. declare module BABYLON {
  45168. /**
  45169. * Defines supported buttons for XBox360 compatible gamepads
  45170. */
  45171. export enum Xbox360Button {
  45172. /** A */
  45173. A = 0,
  45174. /** B */
  45175. B = 1,
  45176. /** X */
  45177. X = 2,
  45178. /** Y */
  45179. Y = 3,
  45180. /** Left button */
  45181. LB = 4,
  45182. /** Right button */
  45183. RB = 5,
  45184. /** Back */
  45185. Back = 8,
  45186. /** Start */
  45187. Start = 9,
  45188. /** Left stick */
  45189. LeftStick = 10,
  45190. /** Right stick */
  45191. RightStick = 11
  45192. }
  45193. /** Defines values for XBox360 DPad */
  45194. export enum Xbox360Dpad {
  45195. /** Up */
  45196. Up = 12,
  45197. /** Down */
  45198. Down = 13,
  45199. /** Left */
  45200. Left = 14,
  45201. /** Right */
  45202. Right = 15
  45203. }
  45204. /**
  45205. * Defines a XBox360 gamepad
  45206. */
  45207. export class Xbox360Pad extends Gamepad {
  45208. private _leftTrigger;
  45209. private _rightTrigger;
  45210. private _onlefttriggerchanged;
  45211. private _onrighttriggerchanged;
  45212. private _onbuttondown;
  45213. private _onbuttonup;
  45214. private _ondpaddown;
  45215. private _ondpadup;
  45216. /** Observable raised when a button is pressed */
  45217. onButtonDownObservable: Observable<Xbox360Button>;
  45218. /** Observable raised when a button is released */
  45219. onButtonUpObservable: Observable<Xbox360Button>;
  45220. /** Observable raised when a pad is pressed */
  45221. onPadDownObservable: Observable<Xbox360Dpad>;
  45222. /** Observable raised when a pad is released */
  45223. onPadUpObservable: Observable<Xbox360Dpad>;
  45224. private _buttonA;
  45225. private _buttonB;
  45226. private _buttonX;
  45227. private _buttonY;
  45228. private _buttonBack;
  45229. private _buttonStart;
  45230. private _buttonLB;
  45231. private _buttonRB;
  45232. private _buttonLeftStick;
  45233. private _buttonRightStick;
  45234. private _dPadUp;
  45235. private _dPadDown;
  45236. private _dPadLeft;
  45237. private _dPadRight;
  45238. private _isXboxOnePad;
  45239. /**
  45240. * Creates a new XBox360 gamepad object
  45241. * @param id defines the id of this gamepad
  45242. * @param index defines its index
  45243. * @param gamepad defines the internal HTML gamepad object
  45244. * @param xboxOne defines if it is a XBox One gamepad
  45245. */
  45246. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  45247. /**
  45248. * Defines the callback to call when left trigger is pressed
  45249. * @param callback defines the callback to use
  45250. */
  45251. onlefttriggerchanged(callback: (value: number) => void): void;
  45252. /**
  45253. * Defines the callback to call when right trigger is pressed
  45254. * @param callback defines the callback to use
  45255. */
  45256. onrighttriggerchanged(callback: (value: number) => void): void;
  45257. /**
  45258. * Gets the left trigger value
  45259. */
  45260. get leftTrigger(): number;
  45261. /**
  45262. * Sets the left trigger value
  45263. */
  45264. set leftTrigger(newValue: number);
  45265. /**
  45266. * Gets the right trigger value
  45267. */
  45268. get rightTrigger(): number;
  45269. /**
  45270. * Sets the right trigger value
  45271. */
  45272. set rightTrigger(newValue: number);
  45273. /**
  45274. * Defines the callback to call when a button is pressed
  45275. * @param callback defines the callback to use
  45276. */
  45277. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  45278. /**
  45279. * Defines the callback to call when a button is released
  45280. * @param callback defines the callback to use
  45281. */
  45282. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  45283. /**
  45284. * Defines the callback to call when a pad is pressed
  45285. * @param callback defines the callback to use
  45286. */
  45287. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  45288. /**
  45289. * Defines the callback to call when a pad is released
  45290. * @param callback defines the callback to use
  45291. */
  45292. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  45293. private _setButtonValue;
  45294. private _setDPadValue;
  45295. /**
  45296. * Gets the value of the `A` button
  45297. */
  45298. get buttonA(): number;
  45299. /**
  45300. * Sets the value of the `A` button
  45301. */
  45302. set buttonA(value: number);
  45303. /**
  45304. * Gets the value of the `B` button
  45305. */
  45306. get buttonB(): number;
  45307. /**
  45308. * Sets the value of the `B` button
  45309. */
  45310. set buttonB(value: number);
  45311. /**
  45312. * Gets the value of the `X` button
  45313. */
  45314. get buttonX(): number;
  45315. /**
  45316. * Sets the value of the `X` button
  45317. */
  45318. set buttonX(value: number);
  45319. /**
  45320. * Gets the value of the `Y` button
  45321. */
  45322. get buttonY(): number;
  45323. /**
  45324. * Sets the value of the `Y` button
  45325. */
  45326. set buttonY(value: number);
  45327. /**
  45328. * Gets the value of the `Start` button
  45329. */
  45330. get buttonStart(): number;
  45331. /**
  45332. * Sets the value of the `Start` button
  45333. */
  45334. set buttonStart(value: number);
  45335. /**
  45336. * Gets the value of the `Back` button
  45337. */
  45338. get buttonBack(): number;
  45339. /**
  45340. * Sets the value of the `Back` button
  45341. */
  45342. set buttonBack(value: number);
  45343. /**
  45344. * Gets the value of the `Left` button
  45345. */
  45346. get buttonLB(): number;
  45347. /**
  45348. * Sets the value of the `Left` button
  45349. */
  45350. set buttonLB(value: number);
  45351. /**
  45352. * Gets the value of the `Right` button
  45353. */
  45354. get buttonRB(): number;
  45355. /**
  45356. * Sets the value of the `Right` button
  45357. */
  45358. set buttonRB(value: number);
  45359. /**
  45360. * Gets the value of the Left joystick
  45361. */
  45362. get buttonLeftStick(): number;
  45363. /**
  45364. * Sets the value of the Left joystick
  45365. */
  45366. set buttonLeftStick(value: number);
  45367. /**
  45368. * Gets the value of the Right joystick
  45369. */
  45370. get buttonRightStick(): number;
  45371. /**
  45372. * Sets the value of the Right joystick
  45373. */
  45374. set buttonRightStick(value: number);
  45375. /**
  45376. * Gets the value of D-pad up
  45377. */
  45378. get dPadUp(): number;
  45379. /**
  45380. * Sets the value of D-pad up
  45381. */
  45382. set dPadUp(value: number);
  45383. /**
  45384. * Gets the value of D-pad down
  45385. */
  45386. get dPadDown(): number;
  45387. /**
  45388. * Sets the value of D-pad down
  45389. */
  45390. set dPadDown(value: number);
  45391. /**
  45392. * Gets the value of D-pad left
  45393. */
  45394. get dPadLeft(): number;
  45395. /**
  45396. * Sets the value of D-pad left
  45397. */
  45398. set dPadLeft(value: number);
  45399. /**
  45400. * Gets the value of D-pad right
  45401. */
  45402. get dPadRight(): number;
  45403. /**
  45404. * Sets the value of D-pad right
  45405. */
  45406. set dPadRight(value: number);
  45407. /**
  45408. * Force the gamepad to synchronize with device values
  45409. */
  45410. update(): void;
  45411. /**
  45412. * Disposes the gamepad
  45413. */
  45414. dispose(): void;
  45415. }
  45416. }
  45417. declare module BABYLON {
  45418. /**
  45419. * Defines supported buttons for DualShock compatible gamepads
  45420. */
  45421. export enum DualShockButton {
  45422. /** Cross */
  45423. Cross = 0,
  45424. /** Circle */
  45425. Circle = 1,
  45426. /** Square */
  45427. Square = 2,
  45428. /** Triangle */
  45429. Triangle = 3,
  45430. /** L1 */
  45431. L1 = 4,
  45432. /** R1 */
  45433. R1 = 5,
  45434. /** Share */
  45435. Share = 8,
  45436. /** Options */
  45437. Options = 9,
  45438. /** Left stick */
  45439. LeftStick = 10,
  45440. /** Right stick */
  45441. RightStick = 11
  45442. }
  45443. /** Defines values for DualShock DPad */
  45444. export enum DualShockDpad {
  45445. /** Up */
  45446. Up = 12,
  45447. /** Down */
  45448. Down = 13,
  45449. /** Left */
  45450. Left = 14,
  45451. /** Right */
  45452. Right = 15
  45453. }
  45454. /**
  45455. * Defines a DualShock gamepad
  45456. */
  45457. export class DualShockPad extends Gamepad {
  45458. private _leftTrigger;
  45459. private _rightTrigger;
  45460. private _onlefttriggerchanged;
  45461. private _onrighttriggerchanged;
  45462. private _onbuttondown;
  45463. private _onbuttonup;
  45464. private _ondpaddown;
  45465. private _ondpadup;
  45466. /** Observable raised when a button is pressed */
  45467. onButtonDownObservable: Observable<DualShockButton>;
  45468. /** Observable raised when a button is released */
  45469. onButtonUpObservable: Observable<DualShockButton>;
  45470. /** Observable raised when a pad is pressed */
  45471. onPadDownObservable: Observable<DualShockDpad>;
  45472. /** Observable raised when a pad is released */
  45473. onPadUpObservable: Observable<DualShockDpad>;
  45474. private _buttonCross;
  45475. private _buttonCircle;
  45476. private _buttonSquare;
  45477. private _buttonTriangle;
  45478. private _buttonShare;
  45479. private _buttonOptions;
  45480. private _buttonL1;
  45481. private _buttonR1;
  45482. private _buttonLeftStick;
  45483. private _buttonRightStick;
  45484. private _dPadUp;
  45485. private _dPadDown;
  45486. private _dPadLeft;
  45487. private _dPadRight;
  45488. /**
  45489. * Creates a new DualShock gamepad object
  45490. * @param id defines the id of this gamepad
  45491. * @param index defines its index
  45492. * @param gamepad defines the internal HTML gamepad object
  45493. */
  45494. constructor(id: string, index: number, gamepad: any);
  45495. /**
  45496. * Defines the callback to call when left trigger is pressed
  45497. * @param callback defines the callback to use
  45498. */
  45499. onlefttriggerchanged(callback: (value: number) => void): void;
  45500. /**
  45501. * Defines the callback to call when right trigger is pressed
  45502. * @param callback defines the callback to use
  45503. */
  45504. onrighttriggerchanged(callback: (value: number) => void): void;
  45505. /**
  45506. * Gets the left trigger value
  45507. */
  45508. get leftTrigger(): number;
  45509. /**
  45510. * Sets the left trigger value
  45511. */
  45512. set leftTrigger(newValue: number);
  45513. /**
  45514. * Gets the right trigger value
  45515. */
  45516. get rightTrigger(): number;
  45517. /**
  45518. * Sets the right trigger value
  45519. */
  45520. set rightTrigger(newValue: number);
  45521. /**
  45522. * Defines the callback to call when a button is pressed
  45523. * @param callback defines the callback to use
  45524. */
  45525. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  45526. /**
  45527. * Defines the callback to call when a button is released
  45528. * @param callback defines the callback to use
  45529. */
  45530. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  45531. /**
  45532. * Defines the callback to call when a pad is pressed
  45533. * @param callback defines the callback to use
  45534. */
  45535. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  45536. /**
  45537. * Defines the callback to call when a pad is released
  45538. * @param callback defines the callback to use
  45539. */
  45540. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  45541. private _setButtonValue;
  45542. private _setDPadValue;
  45543. /**
  45544. * Gets the value of the `Cross` button
  45545. */
  45546. get buttonCross(): number;
  45547. /**
  45548. * Sets the value of the `Cross` button
  45549. */
  45550. set buttonCross(value: number);
  45551. /**
  45552. * Gets the value of the `Circle` button
  45553. */
  45554. get buttonCircle(): number;
  45555. /**
  45556. * Sets the value of the `Circle` button
  45557. */
  45558. set buttonCircle(value: number);
  45559. /**
  45560. * Gets the value of the `Square` button
  45561. */
  45562. get buttonSquare(): number;
  45563. /**
  45564. * Sets the value of the `Square` button
  45565. */
  45566. set buttonSquare(value: number);
  45567. /**
  45568. * Gets the value of the `Triangle` button
  45569. */
  45570. get buttonTriangle(): number;
  45571. /**
  45572. * Sets the value of the `Triangle` button
  45573. */
  45574. set buttonTriangle(value: number);
  45575. /**
  45576. * Gets the value of the `Options` button
  45577. */
  45578. get buttonOptions(): number;
  45579. /**
  45580. * Sets the value of the `Options` button
  45581. */
  45582. set buttonOptions(value: number);
  45583. /**
  45584. * Gets the value of the `Share` button
  45585. */
  45586. get buttonShare(): number;
  45587. /**
  45588. * Sets the value of the `Share` button
  45589. */
  45590. set buttonShare(value: number);
  45591. /**
  45592. * Gets the value of the `L1` button
  45593. */
  45594. get buttonL1(): number;
  45595. /**
  45596. * Sets the value of the `L1` button
  45597. */
  45598. set buttonL1(value: number);
  45599. /**
  45600. * Gets the value of the `R1` button
  45601. */
  45602. get buttonR1(): number;
  45603. /**
  45604. * Sets the value of the `R1` button
  45605. */
  45606. set buttonR1(value: number);
  45607. /**
  45608. * Gets the value of the Left joystick
  45609. */
  45610. get buttonLeftStick(): number;
  45611. /**
  45612. * Sets the value of the Left joystick
  45613. */
  45614. set buttonLeftStick(value: number);
  45615. /**
  45616. * Gets the value of the Right joystick
  45617. */
  45618. get buttonRightStick(): number;
  45619. /**
  45620. * Sets the value of the Right joystick
  45621. */
  45622. set buttonRightStick(value: number);
  45623. /**
  45624. * Gets the value of D-pad up
  45625. */
  45626. get dPadUp(): number;
  45627. /**
  45628. * Sets the value of D-pad up
  45629. */
  45630. set dPadUp(value: number);
  45631. /**
  45632. * Gets the value of D-pad down
  45633. */
  45634. get dPadDown(): number;
  45635. /**
  45636. * Sets the value of D-pad down
  45637. */
  45638. set dPadDown(value: number);
  45639. /**
  45640. * Gets the value of D-pad left
  45641. */
  45642. get dPadLeft(): number;
  45643. /**
  45644. * Sets the value of D-pad left
  45645. */
  45646. set dPadLeft(value: number);
  45647. /**
  45648. * Gets the value of D-pad right
  45649. */
  45650. get dPadRight(): number;
  45651. /**
  45652. * Sets the value of D-pad right
  45653. */
  45654. set dPadRight(value: number);
  45655. /**
  45656. * Force the gamepad to synchronize with device values
  45657. */
  45658. update(): void;
  45659. /**
  45660. * Disposes the gamepad
  45661. */
  45662. dispose(): void;
  45663. }
  45664. }
  45665. declare module BABYLON {
  45666. /**
  45667. * Manager for handling gamepads
  45668. */
  45669. export class GamepadManager {
  45670. private _scene?;
  45671. private _babylonGamepads;
  45672. private _oneGamepadConnected;
  45673. /** @hidden */
  45674. _isMonitoring: boolean;
  45675. private _gamepadEventSupported;
  45676. private _gamepadSupport?;
  45677. /**
  45678. * observable to be triggered when the gamepad controller has been connected
  45679. */
  45680. onGamepadConnectedObservable: Observable<Gamepad>;
  45681. /**
  45682. * observable to be triggered when the gamepad controller has been disconnected
  45683. */
  45684. onGamepadDisconnectedObservable: Observable<Gamepad>;
  45685. private _onGamepadConnectedEvent;
  45686. private _onGamepadDisconnectedEvent;
  45687. /**
  45688. * Initializes the gamepad manager
  45689. * @param _scene BabylonJS scene
  45690. */
  45691. constructor(_scene?: Scene | undefined);
  45692. /**
  45693. * The gamepads in the game pad manager
  45694. */
  45695. get gamepads(): Gamepad[];
  45696. /**
  45697. * Get the gamepad controllers based on type
  45698. * @param type The type of gamepad controller
  45699. * @returns Nullable gamepad
  45700. */
  45701. getGamepadByType(type?: number): Nullable<Gamepad>;
  45702. /**
  45703. * Disposes the gamepad manager
  45704. */
  45705. dispose(): void;
  45706. private _addNewGamepad;
  45707. private _startMonitoringGamepads;
  45708. private _stopMonitoringGamepads;
  45709. /** @hidden */
  45710. _checkGamepadsStatus(): void;
  45711. private _updateGamepadObjects;
  45712. }
  45713. }
  45714. declare module BABYLON {
  45715. interface Scene {
  45716. /** @hidden */
  45717. _gamepadManager: Nullable<GamepadManager>;
  45718. /**
  45719. * Gets the gamepad manager associated with the scene
  45720. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  45721. */
  45722. gamepadManager: GamepadManager;
  45723. }
  45724. /**
  45725. * Interface representing a free camera inputs manager
  45726. */
  45727. interface FreeCameraInputsManager {
  45728. /**
  45729. * Adds gamepad input support to the FreeCameraInputsManager.
  45730. * @returns the FreeCameraInputsManager
  45731. */
  45732. addGamepad(): FreeCameraInputsManager;
  45733. }
  45734. /**
  45735. * Interface representing an arc rotate camera inputs manager
  45736. */
  45737. interface ArcRotateCameraInputsManager {
  45738. /**
  45739. * Adds gamepad input support to the ArcRotateCamera InputManager.
  45740. * @returns the camera inputs manager
  45741. */
  45742. addGamepad(): ArcRotateCameraInputsManager;
  45743. }
  45744. /**
  45745. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  45746. */
  45747. export class GamepadSystemSceneComponent implements ISceneComponent {
  45748. /**
  45749. * The component name helpfull to identify the component in the list of scene components.
  45750. */
  45751. readonly name: string;
  45752. /**
  45753. * The scene the component belongs to.
  45754. */
  45755. scene: Scene;
  45756. /**
  45757. * Creates a new instance of the component for the given scene
  45758. * @param scene Defines the scene to register the component in
  45759. */
  45760. constructor(scene: Scene);
  45761. /**
  45762. * Registers the component in a given scene
  45763. */
  45764. register(): void;
  45765. /**
  45766. * Rebuilds the elements related to this component in case of
  45767. * context lost for instance.
  45768. */
  45769. rebuild(): void;
  45770. /**
  45771. * Disposes the component and the associated ressources
  45772. */
  45773. dispose(): void;
  45774. private _beforeCameraUpdate;
  45775. }
  45776. }
  45777. declare module BABYLON {
  45778. /**
  45779. * 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,
  45780. * which still works and will still be found in many Playgrounds.
  45781. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45782. */
  45783. export class UniversalCamera extends TouchCamera {
  45784. /**
  45785. * Defines the gamepad rotation sensiblity.
  45786. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45787. */
  45788. get gamepadAngularSensibility(): number;
  45789. set gamepadAngularSensibility(value: number);
  45790. /**
  45791. * Defines the gamepad move sensiblity.
  45792. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45793. */
  45794. get gamepadMoveSensibility(): number;
  45795. set gamepadMoveSensibility(value: number);
  45796. /**
  45797. * 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,
  45798. * which still works and will still be found in many Playgrounds.
  45799. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45800. * @param name Define the name of the camera in the scene
  45801. * @param position Define the start position of the camera in the scene
  45802. * @param scene Define the scene the camera belongs to
  45803. */
  45804. constructor(name: string, position: Vector3, scene: Scene);
  45805. /**
  45806. * Gets the current object class name.
  45807. * @return the class name
  45808. */
  45809. getClassName(): string;
  45810. }
  45811. }
  45812. declare module BABYLON {
  45813. /**
  45814. * This represents a FPS type of camera. This is only here for back compat purpose.
  45815. * Please use the UniversalCamera instead as both are identical.
  45816. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45817. */
  45818. export class GamepadCamera extends UniversalCamera {
  45819. /**
  45820. * Instantiates a new Gamepad Camera
  45821. * This represents a FPS type of camera. This is only here for back compat purpose.
  45822. * Please use the UniversalCamera instead as both are identical.
  45823. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45824. * @param name Define the name of the camera in the scene
  45825. * @param position Define the start position of the camera in the scene
  45826. * @param scene Define the scene the camera belongs to
  45827. */
  45828. constructor(name: string, position: Vector3, scene: Scene);
  45829. /**
  45830. * Gets the current object class name.
  45831. * @return the class name
  45832. */
  45833. getClassName(): string;
  45834. }
  45835. }
  45836. declare module BABYLON {
  45837. /** @hidden */
  45838. export var passPixelShader: {
  45839. name: string;
  45840. shader: string;
  45841. };
  45842. }
  45843. declare module BABYLON {
  45844. /** @hidden */
  45845. export var passCubePixelShader: {
  45846. name: string;
  45847. shader: string;
  45848. };
  45849. }
  45850. declare module BABYLON {
  45851. /**
  45852. * PassPostProcess which produces an output the same as it's input
  45853. */
  45854. export class PassPostProcess extends PostProcess {
  45855. /**
  45856. * Creates the PassPostProcess
  45857. * @param name The name of the effect.
  45858. * @param options The required width/height ratio to downsize to before computing the render pass.
  45859. * @param camera The camera to apply the render pass to.
  45860. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  45861. * @param engine The engine which the post process will be applied. (default: current engine)
  45862. * @param reusable If the post process can be reused on the same frame. (default: false)
  45863. * @param textureType The type of texture to be used when performing the post processing.
  45864. * @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)
  45865. */
  45866. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  45867. }
  45868. /**
  45869. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  45870. */
  45871. export class PassCubePostProcess extends PostProcess {
  45872. private _face;
  45873. /**
  45874. * Gets or sets the cube face to display.
  45875. * * 0 is +X
  45876. * * 1 is -X
  45877. * * 2 is +Y
  45878. * * 3 is -Y
  45879. * * 4 is +Z
  45880. * * 5 is -Z
  45881. */
  45882. get face(): number;
  45883. set face(value: number);
  45884. /**
  45885. * Creates the PassCubePostProcess
  45886. * @param name The name of the effect.
  45887. * @param options The required width/height ratio to downsize to before computing the render pass.
  45888. * @param camera The camera to apply the render pass to.
  45889. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  45890. * @param engine The engine which the post process will be applied. (default: current engine)
  45891. * @param reusable If the post process can be reused on the same frame. (default: false)
  45892. * @param textureType The type of texture to be used when performing the post processing.
  45893. * @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)
  45894. */
  45895. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  45896. }
  45897. }
  45898. declare module BABYLON {
  45899. /** @hidden */
  45900. export var anaglyphPixelShader: {
  45901. name: string;
  45902. shader: string;
  45903. };
  45904. }
  45905. declare module BABYLON {
  45906. /**
  45907. * Postprocess used to generate anaglyphic rendering
  45908. */
  45909. export class AnaglyphPostProcess extends PostProcess {
  45910. private _passedProcess;
  45911. /**
  45912. * Creates a new AnaglyphPostProcess
  45913. * @param name defines postprocess name
  45914. * @param options defines creation options or target ratio scale
  45915. * @param rigCameras defines cameras using this postprocess
  45916. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  45917. * @param engine defines hosting engine
  45918. * @param reusable defines if the postprocess will be reused multiple times per frame
  45919. */
  45920. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  45921. }
  45922. }
  45923. declare module BABYLON {
  45924. /**
  45925. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  45926. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45927. */
  45928. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  45929. /**
  45930. * Creates a new AnaglyphArcRotateCamera
  45931. * @param name defines camera name
  45932. * @param alpha defines alpha angle (in radians)
  45933. * @param beta defines beta angle (in radians)
  45934. * @param radius defines radius
  45935. * @param target defines camera target
  45936. * @param interaxialDistance defines distance between each color axis
  45937. * @param scene defines the hosting scene
  45938. */
  45939. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  45940. /**
  45941. * Gets camera class name
  45942. * @returns AnaglyphArcRotateCamera
  45943. */
  45944. getClassName(): string;
  45945. }
  45946. }
  45947. declare module BABYLON {
  45948. /**
  45949. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  45950. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45951. */
  45952. export class AnaglyphFreeCamera extends FreeCamera {
  45953. /**
  45954. * Creates a new AnaglyphFreeCamera
  45955. * @param name defines camera name
  45956. * @param position defines initial position
  45957. * @param interaxialDistance defines distance between each color axis
  45958. * @param scene defines the hosting scene
  45959. */
  45960. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45961. /**
  45962. * Gets camera class name
  45963. * @returns AnaglyphFreeCamera
  45964. */
  45965. getClassName(): string;
  45966. }
  45967. }
  45968. declare module BABYLON {
  45969. /**
  45970. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  45971. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45972. */
  45973. export class AnaglyphGamepadCamera extends GamepadCamera {
  45974. /**
  45975. * Creates a new AnaglyphGamepadCamera
  45976. * @param name defines camera name
  45977. * @param position defines initial position
  45978. * @param interaxialDistance defines distance between each color axis
  45979. * @param scene defines the hosting scene
  45980. */
  45981. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  45982. /**
  45983. * Gets camera class name
  45984. * @returns AnaglyphGamepadCamera
  45985. */
  45986. getClassName(): string;
  45987. }
  45988. }
  45989. declare module BABYLON {
  45990. /**
  45991. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  45992. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  45993. */
  45994. export class AnaglyphUniversalCamera extends UniversalCamera {
  45995. /**
  45996. * Creates a new AnaglyphUniversalCamera
  45997. * @param name defines camera name
  45998. * @param position defines initial position
  45999. * @param interaxialDistance defines distance between each color axis
  46000. * @param scene defines the hosting scene
  46001. */
  46002. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46003. /**
  46004. * Gets camera class name
  46005. * @returns AnaglyphUniversalCamera
  46006. */
  46007. getClassName(): string;
  46008. }
  46009. }
  46010. declare module BABYLON {
  46011. /**
  46012. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  46013. * @see https://doc.babylonjs.com/features/cameras
  46014. */
  46015. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  46016. /**
  46017. * Creates a new StereoscopicArcRotateCamera
  46018. * @param name defines camera name
  46019. * @param alpha defines alpha angle (in radians)
  46020. * @param beta defines beta angle (in radians)
  46021. * @param radius defines radius
  46022. * @param target defines camera target
  46023. * @param interaxialDistance defines distance between each color axis
  46024. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46025. * @param scene defines the hosting scene
  46026. */
  46027. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46028. /**
  46029. * Gets camera class name
  46030. * @returns StereoscopicArcRotateCamera
  46031. */
  46032. getClassName(): string;
  46033. }
  46034. }
  46035. declare module BABYLON {
  46036. /**
  46037. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  46038. * @see https://doc.babylonjs.com/features/cameras
  46039. */
  46040. export class StereoscopicFreeCamera extends FreeCamera {
  46041. /**
  46042. * Creates a new StereoscopicFreeCamera
  46043. * @param name defines camera name
  46044. * @param position defines initial position
  46045. * @param interaxialDistance defines distance between each color axis
  46046. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46047. * @param scene defines the hosting scene
  46048. */
  46049. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46050. /**
  46051. * Gets camera class name
  46052. * @returns StereoscopicFreeCamera
  46053. */
  46054. getClassName(): string;
  46055. }
  46056. }
  46057. declare module BABYLON {
  46058. /**
  46059. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  46060. * @see https://doc.babylonjs.com/features/cameras
  46061. */
  46062. export class StereoscopicGamepadCamera extends GamepadCamera {
  46063. /**
  46064. * Creates a new StereoscopicGamepadCamera
  46065. * @param name defines camera name
  46066. * @param position defines initial position
  46067. * @param interaxialDistance defines distance between each color axis
  46068. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46069. * @param scene defines the hosting scene
  46070. */
  46071. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46072. /**
  46073. * Gets camera class name
  46074. * @returns StereoscopicGamepadCamera
  46075. */
  46076. getClassName(): string;
  46077. }
  46078. }
  46079. declare module BABYLON {
  46080. /**
  46081. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  46082. * @see https://doc.babylonjs.com/features/cameras
  46083. */
  46084. export class StereoscopicUniversalCamera extends UniversalCamera {
  46085. /**
  46086. * Creates a new StereoscopicUniversalCamera
  46087. * @param name defines camera name
  46088. * @param position defines initial position
  46089. * @param interaxialDistance defines distance between each color axis
  46090. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46091. * @param scene defines the hosting scene
  46092. */
  46093. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46094. /**
  46095. * Gets camera class name
  46096. * @returns StereoscopicUniversalCamera
  46097. */
  46098. getClassName(): string;
  46099. }
  46100. }
  46101. declare module BABYLON {
  46102. /**
  46103. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  46104. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46105. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46106. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46107. */
  46108. export class VirtualJoysticksCamera extends FreeCamera {
  46109. /**
  46110. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  46111. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46112. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46113. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46114. * @param name Define the name of the camera in the scene
  46115. * @param position Define the start position of the camera in the scene
  46116. * @param scene Define the scene the camera belongs to
  46117. */
  46118. constructor(name: string, position: Vector3, scene: Scene);
  46119. /**
  46120. * Gets the current object class name.
  46121. * @return the class name
  46122. */
  46123. getClassName(): string;
  46124. }
  46125. }
  46126. declare module BABYLON {
  46127. /**
  46128. * This represents all the required metrics to create a VR camera.
  46129. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  46130. */
  46131. export class VRCameraMetrics {
  46132. /**
  46133. * Define the horizontal resolution off the screen.
  46134. */
  46135. hResolution: number;
  46136. /**
  46137. * Define the vertical resolution off the screen.
  46138. */
  46139. vResolution: number;
  46140. /**
  46141. * Define the horizontal screen size.
  46142. */
  46143. hScreenSize: number;
  46144. /**
  46145. * Define the vertical screen size.
  46146. */
  46147. vScreenSize: number;
  46148. /**
  46149. * Define the vertical screen center position.
  46150. */
  46151. vScreenCenter: number;
  46152. /**
  46153. * Define the distance of the eyes to the screen.
  46154. */
  46155. eyeToScreenDistance: number;
  46156. /**
  46157. * Define the distance between both lenses
  46158. */
  46159. lensSeparationDistance: number;
  46160. /**
  46161. * Define the distance between both viewer's eyes.
  46162. */
  46163. interpupillaryDistance: number;
  46164. /**
  46165. * Define the distortion factor of the VR postprocess.
  46166. * Please, touch with care.
  46167. */
  46168. distortionK: number[];
  46169. /**
  46170. * Define the chromatic aberration correction factors for the VR post process.
  46171. */
  46172. chromaAbCorrection: number[];
  46173. /**
  46174. * Define the scale factor of the post process.
  46175. * The smaller the better but the slower.
  46176. */
  46177. postProcessScaleFactor: number;
  46178. /**
  46179. * Define an offset for the lens center.
  46180. */
  46181. lensCenterOffset: number;
  46182. /**
  46183. * Define if the current vr camera should compensate the distortion of the lense or not.
  46184. */
  46185. compensateDistortion: boolean;
  46186. /**
  46187. * Defines if multiview should be enabled when rendering (Default: false)
  46188. */
  46189. multiviewEnabled: boolean;
  46190. /**
  46191. * Gets the rendering aspect ratio based on the provided resolutions.
  46192. */
  46193. get aspectRatio(): number;
  46194. /**
  46195. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  46196. */
  46197. get aspectRatioFov(): number;
  46198. /**
  46199. * @hidden
  46200. */
  46201. get leftHMatrix(): Matrix;
  46202. /**
  46203. * @hidden
  46204. */
  46205. get rightHMatrix(): Matrix;
  46206. /**
  46207. * @hidden
  46208. */
  46209. get leftPreViewMatrix(): Matrix;
  46210. /**
  46211. * @hidden
  46212. */
  46213. get rightPreViewMatrix(): Matrix;
  46214. /**
  46215. * Get the default VRMetrics based on the most generic setup.
  46216. * @returns the default vr metrics
  46217. */
  46218. static GetDefault(): VRCameraMetrics;
  46219. }
  46220. }
  46221. declare module BABYLON {
  46222. /** @hidden */
  46223. export var vrDistortionCorrectionPixelShader: {
  46224. name: string;
  46225. shader: string;
  46226. };
  46227. }
  46228. declare module BABYLON {
  46229. /**
  46230. * VRDistortionCorrectionPostProcess used for mobile VR
  46231. */
  46232. export class VRDistortionCorrectionPostProcess extends PostProcess {
  46233. private _isRightEye;
  46234. private _distortionFactors;
  46235. private _postProcessScaleFactor;
  46236. private _lensCenterOffset;
  46237. private _scaleIn;
  46238. private _scaleFactor;
  46239. private _lensCenter;
  46240. /**
  46241. * Initializes the VRDistortionCorrectionPostProcess
  46242. * @param name The name of the effect.
  46243. * @param camera The camera to apply the render pass to.
  46244. * @param isRightEye If this is for the right eye distortion
  46245. * @param vrMetrics All the required metrics for the VR camera
  46246. */
  46247. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  46248. }
  46249. }
  46250. declare module BABYLON {
  46251. /**
  46252. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  46253. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46254. */
  46255. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  46256. /**
  46257. * Creates a new VRDeviceOrientationArcRotateCamera
  46258. * @param name defines camera name
  46259. * @param alpha defines the camera rotation along the logitudinal axis
  46260. * @param beta defines the camera rotation along the latitudinal axis
  46261. * @param radius defines the camera distance from its target
  46262. * @param target defines the camera target
  46263. * @param scene defines the scene the camera belongs to
  46264. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46265. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46266. */
  46267. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46268. /**
  46269. * Gets camera class name
  46270. * @returns VRDeviceOrientationArcRotateCamera
  46271. */
  46272. getClassName(): string;
  46273. }
  46274. }
  46275. declare module BABYLON {
  46276. /**
  46277. * Camera used to simulate VR rendering (based on FreeCamera)
  46278. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46279. */
  46280. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  46281. /**
  46282. * Creates a new VRDeviceOrientationFreeCamera
  46283. * @param name defines camera name
  46284. * @param position defines the start position of the camera
  46285. * @param scene defines the scene the camera belongs to
  46286. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46287. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46288. */
  46289. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46290. /**
  46291. * Gets camera class name
  46292. * @returns VRDeviceOrientationFreeCamera
  46293. */
  46294. getClassName(): string;
  46295. }
  46296. }
  46297. declare module BABYLON {
  46298. /**
  46299. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  46300. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46301. */
  46302. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  46303. /**
  46304. * Creates a new VRDeviceOrientationGamepadCamera
  46305. * @param name defines camera name
  46306. * @param position defines the start position of the camera
  46307. * @param scene defines the scene the camera belongs to
  46308. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46309. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46310. */
  46311. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46312. /**
  46313. * Gets camera class name
  46314. * @returns VRDeviceOrientationGamepadCamera
  46315. */
  46316. getClassName(): string;
  46317. }
  46318. }
  46319. declare module BABYLON {
  46320. /**
  46321. * A class extending Texture allowing drawing on a texture
  46322. * @see https://doc.babylonjs.com/how_to/dynamictexture
  46323. */
  46324. export class DynamicTexture extends Texture {
  46325. private _generateMipMaps;
  46326. private _canvas;
  46327. private _context;
  46328. /**
  46329. * Creates a DynamicTexture
  46330. * @param name defines the name of the texture
  46331. * @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
  46332. * @param scene defines the scene where you want the texture
  46333. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  46334. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  46335. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  46336. */
  46337. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  46338. /**
  46339. * Get the current class name of the texture useful for serialization or dynamic coding.
  46340. * @returns "DynamicTexture"
  46341. */
  46342. getClassName(): string;
  46343. /**
  46344. * Gets the current state of canRescale
  46345. */
  46346. get canRescale(): boolean;
  46347. private _recreate;
  46348. /**
  46349. * Scales the texture
  46350. * @param ratio the scale factor to apply to both width and height
  46351. */
  46352. scale(ratio: number): void;
  46353. /**
  46354. * Resizes the texture
  46355. * @param width the new width
  46356. * @param height the new height
  46357. */
  46358. scaleTo(width: number, height: number): void;
  46359. /**
  46360. * Gets the context of the canvas used by the texture
  46361. * @returns the canvas context of the dynamic texture
  46362. */
  46363. getContext(): CanvasRenderingContext2D;
  46364. /**
  46365. * Clears the texture
  46366. */
  46367. clear(): void;
  46368. /**
  46369. * Updates the texture
  46370. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46371. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  46372. */
  46373. update(invertY?: boolean, premulAlpha?: boolean): void;
  46374. /**
  46375. * Draws text onto the texture
  46376. * @param text defines the text to be drawn
  46377. * @param x defines the placement of the text from the left
  46378. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  46379. * @param font defines the font to be used with font-style, font-size, font-name
  46380. * @param color defines the color used for the text
  46381. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  46382. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46383. * @param update defines whether texture is immediately update (default is true)
  46384. */
  46385. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  46386. /**
  46387. * Clones the texture
  46388. * @returns the clone of the texture.
  46389. */
  46390. clone(): DynamicTexture;
  46391. /**
  46392. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  46393. * @returns a serialized dynamic texture object
  46394. */
  46395. serialize(): any;
  46396. private _IsCanvasElement;
  46397. /** @hidden */
  46398. _rebuild(): void;
  46399. }
  46400. }
  46401. declare module BABYLON {
  46402. /**
  46403. * Class containing static functions to help procedurally build meshes
  46404. */
  46405. export class GroundBuilder {
  46406. /**
  46407. * Creates a ground mesh
  46408. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  46409. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  46410. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46411. * @param name defines the name of the mesh
  46412. * @param options defines the options used to create the mesh
  46413. * @param scene defines the hosting scene
  46414. * @returns the ground mesh
  46415. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  46416. */
  46417. static CreateGround(name: string, options: {
  46418. width?: number;
  46419. height?: number;
  46420. subdivisions?: number;
  46421. subdivisionsX?: number;
  46422. subdivisionsY?: number;
  46423. updatable?: boolean;
  46424. }, scene: any): Mesh;
  46425. /**
  46426. * Creates a tiled ground mesh
  46427. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  46428. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  46429. * * 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
  46430. * * 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
  46431. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46432. * @param name defines the name of the mesh
  46433. * @param options defines the options used to create the mesh
  46434. * @param scene defines the hosting scene
  46435. * @returns the tiled ground mesh
  46436. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  46437. */
  46438. static CreateTiledGround(name: string, options: {
  46439. xmin: number;
  46440. zmin: number;
  46441. xmax: number;
  46442. zmax: number;
  46443. subdivisions?: {
  46444. w: number;
  46445. h: number;
  46446. };
  46447. precision?: {
  46448. w: number;
  46449. h: number;
  46450. };
  46451. updatable?: boolean;
  46452. }, scene?: Nullable<Scene>): Mesh;
  46453. /**
  46454. * Creates a ground mesh from a height map
  46455. * * The parameter `url` sets the URL of the height map image resource.
  46456. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  46457. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  46458. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  46459. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  46460. * * 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.
  46461. * * 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).
  46462. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  46463. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46464. * @param name defines the name of the mesh
  46465. * @param url defines the url to the height map
  46466. * @param options defines the options used to create the mesh
  46467. * @param scene defines the hosting scene
  46468. * @returns the ground mesh
  46469. * @see https://doc.babylonjs.com/babylon101/height_map
  46470. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  46471. */
  46472. static CreateGroundFromHeightMap(name: string, url: string, options: {
  46473. width?: number;
  46474. height?: number;
  46475. subdivisions?: number;
  46476. minHeight?: number;
  46477. maxHeight?: number;
  46478. colorFilter?: Color3;
  46479. alphaFilter?: number;
  46480. updatable?: boolean;
  46481. onReady?: (mesh: GroundMesh) => void;
  46482. }, scene?: Nullable<Scene>): GroundMesh;
  46483. }
  46484. }
  46485. declare module BABYLON {
  46486. /**
  46487. * Class containing static functions to help procedurally build meshes
  46488. */
  46489. export class TorusBuilder {
  46490. /**
  46491. * Creates a torus mesh
  46492. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  46493. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  46494. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  46495. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46496. * * 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
  46497. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46498. * @param name defines the name of the mesh
  46499. * @param options defines the options used to create the mesh
  46500. * @param scene defines the hosting scene
  46501. * @returns the torus mesh
  46502. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  46503. */
  46504. static CreateTorus(name: string, options: {
  46505. diameter?: number;
  46506. thickness?: number;
  46507. tessellation?: number;
  46508. updatable?: boolean;
  46509. sideOrientation?: number;
  46510. frontUVs?: Vector4;
  46511. backUVs?: Vector4;
  46512. }, scene: any): Mesh;
  46513. }
  46514. }
  46515. declare module BABYLON {
  46516. /**
  46517. * Class containing static functions to help procedurally build meshes
  46518. */
  46519. export class CylinderBuilder {
  46520. /**
  46521. * Creates a cylinder or a cone mesh
  46522. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  46523. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  46524. * * 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.
  46525. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  46526. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  46527. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  46528. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  46529. * * 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).
  46530. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  46531. * * 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).
  46532. * * 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
  46533. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  46534. * * 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
  46535. * * 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.
  46536. * * If `enclose` is false, a ring surface is one element.
  46537. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  46538. * * 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
  46539. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46540. * * 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
  46541. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46542. * @param name defines the name of the mesh
  46543. * @param options defines the options used to create the mesh
  46544. * @param scene defines the hosting scene
  46545. * @returns the cylinder mesh
  46546. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  46547. */
  46548. static CreateCylinder(name: string, options: {
  46549. height?: number;
  46550. diameterTop?: number;
  46551. diameterBottom?: number;
  46552. diameter?: number;
  46553. tessellation?: number;
  46554. subdivisions?: number;
  46555. arc?: number;
  46556. faceColors?: Color4[];
  46557. faceUV?: Vector4[];
  46558. updatable?: boolean;
  46559. hasRings?: boolean;
  46560. enclose?: boolean;
  46561. cap?: number;
  46562. sideOrientation?: number;
  46563. frontUVs?: Vector4;
  46564. backUVs?: Vector4;
  46565. }, scene: any): Mesh;
  46566. }
  46567. }
  46568. declare module BABYLON {
  46569. /**
  46570. * States of the webXR experience
  46571. */
  46572. export enum WebXRState {
  46573. /**
  46574. * Transitioning to being in XR mode
  46575. */
  46576. ENTERING_XR = 0,
  46577. /**
  46578. * Transitioning to non XR mode
  46579. */
  46580. EXITING_XR = 1,
  46581. /**
  46582. * In XR mode and presenting
  46583. */
  46584. IN_XR = 2,
  46585. /**
  46586. * Not entered XR mode
  46587. */
  46588. NOT_IN_XR = 3
  46589. }
  46590. /**
  46591. * Abstraction of the XR render target
  46592. */
  46593. export interface WebXRRenderTarget extends IDisposable {
  46594. /**
  46595. * xrpresent context of the canvas which can be used to display/mirror xr content
  46596. */
  46597. canvasContext: WebGLRenderingContext;
  46598. /**
  46599. * xr layer for the canvas
  46600. */
  46601. xrLayer: Nullable<XRWebGLLayer>;
  46602. /**
  46603. * Initializes the xr layer for the session
  46604. * @param xrSession xr session
  46605. * @returns a promise that will resolve once the XR Layer has been created
  46606. */
  46607. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46608. }
  46609. }
  46610. declare module BABYLON {
  46611. /**
  46612. * COnfiguration object for WebXR output canvas
  46613. */
  46614. export class WebXRManagedOutputCanvasOptions {
  46615. /**
  46616. * An optional canvas in case you wish to create it yourself and provide it here.
  46617. * If not provided, a new canvas will be created
  46618. */
  46619. canvasElement?: HTMLCanvasElement;
  46620. /**
  46621. * Options for this XR Layer output
  46622. */
  46623. canvasOptions?: XRWebGLLayerOptions;
  46624. /**
  46625. * CSS styling for a newly created canvas (if not provided)
  46626. */
  46627. newCanvasCssStyle?: string;
  46628. /**
  46629. * Get the default values of the configuration object
  46630. * @returns default values of this configuration object
  46631. */
  46632. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  46633. }
  46634. /**
  46635. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  46636. */
  46637. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  46638. private _options;
  46639. private _canvas;
  46640. private _engine;
  46641. private _originalCanvasSize;
  46642. /**
  46643. * Rendering context of the canvas which can be used to display/mirror xr content
  46644. */
  46645. canvasContext: WebGLRenderingContext;
  46646. /**
  46647. * xr layer for the canvas
  46648. */
  46649. xrLayer: Nullable<XRWebGLLayer>;
  46650. /**
  46651. * Obseervers registered here will be triggered when the xr layer was initialized
  46652. */
  46653. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  46654. /**
  46655. * Initializes the canvas to be added/removed upon entering/exiting xr
  46656. * @param _xrSessionManager The XR Session manager
  46657. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  46658. */
  46659. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  46660. /**
  46661. * Disposes of the object
  46662. */
  46663. dispose(): void;
  46664. /**
  46665. * Initializes the xr layer for the session
  46666. * @param xrSession xr session
  46667. * @returns a promise that will resolve once the XR Layer has been created
  46668. */
  46669. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  46670. private _addCanvas;
  46671. private _removeCanvas;
  46672. private _setCanvasSize;
  46673. private _setManagedOutputCanvas;
  46674. }
  46675. }
  46676. declare module BABYLON {
  46677. /**
  46678. * Manages an XRSession to work with Babylon's engine
  46679. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  46680. */
  46681. export class WebXRSessionManager implements IDisposable {
  46682. /** The scene which the session should be created for */
  46683. scene: Scene;
  46684. private _referenceSpace;
  46685. private _rttProvider;
  46686. private _sessionEnded;
  46687. private _xrNavigator;
  46688. private baseLayer;
  46689. /**
  46690. * The base reference space from which the session started. good if you want to reset your
  46691. * reference space
  46692. */
  46693. baseReferenceSpace: XRReferenceSpace;
  46694. /**
  46695. * Current XR frame
  46696. */
  46697. currentFrame: Nullable<XRFrame>;
  46698. /** WebXR timestamp updated every frame */
  46699. currentTimestamp: number;
  46700. /**
  46701. * Used just in case of a failure to initialize an immersive session.
  46702. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  46703. */
  46704. defaultHeightCompensation: number;
  46705. /**
  46706. * Fires every time a new xrFrame arrives which can be used to update the camera
  46707. */
  46708. onXRFrameObservable: Observable<XRFrame>;
  46709. /**
  46710. * Fires when the reference space changed
  46711. */
  46712. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  46713. /**
  46714. * Fires when the xr session is ended either by the device or manually done
  46715. */
  46716. onXRSessionEnded: Observable<any>;
  46717. /**
  46718. * Fires when the xr session is ended either by the device or manually done
  46719. */
  46720. onXRSessionInit: Observable<XRSession>;
  46721. /**
  46722. * Underlying xr session
  46723. */
  46724. session: XRSession;
  46725. /**
  46726. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  46727. * or get the offset the player is currently at.
  46728. */
  46729. viewerReferenceSpace: XRReferenceSpace;
  46730. /**
  46731. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  46732. * @param scene The scene which the session should be created for
  46733. */
  46734. constructor(
  46735. /** The scene which the session should be created for */
  46736. scene: Scene);
  46737. /**
  46738. * The current reference space used in this session. This reference space can constantly change!
  46739. * It is mainly used to offset the camera's position.
  46740. */
  46741. get referenceSpace(): XRReferenceSpace;
  46742. /**
  46743. * Set a new reference space and triggers the observable
  46744. */
  46745. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  46746. /**
  46747. * Disposes of the session manager
  46748. */
  46749. dispose(): void;
  46750. /**
  46751. * Stops the xrSession and restores the render loop
  46752. * @returns Promise which resolves after it exits XR
  46753. */
  46754. exitXRAsync(): Promise<void>;
  46755. /**
  46756. * Gets the correct render target texture to be rendered this frame for this eye
  46757. * @param eye the eye for which to get the render target
  46758. * @returns the render target for the specified eye
  46759. */
  46760. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  46761. /**
  46762. * Creates a WebXRRenderTarget object for the XR session
  46763. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  46764. * @param options optional options to provide when creating a new render target
  46765. * @returns a WebXR render target to which the session can render
  46766. */
  46767. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  46768. /**
  46769. * Initializes the manager
  46770. * After initialization enterXR can be called to start an XR session
  46771. * @returns Promise which resolves after it is initialized
  46772. */
  46773. initializeAsync(): Promise<void>;
  46774. /**
  46775. * Initializes an xr session
  46776. * @param xrSessionMode mode to initialize
  46777. * @param xrSessionInit defines optional and required values to pass to the session builder
  46778. * @returns a promise which will resolve once the session has been initialized
  46779. */
  46780. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  46781. /**
  46782. * Checks if a session would be supported for the creation options specified
  46783. * @param sessionMode session mode to check if supported eg. immersive-vr
  46784. * @returns A Promise that resolves to true if supported and false if not
  46785. */
  46786. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46787. /**
  46788. * Resets the reference space to the one started the session
  46789. */
  46790. resetReferenceSpace(): void;
  46791. /**
  46792. * Starts rendering to the xr layer
  46793. */
  46794. runXRRenderLoop(): void;
  46795. /**
  46796. * Sets the reference space on the xr session
  46797. * @param referenceSpaceType space to set
  46798. * @returns a promise that will resolve once the reference space has been set
  46799. */
  46800. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  46801. /**
  46802. * Updates the render state of the session
  46803. * @param state state to set
  46804. * @returns a promise that resolves once the render state has been updated
  46805. */
  46806. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  46807. /**
  46808. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  46809. * @param sessionMode defines the session to test
  46810. * @returns a promise with boolean as final value
  46811. */
  46812. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  46813. private _createRenderTargetTexture;
  46814. }
  46815. }
  46816. declare module BABYLON {
  46817. /**
  46818. * WebXR Camera which holds the views for the xrSession
  46819. * @see https://doc.babylonjs.com/how_to/webxr_camera
  46820. */
  46821. export class WebXRCamera extends FreeCamera {
  46822. private _xrSessionManager;
  46823. private _firstFrame;
  46824. private _referenceQuaternion;
  46825. private _referencedPosition;
  46826. private _xrInvPositionCache;
  46827. private _xrInvQuaternionCache;
  46828. /**
  46829. * Should position compensation execute on first frame.
  46830. * This is used when copying the position from a native (non XR) camera
  46831. */
  46832. compensateOnFirstFrame: boolean;
  46833. /**
  46834. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  46835. * @param name the name of the camera
  46836. * @param scene the scene to add the camera to
  46837. * @param _xrSessionManager a constructed xr session manager
  46838. */
  46839. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  46840. /**
  46841. * Return the user's height, unrelated to the current ground.
  46842. * This will be the y position of this camera, when ground level is 0.
  46843. */
  46844. get realWorldHeight(): number;
  46845. /** @hidden */
  46846. _updateForDualEyeDebugging(): void;
  46847. /**
  46848. * Sets this camera's transformation based on a non-vr camera
  46849. * @param otherCamera the non-vr camera to copy the transformation from
  46850. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  46851. */
  46852. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  46853. /**
  46854. * Gets the current instance class name ("WebXRCamera").
  46855. * @returns the class name
  46856. */
  46857. getClassName(): string;
  46858. private _rotate180;
  46859. private _updateFromXRSession;
  46860. private _updateNumberOfRigCameras;
  46861. private _updateReferenceSpace;
  46862. private _updateReferenceSpaceOffset;
  46863. }
  46864. }
  46865. declare module BABYLON {
  46866. /**
  46867. * Defining the interface required for a (webxr) feature
  46868. */
  46869. export interface IWebXRFeature extends IDisposable {
  46870. /**
  46871. * Is this feature attached
  46872. */
  46873. attached: boolean;
  46874. /**
  46875. * Should auto-attach be disabled?
  46876. */
  46877. disableAutoAttach: boolean;
  46878. /**
  46879. * Attach the feature to the session
  46880. * Will usually be called by the features manager
  46881. *
  46882. * @param force should attachment be forced (even when already attached)
  46883. * @returns true if successful.
  46884. */
  46885. attach(force?: boolean): boolean;
  46886. /**
  46887. * Detach the feature from the session
  46888. * Will usually be called by the features manager
  46889. *
  46890. * @returns true if successful.
  46891. */
  46892. detach(): boolean;
  46893. /**
  46894. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  46895. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  46896. *
  46897. * @returns whether or not the feature is compatible in this environment
  46898. */
  46899. isCompatible(): boolean;
  46900. /**
  46901. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  46902. */
  46903. xrNativeFeatureName?: string;
  46904. }
  46905. /**
  46906. * A list of the currently available features without referencing them
  46907. */
  46908. export class WebXRFeatureName {
  46909. /**
  46910. * The name of the anchor system feature
  46911. */
  46912. static ANCHOR_SYSTEM: string;
  46913. /**
  46914. * The name of the background remover feature
  46915. */
  46916. static BACKGROUND_REMOVER: string;
  46917. /**
  46918. * The name of the hit test feature
  46919. */
  46920. static HIT_TEST: string;
  46921. /**
  46922. * physics impostors for xr controllers feature
  46923. */
  46924. static PHYSICS_CONTROLLERS: string;
  46925. /**
  46926. * The name of the plane detection feature
  46927. */
  46928. static PLANE_DETECTION: string;
  46929. /**
  46930. * The name of the pointer selection feature
  46931. */
  46932. static POINTER_SELECTION: string;
  46933. /**
  46934. * The name of the teleportation feature
  46935. */
  46936. static TELEPORTATION: string;
  46937. }
  46938. /**
  46939. * Defining the constructor of a feature. Used to register the modules.
  46940. */
  46941. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  46942. /**
  46943. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  46944. * It is mainly used in AR sessions.
  46945. *
  46946. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  46947. */
  46948. export class WebXRFeaturesManager implements IDisposable {
  46949. private _xrSessionManager;
  46950. private static readonly _AvailableFeatures;
  46951. private _features;
  46952. /**
  46953. * constructs a new features manages.
  46954. *
  46955. * @param _xrSessionManager an instance of WebXRSessionManager
  46956. */
  46957. constructor(_xrSessionManager: WebXRSessionManager);
  46958. /**
  46959. * Used to register a module. After calling this function a developer can use this feature in the scene.
  46960. * Mainly used internally.
  46961. *
  46962. * @param featureName the name of the feature to register
  46963. * @param constructorFunction the function used to construct the module
  46964. * @param version the (babylon) version of the module
  46965. * @param stable is that a stable version of this module
  46966. */
  46967. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  46968. /**
  46969. * Returns a constructor of a specific feature.
  46970. *
  46971. * @param featureName the name of the feature to construct
  46972. * @param version the version of the feature to load
  46973. * @param xrSessionManager the xrSessionManager. Used to construct the module
  46974. * @param options optional options provided to the module.
  46975. * @returns a function that, when called, will return a new instance of this feature
  46976. */
  46977. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  46978. /**
  46979. * Can be used to return the list of features currently registered
  46980. *
  46981. * @returns an Array of available features
  46982. */
  46983. static GetAvailableFeatures(): string[];
  46984. /**
  46985. * Gets the versions available for a specific feature
  46986. * @param featureName the name of the feature
  46987. * @returns an array with the available versions
  46988. */
  46989. static GetAvailableVersions(featureName: string): string[];
  46990. /**
  46991. * Return the latest unstable version of this feature
  46992. * @param featureName the name of the feature to search
  46993. * @returns the version number. if not found will return -1
  46994. */
  46995. static GetLatestVersionOfFeature(featureName: string): number;
  46996. /**
  46997. * Return the latest stable version of this feature
  46998. * @param featureName the name of the feature to search
  46999. * @returns the version number. if not found will return -1
  47000. */
  47001. static GetStableVersionOfFeature(featureName: string): number;
  47002. /**
  47003. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  47004. * Can be used during a session to start a feature
  47005. * @param featureName the name of feature to attach
  47006. */
  47007. attachFeature(featureName: string): void;
  47008. /**
  47009. * Can be used inside a session or when the session ends to detach a specific feature
  47010. * @param featureName the name of the feature to detach
  47011. */
  47012. detachFeature(featureName: string): void;
  47013. /**
  47014. * Used to disable an already-enabled feature
  47015. * The feature will be disposed and will be recreated once enabled.
  47016. * @param featureName the feature to disable
  47017. * @returns true if disable was successful
  47018. */
  47019. disableFeature(featureName: string | {
  47020. Name: string;
  47021. }): boolean;
  47022. /**
  47023. * dispose this features manager
  47024. */
  47025. dispose(): void;
  47026. /**
  47027. * 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.
  47028. * 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.
  47029. *
  47030. * @param featureName the name of the feature to load or the class of the feature
  47031. * @param version optional version to load. if not provided the latest version will be enabled
  47032. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  47033. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  47034. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  47035. * @returns a new constructed feature or throws an error if feature not found.
  47036. */
  47037. enableFeature(featureName: string | {
  47038. Name: string;
  47039. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  47040. /**
  47041. * get the implementation of an enabled feature.
  47042. * @param featureName the name of the feature to load
  47043. * @returns the feature class, if found
  47044. */
  47045. getEnabledFeature(featureName: string): IWebXRFeature;
  47046. /**
  47047. * Get the list of enabled features
  47048. * @returns an array of enabled features
  47049. */
  47050. getEnabledFeatures(): string[];
  47051. /**
  47052. * This function will exten the session creation configuration object with enabled features.
  47053. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  47054. * according to the defined "required" variable, provided during enableFeature call
  47055. * @param xrSessionInit the xr Session init object to extend
  47056. *
  47057. * @returns an extended XRSessionInit object
  47058. */
  47059. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  47060. }
  47061. }
  47062. declare module BABYLON {
  47063. /**
  47064. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  47065. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  47066. */
  47067. export class WebXRExperienceHelper implements IDisposable {
  47068. private scene;
  47069. private _nonVRCamera;
  47070. private _originalSceneAutoClear;
  47071. private _supported;
  47072. /**
  47073. * Camera used to render xr content
  47074. */
  47075. camera: WebXRCamera;
  47076. /** A features manager for this xr session */
  47077. featuresManager: WebXRFeaturesManager;
  47078. /**
  47079. * Observers registered here will be triggered after the camera's initial transformation is set
  47080. * This can be used to set a different ground level or an extra rotation.
  47081. *
  47082. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  47083. * to the position set after this observable is done executing.
  47084. */
  47085. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  47086. /**
  47087. * Fires when the state of the experience helper has changed
  47088. */
  47089. onStateChangedObservable: Observable<WebXRState>;
  47090. /** Session manager used to keep track of xr session */
  47091. sessionManager: WebXRSessionManager;
  47092. /**
  47093. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  47094. */
  47095. state: WebXRState;
  47096. /**
  47097. * Creates a WebXRExperienceHelper
  47098. * @param scene The scene the helper should be created in
  47099. */
  47100. private constructor();
  47101. /**
  47102. * Creates the experience helper
  47103. * @param scene the scene to attach the experience helper to
  47104. * @returns a promise for the experience helper
  47105. */
  47106. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  47107. /**
  47108. * Disposes of the experience helper
  47109. */
  47110. dispose(): void;
  47111. /**
  47112. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  47113. * @param sessionMode options for the XR session
  47114. * @param referenceSpaceType frame of reference of the XR session
  47115. * @param renderTarget the output canvas that will be used to enter XR mode
  47116. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  47117. * @returns promise that resolves after xr mode has entered
  47118. */
  47119. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  47120. /**
  47121. * Exits XR mode and returns the scene to its original state
  47122. * @returns promise that resolves after xr mode has exited
  47123. */
  47124. exitXRAsync(): Promise<void>;
  47125. private _nonXRToXRCamera;
  47126. private _setState;
  47127. }
  47128. }
  47129. declare module BABYLON {
  47130. /**
  47131. * X-Y values for axes in WebXR
  47132. */
  47133. export interface IWebXRMotionControllerAxesValue {
  47134. /**
  47135. * The value of the x axis
  47136. */
  47137. x: number;
  47138. /**
  47139. * The value of the y-axis
  47140. */
  47141. y: number;
  47142. }
  47143. /**
  47144. * changed / previous values for the values of this component
  47145. */
  47146. export interface IWebXRMotionControllerComponentChangesValues<T> {
  47147. /**
  47148. * current (this frame) value
  47149. */
  47150. current: T;
  47151. /**
  47152. * previous (last change) value
  47153. */
  47154. previous: T;
  47155. }
  47156. /**
  47157. * Represents changes in the component between current frame and last values recorded
  47158. */
  47159. export interface IWebXRMotionControllerComponentChanges {
  47160. /**
  47161. * will be populated with previous and current values if axes changed
  47162. */
  47163. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  47164. /**
  47165. * will be populated with previous and current values if pressed changed
  47166. */
  47167. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47168. /**
  47169. * will be populated with previous and current values if touched changed
  47170. */
  47171. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47172. /**
  47173. * will be populated with previous and current values if value changed
  47174. */
  47175. value?: IWebXRMotionControllerComponentChangesValues<number>;
  47176. }
  47177. /**
  47178. * This class represents a single component (for example button or thumbstick) of a motion controller
  47179. */
  47180. export class WebXRControllerComponent implements IDisposable {
  47181. /**
  47182. * the id of this component
  47183. */
  47184. id: string;
  47185. /**
  47186. * the type of the component
  47187. */
  47188. type: MotionControllerComponentType;
  47189. private _buttonIndex;
  47190. private _axesIndices;
  47191. private _axes;
  47192. private _changes;
  47193. private _currentValue;
  47194. private _hasChanges;
  47195. private _pressed;
  47196. private _touched;
  47197. /**
  47198. * button component type
  47199. */
  47200. static BUTTON_TYPE: MotionControllerComponentType;
  47201. /**
  47202. * squeeze component type
  47203. */
  47204. static SQUEEZE_TYPE: MotionControllerComponentType;
  47205. /**
  47206. * Thumbstick component type
  47207. */
  47208. static THUMBSTICK_TYPE: MotionControllerComponentType;
  47209. /**
  47210. * Touchpad component type
  47211. */
  47212. static TOUCHPAD_TYPE: MotionControllerComponentType;
  47213. /**
  47214. * trigger component type
  47215. */
  47216. static TRIGGER_TYPE: MotionControllerComponentType;
  47217. /**
  47218. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  47219. * the axes data changes
  47220. */
  47221. onAxisValueChangedObservable: Observable<{
  47222. x: number;
  47223. y: number;
  47224. }>;
  47225. /**
  47226. * Observers registered here will be triggered when the state of a button changes
  47227. * State change is either pressed / touched / value
  47228. */
  47229. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  47230. /**
  47231. * Creates a new component for a motion controller.
  47232. * It is created by the motion controller itself
  47233. *
  47234. * @param id the id of this component
  47235. * @param type the type of the component
  47236. * @param _buttonIndex index in the buttons array of the gamepad
  47237. * @param _axesIndices indices of the values in the axes array of the gamepad
  47238. */
  47239. constructor(
  47240. /**
  47241. * the id of this component
  47242. */
  47243. id: string,
  47244. /**
  47245. * the type of the component
  47246. */
  47247. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  47248. /**
  47249. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  47250. */
  47251. get axes(): IWebXRMotionControllerAxesValue;
  47252. /**
  47253. * Get the changes. Elements will be populated only if they changed with their previous and current value
  47254. */
  47255. get changes(): IWebXRMotionControllerComponentChanges;
  47256. /**
  47257. * Return whether or not the component changed the last frame
  47258. */
  47259. get hasChanges(): boolean;
  47260. /**
  47261. * is the button currently pressed
  47262. */
  47263. get pressed(): boolean;
  47264. /**
  47265. * is the button currently touched
  47266. */
  47267. get touched(): boolean;
  47268. /**
  47269. * Get the current value of this component
  47270. */
  47271. get value(): number;
  47272. /**
  47273. * Dispose this component
  47274. */
  47275. dispose(): void;
  47276. /**
  47277. * Are there axes correlating to this component
  47278. * @return true is axes data is available
  47279. */
  47280. isAxes(): boolean;
  47281. /**
  47282. * Is this component a button (hence - pressable)
  47283. * @returns true if can be pressed
  47284. */
  47285. isButton(): boolean;
  47286. /**
  47287. * update this component using the gamepad object it is in. Called on every frame
  47288. * @param nativeController the native gamepad controller object
  47289. */
  47290. update(nativeController: IMinimalMotionControllerObject): void;
  47291. }
  47292. }
  47293. declare module BABYLON {
  47294. /**
  47295. * Interface used to represent data loading progression
  47296. */
  47297. export interface ISceneLoaderProgressEvent {
  47298. /**
  47299. * Defines if data length to load can be evaluated
  47300. */
  47301. readonly lengthComputable: boolean;
  47302. /**
  47303. * Defines the loaded data length
  47304. */
  47305. readonly loaded: number;
  47306. /**
  47307. * Defines the data length to load
  47308. */
  47309. readonly total: number;
  47310. }
  47311. /**
  47312. * Interface used by SceneLoader plugins to define supported file extensions
  47313. */
  47314. export interface ISceneLoaderPluginExtensions {
  47315. /**
  47316. * Defines the list of supported extensions
  47317. */
  47318. [extension: string]: {
  47319. isBinary: boolean;
  47320. };
  47321. }
  47322. /**
  47323. * Interface used by SceneLoader plugin factory
  47324. */
  47325. export interface ISceneLoaderPluginFactory {
  47326. /**
  47327. * Defines the name of the factory
  47328. */
  47329. name: string;
  47330. /**
  47331. * Function called to create a new plugin
  47332. * @return the new plugin
  47333. */
  47334. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  47335. /**
  47336. * The callback that returns true if the data can be directly loaded.
  47337. * @param data string containing the file data
  47338. * @returns if the data can be loaded directly
  47339. */
  47340. canDirectLoad?(data: string): boolean;
  47341. }
  47342. /**
  47343. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  47344. */
  47345. export interface ISceneLoaderPluginBase {
  47346. /**
  47347. * The friendly name of this plugin.
  47348. */
  47349. name: string;
  47350. /**
  47351. * The file extensions supported by this plugin.
  47352. */
  47353. extensions: string | ISceneLoaderPluginExtensions;
  47354. /**
  47355. * The callback called when loading from a url.
  47356. * @param scene scene loading this url
  47357. * @param url url to load
  47358. * @param onSuccess callback called when the file successfully loads
  47359. * @param onProgress callback called while file is loading (if the server supports this mode)
  47360. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  47361. * @param onError callback called when the file fails to load
  47362. * @returns a file request object
  47363. */
  47364. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47365. /**
  47366. * The callback called when loading from a file object.
  47367. * @param scene scene loading this file
  47368. * @param file defines the file to load
  47369. * @param onSuccess defines the callback to call when data is loaded
  47370. * @param onProgress defines the callback to call during loading process
  47371. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  47372. * @param onError defines the callback to call when an error occurs
  47373. * @returns a file request object
  47374. */
  47375. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47376. /**
  47377. * The callback that returns true if the data can be directly loaded.
  47378. * @param data string containing the file data
  47379. * @returns if the data can be loaded directly
  47380. */
  47381. canDirectLoad?(data: string): boolean;
  47382. /**
  47383. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  47384. * @param scene scene loading this data
  47385. * @param data string containing the data
  47386. * @returns data to pass to the plugin
  47387. */
  47388. directLoad?(scene: Scene, data: string): any;
  47389. /**
  47390. * The callback that allows custom handling of the root url based on the response url.
  47391. * @param rootUrl the original root url
  47392. * @param responseURL the response url if available
  47393. * @returns the new root url
  47394. */
  47395. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  47396. }
  47397. /**
  47398. * Interface used to define a SceneLoader plugin
  47399. */
  47400. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  47401. /**
  47402. * Import meshes into a scene.
  47403. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47404. * @param scene The scene to import into
  47405. * @param data The data to import
  47406. * @param rootUrl The root url for scene and resources
  47407. * @param meshes The meshes array to import into
  47408. * @param particleSystems The particle systems array to import into
  47409. * @param skeletons The skeletons array to import into
  47410. * @param onError The callback when import fails
  47411. * @returns True if successful or false otherwise
  47412. */
  47413. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  47414. /**
  47415. * Load into a scene.
  47416. * @param scene The scene to load into
  47417. * @param data The data to import
  47418. * @param rootUrl The root url for scene and resources
  47419. * @param onError The callback when import fails
  47420. * @returns True if successful or false otherwise
  47421. */
  47422. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  47423. /**
  47424. * Load into an asset container.
  47425. * @param scene The scene to load into
  47426. * @param data The data to import
  47427. * @param rootUrl The root url for scene and resources
  47428. * @param onError The callback when import fails
  47429. * @returns The loaded asset container
  47430. */
  47431. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  47432. }
  47433. /**
  47434. * Interface used to define an async SceneLoader plugin
  47435. */
  47436. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  47437. /**
  47438. * Import meshes into a scene.
  47439. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47440. * @param scene The scene to import into
  47441. * @param data The data to import
  47442. * @param rootUrl The root url for scene and resources
  47443. * @param onProgress The callback when the load progresses
  47444. * @param fileName Defines the name of the file to load
  47445. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  47446. */
  47447. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  47448. meshes: AbstractMesh[];
  47449. particleSystems: IParticleSystem[];
  47450. skeletons: Skeleton[];
  47451. animationGroups: AnimationGroup[];
  47452. }>;
  47453. /**
  47454. * Load into a scene.
  47455. * @param scene The scene to load into
  47456. * @param data The data to import
  47457. * @param rootUrl The root url for scene and resources
  47458. * @param onProgress The callback when the load progresses
  47459. * @param fileName Defines the name of the file to load
  47460. * @returns Nothing
  47461. */
  47462. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  47463. /**
  47464. * Load into an asset container.
  47465. * @param scene The scene to load into
  47466. * @param data The data to import
  47467. * @param rootUrl The root url for scene and resources
  47468. * @param onProgress The callback when the load progresses
  47469. * @param fileName Defines the name of the file to load
  47470. * @returns The loaded asset container
  47471. */
  47472. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  47473. }
  47474. /**
  47475. * Mode that determines how to handle old animation groups before loading new ones.
  47476. */
  47477. export enum SceneLoaderAnimationGroupLoadingMode {
  47478. /**
  47479. * Reset all old animations to initial state then dispose them.
  47480. */
  47481. Clean = 0,
  47482. /**
  47483. * Stop all old animations.
  47484. */
  47485. Stop = 1,
  47486. /**
  47487. * Restart old animations from first frame.
  47488. */
  47489. Sync = 2,
  47490. /**
  47491. * Old animations remains untouched.
  47492. */
  47493. NoSync = 3
  47494. }
  47495. /**
  47496. * Defines a plugin registered by the SceneLoader
  47497. */
  47498. interface IRegisteredPlugin {
  47499. /**
  47500. * Defines the plugin to use
  47501. */
  47502. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  47503. /**
  47504. * Defines if the plugin supports binary data
  47505. */
  47506. isBinary: boolean;
  47507. }
  47508. /**
  47509. * Class used to load scene from various file formats using registered plugins
  47510. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  47511. */
  47512. export class SceneLoader {
  47513. /**
  47514. * No logging while loading
  47515. */
  47516. static readonly NO_LOGGING: number;
  47517. /**
  47518. * Minimal logging while loading
  47519. */
  47520. static readonly MINIMAL_LOGGING: number;
  47521. /**
  47522. * Summary logging while loading
  47523. */
  47524. static readonly SUMMARY_LOGGING: number;
  47525. /**
  47526. * Detailled logging while loading
  47527. */
  47528. static readonly DETAILED_LOGGING: number;
  47529. /**
  47530. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  47531. */
  47532. static get ForceFullSceneLoadingForIncremental(): boolean;
  47533. static set ForceFullSceneLoadingForIncremental(value: boolean);
  47534. /**
  47535. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  47536. */
  47537. static get ShowLoadingScreen(): boolean;
  47538. static set ShowLoadingScreen(value: boolean);
  47539. /**
  47540. * Defines the current logging level (while loading the scene)
  47541. * @ignorenaming
  47542. */
  47543. static get loggingLevel(): number;
  47544. static set loggingLevel(value: number);
  47545. /**
  47546. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  47547. */
  47548. static get CleanBoneMatrixWeights(): boolean;
  47549. static set CleanBoneMatrixWeights(value: boolean);
  47550. /**
  47551. * Event raised when a plugin is used to load a scene
  47552. */
  47553. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  47554. private static _registeredPlugins;
  47555. private static _showingLoadingScreen;
  47556. /**
  47557. * Gets the default plugin (used to load Babylon files)
  47558. * @returns the .babylon plugin
  47559. */
  47560. static GetDefaultPlugin(): IRegisteredPlugin;
  47561. private static _GetPluginForExtension;
  47562. private static _GetPluginForDirectLoad;
  47563. private static _GetPluginForFilename;
  47564. private static _GetDirectLoad;
  47565. private static _LoadData;
  47566. private static _GetFileInfo;
  47567. /**
  47568. * Gets a plugin that can load the given extension
  47569. * @param extension defines the extension to load
  47570. * @returns a plugin or null if none works
  47571. */
  47572. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  47573. /**
  47574. * Gets a boolean indicating that the given extension can be loaded
  47575. * @param extension defines the extension to load
  47576. * @returns true if the extension is supported
  47577. */
  47578. static IsPluginForExtensionAvailable(extension: string): boolean;
  47579. /**
  47580. * Adds a new plugin to the list of registered plugins
  47581. * @param plugin defines the plugin to add
  47582. */
  47583. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  47584. /**
  47585. * Import meshes into a scene
  47586. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47587. * @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)
  47588. * @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)
  47589. * @param scene the instance of BABYLON.Scene to append to
  47590. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  47591. * @param onProgress a callback with a progress event for each file being loaded
  47592. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47593. * @param pluginExtension the extension used to determine the plugin
  47594. * @returns The loaded plugin
  47595. */
  47596. 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>;
  47597. /**
  47598. * Import meshes into a scene
  47599. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47600. * @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)
  47601. * @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)
  47602. * @param scene the instance of BABYLON.Scene to append to
  47603. * @param onProgress a callback with a progress event for each file being loaded
  47604. * @param pluginExtension the extension used to determine the plugin
  47605. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  47606. */
  47607. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  47608. meshes: AbstractMesh[];
  47609. particleSystems: IParticleSystem[];
  47610. skeletons: Skeleton[];
  47611. animationGroups: AnimationGroup[];
  47612. }>;
  47613. /**
  47614. * Load a scene
  47615. * @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)
  47616. * @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)
  47617. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47618. * @param onSuccess a callback with the scene when import succeeds
  47619. * @param onProgress a callback with a progress event for each file being loaded
  47620. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47621. * @param pluginExtension the extension used to determine the plugin
  47622. * @returns The loaded plugin
  47623. */
  47624. 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>;
  47625. /**
  47626. * Load a scene
  47627. * @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)
  47628. * @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)
  47629. * @param engine is the instance of BABYLON.Engine to use to create the scene
  47630. * @param onProgress a callback with a progress event for each file being loaded
  47631. * @param pluginExtension the extension used to determine the plugin
  47632. * @returns The loaded scene
  47633. */
  47634. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  47635. /**
  47636. * Append a scene
  47637. * @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)
  47638. * @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)
  47639. * @param scene is the instance of BABYLON.Scene to append to
  47640. * @param onSuccess a callback with the scene when import succeeds
  47641. * @param onProgress a callback with a progress event for each file being loaded
  47642. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47643. * @param pluginExtension the extension used to determine the plugin
  47644. * @returns The loaded plugin
  47645. */
  47646. 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>;
  47647. /**
  47648. * Append a scene
  47649. * @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)
  47650. * @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)
  47651. * @param scene is the instance of BABYLON.Scene to append to
  47652. * @param onProgress a callback with a progress event for each file being loaded
  47653. * @param pluginExtension the extension used to determine the plugin
  47654. * @returns The given scene
  47655. */
  47656. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  47657. /**
  47658. * Load a scene into an asset container
  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 scene is the instance of BABYLON.Scene to append to (default: last created 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 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>;
  47669. /**
  47670. * Load a scene into an asset container
  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 (default: empty string)
  47673. * @param scene is the instance of Scene to append to
  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 asset container
  47677. */
  47678. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  47679. /**
  47680. * Import animations from a file into 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 (default: last created scene)
  47684. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  47685. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  47686. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  47687. * @param onSuccess a callback with the scene when import succeeds
  47688. * @param onProgress a callback with a progress event for each file being loaded
  47689. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47690. * @param pluginExtension the extension used to determine the plugin
  47691. */
  47692. 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;
  47693. /**
  47694. * Import animations from a file into a scene
  47695. * @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)
  47696. * @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)
  47697. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47698. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  47699. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  47700. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  47701. * @param onSuccess a callback with the scene when import succeeds
  47702. * @param onProgress a callback with a progress event for each file being loaded
  47703. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  47704. * @param pluginExtension the extension used to determine the plugin
  47705. * @returns the updated scene with imported animations
  47706. */
  47707. 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>;
  47708. }
  47709. }
  47710. declare module BABYLON {
  47711. /**
  47712. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  47713. */
  47714. export type MotionControllerHandedness = "none" | "left" | "right";
  47715. /**
  47716. * The type of components available in motion controllers.
  47717. * This is not the name of the component.
  47718. */
  47719. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  47720. /**
  47721. * The state of a controller component
  47722. */
  47723. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  47724. /**
  47725. * The schema of motion controller layout.
  47726. * No object will be initialized using this interface
  47727. * This is used just to define the profile.
  47728. */
  47729. export interface IMotionControllerLayout {
  47730. /**
  47731. * Path to load the assets. Usually relative to the base path
  47732. */
  47733. assetPath: string;
  47734. /**
  47735. * Available components (unsorted)
  47736. */
  47737. components: {
  47738. /**
  47739. * A map of component Ids
  47740. */
  47741. [componentId: string]: {
  47742. /**
  47743. * The type of input the component outputs
  47744. */
  47745. type: MotionControllerComponentType;
  47746. /**
  47747. * The indices of this component in the gamepad object
  47748. */
  47749. gamepadIndices: {
  47750. /**
  47751. * Index of button
  47752. */
  47753. button?: number;
  47754. /**
  47755. * If available, index of x-axis
  47756. */
  47757. xAxis?: number;
  47758. /**
  47759. * If available, index of y-axis
  47760. */
  47761. yAxis?: number;
  47762. };
  47763. /**
  47764. * The mesh's root node name
  47765. */
  47766. rootNodeName: string;
  47767. /**
  47768. * Animation definitions for this model
  47769. */
  47770. visualResponses: {
  47771. [stateKey: string]: {
  47772. /**
  47773. * What property will be animated
  47774. */
  47775. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  47776. /**
  47777. * What states influence this visual response
  47778. */
  47779. states: MotionControllerComponentStateType[];
  47780. /**
  47781. * Type of animation - movement or visibility
  47782. */
  47783. valueNodeProperty: "transform" | "visibility";
  47784. /**
  47785. * Base node name to move. Its position will be calculated according to the min and max nodes
  47786. */
  47787. valueNodeName?: string;
  47788. /**
  47789. * Minimum movement node
  47790. */
  47791. minNodeName?: string;
  47792. /**
  47793. * Max movement node
  47794. */
  47795. maxNodeName?: string;
  47796. };
  47797. };
  47798. /**
  47799. * If touch enabled, what is the name of node to display user feedback
  47800. */
  47801. touchPointNodeName?: string;
  47802. };
  47803. };
  47804. /**
  47805. * Is it xr standard mapping or not
  47806. */
  47807. gamepadMapping: "" | "xr-standard";
  47808. /**
  47809. * Base root node of this entire model
  47810. */
  47811. rootNodeName: string;
  47812. /**
  47813. * Defines the main button component id
  47814. */
  47815. selectComponentId: string;
  47816. }
  47817. /**
  47818. * A definition for the layout map in the input profile
  47819. */
  47820. export interface IMotionControllerLayoutMap {
  47821. /**
  47822. * Layouts with handedness type as a key
  47823. */
  47824. [handedness: string]: IMotionControllerLayout;
  47825. }
  47826. /**
  47827. * The XR Input profile schema
  47828. * Profiles can be found here:
  47829. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  47830. */
  47831. export interface IMotionControllerProfile {
  47832. /**
  47833. * fallback profiles for this profileId
  47834. */
  47835. fallbackProfileIds: string[];
  47836. /**
  47837. * The layout map, with handedness as key
  47838. */
  47839. layouts: IMotionControllerLayoutMap;
  47840. /**
  47841. * The id of this profile
  47842. * correlates to the profile(s) in the xrInput.profiles array
  47843. */
  47844. profileId: string;
  47845. }
  47846. /**
  47847. * A helper-interface for the 3 meshes needed for controller button animation
  47848. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  47849. */
  47850. export interface IMotionControllerButtonMeshMap {
  47851. /**
  47852. * the mesh that defines the pressed value mesh position.
  47853. * This is used to find the max-position of this button
  47854. */
  47855. pressedMesh: AbstractMesh;
  47856. /**
  47857. * the mesh that defines the unpressed value mesh position.
  47858. * This is used to find the min (or initial) position of this button
  47859. */
  47860. unpressedMesh: AbstractMesh;
  47861. /**
  47862. * The mesh that will be changed when value changes
  47863. */
  47864. valueMesh: AbstractMesh;
  47865. }
  47866. /**
  47867. * A helper-interface for the 3 meshes needed for controller axis animation.
  47868. * This will be expanded when touchpad animations are fully supported
  47869. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  47870. */
  47871. export interface IMotionControllerMeshMap {
  47872. /**
  47873. * the mesh that defines the maximum value mesh position.
  47874. */
  47875. maxMesh?: AbstractMesh;
  47876. /**
  47877. * the mesh that defines the minimum value mesh position.
  47878. */
  47879. minMesh?: AbstractMesh;
  47880. /**
  47881. * The mesh that will be changed when axis value changes
  47882. */
  47883. valueMesh: AbstractMesh;
  47884. }
  47885. /**
  47886. * The elements needed for change-detection of the gamepad objects in motion controllers
  47887. */
  47888. export interface IMinimalMotionControllerObject {
  47889. /**
  47890. * Available axes of this controller
  47891. */
  47892. axes: number[];
  47893. /**
  47894. * An array of available buttons
  47895. */
  47896. buttons: Array<{
  47897. /**
  47898. * Value of the button/trigger
  47899. */
  47900. value: number;
  47901. /**
  47902. * If the button/trigger is currently touched
  47903. */
  47904. touched: boolean;
  47905. /**
  47906. * If the button/trigger is currently pressed
  47907. */
  47908. pressed: boolean;
  47909. }>;
  47910. /**
  47911. * EXPERIMENTAL haptic support.
  47912. */
  47913. hapticActuators?: Array<{
  47914. pulse: (value: number, duration: number) => Promise<boolean>;
  47915. }>;
  47916. }
  47917. /**
  47918. * An Abstract Motion controller
  47919. * This class receives an xrInput and a profile layout and uses those to initialize the components
  47920. * Each component has an observable to check for changes in value and state
  47921. */
  47922. export abstract class WebXRAbstractMotionController implements IDisposable {
  47923. protected scene: Scene;
  47924. protected layout: IMotionControllerLayout;
  47925. /**
  47926. * The gamepad object correlating to this controller
  47927. */
  47928. gamepadObject: IMinimalMotionControllerObject;
  47929. /**
  47930. * handedness (left/right/none) of this controller
  47931. */
  47932. handedness: MotionControllerHandedness;
  47933. private _initComponent;
  47934. private _modelReady;
  47935. /**
  47936. * A map of components (WebXRControllerComponent) in this motion controller
  47937. * Components have a ComponentType and can also have both button and axis definitions
  47938. */
  47939. readonly components: {
  47940. [id: string]: WebXRControllerComponent;
  47941. };
  47942. /**
  47943. * Disable the model's animation. Can be set at any time.
  47944. */
  47945. disableAnimation: boolean;
  47946. /**
  47947. * Observers registered here will be triggered when the model of this controller is done loading
  47948. */
  47949. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  47950. /**
  47951. * The profile id of this motion controller
  47952. */
  47953. abstract profileId: string;
  47954. /**
  47955. * The root mesh of the model. It is null if the model was not yet initialized
  47956. */
  47957. rootMesh: Nullable<AbstractMesh>;
  47958. /**
  47959. * constructs a new abstract motion controller
  47960. * @param scene the scene to which the model of the controller will be added
  47961. * @param layout The profile layout to load
  47962. * @param gamepadObject The gamepad object correlating to this controller
  47963. * @param handedness handedness (left/right/none) of this controller
  47964. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  47965. */
  47966. constructor(scene: Scene, layout: IMotionControllerLayout,
  47967. /**
  47968. * The gamepad object correlating to this controller
  47969. */
  47970. gamepadObject: IMinimalMotionControllerObject,
  47971. /**
  47972. * handedness (left/right/none) of this controller
  47973. */
  47974. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  47975. /**
  47976. * Dispose this controller, the model mesh and all its components
  47977. */
  47978. dispose(): void;
  47979. /**
  47980. * Returns all components of specific type
  47981. * @param type the type to search for
  47982. * @return an array of components with this type
  47983. */
  47984. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  47985. /**
  47986. * get a component based an its component id as defined in layout.components
  47987. * @param id the id of the component
  47988. * @returns the component correlates to the id or undefined if not found
  47989. */
  47990. getComponent(id: string): WebXRControllerComponent;
  47991. /**
  47992. * Get the list of components available in this motion controller
  47993. * @returns an array of strings correlating to available components
  47994. */
  47995. getComponentIds(): string[];
  47996. /**
  47997. * Get the first component of specific type
  47998. * @param type type of component to find
  47999. * @return a controller component or null if not found
  48000. */
  48001. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  48002. /**
  48003. * Get the main (Select) component of this controller as defined in the layout
  48004. * @returns the main component of this controller
  48005. */
  48006. getMainComponent(): WebXRControllerComponent;
  48007. /**
  48008. * Loads the model correlating to this controller
  48009. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  48010. * @returns A promise fulfilled with the result of the model loading
  48011. */
  48012. loadModel(): Promise<boolean>;
  48013. /**
  48014. * Update this model using the current XRFrame
  48015. * @param xrFrame the current xr frame to use and update the model
  48016. */
  48017. updateFromXRFrame(xrFrame: XRFrame): void;
  48018. /**
  48019. * Backwards compatibility due to a deeply-integrated typo
  48020. */
  48021. get handness(): XREye;
  48022. /**
  48023. * Pulse (vibrate) this controller
  48024. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  48025. * Consecutive calls to this function will cancel the last pulse call
  48026. *
  48027. * @param value the strength of the pulse in 0.0...1.0 range
  48028. * @param duration Duration of the pulse in milliseconds
  48029. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  48030. * @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
  48031. */
  48032. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  48033. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  48034. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  48035. /**
  48036. * Moves the axis on the controller mesh based on its current state
  48037. * @param axis the index of the axis
  48038. * @param axisValue the value of the axis which determines the meshes new position
  48039. * @hidden
  48040. */
  48041. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  48042. /**
  48043. * Update the model itself with the current frame data
  48044. * @param xrFrame the frame to use for updating the model mesh
  48045. */
  48046. protected updateModel(xrFrame: XRFrame): void;
  48047. /**
  48048. * Get the filename and path for this controller's model
  48049. * @returns a map of filename and path
  48050. */
  48051. protected abstract _getFilenameAndPath(): {
  48052. filename: string;
  48053. path: string;
  48054. };
  48055. /**
  48056. * This function is called before the mesh is loaded. It checks for loading constraints.
  48057. * For example, this function can check if the GLB loader is available
  48058. * If this function returns false, the generic controller will be loaded instead
  48059. * @returns Is the client ready to load the mesh
  48060. */
  48061. protected abstract _getModelLoadingConstraints(): boolean;
  48062. /**
  48063. * This function will be called after the model was successfully loaded and can be used
  48064. * for mesh transformations before it is available for the user
  48065. * @param meshes the loaded meshes
  48066. */
  48067. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  48068. /**
  48069. * Set the root mesh for this controller. Important for the WebXR controller class
  48070. * @param meshes the loaded meshes
  48071. */
  48072. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  48073. /**
  48074. * A function executed each frame that updates the mesh (if needed)
  48075. * @param xrFrame the current xrFrame
  48076. */
  48077. protected abstract _updateModel(xrFrame: XRFrame): void;
  48078. private _getGenericFilenameAndPath;
  48079. private _getGenericParentMesh;
  48080. }
  48081. }
  48082. declare module BABYLON {
  48083. /**
  48084. * A generic trigger-only motion controller for WebXR
  48085. */
  48086. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  48087. /**
  48088. * Static version of the profile id of this controller
  48089. */
  48090. static ProfileId: string;
  48091. profileId: string;
  48092. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  48093. protected _getFilenameAndPath(): {
  48094. filename: string;
  48095. path: string;
  48096. };
  48097. protected _getModelLoadingConstraints(): boolean;
  48098. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  48099. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48100. protected _updateModel(): void;
  48101. }
  48102. }
  48103. declare module BABYLON {
  48104. /**
  48105. * Class containing static functions to help procedurally build meshes
  48106. */
  48107. export class SphereBuilder {
  48108. /**
  48109. * Creates a sphere mesh
  48110. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  48111. * * 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`)
  48112. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  48113. * * 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
  48114. * * 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)
  48115. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48116. * * 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
  48117. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48118. * @param name defines the name of the mesh
  48119. * @param options defines the options used to create the mesh
  48120. * @param scene defines the hosting scene
  48121. * @returns the sphere mesh
  48122. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  48123. */
  48124. static CreateSphere(name: string, options: {
  48125. segments?: number;
  48126. diameter?: number;
  48127. diameterX?: number;
  48128. diameterY?: number;
  48129. diameterZ?: number;
  48130. arc?: number;
  48131. slice?: number;
  48132. sideOrientation?: number;
  48133. frontUVs?: Vector4;
  48134. backUVs?: Vector4;
  48135. updatable?: boolean;
  48136. }, scene?: Nullable<Scene>): Mesh;
  48137. }
  48138. }
  48139. declare module BABYLON {
  48140. /**
  48141. * A profiled motion controller has its profile loaded from an online repository.
  48142. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  48143. */
  48144. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  48145. private _repositoryUrl;
  48146. private _buttonMeshMapping;
  48147. private _touchDots;
  48148. /**
  48149. * The profile ID of this controller. Will be populated when the controller initializes.
  48150. */
  48151. profileId: string;
  48152. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  48153. dispose(): void;
  48154. protected _getFilenameAndPath(): {
  48155. filename: string;
  48156. path: string;
  48157. };
  48158. protected _getModelLoadingConstraints(): boolean;
  48159. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  48160. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48161. protected _updateModel(_xrFrame: XRFrame): void;
  48162. }
  48163. }
  48164. declare module BABYLON {
  48165. /**
  48166. * A construction function type to create a new controller based on an xrInput object
  48167. */
  48168. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  48169. /**
  48170. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  48171. *
  48172. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  48173. * it should be replaced with auto-loaded controllers.
  48174. *
  48175. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  48176. */
  48177. export class WebXRMotionControllerManager {
  48178. private static _AvailableControllers;
  48179. private static _Fallbacks;
  48180. private static _ProfileLoadingPromises;
  48181. private static _ProfilesList;
  48182. /**
  48183. * The base URL of the online controller repository. Can be changed at any time.
  48184. */
  48185. static BaseRepositoryUrl: string;
  48186. /**
  48187. * Which repository gets priority - local or online
  48188. */
  48189. static PrioritizeOnlineRepository: boolean;
  48190. /**
  48191. * Use the online repository, or use only locally-defined controllers
  48192. */
  48193. static UseOnlineRepository: boolean;
  48194. /**
  48195. * Clear the cache used for profile loading and reload when requested again
  48196. */
  48197. static ClearProfilesCache(): void;
  48198. /**
  48199. * Register the default fallbacks.
  48200. * This function is called automatically when this file is imported.
  48201. */
  48202. static DefaultFallbacks(): void;
  48203. /**
  48204. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  48205. * @param profileId the profile to which a fallback needs to be found
  48206. * @return an array with corresponding fallback profiles
  48207. */
  48208. static FindFallbackWithProfileId(profileId: string): string[];
  48209. /**
  48210. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  48211. * The order of search:
  48212. *
  48213. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  48214. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  48215. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  48216. * 4) return the generic trigger controller if none were found
  48217. *
  48218. * @param xrInput the xrInput to which a new controller is initialized
  48219. * @param scene the scene to which the model will be added
  48220. * @param forceProfile force a certain profile for this controller
  48221. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  48222. */
  48223. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  48224. /**
  48225. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  48226. *
  48227. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  48228. *
  48229. * @param type the profile type to register
  48230. * @param constructFunction the function to be called when loading this profile
  48231. */
  48232. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  48233. /**
  48234. * Register a fallback to a specific profile.
  48235. * @param profileId the profileId that will receive the fallbacks
  48236. * @param fallbacks A list of fallback profiles
  48237. */
  48238. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  48239. /**
  48240. * Will update the list of profiles available in the repository
  48241. * @return a promise that resolves to a map of profiles available online
  48242. */
  48243. static UpdateProfilesList(): Promise<{
  48244. [profile: string]: string;
  48245. }>;
  48246. private static _LoadProfileFromRepository;
  48247. private static _LoadProfilesFromAvailableControllers;
  48248. }
  48249. }
  48250. declare module BABYLON {
  48251. /**
  48252. * Configuration options for the WebXR controller creation
  48253. */
  48254. export interface IWebXRControllerOptions {
  48255. /**
  48256. * Should the controller mesh be animated when a user interacts with it
  48257. * The pressed buttons / thumbstick and touchpad animations will be disabled
  48258. */
  48259. disableMotionControllerAnimation?: boolean;
  48260. /**
  48261. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  48262. */
  48263. doNotLoadControllerMesh?: boolean;
  48264. /**
  48265. * Force a specific controller type for this controller.
  48266. * This can be used when creating your own profile or when testing different controllers
  48267. */
  48268. forceControllerProfile?: string;
  48269. /**
  48270. * Defines a rendering group ID for meshes that will be loaded.
  48271. * This is for the default controllers only.
  48272. */
  48273. renderingGroupId?: number;
  48274. }
  48275. /**
  48276. * Represents an XR controller
  48277. */
  48278. export class WebXRInputSource {
  48279. private _scene;
  48280. /** The underlying input source for the controller */
  48281. inputSource: XRInputSource;
  48282. private _options;
  48283. private _tmpVector;
  48284. private _uniqueId;
  48285. /**
  48286. * 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
  48287. */
  48288. grip?: AbstractMesh;
  48289. /**
  48290. * If available, this is the gamepad object related to this controller.
  48291. * Using this object it is possible to get click events and trackpad changes of the
  48292. * webxr controller that is currently being used.
  48293. */
  48294. motionController?: WebXRAbstractMotionController;
  48295. /**
  48296. * Event that fires when the controller is removed/disposed.
  48297. * The object provided as event data is this controller, after associated assets were disposed.
  48298. * uniqueId is still available.
  48299. */
  48300. onDisposeObservable: Observable<WebXRInputSource>;
  48301. /**
  48302. * Will be triggered when the mesh associated with the motion controller is done loading.
  48303. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  48304. * A shortened version of controller -> motion controller -> on mesh loaded.
  48305. */
  48306. onMeshLoadedObservable: Observable<AbstractMesh>;
  48307. /**
  48308. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  48309. */
  48310. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  48311. /**
  48312. * Pointer which can be used to select objects or attach a visible laser to
  48313. */
  48314. pointer: AbstractMesh;
  48315. /**
  48316. * Creates the input source object
  48317. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  48318. * @param _scene the scene which the controller should be associated to
  48319. * @param inputSource the underlying input source for the controller
  48320. * @param _options options for this controller creation
  48321. */
  48322. constructor(_scene: Scene,
  48323. /** The underlying input source for the controller */
  48324. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  48325. /**
  48326. * Get this controllers unique id
  48327. */
  48328. get uniqueId(): string;
  48329. /**
  48330. * Disposes of the object
  48331. */
  48332. dispose(): void;
  48333. /**
  48334. * Gets a world space ray coming from the pointer or grip
  48335. * @param result the resulting ray
  48336. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  48337. */
  48338. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  48339. /**
  48340. * Updates the controller pose based on the given XRFrame
  48341. * @param xrFrame xr frame to update the pose with
  48342. * @param referenceSpace reference space to use
  48343. */
  48344. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  48345. }
  48346. }
  48347. declare module BABYLON {
  48348. /**
  48349. * The schema for initialization options of the XR Input class
  48350. */
  48351. export interface IWebXRInputOptions {
  48352. /**
  48353. * If set to true no model will be automatically loaded
  48354. */
  48355. doNotLoadControllerMeshes?: boolean;
  48356. /**
  48357. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  48358. * If not found, the xr input profile data will be used.
  48359. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  48360. */
  48361. forceInputProfile?: string;
  48362. /**
  48363. * Do not send a request to the controller repository to load the profile.
  48364. *
  48365. * Instead, use the controllers available in babylon itself.
  48366. */
  48367. disableOnlineControllerRepository?: boolean;
  48368. /**
  48369. * A custom URL for the controllers repository
  48370. */
  48371. customControllersRepositoryURL?: string;
  48372. /**
  48373. * Should the controller model's components not move according to the user input
  48374. */
  48375. disableControllerAnimation?: boolean;
  48376. /**
  48377. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  48378. */
  48379. controllerOptions?: IWebXRControllerOptions;
  48380. }
  48381. /**
  48382. * XR input used to track XR inputs such as controllers/rays
  48383. */
  48384. export class WebXRInput implements IDisposable {
  48385. /**
  48386. * the xr session manager for this session
  48387. */
  48388. xrSessionManager: WebXRSessionManager;
  48389. /**
  48390. * the WebXR camera for this session. Mainly used for teleportation
  48391. */
  48392. xrCamera: WebXRCamera;
  48393. private readonly options;
  48394. /**
  48395. * XR controllers being tracked
  48396. */
  48397. controllers: Array<WebXRInputSource>;
  48398. private _frameObserver;
  48399. private _sessionEndedObserver;
  48400. private _sessionInitObserver;
  48401. /**
  48402. * Event when a controller has been connected/added
  48403. */
  48404. onControllerAddedObservable: Observable<WebXRInputSource>;
  48405. /**
  48406. * Event when a controller has been removed/disconnected
  48407. */
  48408. onControllerRemovedObservable: Observable<WebXRInputSource>;
  48409. /**
  48410. * Initializes the WebXRInput
  48411. * @param xrSessionManager the xr session manager for this session
  48412. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  48413. * @param options = initialization options for this xr input
  48414. */
  48415. constructor(
  48416. /**
  48417. * the xr session manager for this session
  48418. */
  48419. xrSessionManager: WebXRSessionManager,
  48420. /**
  48421. * the WebXR camera for this session. Mainly used for teleportation
  48422. */
  48423. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  48424. private _onInputSourcesChange;
  48425. private _addAndRemoveControllers;
  48426. /**
  48427. * Disposes of the object
  48428. */
  48429. dispose(): void;
  48430. }
  48431. }
  48432. declare module BABYLON {
  48433. /**
  48434. * This is the base class for all WebXR features.
  48435. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  48436. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  48437. */
  48438. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  48439. protected _xrSessionManager: WebXRSessionManager;
  48440. private _attached;
  48441. private _removeOnDetach;
  48442. /**
  48443. * Should auto-attach be disabled?
  48444. */
  48445. disableAutoAttach: boolean;
  48446. /**
  48447. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  48448. */
  48449. xrNativeFeatureName: string;
  48450. /**
  48451. * Construct a new (abstract) WebXR feature
  48452. * @param _xrSessionManager the xr session manager for this feature
  48453. */
  48454. constructor(_xrSessionManager: WebXRSessionManager);
  48455. /**
  48456. * Is this feature attached
  48457. */
  48458. get attached(): boolean;
  48459. /**
  48460. * attach this feature
  48461. *
  48462. * @param force should attachment be forced (even when already attached)
  48463. * @returns true if successful, false is failed or already attached
  48464. */
  48465. attach(force?: boolean): boolean;
  48466. /**
  48467. * detach this feature.
  48468. *
  48469. * @returns true if successful, false if failed or already detached
  48470. */
  48471. detach(): boolean;
  48472. /**
  48473. * Dispose this feature and all of the resources attached
  48474. */
  48475. dispose(): void;
  48476. /**
  48477. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  48478. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  48479. *
  48480. * @returns whether or not the feature is compatible in this environment
  48481. */
  48482. isCompatible(): boolean;
  48483. /**
  48484. * This is used to register callbacks that will automatically be removed when detach is called.
  48485. * @param observable the observable to which the observer will be attached
  48486. * @param callback the callback to register
  48487. */
  48488. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  48489. /**
  48490. * Code in this function will be executed on each xrFrame received from the browser.
  48491. * This function will not execute after the feature is detached.
  48492. * @param _xrFrame the current frame
  48493. */
  48494. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  48495. }
  48496. }
  48497. declare module BABYLON {
  48498. /**
  48499. * Renders a layer on top of an existing scene
  48500. */
  48501. export class UtilityLayerRenderer implements IDisposable {
  48502. /** the original scene that will be rendered on top of */
  48503. originalScene: Scene;
  48504. private _pointerCaptures;
  48505. private _lastPointerEvents;
  48506. private static _DefaultUtilityLayer;
  48507. private static _DefaultKeepDepthUtilityLayer;
  48508. private _sharedGizmoLight;
  48509. private _renderCamera;
  48510. /**
  48511. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  48512. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  48513. * @returns the camera that is used when rendering the utility layer
  48514. */
  48515. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  48516. /**
  48517. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  48518. * @param cam the camera that should be used when rendering the utility layer
  48519. */
  48520. setRenderCamera(cam: Nullable<Camera>): void;
  48521. /**
  48522. * @hidden
  48523. * Light which used by gizmos to get light shading
  48524. */
  48525. _getSharedGizmoLight(): HemisphericLight;
  48526. /**
  48527. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  48528. */
  48529. pickUtilitySceneFirst: boolean;
  48530. /**
  48531. * 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)
  48532. */
  48533. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  48534. /**
  48535. * 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)
  48536. */
  48537. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  48538. /**
  48539. * The scene that is rendered on top of the original scene
  48540. */
  48541. utilityLayerScene: Scene;
  48542. /**
  48543. * If the utility layer should automatically be rendered on top of existing scene
  48544. */
  48545. shouldRender: boolean;
  48546. /**
  48547. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  48548. */
  48549. onlyCheckPointerDownEvents: boolean;
  48550. /**
  48551. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  48552. */
  48553. processAllEvents: boolean;
  48554. /**
  48555. * Observable raised when the pointer move from the utility layer scene to the main scene
  48556. */
  48557. onPointerOutObservable: Observable<number>;
  48558. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  48559. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  48560. private _afterRenderObserver;
  48561. private _sceneDisposeObserver;
  48562. private _originalPointerObserver;
  48563. /**
  48564. * Instantiates a UtilityLayerRenderer
  48565. * @param originalScene the original scene that will be rendered on top of
  48566. * @param handleEvents boolean indicating if the utility layer should handle events
  48567. */
  48568. constructor(
  48569. /** the original scene that will be rendered on top of */
  48570. originalScene: Scene, handleEvents?: boolean);
  48571. private _notifyObservers;
  48572. /**
  48573. * Renders the utility layers scene on top of the original scene
  48574. */
  48575. render(): void;
  48576. /**
  48577. * Disposes of the renderer
  48578. */
  48579. dispose(): void;
  48580. private _updateCamera;
  48581. }
  48582. }
  48583. declare module BABYLON {
  48584. /**
  48585. * Options interface for the pointer selection module
  48586. */
  48587. export interface IWebXRControllerPointerSelectionOptions {
  48588. /**
  48589. * if provided, this scene will be used to render meshes.
  48590. */
  48591. customUtilityLayerScene?: Scene;
  48592. /**
  48593. * 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)
  48594. * If not disabled, the last picked point will be used to execute a pointer up event
  48595. * If disabled, pointer up event will be triggered right after the pointer down event.
  48596. * Used in screen and gaze target ray mode only
  48597. */
  48598. disablePointerUpOnTouchOut: boolean;
  48599. /**
  48600. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  48601. */
  48602. forceGazeMode: boolean;
  48603. /**
  48604. * 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
  48605. * to start a new countdown to the pointer down event.
  48606. * Defaults to 1.
  48607. */
  48608. gazeModePointerMovedFactor?: number;
  48609. /**
  48610. * Different button type to use instead of the main component
  48611. */
  48612. overrideButtonId?: string;
  48613. /**
  48614. * use this rendering group id for the meshes (optional)
  48615. */
  48616. renderingGroupId?: number;
  48617. /**
  48618. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  48619. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  48620. * 3000 means 3 seconds between pointing at something and selecting it
  48621. */
  48622. timeToSelect?: number;
  48623. /**
  48624. * Should meshes created here be added to a utility layer or the main scene
  48625. */
  48626. useUtilityLayer?: boolean;
  48627. /**
  48628. * Optional WebXR camera to be used for gaze selection
  48629. */
  48630. gazeCamera?: WebXRCamera;
  48631. /**
  48632. * the xr input to use with this pointer selection
  48633. */
  48634. xrInput: WebXRInput;
  48635. }
  48636. /**
  48637. * A module that will enable pointer selection for motion controllers of XR Input Sources
  48638. */
  48639. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  48640. private readonly _options;
  48641. private static _idCounter;
  48642. private _attachController;
  48643. private _controllers;
  48644. private _scene;
  48645. private _tmpVectorForPickCompare;
  48646. /**
  48647. * The module's name
  48648. */
  48649. static readonly Name: string;
  48650. /**
  48651. * The (Babylon) version of this module.
  48652. * This is an integer representing the implementation version.
  48653. * This number does not correspond to the WebXR specs version
  48654. */
  48655. static readonly Version: number;
  48656. /**
  48657. * Disable lighting on the laser pointer (so it will always be visible)
  48658. */
  48659. disablePointerLighting: boolean;
  48660. /**
  48661. * Disable lighting on the selection mesh (so it will always be visible)
  48662. */
  48663. disableSelectionMeshLighting: boolean;
  48664. /**
  48665. * Should the laser pointer be displayed
  48666. */
  48667. displayLaserPointer: boolean;
  48668. /**
  48669. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  48670. */
  48671. displaySelectionMesh: boolean;
  48672. /**
  48673. * This color will be set to the laser pointer when selection is triggered
  48674. */
  48675. laserPointerPickedColor: Color3;
  48676. /**
  48677. * Default color of the laser pointer
  48678. */
  48679. laserPointerDefaultColor: Color3;
  48680. /**
  48681. * default color of the selection ring
  48682. */
  48683. selectionMeshDefaultColor: Color3;
  48684. /**
  48685. * This color will be applied to the selection ring when selection is triggered
  48686. */
  48687. selectionMeshPickedColor: Color3;
  48688. /**
  48689. * Optional filter to be used for ray selection. This predicate shares behavior with
  48690. * scene.pointerMovePredicate which takes priority if it is also assigned.
  48691. */
  48692. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  48693. /**
  48694. * constructs a new background remover module
  48695. * @param _xrSessionManager the session manager for this module
  48696. * @param _options read-only options to be used in this module
  48697. */
  48698. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  48699. /**
  48700. * attach this feature
  48701. * Will usually be called by the features manager
  48702. *
  48703. * @returns true if successful.
  48704. */
  48705. attach(): boolean;
  48706. /**
  48707. * detach this feature.
  48708. * Will usually be called by the features manager
  48709. *
  48710. * @returns true if successful.
  48711. */
  48712. detach(): boolean;
  48713. /**
  48714. * Will get the mesh under a specific pointer.
  48715. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  48716. * @param controllerId the controllerId to check
  48717. * @returns The mesh under pointer or null if no mesh is under the pointer
  48718. */
  48719. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  48720. /**
  48721. * Get the xr controller that correlates to the pointer id in the pointer event
  48722. *
  48723. * @param id the pointer id to search for
  48724. * @returns the controller that correlates to this id or null if not found
  48725. */
  48726. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  48727. protected _onXRFrame(_xrFrame: XRFrame): void;
  48728. private _attachGazeMode;
  48729. private _attachScreenRayMode;
  48730. private _attachTrackedPointerRayMode;
  48731. private _convertNormalToDirectionOfRay;
  48732. private _detachController;
  48733. private _generateNewMeshPair;
  48734. private _pickingMoved;
  48735. private _updatePointerDistance;
  48736. /** @hidden */
  48737. get lasterPointerDefaultColor(): Color3;
  48738. }
  48739. }
  48740. declare module BABYLON {
  48741. /**
  48742. * Button which can be used to enter a different mode of XR
  48743. */
  48744. export class WebXREnterExitUIButton {
  48745. /** button element */
  48746. element: HTMLElement;
  48747. /** XR initialization options for the button */
  48748. sessionMode: XRSessionMode;
  48749. /** Reference space type */
  48750. referenceSpaceType: XRReferenceSpaceType;
  48751. /**
  48752. * Creates a WebXREnterExitUIButton
  48753. * @param element button element
  48754. * @param sessionMode XR initialization session mode
  48755. * @param referenceSpaceType the type of reference space to be used
  48756. */
  48757. constructor(
  48758. /** button element */
  48759. element: HTMLElement,
  48760. /** XR initialization options for the button */
  48761. sessionMode: XRSessionMode,
  48762. /** Reference space type */
  48763. referenceSpaceType: XRReferenceSpaceType);
  48764. /**
  48765. * Extendable function which can be used to update the button's visuals when the state changes
  48766. * @param activeButton the current active button in the UI
  48767. */
  48768. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  48769. }
  48770. /**
  48771. * Options to create the webXR UI
  48772. */
  48773. export class WebXREnterExitUIOptions {
  48774. /**
  48775. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  48776. */
  48777. customButtons?: Array<WebXREnterExitUIButton>;
  48778. /**
  48779. * A reference space type to use when creating the default button.
  48780. * Default is local-floor
  48781. */
  48782. referenceSpaceType?: XRReferenceSpaceType;
  48783. /**
  48784. * Context to enter xr with
  48785. */
  48786. renderTarget?: Nullable<WebXRRenderTarget>;
  48787. /**
  48788. * A session mode to use when creating the default button.
  48789. * Default is immersive-vr
  48790. */
  48791. sessionMode?: XRSessionMode;
  48792. /**
  48793. * A list of optional features to init the session with
  48794. */
  48795. optionalFeatures?: string[];
  48796. /**
  48797. * A list of optional features to init the session with
  48798. */
  48799. requiredFeatures?: string[];
  48800. }
  48801. /**
  48802. * UI to allow the user to enter/exit XR mode
  48803. */
  48804. export class WebXREnterExitUI implements IDisposable {
  48805. private scene;
  48806. /** version of the options passed to this UI */
  48807. options: WebXREnterExitUIOptions;
  48808. private _activeButton;
  48809. private _buttons;
  48810. private _overlay;
  48811. /**
  48812. * Fired every time the active button is changed.
  48813. *
  48814. * When xr is entered via a button that launches xr that button will be the callback parameter
  48815. *
  48816. * When exiting xr the callback parameter will be null)
  48817. */
  48818. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  48819. /**
  48820. *
  48821. * @param scene babylon scene object to use
  48822. * @param options (read-only) version of the options passed to this UI
  48823. */
  48824. private constructor();
  48825. /**
  48826. * Creates UI to allow the user to enter/exit XR mode
  48827. * @param scene the scene to add the ui to
  48828. * @param helper the xr experience helper to enter/exit xr with
  48829. * @param options options to configure the UI
  48830. * @returns the created ui
  48831. */
  48832. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  48833. /**
  48834. * Disposes of the XR UI component
  48835. */
  48836. dispose(): void;
  48837. private _updateButtons;
  48838. }
  48839. }
  48840. declare module BABYLON {
  48841. /**
  48842. * Class containing static functions to help procedurally build meshes
  48843. */
  48844. export class LinesBuilder {
  48845. /**
  48846. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  48847. * * 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
  48848. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  48849. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  48850. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  48851. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  48852. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  48853. * * 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
  48854. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  48855. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48856. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  48857. * @param name defines the name of the new line system
  48858. * @param options defines the options used to create the line system
  48859. * @param scene defines the hosting scene
  48860. * @returns a new line system mesh
  48861. */
  48862. static CreateLineSystem(name: string, options: {
  48863. lines: Vector3[][];
  48864. updatable?: boolean;
  48865. instance?: Nullable<LinesMesh>;
  48866. colors?: Nullable<Color4[][]>;
  48867. useVertexAlpha?: boolean;
  48868. }, scene: Nullable<Scene>): LinesMesh;
  48869. /**
  48870. * Creates a line mesh
  48871. * 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
  48872. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  48873. * * The parameter `points` is an array successive Vector3
  48874. * * 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
  48875. * * The optional parameter `colors` is an array of successive Color4, one per line point
  48876. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  48877. * * When updating an instance, remember that only point positions can change, not the number of points
  48878. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48879. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  48880. * @param name defines the name of the new line system
  48881. * @param options defines the options used to create the line system
  48882. * @param scene defines the hosting scene
  48883. * @returns a new line mesh
  48884. */
  48885. static CreateLines(name: string, options: {
  48886. points: Vector3[];
  48887. updatable?: boolean;
  48888. instance?: Nullable<LinesMesh>;
  48889. colors?: Color4[];
  48890. useVertexAlpha?: boolean;
  48891. }, scene?: Nullable<Scene>): LinesMesh;
  48892. /**
  48893. * Creates a dashed line mesh
  48894. * * 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
  48895. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  48896. * * The parameter `points` is an array successive Vector3
  48897. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  48898. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  48899. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  48900. * * 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
  48901. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  48902. * * When updating an instance, remember that only point positions can change, not the number of points
  48903. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48904. * @param name defines the name of the mesh
  48905. * @param options defines the options used to create the mesh
  48906. * @param scene defines the hosting scene
  48907. * @returns the dashed line mesh
  48908. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  48909. */
  48910. static CreateDashedLines(name: string, options: {
  48911. points: Vector3[];
  48912. dashSize?: number;
  48913. gapSize?: number;
  48914. dashNb?: number;
  48915. updatable?: boolean;
  48916. instance?: LinesMesh;
  48917. useVertexAlpha?: boolean;
  48918. }, scene?: Nullable<Scene>): LinesMesh;
  48919. }
  48920. }
  48921. declare module BABYLON {
  48922. /**
  48923. * Construction options for a timer
  48924. */
  48925. export interface ITimerOptions<T> {
  48926. /**
  48927. * Time-to-end
  48928. */
  48929. timeout: number;
  48930. /**
  48931. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  48932. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  48933. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  48934. */
  48935. contextObservable: Observable<T>;
  48936. /**
  48937. * Optional parameters when adding an observer to the observable
  48938. */
  48939. observableParameters?: {
  48940. mask?: number;
  48941. insertFirst?: boolean;
  48942. scope?: any;
  48943. };
  48944. /**
  48945. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  48946. */
  48947. breakCondition?: (data?: ITimerData<T>) => boolean;
  48948. /**
  48949. * Will be triggered when the time condition has met
  48950. */
  48951. onEnded?: (data: ITimerData<any>) => void;
  48952. /**
  48953. * Will be triggered when the break condition has met (prematurely ended)
  48954. */
  48955. onAborted?: (data: ITimerData<any>) => void;
  48956. /**
  48957. * Optional function to execute on each tick (or count)
  48958. */
  48959. onTick?: (data: ITimerData<any>) => void;
  48960. }
  48961. /**
  48962. * An interface defining the data sent by the timer
  48963. */
  48964. export interface ITimerData<T> {
  48965. /**
  48966. * When did it start
  48967. */
  48968. startTime: number;
  48969. /**
  48970. * Time now
  48971. */
  48972. currentTime: number;
  48973. /**
  48974. * Time passed since started
  48975. */
  48976. deltaTime: number;
  48977. /**
  48978. * How much is completed, in [0.0...1.0].
  48979. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  48980. */
  48981. completeRate: number;
  48982. /**
  48983. * What the registered observable sent in the last count
  48984. */
  48985. payload: T;
  48986. }
  48987. /**
  48988. * The current state of the timer
  48989. */
  48990. export enum TimerState {
  48991. /**
  48992. * Timer initialized, not yet started
  48993. */
  48994. INIT = 0,
  48995. /**
  48996. * Timer started and counting
  48997. */
  48998. STARTED = 1,
  48999. /**
  49000. * Timer ended (whether aborted or time reached)
  49001. */
  49002. ENDED = 2
  49003. }
  49004. /**
  49005. * A simple version of the timer. Will take options and start the timer immediately after calling it
  49006. *
  49007. * @param options options with which to initialize this timer
  49008. */
  49009. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  49010. /**
  49011. * An advanced implementation of a timer class
  49012. */
  49013. export class AdvancedTimer<T = any> implements IDisposable {
  49014. /**
  49015. * Will notify each time the timer calculates the remaining time
  49016. */
  49017. onEachCountObservable: Observable<ITimerData<T>>;
  49018. /**
  49019. * Will trigger when the timer was aborted due to the break condition
  49020. */
  49021. onTimerAbortedObservable: Observable<ITimerData<T>>;
  49022. /**
  49023. * Will trigger when the timer ended successfully
  49024. */
  49025. onTimerEndedObservable: Observable<ITimerData<T>>;
  49026. /**
  49027. * Will trigger when the timer state has changed
  49028. */
  49029. onStateChangedObservable: Observable<TimerState>;
  49030. private _observer;
  49031. private _contextObservable;
  49032. private _observableParameters;
  49033. private _startTime;
  49034. private _timer;
  49035. private _state;
  49036. private _breakCondition;
  49037. private _timeToEnd;
  49038. private _breakOnNextTick;
  49039. /**
  49040. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  49041. * @param options construction options for this advanced timer
  49042. */
  49043. constructor(options: ITimerOptions<T>);
  49044. /**
  49045. * set a breaking condition for this timer. Default is to never break during count
  49046. * @param predicate the new break condition. Returns true to break, false otherwise
  49047. */
  49048. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  49049. /**
  49050. * Reset ALL associated observables in this advanced timer
  49051. */
  49052. clearObservables(): void;
  49053. /**
  49054. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  49055. *
  49056. * @param timeToEnd how much time to measure until timer ended
  49057. */
  49058. start(timeToEnd?: number): void;
  49059. /**
  49060. * Will force a stop on the next tick.
  49061. */
  49062. stop(): void;
  49063. /**
  49064. * Dispose this timer, clearing all resources
  49065. */
  49066. dispose(): void;
  49067. private _setState;
  49068. private _tick;
  49069. private _stop;
  49070. }
  49071. }
  49072. declare module BABYLON {
  49073. /**
  49074. * The options container for the teleportation module
  49075. */
  49076. export interface IWebXRTeleportationOptions {
  49077. /**
  49078. * if provided, this scene will be used to render meshes.
  49079. */
  49080. customUtilityLayerScene?: Scene;
  49081. /**
  49082. * Values to configure the default target mesh
  49083. */
  49084. defaultTargetMeshOptions?: {
  49085. /**
  49086. * Fill color of the teleportation area
  49087. */
  49088. teleportationFillColor?: string;
  49089. /**
  49090. * Border color for the teleportation area
  49091. */
  49092. teleportationBorderColor?: string;
  49093. /**
  49094. * Disable the mesh's animation sequence
  49095. */
  49096. disableAnimation?: boolean;
  49097. /**
  49098. * Disable lighting on the material or the ring and arrow
  49099. */
  49100. disableLighting?: boolean;
  49101. /**
  49102. * Override the default material of the torus and arrow
  49103. */
  49104. torusArrowMaterial?: Material;
  49105. };
  49106. /**
  49107. * A list of meshes to use as floor meshes.
  49108. * Meshes can be added and removed after initializing the feature using the
  49109. * addFloorMesh and removeFloorMesh functions
  49110. * If empty, rotation will still work
  49111. */
  49112. floorMeshes?: AbstractMesh[];
  49113. /**
  49114. * use this rendering group id for the meshes (optional)
  49115. */
  49116. renderingGroupId?: number;
  49117. /**
  49118. * Should teleportation move only to snap points
  49119. */
  49120. snapPointsOnly?: boolean;
  49121. /**
  49122. * An array of points to which the teleportation will snap to.
  49123. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  49124. */
  49125. snapPositions?: Vector3[];
  49126. /**
  49127. * How close should the teleportation ray be in order to snap to position.
  49128. * Default to 0.8 units (meters)
  49129. */
  49130. snapToPositionRadius?: number;
  49131. /**
  49132. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  49133. * If you want to support rotation, make sure your mesh has a direction indicator.
  49134. *
  49135. * When left untouched, the default mesh will be initialized.
  49136. */
  49137. teleportationTargetMesh?: AbstractMesh;
  49138. /**
  49139. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  49140. */
  49141. timeToTeleport?: number;
  49142. /**
  49143. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  49144. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  49145. */
  49146. useMainComponentOnly?: boolean;
  49147. /**
  49148. * Should meshes created here be added to a utility layer or the main scene
  49149. */
  49150. useUtilityLayer?: boolean;
  49151. /**
  49152. * Babylon XR Input class for controller
  49153. */
  49154. xrInput: WebXRInput;
  49155. }
  49156. /**
  49157. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  49158. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  49159. * the input of the attached controllers.
  49160. */
  49161. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  49162. private _options;
  49163. private _controllers;
  49164. private _currentTeleportationControllerId;
  49165. private _floorMeshes;
  49166. private _quadraticBezierCurve;
  49167. private _selectionFeature;
  49168. private _snapToPositions;
  49169. private _snappedToPoint;
  49170. private _teleportationRingMaterial?;
  49171. private _tmpRay;
  49172. private _tmpVector;
  49173. /**
  49174. * The module's name
  49175. */
  49176. static readonly Name: string;
  49177. /**
  49178. * The (Babylon) version of this module.
  49179. * This is an integer representing the implementation version.
  49180. * This number does not correspond to the webxr specs version
  49181. */
  49182. static readonly Version: number;
  49183. /**
  49184. * Is movement backwards enabled
  49185. */
  49186. backwardsMovementEnabled: boolean;
  49187. /**
  49188. * Distance to travel when moving backwards
  49189. */
  49190. backwardsTeleportationDistance: number;
  49191. /**
  49192. * The distance from the user to the inspection point in the direction of the controller
  49193. * A higher number will allow the user to move further
  49194. * defaults to 5 (meters, in xr units)
  49195. */
  49196. parabolicCheckRadius: number;
  49197. /**
  49198. * Should the module support parabolic ray on top of direct ray
  49199. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  49200. * Very helpful when moving between floors / different heights
  49201. */
  49202. parabolicRayEnabled: boolean;
  49203. /**
  49204. * How much rotation should be applied when rotating right and left
  49205. */
  49206. rotationAngle: number;
  49207. /**
  49208. * Is rotation enabled when moving forward?
  49209. * Disabling this feature will prevent the user from deciding the direction when teleporting
  49210. */
  49211. rotationEnabled: boolean;
  49212. /**
  49213. * constructs a new anchor system
  49214. * @param _xrSessionManager an instance of WebXRSessionManager
  49215. * @param _options configuration object for this feature
  49216. */
  49217. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  49218. /**
  49219. * Get the snapPointsOnly flag
  49220. */
  49221. get snapPointsOnly(): boolean;
  49222. /**
  49223. * Sets the snapPointsOnly flag
  49224. * @param snapToPoints should teleportation be exclusively to snap points
  49225. */
  49226. set snapPointsOnly(snapToPoints: boolean);
  49227. /**
  49228. * Add a new mesh to the floor meshes array
  49229. * @param mesh the mesh to use as floor mesh
  49230. */
  49231. addFloorMesh(mesh: AbstractMesh): void;
  49232. /**
  49233. * Add a new snap-to point to fix teleportation to this position
  49234. * @param newSnapPoint The new Snap-To point
  49235. */
  49236. addSnapPoint(newSnapPoint: Vector3): void;
  49237. attach(): boolean;
  49238. detach(): boolean;
  49239. dispose(): void;
  49240. /**
  49241. * Remove a mesh from the floor meshes array
  49242. * @param mesh the mesh to remove
  49243. */
  49244. removeFloorMesh(mesh: AbstractMesh): void;
  49245. /**
  49246. * Remove a mesh from the floor meshes array using its name
  49247. * @param name the mesh name to remove
  49248. */
  49249. removeFloorMeshByName(name: string): void;
  49250. /**
  49251. * 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
  49252. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  49253. * @returns was the point found and removed or not
  49254. */
  49255. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  49256. /**
  49257. * This function sets a selection feature that will be disabled when
  49258. * the forward ray is shown and will be reattached when hidden.
  49259. * This is used to remove the selection rays when moving.
  49260. * @param selectionFeature the feature to disable when forward movement is enabled
  49261. */
  49262. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  49263. protected _onXRFrame(_xrFrame: XRFrame): void;
  49264. private _attachController;
  49265. private _createDefaultTargetMesh;
  49266. private _detachController;
  49267. private _findClosestSnapPointWithRadius;
  49268. private _setTargetMeshPosition;
  49269. private _setTargetMeshVisibility;
  49270. private _showParabolicPath;
  49271. private _teleportForward;
  49272. }
  49273. }
  49274. declare module BABYLON {
  49275. /**
  49276. * Options for the default xr helper
  49277. */
  49278. export class WebXRDefaultExperienceOptions {
  49279. /**
  49280. * Enable or disable default UI to enter XR
  49281. */
  49282. disableDefaultUI?: boolean;
  49283. /**
  49284. * Should teleportation not initialize. defaults to false.
  49285. */
  49286. disableTeleportation?: boolean;
  49287. /**
  49288. * Floor meshes that will be used for teleport
  49289. */
  49290. floorMeshes?: Array<AbstractMesh>;
  49291. /**
  49292. * If set to true, the first frame will not be used to reset position
  49293. * The first frame is mainly used when copying transformation from the old camera
  49294. * Mainly used in AR
  49295. */
  49296. ignoreNativeCameraTransformation?: boolean;
  49297. /**
  49298. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  49299. */
  49300. inputOptions?: IWebXRInputOptions;
  49301. /**
  49302. * optional configuration for the output canvas
  49303. */
  49304. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  49305. /**
  49306. * optional UI options. This can be used among other to change session mode and reference space type
  49307. */
  49308. uiOptions?: WebXREnterExitUIOptions;
  49309. /**
  49310. * When loading teleportation and pointer select, use stable versions instead of latest.
  49311. */
  49312. useStablePlugins?: boolean;
  49313. /**
  49314. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  49315. */
  49316. renderingGroupId?: number;
  49317. /**
  49318. * A list of optional features to init the session with
  49319. * If set to true, all features we support will be added
  49320. */
  49321. optionalFeatures?: boolean | string[];
  49322. }
  49323. /**
  49324. * Default experience which provides a similar setup to the previous webVRExperience
  49325. */
  49326. export class WebXRDefaultExperience {
  49327. /**
  49328. * Base experience
  49329. */
  49330. baseExperience: WebXRExperienceHelper;
  49331. /**
  49332. * Enables ui for entering/exiting xr
  49333. */
  49334. enterExitUI: WebXREnterExitUI;
  49335. /**
  49336. * Input experience extension
  49337. */
  49338. input: WebXRInput;
  49339. /**
  49340. * Enables laser pointer and selection
  49341. */
  49342. pointerSelection: WebXRControllerPointerSelection;
  49343. /**
  49344. * Default target xr should render to
  49345. */
  49346. renderTarget: WebXRRenderTarget;
  49347. /**
  49348. * Enables teleportation
  49349. */
  49350. teleportation: WebXRMotionControllerTeleportation;
  49351. private constructor();
  49352. /**
  49353. * Creates the default xr experience
  49354. * @param scene scene
  49355. * @param options options for basic configuration
  49356. * @returns resulting WebXRDefaultExperience
  49357. */
  49358. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49359. /**
  49360. * DIsposes of the experience helper
  49361. */
  49362. dispose(): void;
  49363. }
  49364. }
  49365. declare module BABYLON {
  49366. /**
  49367. * Options to modify the vr teleportation behavior.
  49368. */
  49369. export interface VRTeleportationOptions {
  49370. /**
  49371. * The name of the mesh which should be used as the teleportation floor. (default: null)
  49372. */
  49373. floorMeshName?: string;
  49374. /**
  49375. * A list of meshes to be used as the teleportation floor. (default: empty)
  49376. */
  49377. floorMeshes?: Mesh[];
  49378. /**
  49379. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  49380. */
  49381. teleportationMode?: number;
  49382. /**
  49383. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  49384. */
  49385. teleportationTime?: number;
  49386. /**
  49387. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  49388. */
  49389. teleportationSpeed?: number;
  49390. /**
  49391. * The easing function used in the animation or null for Linear. (default CircleEase)
  49392. */
  49393. easingFunction?: EasingFunction;
  49394. }
  49395. /**
  49396. * Options to modify the vr experience helper's behavior.
  49397. */
  49398. export interface VRExperienceHelperOptions extends WebVROptions {
  49399. /**
  49400. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  49401. */
  49402. createDeviceOrientationCamera?: boolean;
  49403. /**
  49404. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  49405. */
  49406. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  49407. /**
  49408. * Uses the main button on the controller to toggle the laser casted. (default: true)
  49409. */
  49410. laserToggle?: boolean;
  49411. /**
  49412. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  49413. */
  49414. floorMeshes?: Mesh[];
  49415. /**
  49416. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  49417. */
  49418. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  49419. /**
  49420. * Defines if WebXR should be used instead of WebVR (if available)
  49421. */
  49422. useXR?: boolean;
  49423. }
  49424. /**
  49425. * Event containing information after VR has been entered
  49426. */
  49427. export class OnAfterEnteringVRObservableEvent {
  49428. /**
  49429. * If entering vr was successful
  49430. */
  49431. success: boolean;
  49432. }
  49433. /**
  49434. * Helps to quickly add VR support to an existing scene.
  49435. * See https://doc.babylonjs.com/how_to/webvr_helper
  49436. */
  49437. export class VRExperienceHelper {
  49438. /** Options to modify the vr experience helper's behavior. */
  49439. webVROptions: VRExperienceHelperOptions;
  49440. private _scene;
  49441. private _position;
  49442. private _btnVR;
  49443. private _btnVRDisplayed;
  49444. private _webVRsupported;
  49445. private _webVRready;
  49446. private _webVRrequesting;
  49447. private _webVRpresenting;
  49448. private _hasEnteredVR;
  49449. private _fullscreenVRpresenting;
  49450. private _inputElement;
  49451. private _webVRCamera;
  49452. private _vrDeviceOrientationCamera;
  49453. private _deviceOrientationCamera;
  49454. private _existingCamera;
  49455. private _onKeyDown;
  49456. private _onVrDisplayPresentChange;
  49457. private _onVRDisplayChanged;
  49458. private _onVRRequestPresentStart;
  49459. private _onVRRequestPresentComplete;
  49460. /**
  49461. * 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)
  49462. */
  49463. enableGazeEvenWhenNoPointerLock: boolean;
  49464. /**
  49465. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  49466. */
  49467. exitVROnDoubleTap: boolean;
  49468. /**
  49469. * Observable raised right before entering VR.
  49470. */
  49471. onEnteringVRObservable: Observable<VRExperienceHelper>;
  49472. /**
  49473. * Observable raised when entering VR has completed.
  49474. */
  49475. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  49476. /**
  49477. * Observable raised when exiting VR.
  49478. */
  49479. onExitingVRObservable: Observable<VRExperienceHelper>;
  49480. /**
  49481. * Observable raised when controller mesh is loaded.
  49482. */
  49483. onControllerMeshLoadedObservable: Observable<WebVRController>;
  49484. /** Return this.onEnteringVRObservable
  49485. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  49486. */
  49487. get onEnteringVR(): Observable<VRExperienceHelper>;
  49488. /** Return this.onExitingVRObservable
  49489. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  49490. */
  49491. get onExitingVR(): Observable<VRExperienceHelper>;
  49492. /** Return this.onControllerMeshLoadedObservable
  49493. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  49494. */
  49495. get onControllerMeshLoaded(): Observable<WebVRController>;
  49496. private _rayLength;
  49497. private _useCustomVRButton;
  49498. private _teleportationRequested;
  49499. private _teleportActive;
  49500. private _floorMeshName;
  49501. private _floorMeshesCollection;
  49502. private _teleportationMode;
  49503. private _teleportationTime;
  49504. private _teleportationSpeed;
  49505. private _teleportationEasing;
  49506. private _rotationAllowed;
  49507. private _teleportBackwardsVector;
  49508. private _teleportationTarget;
  49509. private _isDefaultTeleportationTarget;
  49510. private _postProcessMove;
  49511. private _teleportationFillColor;
  49512. private _teleportationBorderColor;
  49513. private _rotationAngle;
  49514. private _haloCenter;
  49515. private _cameraGazer;
  49516. private _padSensibilityUp;
  49517. private _padSensibilityDown;
  49518. private _leftController;
  49519. private _rightController;
  49520. private _gazeColor;
  49521. private _laserColor;
  49522. private _pickedLaserColor;
  49523. private _pickedGazeColor;
  49524. /**
  49525. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  49526. */
  49527. onNewMeshSelected: Observable<AbstractMesh>;
  49528. /**
  49529. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  49530. * This observable will provide the mesh and the controller used to select the mesh
  49531. */
  49532. onMeshSelectedWithController: Observable<{
  49533. mesh: AbstractMesh;
  49534. controller: WebVRController;
  49535. }>;
  49536. /**
  49537. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  49538. */
  49539. onNewMeshPicked: Observable<PickingInfo>;
  49540. private _circleEase;
  49541. /**
  49542. * Observable raised before camera teleportation
  49543. */
  49544. onBeforeCameraTeleport: Observable<Vector3>;
  49545. /**
  49546. * Observable raised after camera teleportation
  49547. */
  49548. onAfterCameraTeleport: Observable<Vector3>;
  49549. /**
  49550. * Observable raised when current selected mesh gets unselected
  49551. */
  49552. onSelectedMeshUnselected: Observable<AbstractMesh>;
  49553. private _raySelectionPredicate;
  49554. /**
  49555. * To be optionaly changed by user to define custom ray selection
  49556. */
  49557. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49558. /**
  49559. * To be optionaly changed by user to define custom selection logic (after ray selection)
  49560. */
  49561. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49562. /**
  49563. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  49564. */
  49565. teleportationEnabled: boolean;
  49566. private _defaultHeight;
  49567. private _teleportationInitialized;
  49568. private _interactionsEnabled;
  49569. private _interactionsRequested;
  49570. private _displayGaze;
  49571. private _displayLaserPointer;
  49572. /**
  49573. * The mesh used to display where the user is going to teleport.
  49574. */
  49575. get teleportationTarget(): Mesh;
  49576. /**
  49577. * Sets the mesh to be used to display where the user is going to teleport.
  49578. */
  49579. set teleportationTarget(value: Mesh);
  49580. /**
  49581. * 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
  49582. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  49583. * See https://doc.babylonjs.com/resources/baking_transformations
  49584. */
  49585. get gazeTrackerMesh(): Mesh;
  49586. set gazeTrackerMesh(value: Mesh);
  49587. /**
  49588. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  49589. */
  49590. updateGazeTrackerScale: boolean;
  49591. /**
  49592. * If the gaze trackers color should be updated when selecting meshes
  49593. */
  49594. updateGazeTrackerColor: boolean;
  49595. /**
  49596. * If the controller laser color should be updated when selecting meshes
  49597. */
  49598. updateControllerLaserColor: boolean;
  49599. /**
  49600. * The gaze tracking mesh corresponding to the left controller
  49601. */
  49602. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  49603. /**
  49604. * The gaze tracking mesh corresponding to the right controller
  49605. */
  49606. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  49607. /**
  49608. * If the ray of the gaze should be displayed.
  49609. */
  49610. get displayGaze(): boolean;
  49611. /**
  49612. * Sets if the ray of the gaze should be displayed.
  49613. */
  49614. set displayGaze(value: boolean);
  49615. /**
  49616. * If the ray of the LaserPointer should be displayed.
  49617. */
  49618. get displayLaserPointer(): boolean;
  49619. /**
  49620. * Sets if the ray of the LaserPointer should be displayed.
  49621. */
  49622. set displayLaserPointer(value: boolean);
  49623. /**
  49624. * The deviceOrientationCamera used as the camera when not in VR.
  49625. */
  49626. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  49627. /**
  49628. * Based on the current WebVR support, returns the current VR camera used.
  49629. */
  49630. get currentVRCamera(): Nullable<Camera>;
  49631. /**
  49632. * The webVRCamera which is used when in VR.
  49633. */
  49634. get webVRCamera(): WebVRFreeCamera;
  49635. /**
  49636. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  49637. */
  49638. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  49639. /**
  49640. * The html button that is used to trigger entering into VR.
  49641. */
  49642. get vrButton(): Nullable<HTMLButtonElement>;
  49643. private get _teleportationRequestInitiated();
  49644. /**
  49645. * Defines whether or not Pointer lock should be requested when switching to
  49646. * full screen.
  49647. */
  49648. requestPointerLockOnFullScreen: boolean;
  49649. /**
  49650. * If asking to force XR, this will be populated with the default xr experience
  49651. */
  49652. xr: WebXRDefaultExperience;
  49653. /**
  49654. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  49655. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  49656. */
  49657. xrTestDone: boolean;
  49658. /**
  49659. * Instantiates a VRExperienceHelper.
  49660. * Helps to quickly add VR support to an existing scene.
  49661. * @param scene The scene the VRExperienceHelper belongs to.
  49662. * @param webVROptions Options to modify the vr experience helper's behavior.
  49663. */
  49664. constructor(scene: Scene,
  49665. /** Options to modify the vr experience helper's behavior. */
  49666. webVROptions?: VRExperienceHelperOptions);
  49667. private completeVRInit;
  49668. private _onDefaultMeshLoaded;
  49669. private _onResize;
  49670. private _onFullscreenChange;
  49671. /**
  49672. * Gets a value indicating if we are currently in VR mode.
  49673. */
  49674. get isInVRMode(): boolean;
  49675. private onVrDisplayPresentChange;
  49676. private onVRDisplayChanged;
  49677. private moveButtonToBottomRight;
  49678. private displayVRButton;
  49679. private updateButtonVisibility;
  49680. private _cachedAngularSensibility;
  49681. /**
  49682. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  49683. * Otherwise, will use the fullscreen API.
  49684. */
  49685. enterVR(): void;
  49686. /**
  49687. * Attempt to exit VR, or fullscreen.
  49688. */
  49689. exitVR(): void;
  49690. /**
  49691. * The position of the vr experience helper.
  49692. */
  49693. get position(): Vector3;
  49694. /**
  49695. * Sets the position of the vr experience helper.
  49696. */
  49697. set position(value: Vector3);
  49698. /**
  49699. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  49700. */
  49701. enableInteractions(): void;
  49702. private get _noControllerIsActive();
  49703. private beforeRender;
  49704. private _isTeleportationFloor;
  49705. /**
  49706. * Adds a floor mesh to be used for teleportation.
  49707. * @param floorMesh the mesh to be used for teleportation.
  49708. */
  49709. addFloorMesh(floorMesh: Mesh): void;
  49710. /**
  49711. * Removes a floor mesh from being used for teleportation.
  49712. * @param floorMesh the mesh to be removed.
  49713. */
  49714. removeFloorMesh(floorMesh: Mesh): void;
  49715. /**
  49716. * Enables interactions and teleportation using the VR controllers and gaze.
  49717. * @param vrTeleportationOptions options to modify teleportation behavior.
  49718. */
  49719. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  49720. private _onNewGamepadConnected;
  49721. private _tryEnableInteractionOnController;
  49722. private _onNewGamepadDisconnected;
  49723. private _enableInteractionOnController;
  49724. private _checkTeleportWithRay;
  49725. private _checkRotate;
  49726. private _checkTeleportBackwards;
  49727. private _enableTeleportationOnController;
  49728. private _createTeleportationCircles;
  49729. private _displayTeleportationTarget;
  49730. private _hideTeleportationTarget;
  49731. private _rotateCamera;
  49732. private _moveTeleportationSelectorTo;
  49733. private _workingVector;
  49734. private _workingQuaternion;
  49735. private _workingMatrix;
  49736. /**
  49737. * Time Constant Teleportation Mode
  49738. */
  49739. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  49740. /**
  49741. * Speed Constant Teleportation Mode
  49742. */
  49743. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  49744. /**
  49745. * Teleports the users feet to the desired location
  49746. * @param location The location where the user's feet should be placed
  49747. */
  49748. teleportCamera(location: Vector3): void;
  49749. private _convertNormalToDirectionOfRay;
  49750. private _castRayAndSelectObject;
  49751. private _notifySelectedMeshUnselected;
  49752. /**
  49753. * Permanently set new colors for the laser pointer
  49754. * @param color the new laser color
  49755. * @param pickedColor the new laser color when picked mesh detected
  49756. */
  49757. setLaserColor(color: Color3, pickedColor?: Color3): void;
  49758. /**
  49759. * Set lighting enabled / disabled on the laser pointer of both controllers
  49760. * @param enabled should the lighting be enabled on the laser pointer
  49761. */
  49762. setLaserLightingState(enabled?: boolean): void;
  49763. /**
  49764. * Permanently set new colors for the gaze pointer
  49765. * @param color the new gaze color
  49766. * @param pickedColor the new gaze color when picked mesh detected
  49767. */
  49768. setGazeColor(color: Color3, pickedColor?: Color3): void;
  49769. /**
  49770. * Sets the color of the laser ray from the vr controllers.
  49771. * @param color new color for the ray.
  49772. */
  49773. changeLaserColor(color: Color3): void;
  49774. /**
  49775. * Sets the color of the ray from the vr headsets gaze.
  49776. * @param color new color for the ray.
  49777. */
  49778. changeGazeColor(color: Color3): void;
  49779. /**
  49780. * Exits VR and disposes of the vr experience helper
  49781. */
  49782. dispose(): void;
  49783. /**
  49784. * Gets the name of the VRExperienceHelper class
  49785. * @returns "VRExperienceHelper"
  49786. */
  49787. getClassName(): string;
  49788. }
  49789. }
  49790. declare module BABYLON {
  49791. /**
  49792. * Contains an array of blocks representing the octree
  49793. */
  49794. export interface IOctreeContainer<T> {
  49795. /**
  49796. * Blocks within the octree
  49797. */
  49798. blocks: Array<OctreeBlock<T>>;
  49799. }
  49800. /**
  49801. * Class used to store a cell in an octree
  49802. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49803. */
  49804. export class OctreeBlock<T> {
  49805. /**
  49806. * Gets the content of the current block
  49807. */
  49808. entries: T[];
  49809. /**
  49810. * Gets the list of block children
  49811. */
  49812. blocks: Array<OctreeBlock<T>>;
  49813. private _depth;
  49814. private _maxDepth;
  49815. private _capacity;
  49816. private _minPoint;
  49817. private _maxPoint;
  49818. private _boundingVectors;
  49819. private _creationFunc;
  49820. /**
  49821. * Creates a new block
  49822. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  49823. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  49824. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  49825. * @param depth defines the current depth of this block in the octree
  49826. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  49827. * @param creationFunc defines a callback to call when an element is added to the block
  49828. */
  49829. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  49830. /**
  49831. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  49832. */
  49833. get capacity(): number;
  49834. /**
  49835. * Gets the minimum vector (in world space) of the block's bounding box
  49836. */
  49837. get minPoint(): Vector3;
  49838. /**
  49839. * Gets the maximum vector (in world space) of the block's bounding box
  49840. */
  49841. get maxPoint(): Vector3;
  49842. /**
  49843. * Add a new element to this block
  49844. * @param entry defines the element to add
  49845. */
  49846. addEntry(entry: T): void;
  49847. /**
  49848. * Remove an element from this block
  49849. * @param entry defines the element to remove
  49850. */
  49851. removeEntry(entry: T): void;
  49852. /**
  49853. * Add an array of elements to this block
  49854. * @param entries defines the array of elements to add
  49855. */
  49856. addEntries(entries: T[]): void;
  49857. /**
  49858. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  49859. * @param frustumPlanes defines the frustum planes to test
  49860. * @param selection defines the array to store current content if selection is positive
  49861. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49862. */
  49863. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  49864. /**
  49865. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  49866. * @param sphereCenter defines the bounding sphere center
  49867. * @param sphereRadius defines the bounding sphere radius
  49868. * @param selection defines the array to store current content if selection is positive
  49869. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49870. */
  49871. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  49872. /**
  49873. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  49874. * @param ray defines the ray to test with
  49875. * @param selection defines the array to store current content if selection is positive
  49876. */
  49877. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  49878. /**
  49879. * Subdivide the content into child blocks (this block will then be empty)
  49880. */
  49881. createInnerBlocks(): void;
  49882. /**
  49883. * @hidden
  49884. */
  49885. 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;
  49886. }
  49887. }
  49888. declare module BABYLON {
  49889. /**
  49890. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  49891. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49892. */
  49893. export class Octree<T> {
  49894. /** 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.) */
  49895. maxDepth: number;
  49896. /**
  49897. * Blocks within the octree containing objects
  49898. */
  49899. blocks: Array<OctreeBlock<T>>;
  49900. /**
  49901. * Content stored in the octree
  49902. */
  49903. dynamicContent: T[];
  49904. private _maxBlockCapacity;
  49905. private _selectionContent;
  49906. private _creationFunc;
  49907. /**
  49908. * Creates a octree
  49909. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49910. * @param creationFunc function to be used to instatiate the octree
  49911. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  49912. * @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.)
  49913. */
  49914. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  49915. /** 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.) */
  49916. maxDepth?: number);
  49917. /**
  49918. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  49919. * @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);
  49920. * @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);
  49921. * @param entries meshes to be added to the octree blocks
  49922. */
  49923. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  49924. /**
  49925. * Adds a mesh to the octree
  49926. * @param entry Mesh to add to the octree
  49927. */
  49928. addMesh(entry: T): void;
  49929. /**
  49930. * Remove an element from the octree
  49931. * @param entry defines the element to remove
  49932. */
  49933. removeMesh(entry: T): void;
  49934. /**
  49935. * Selects an array of meshes within the frustum
  49936. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  49937. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  49938. * @returns array of meshes within the frustum
  49939. */
  49940. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  49941. /**
  49942. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  49943. * @param sphereCenter defines the bounding sphere center
  49944. * @param sphereRadius defines the bounding sphere radius
  49945. * @param allowDuplicate defines if the selection array can contains duplicated entries
  49946. * @returns an array of objects that intersect the sphere
  49947. */
  49948. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  49949. /**
  49950. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  49951. * @param ray defines the ray to test with
  49952. * @returns array of intersected objects
  49953. */
  49954. intersectsRay(ray: Ray): SmartArray<T>;
  49955. /**
  49956. * Adds a mesh into the octree block if it intersects the block
  49957. */
  49958. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  49959. /**
  49960. * Adds a submesh into the octree block if it intersects the block
  49961. */
  49962. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  49963. }
  49964. }
  49965. declare module BABYLON {
  49966. interface Scene {
  49967. /**
  49968. * @hidden
  49969. * Backing Filed
  49970. */
  49971. _selectionOctree: Octree<AbstractMesh>;
  49972. /**
  49973. * Gets the octree used to boost mesh selection (picking)
  49974. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49975. */
  49976. selectionOctree: Octree<AbstractMesh>;
  49977. /**
  49978. * Creates or updates the octree used to boost selection (picking)
  49979. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  49980. * @param maxCapacity defines the maximum capacity per leaf
  49981. * @param maxDepth defines the maximum depth of the octree
  49982. * @returns an octree of AbstractMesh
  49983. */
  49984. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  49985. }
  49986. interface AbstractMesh {
  49987. /**
  49988. * @hidden
  49989. * Backing Field
  49990. */
  49991. _submeshesOctree: Octree<SubMesh>;
  49992. /**
  49993. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  49994. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  49995. * @param maxCapacity defines the maximum size of each block (64 by default)
  49996. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  49997. * @returns the new octree
  49998. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  49999. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50000. */
  50001. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  50002. }
  50003. /**
  50004. * Defines the octree scene component responsible to manage any octrees
  50005. * in a given scene.
  50006. */
  50007. export class OctreeSceneComponent {
  50008. /**
  50009. * The component name help to identify the component in the list of scene components.
  50010. */
  50011. readonly name: string;
  50012. /**
  50013. * The scene the component belongs to.
  50014. */
  50015. scene: Scene;
  50016. /**
  50017. * Indicates if the meshes have been checked to make sure they are isEnabled()
  50018. */
  50019. readonly checksIsEnabled: boolean;
  50020. /**
  50021. * Creates a new instance of the component for the given scene
  50022. * @param scene Defines the scene to register the component in
  50023. */
  50024. constructor(scene: Scene);
  50025. /**
  50026. * Registers the component in a given scene
  50027. */
  50028. register(): void;
  50029. /**
  50030. * Return the list of active meshes
  50031. * @returns the list of active meshes
  50032. */
  50033. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  50034. /**
  50035. * Return the list of active sub meshes
  50036. * @param mesh The mesh to get the candidates sub meshes from
  50037. * @returns the list of active sub meshes
  50038. */
  50039. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  50040. private _tempRay;
  50041. /**
  50042. * Return the list of sub meshes intersecting with a given local ray
  50043. * @param mesh defines the mesh to find the submesh for
  50044. * @param localRay defines the ray in local space
  50045. * @returns the list of intersecting sub meshes
  50046. */
  50047. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  50048. /**
  50049. * Return the list of sub meshes colliding with a collider
  50050. * @param mesh defines the mesh to find the submesh for
  50051. * @param collider defines the collider to evaluate the collision against
  50052. * @returns the list of colliding sub meshes
  50053. */
  50054. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  50055. /**
  50056. * Rebuilds the elements related to this component in case of
  50057. * context lost for instance.
  50058. */
  50059. rebuild(): void;
  50060. /**
  50061. * Disposes the component and the associated ressources.
  50062. */
  50063. dispose(): void;
  50064. }
  50065. }
  50066. declare module BABYLON {
  50067. /**
  50068. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  50069. */
  50070. export class Gizmo implements IDisposable {
  50071. /** The utility layer the gizmo will be added to */
  50072. gizmoLayer: UtilityLayerRenderer;
  50073. /**
  50074. * The root mesh of the gizmo
  50075. */
  50076. _rootMesh: Mesh;
  50077. private _attachedMesh;
  50078. private _attachedNode;
  50079. /**
  50080. * Ratio for the scale of the gizmo (Default: 1)
  50081. */
  50082. scaleRatio: number;
  50083. /**
  50084. * If a custom mesh has been set (Default: false)
  50085. */
  50086. protected _customMeshSet: boolean;
  50087. /**
  50088. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  50089. * * When set, interactions will be enabled
  50090. */
  50091. get attachedMesh(): Nullable<AbstractMesh>;
  50092. set attachedMesh(value: Nullable<AbstractMesh>);
  50093. /**
  50094. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  50095. * * When set, interactions will be enabled
  50096. */
  50097. get attachedNode(): Nullable<Node>;
  50098. set attachedNode(value: Nullable<Node>);
  50099. /**
  50100. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50101. * @param mesh The mesh to replace the default mesh of the gizmo
  50102. */
  50103. setCustomMesh(mesh: Mesh): void;
  50104. /**
  50105. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  50106. */
  50107. updateGizmoRotationToMatchAttachedMesh: boolean;
  50108. /**
  50109. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  50110. */
  50111. updateGizmoPositionToMatchAttachedMesh: boolean;
  50112. /**
  50113. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  50114. */
  50115. updateScale: boolean;
  50116. protected _interactionsEnabled: boolean;
  50117. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50118. private _beforeRenderObserver;
  50119. private _tempVector;
  50120. /**
  50121. * Creates a gizmo
  50122. * @param gizmoLayer The utility layer the gizmo will be added to
  50123. */
  50124. constructor(
  50125. /** The utility layer the gizmo will be added to */
  50126. gizmoLayer?: UtilityLayerRenderer);
  50127. /**
  50128. * Updates the gizmo to match the attached mesh's position/rotation
  50129. */
  50130. protected _update(): void;
  50131. /**
  50132. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  50133. * @param value Node, TransformNode or mesh
  50134. */
  50135. protected _matrixChanged(): void;
  50136. /**
  50137. * Disposes of the gizmo
  50138. */
  50139. dispose(): void;
  50140. }
  50141. }
  50142. declare module BABYLON {
  50143. /**
  50144. * Single plane drag gizmo
  50145. */
  50146. export class PlaneDragGizmo extends Gizmo {
  50147. /**
  50148. * Drag behavior responsible for the gizmos dragging interactions
  50149. */
  50150. dragBehavior: PointerDragBehavior;
  50151. private _pointerObserver;
  50152. /**
  50153. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50154. */
  50155. snapDistance: number;
  50156. /**
  50157. * Event that fires each time the gizmo snaps to a new location.
  50158. * * snapDistance is the the change in distance
  50159. */
  50160. onSnapObservable: Observable<{
  50161. snapDistance: number;
  50162. }>;
  50163. private _plane;
  50164. private _coloredMaterial;
  50165. private _hoverMaterial;
  50166. private _isEnabled;
  50167. private _parent;
  50168. /** @hidden */
  50169. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  50170. /** @hidden */
  50171. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50172. /**
  50173. * Creates a PlaneDragGizmo
  50174. * @param gizmoLayer The utility layer the gizmo will be added to
  50175. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  50176. * @param color The color of the gizmo
  50177. */
  50178. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  50179. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50180. /**
  50181. * If the gizmo is enabled
  50182. */
  50183. set isEnabled(value: boolean);
  50184. get isEnabled(): boolean;
  50185. /**
  50186. * Disposes of the gizmo
  50187. */
  50188. dispose(): void;
  50189. }
  50190. }
  50191. declare module BABYLON {
  50192. /**
  50193. * Gizmo that enables dragging a mesh along 3 axis
  50194. */
  50195. export class PositionGizmo extends Gizmo {
  50196. /**
  50197. * Internal gizmo used for interactions on the x axis
  50198. */
  50199. xGizmo: AxisDragGizmo;
  50200. /**
  50201. * Internal gizmo used for interactions on the y axis
  50202. */
  50203. yGizmo: AxisDragGizmo;
  50204. /**
  50205. * Internal gizmo used for interactions on the z axis
  50206. */
  50207. zGizmo: AxisDragGizmo;
  50208. /**
  50209. * Internal gizmo used for interactions on the yz plane
  50210. */
  50211. xPlaneGizmo: PlaneDragGizmo;
  50212. /**
  50213. * Internal gizmo used for interactions on the xz plane
  50214. */
  50215. yPlaneGizmo: PlaneDragGizmo;
  50216. /**
  50217. * Internal gizmo used for interactions on the xy plane
  50218. */
  50219. zPlaneGizmo: PlaneDragGizmo;
  50220. /**
  50221. * private variables
  50222. */
  50223. private _meshAttached;
  50224. private _nodeAttached;
  50225. private _updateGizmoRotationToMatchAttachedMesh;
  50226. private _snapDistance;
  50227. private _scaleRatio;
  50228. /** Fires an event when any of it's sub gizmos are dragged */
  50229. onDragStartObservable: Observable<unknown>;
  50230. /** Fires an event when any of it's sub gizmos are released from dragging */
  50231. onDragEndObservable: Observable<unknown>;
  50232. /**
  50233. * If set to true, planar drag is enabled
  50234. */
  50235. private _planarGizmoEnabled;
  50236. get attachedMesh(): Nullable<AbstractMesh>;
  50237. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50238. get attachedNode(): Nullable<Node>;
  50239. set attachedNode(node: Nullable<Node>);
  50240. /**
  50241. * Creates a PositionGizmo
  50242. * @param gizmoLayer The utility layer the gizmo will be added to
  50243. @param thickness display gizmo axis thickness
  50244. */
  50245. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  50246. /**
  50247. * If the planar drag gizmo is enabled
  50248. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  50249. */
  50250. set planarGizmoEnabled(value: boolean);
  50251. get planarGizmoEnabled(): boolean;
  50252. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50253. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50254. /**
  50255. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50256. */
  50257. set snapDistance(value: number);
  50258. get snapDistance(): number;
  50259. /**
  50260. * Ratio for the scale of the gizmo (Default: 1)
  50261. */
  50262. set scaleRatio(value: number);
  50263. get scaleRatio(): number;
  50264. /**
  50265. * Disposes of the gizmo
  50266. */
  50267. dispose(): void;
  50268. /**
  50269. * CustomMeshes are not supported by this gizmo
  50270. * @param mesh The mesh to replace the default mesh of the gizmo
  50271. */
  50272. setCustomMesh(mesh: Mesh): void;
  50273. }
  50274. }
  50275. declare module BABYLON {
  50276. /**
  50277. * Single axis drag gizmo
  50278. */
  50279. export class AxisDragGizmo extends Gizmo {
  50280. /**
  50281. * Drag behavior responsible for the gizmos dragging interactions
  50282. */
  50283. dragBehavior: PointerDragBehavior;
  50284. private _pointerObserver;
  50285. /**
  50286. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50287. */
  50288. snapDistance: number;
  50289. /**
  50290. * Event that fires each time the gizmo snaps to a new location.
  50291. * * snapDistance is the the change in distance
  50292. */
  50293. onSnapObservable: Observable<{
  50294. snapDistance: number;
  50295. }>;
  50296. private _isEnabled;
  50297. private _parent;
  50298. private _arrow;
  50299. private _coloredMaterial;
  50300. private _hoverMaterial;
  50301. /** @hidden */
  50302. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  50303. /** @hidden */
  50304. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50305. /**
  50306. * Creates an AxisDragGizmo
  50307. * @param gizmoLayer The utility layer the gizmo will be added to
  50308. * @param dragAxis The axis which the gizmo will be able to drag on
  50309. * @param color The color of the gizmo
  50310. * @param thickness display gizmo axis thickness
  50311. */
  50312. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  50313. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50314. /**
  50315. * If the gizmo is enabled
  50316. */
  50317. set isEnabled(value: boolean);
  50318. get isEnabled(): boolean;
  50319. /**
  50320. * Disposes of the gizmo
  50321. */
  50322. dispose(): void;
  50323. }
  50324. }
  50325. declare module BABYLON.Debug {
  50326. /**
  50327. * The Axes viewer will show 3 axes in a specific point in space
  50328. */
  50329. export class AxesViewer {
  50330. private _xAxis;
  50331. private _yAxis;
  50332. private _zAxis;
  50333. private _scaleLinesFactor;
  50334. private _instanced;
  50335. /**
  50336. * Gets the hosting scene
  50337. */
  50338. scene: Scene;
  50339. /**
  50340. * Gets or sets a number used to scale line length
  50341. */
  50342. scaleLines: number;
  50343. /** Gets the node hierarchy used to render x-axis */
  50344. get xAxis(): TransformNode;
  50345. /** Gets the node hierarchy used to render y-axis */
  50346. get yAxis(): TransformNode;
  50347. /** Gets the node hierarchy used to render z-axis */
  50348. get zAxis(): TransformNode;
  50349. /**
  50350. * Creates a new AxesViewer
  50351. * @param scene defines the hosting scene
  50352. * @param scaleLines defines a number used to scale line length (1 by default)
  50353. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  50354. * @param xAxis defines the node hierarchy used to render the x-axis
  50355. * @param yAxis defines the node hierarchy used to render the y-axis
  50356. * @param zAxis defines the node hierarchy used to render the z-axis
  50357. */
  50358. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  50359. /**
  50360. * Force the viewer to update
  50361. * @param position defines the position of the viewer
  50362. * @param xaxis defines the x axis of the viewer
  50363. * @param yaxis defines the y axis of the viewer
  50364. * @param zaxis defines the z axis of the viewer
  50365. */
  50366. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  50367. /**
  50368. * Creates an instance of this axes viewer.
  50369. * @returns a new axes viewer with instanced meshes
  50370. */
  50371. createInstance(): AxesViewer;
  50372. /** Releases resources */
  50373. dispose(): void;
  50374. private static _SetRenderingGroupId;
  50375. }
  50376. }
  50377. declare module BABYLON.Debug {
  50378. /**
  50379. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  50380. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  50381. */
  50382. export class BoneAxesViewer extends AxesViewer {
  50383. /**
  50384. * Gets or sets the target mesh where to display the axes viewer
  50385. */
  50386. mesh: Nullable<Mesh>;
  50387. /**
  50388. * Gets or sets the target bone where to display the axes viewer
  50389. */
  50390. bone: Nullable<Bone>;
  50391. /** Gets current position */
  50392. pos: Vector3;
  50393. /** Gets direction of X axis */
  50394. xaxis: Vector3;
  50395. /** Gets direction of Y axis */
  50396. yaxis: Vector3;
  50397. /** Gets direction of Z axis */
  50398. zaxis: Vector3;
  50399. /**
  50400. * Creates a new BoneAxesViewer
  50401. * @param scene defines the hosting scene
  50402. * @param bone defines the target bone
  50403. * @param mesh defines the target mesh
  50404. * @param scaleLines defines a scaling factor for line length (1 by default)
  50405. */
  50406. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  50407. /**
  50408. * Force the viewer to update
  50409. */
  50410. update(): void;
  50411. /** Releases resources */
  50412. dispose(): void;
  50413. }
  50414. }
  50415. declare module BABYLON {
  50416. /**
  50417. * Interface used to define scene explorer extensibility option
  50418. */
  50419. export interface IExplorerExtensibilityOption {
  50420. /**
  50421. * Define the option label
  50422. */
  50423. label: string;
  50424. /**
  50425. * Defines the action to execute on click
  50426. */
  50427. action: (entity: any) => void;
  50428. }
  50429. /**
  50430. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  50431. */
  50432. export interface IExplorerExtensibilityGroup {
  50433. /**
  50434. * Defines a predicate to test if a given type mut be extended
  50435. */
  50436. predicate: (entity: any) => boolean;
  50437. /**
  50438. * Gets the list of options added to a type
  50439. */
  50440. entries: IExplorerExtensibilityOption[];
  50441. }
  50442. /**
  50443. * Interface used to define the options to use to create the Inspector
  50444. */
  50445. export interface IInspectorOptions {
  50446. /**
  50447. * Display in overlay mode (default: false)
  50448. */
  50449. overlay?: boolean;
  50450. /**
  50451. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  50452. */
  50453. globalRoot?: HTMLElement;
  50454. /**
  50455. * Display the Scene explorer
  50456. */
  50457. showExplorer?: boolean;
  50458. /**
  50459. * Display the property inspector
  50460. */
  50461. showInspector?: boolean;
  50462. /**
  50463. * Display in embed mode (both panes on the right)
  50464. */
  50465. embedMode?: boolean;
  50466. /**
  50467. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  50468. */
  50469. handleResize?: boolean;
  50470. /**
  50471. * Allow the panes to popup (default: true)
  50472. */
  50473. enablePopup?: boolean;
  50474. /**
  50475. * Allow the panes to be closed by users (default: true)
  50476. */
  50477. enableClose?: boolean;
  50478. /**
  50479. * Optional list of extensibility entries
  50480. */
  50481. explorerExtensibility?: IExplorerExtensibilityGroup[];
  50482. /**
  50483. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  50484. */
  50485. inspectorURL?: string;
  50486. /**
  50487. * Optional initial tab (default to DebugLayerTab.Properties)
  50488. */
  50489. initialTab?: DebugLayerTab;
  50490. }
  50491. interface Scene {
  50492. /**
  50493. * @hidden
  50494. * Backing field
  50495. */
  50496. _debugLayer: DebugLayer;
  50497. /**
  50498. * Gets the debug layer (aka Inspector) associated with the scene
  50499. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50500. */
  50501. debugLayer: DebugLayer;
  50502. }
  50503. /**
  50504. * Enum of inspector action tab
  50505. */
  50506. export enum DebugLayerTab {
  50507. /**
  50508. * Properties tag (default)
  50509. */
  50510. Properties = 0,
  50511. /**
  50512. * Debug tab
  50513. */
  50514. Debug = 1,
  50515. /**
  50516. * Statistics tab
  50517. */
  50518. Statistics = 2,
  50519. /**
  50520. * Tools tab
  50521. */
  50522. Tools = 3,
  50523. /**
  50524. * Settings tab
  50525. */
  50526. Settings = 4
  50527. }
  50528. /**
  50529. * The debug layer (aka Inspector) is the go to tool in order to better understand
  50530. * what is happening in your scene
  50531. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50532. */
  50533. export class DebugLayer {
  50534. /**
  50535. * Define the url to get the inspector script from.
  50536. * By default it uses the babylonjs CDN.
  50537. * @ignoreNaming
  50538. */
  50539. static InspectorURL: string;
  50540. private _scene;
  50541. private BJSINSPECTOR;
  50542. private _onPropertyChangedObservable?;
  50543. /**
  50544. * Observable triggered when a property is changed through the inspector.
  50545. */
  50546. get onPropertyChangedObservable(): any;
  50547. /**
  50548. * Instantiates a new debug layer.
  50549. * The debug layer (aka Inspector) is the go to tool in order to better understand
  50550. * what is happening in your scene
  50551. * @see https://doc.babylonjs.com/features/playground_debuglayer
  50552. * @param scene Defines the scene to inspect
  50553. */
  50554. constructor(scene: Scene);
  50555. /** Creates the inspector window. */
  50556. private _createInspector;
  50557. /**
  50558. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  50559. * @param entity defines the entity to select
  50560. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  50561. */
  50562. select(entity: any, lineContainerTitles?: string | string[]): void;
  50563. /** Get the inspector from bundle or global */
  50564. private _getGlobalInspector;
  50565. /**
  50566. * Get if the inspector is visible or not.
  50567. * @returns true if visible otherwise, false
  50568. */
  50569. isVisible(): boolean;
  50570. /**
  50571. * Hide the inspector and close its window.
  50572. */
  50573. hide(): void;
  50574. /**
  50575. * Update the scene in the inspector
  50576. */
  50577. setAsActiveScene(): void;
  50578. /**
  50579. * Launch the debugLayer.
  50580. * @param config Define the configuration of the inspector
  50581. * @return a promise fulfilled when the debug layer is visible
  50582. */
  50583. show(config?: IInspectorOptions): Promise<DebugLayer>;
  50584. }
  50585. }
  50586. declare module BABYLON {
  50587. /**
  50588. * Class containing static functions to help procedurally build meshes
  50589. */
  50590. export class BoxBuilder {
  50591. /**
  50592. * Creates a box mesh
  50593. * * The parameter `size` sets the size (float) of each box side (default 1)
  50594. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  50595. * * 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)
  50596. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50597. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50598. * * 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
  50599. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50600. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  50601. * @param name defines the name of the mesh
  50602. * @param options defines the options used to create the mesh
  50603. * @param scene defines the hosting scene
  50604. * @returns the box mesh
  50605. */
  50606. static CreateBox(name: string, options: {
  50607. size?: number;
  50608. width?: number;
  50609. height?: number;
  50610. depth?: number;
  50611. faceUV?: Vector4[];
  50612. faceColors?: Color4[];
  50613. sideOrientation?: number;
  50614. frontUVs?: Vector4;
  50615. backUVs?: Vector4;
  50616. wrap?: boolean;
  50617. topBaseAt?: number;
  50618. bottomBaseAt?: number;
  50619. updatable?: boolean;
  50620. }, scene?: Nullable<Scene>): Mesh;
  50621. }
  50622. }
  50623. declare module BABYLON.Debug {
  50624. /**
  50625. * Used to show the physics impostor around the specific mesh
  50626. */
  50627. export class PhysicsViewer {
  50628. /** @hidden */
  50629. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  50630. /** @hidden */
  50631. protected _meshes: Array<Nullable<AbstractMesh>>;
  50632. /** @hidden */
  50633. protected _scene: Nullable<Scene>;
  50634. /** @hidden */
  50635. protected _numMeshes: number;
  50636. /** @hidden */
  50637. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  50638. private _renderFunction;
  50639. private _utilityLayer;
  50640. private _debugBoxMesh;
  50641. private _debugSphereMesh;
  50642. private _debugCylinderMesh;
  50643. private _debugMaterial;
  50644. private _debugMeshMeshes;
  50645. /**
  50646. * Creates a new PhysicsViewer
  50647. * @param scene defines the hosting scene
  50648. */
  50649. constructor(scene: Scene);
  50650. /** @hidden */
  50651. protected _updateDebugMeshes(): void;
  50652. /**
  50653. * Renders a specified physic impostor
  50654. * @param impostor defines the impostor to render
  50655. * @param targetMesh defines the mesh represented by the impostor
  50656. * @returns the new debug mesh used to render the impostor
  50657. */
  50658. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  50659. /**
  50660. * Hides a specified physic impostor
  50661. * @param impostor defines the impostor to hide
  50662. */
  50663. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  50664. private _getDebugMaterial;
  50665. private _getDebugBoxMesh;
  50666. private _getDebugSphereMesh;
  50667. private _getDebugCylinderMesh;
  50668. private _getDebugMeshMesh;
  50669. private _getDebugMesh;
  50670. /** Releases all resources */
  50671. dispose(): void;
  50672. }
  50673. }
  50674. declare module BABYLON {
  50675. /**
  50676. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  50677. * in order to better appreciate the issue one might have.
  50678. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  50679. */
  50680. export class RayHelper {
  50681. /**
  50682. * Defines the ray we are currently tryin to visualize.
  50683. */
  50684. ray: Nullable<Ray>;
  50685. private _renderPoints;
  50686. private _renderLine;
  50687. private _renderFunction;
  50688. private _scene;
  50689. private _updateToMeshFunction;
  50690. private _attachedToMesh;
  50691. private _meshSpaceDirection;
  50692. private _meshSpaceOrigin;
  50693. /**
  50694. * Helper function to create a colored helper in a scene in one line.
  50695. * @param ray Defines the ray we are currently tryin to visualize
  50696. * @param scene Defines the scene the ray is used in
  50697. * @param color Defines the color we want to see the ray in
  50698. * @returns The newly created ray helper.
  50699. */
  50700. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  50701. /**
  50702. * Instantiate a new ray helper.
  50703. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  50704. * in order to better appreciate the issue one might have.
  50705. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  50706. * @param ray Defines the ray we are currently tryin to visualize
  50707. */
  50708. constructor(ray: Ray);
  50709. /**
  50710. * Shows the ray we are willing to debug.
  50711. * @param scene Defines the scene the ray needs to be rendered in
  50712. * @param color Defines the color the ray needs to be rendered in
  50713. */
  50714. show(scene: Scene, color?: Color3): void;
  50715. /**
  50716. * Hides the ray we are debugging.
  50717. */
  50718. hide(): void;
  50719. private _render;
  50720. /**
  50721. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  50722. * @param mesh Defines the mesh we want the helper attached to
  50723. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  50724. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  50725. * @param length Defines the length of the ray
  50726. */
  50727. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  50728. /**
  50729. * Detach the ray helper from the mesh it has previously been attached to.
  50730. */
  50731. detachFromMesh(): void;
  50732. private _updateToMesh;
  50733. /**
  50734. * Dispose the helper and release its associated resources.
  50735. */
  50736. dispose(): void;
  50737. }
  50738. }
  50739. declare module BABYLON.Debug {
  50740. /**
  50741. * Class used to render a debug view of a given skeleton
  50742. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  50743. */
  50744. export class SkeletonViewer {
  50745. /** defines the skeleton to render */
  50746. skeleton: Skeleton;
  50747. /** defines the mesh attached to the skeleton */
  50748. mesh: AbstractMesh;
  50749. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  50750. autoUpdateBonesMatrices: boolean;
  50751. /** defines the rendering group id to use with the viewer */
  50752. renderingGroupId: number;
  50753. /** Gets or sets the color used to render the skeleton */
  50754. color: Color3;
  50755. private _scene;
  50756. private _debugLines;
  50757. private _debugMesh;
  50758. private _isEnabled;
  50759. private _renderFunction;
  50760. private _utilityLayer;
  50761. /**
  50762. * Returns the mesh used to render the bones
  50763. */
  50764. get debugMesh(): Nullable<LinesMesh>;
  50765. /**
  50766. * Creates a new SkeletonViewer
  50767. * @param skeleton defines the skeleton to render
  50768. * @param mesh defines the mesh attached to the skeleton
  50769. * @param scene defines the hosting scene
  50770. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  50771. * @param renderingGroupId defines the rendering group id to use with the viewer
  50772. */
  50773. constructor(
  50774. /** defines the skeleton to render */
  50775. skeleton: Skeleton,
  50776. /** defines the mesh attached to the skeleton */
  50777. mesh: AbstractMesh, scene: Scene,
  50778. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  50779. autoUpdateBonesMatrices?: boolean,
  50780. /** defines the rendering group id to use with the viewer */
  50781. renderingGroupId?: number);
  50782. /** Gets or sets a boolean indicating if the viewer is enabled */
  50783. set isEnabled(value: boolean);
  50784. get isEnabled(): boolean;
  50785. private _getBonePosition;
  50786. private _getLinesForBonesWithLength;
  50787. private _getLinesForBonesNoLength;
  50788. /** Update the viewer to sync with current skeleton state */
  50789. update(): void;
  50790. /** Release associated resources */
  50791. dispose(): void;
  50792. }
  50793. }
  50794. declare module BABYLON {
  50795. /**
  50796. * Enum for Device Types
  50797. */
  50798. export enum DeviceType {
  50799. /** Generic */
  50800. Generic = 0,
  50801. /** Keyboard */
  50802. Keyboard = 1,
  50803. /** Mouse */
  50804. Mouse = 2,
  50805. /** Touch Pointers */
  50806. Touch = 3,
  50807. /** PS4 Dual Shock */
  50808. DualShock = 4,
  50809. /** Xbox */
  50810. Xbox = 5,
  50811. /** Switch Controller */
  50812. Switch = 6
  50813. }
  50814. /**
  50815. * Enum for All Pointers (Touch/Mouse)
  50816. */
  50817. export enum PointerInput {
  50818. /** Horizontal Axis */
  50819. Horizontal = 0,
  50820. /** Vertical Axis */
  50821. Vertical = 1,
  50822. /** Left Click or Touch */
  50823. LeftClick = 2,
  50824. /** Middle Click */
  50825. MiddleClick = 3,
  50826. /** Right Click */
  50827. RightClick = 4,
  50828. /** Browser Back */
  50829. BrowserBack = 5,
  50830. /** Browser Forward */
  50831. BrowserForward = 6
  50832. }
  50833. /**
  50834. * Enum for Dual Shock Gamepad
  50835. */
  50836. export enum DualShockInput {
  50837. /** Cross */
  50838. Cross = 0,
  50839. /** Circle */
  50840. Circle = 1,
  50841. /** Square */
  50842. Square = 2,
  50843. /** Triangle */
  50844. Triangle = 3,
  50845. /** L1 */
  50846. L1 = 4,
  50847. /** R1 */
  50848. R1 = 5,
  50849. /** L2 */
  50850. L2 = 6,
  50851. /** R2 */
  50852. R2 = 7,
  50853. /** Share */
  50854. Share = 8,
  50855. /** Options */
  50856. Options = 9,
  50857. /** L3 */
  50858. L3 = 10,
  50859. /** R3 */
  50860. R3 = 11,
  50861. /** DPadUp */
  50862. DPadUp = 12,
  50863. /** DPadDown */
  50864. DPadDown = 13,
  50865. /** DPadLeft */
  50866. DPadLeft = 14,
  50867. /** DRight */
  50868. DPadRight = 15,
  50869. /** Home */
  50870. Home = 16,
  50871. /** TouchPad */
  50872. TouchPad = 17,
  50873. /** LStickXAxis */
  50874. LStickXAxis = 18,
  50875. /** LStickYAxis */
  50876. LStickYAxis = 19,
  50877. /** RStickXAxis */
  50878. RStickXAxis = 20,
  50879. /** RStickYAxis */
  50880. RStickYAxis = 21
  50881. }
  50882. /**
  50883. * Enum for Xbox Gamepad
  50884. */
  50885. export enum XboxInput {
  50886. /** A */
  50887. A = 0,
  50888. /** B */
  50889. B = 1,
  50890. /** X */
  50891. X = 2,
  50892. /** Y */
  50893. Y = 3,
  50894. /** LB */
  50895. LB = 4,
  50896. /** RB */
  50897. RB = 5,
  50898. /** LT */
  50899. LT = 6,
  50900. /** RT */
  50901. RT = 7,
  50902. /** Back */
  50903. Back = 8,
  50904. /** Start */
  50905. Start = 9,
  50906. /** LS */
  50907. LS = 10,
  50908. /** RS */
  50909. RS = 11,
  50910. /** DPadUp */
  50911. DPadUp = 12,
  50912. /** DPadDown */
  50913. DPadDown = 13,
  50914. /** DPadLeft */
  50915. DPadLeft = 14,
  50916. /** DRight */
  50917. DPadRight = 15,
  50918. /** Home */
  50919. Home = 16,
  50920. /** LStickXAxis */
  50921. LStickXAxis = 17,
  50922. /** LStickYAxis */
  50923. LStickYAxis = 18,
  50924. /** RStickXAxis */
  50925. RStickXAxis = 19,
  50926. /** RStickYAxis */
  50927. RStickYAxis = 20
  50928. }
  50929. /**
  50930. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  50931. */
  50932. export enum SwitchInput {
  50933. /** B */
  50934. B = 0,
  50935. /** A */
  50936. A = 1,
  50937. /** Y */
  50938. Y = 2,
  50939. /** X */
  50940. X = 3,
  50941. /** L */
  50942. L = 4,
  50943. /** R */
  50944. R = 5,
  50945. /** ZL */
  50946. ZL = 6,
  50947. /** ZR */
  50948. ZR = 7,
  50949. /** Minus */
  50950. Minus = 8,
  50951. /** Plus */
  50952. Plus = 9,
  50953. /** LS */
  50954. LS = 10,
  50955. /** RS */
  50956. RS = 11,
  50957. /** DPadUp */
  50958. DPadUp = 12,
  50959. /** DPadDown */
  50960. DPadDown = 13,
  50961. /** DPadLeft */
  50962. DPadLeft = 14,
  50963. /** DRight */
  50964. DPadRight = 15,
  50965. /** Home */
  50966. Home = 16,
  50967. /** Capture */
  50968. Capture = 17,
  50969. /** LStickXAxis */
  50970. LStickXAxis = 18,
  50971. /** LStickYAxis */
  50972. LStickYAxis = 19,
  50973. /** RStickXAxis */
  50974. RStickXAxis = 20,
  50975. /** RStickYAxis */
  50976. RStickYAxis = 21
  50977. }
  50978. }
  50979. declare module BABYLON {
  50980. /**
  50981. * This class will take all inputs from Keyboard, Pointer, and
  50982. * any Gamepads and provide a polling system that all devices
  50983. * will use. This class assumes that there will only be one
  50984. * pointer device and one keyboard.
  50985. */
  50986. export class DeviceInputSystem implements IDisposable {
  50987. /**
  50988. * Callback to be triggered when a device is connected
  50989. */
  50990. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  50991. /**
  50992. * Callback to be triggered when a device is disconnected
  50993. */
  50994. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  50995. /**
  50996. * Callback to be triggered when event driven input is updated
  50997. */
  50998. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  50999. private _inputs;
  51000. private _gamepads;
  51001. private _keyboardActive;
  51002. private _pointerActive;
  51003. private _elementToAttachTo;
  51004. private _keyboardDownEvent;
  51005. private _keyboardUpEvent;
  51006. private _pointerMoveEvent;
  51007. private _pointerDownEvent;
  51008. private _pointerUpEvent;
  51009. private _gamepadConnectedEvent;
  51010. private _gamepadDisconnectedEvent;
  51011. private static _MAX_KEYCODES;
  51012. private static _MAX_POINTER_INPUTS;
  51013. private constructor();
  51014. /**
  51015. * Creates a new DeviceInputSystem instance
  51016. * @param engine Engine to pull input element from
  51017. * @returns The new instance
  51018. */
  51019. static Create(engine: Engine): DeviceInputSystem;
  51020. /**
  51021. * Checks for current device input value, given an id and input index
  51022. * @param deviceName Id of connected device
  51023. * @param inputIndex Index of device input
  51024. * @returns Current value of input
  51025. */
  51026. /**
  51027. * Checks for current device input value, given an id and input index
  51028. * @param deviceType Enum specifiying device type
  51029. * @param deviceSlot "Slot" or index that device is referenced in
  51030. * @param inputIndex Id of input to be checked
  51031. * @returns Current value of input
  51032. */
  51033. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  51034. /**
  51035. * Dispose of all the eventlisteners
  51036. */
  51037. dispose(): void;
  51038. /**
  51039. * Add device and inputs to device array
  51040. * @param deviceType Enum specifiying device type
  51041. * @param deviceSlot "Slot" or index that device is referenced in
  51042. * @param numberOfInputs Number of input entries to create for given device
  51043. */
  51044. private _registerDevice;
  51045. /**
  51046. * Given a specific device name, remove that device from the device map
  51047. * @param deviceType Enum specifiying device type
  51048. * @param deviceSlot "Slot" or index that device is referenced in
  51049. */
  51050. private _unregisterDevice;
  51051. /**
  51052. * Handle all actions that come from keyboard interaction
  51053. */
  51054. private _handleKeyActions;
  51055. /**
  51056. * Handle all actions that come from pointer interaction
  51057. */
  51058. private _handlePointerActions;
  51059. /**
  51060. * Handle all actions that come from gamepad interaction
  51061. */
  51062. private _handleGamepadActions;
  51063. /**
  51064. * Update all non-event based devices with each frame
  51065. * @param deviceType Enum specifiying device type
  51066. * @param deviceSlot "Slot" or index that device is referenced in
  51067. * @param inputIndex Id of input to be checked
  51068. */
  51069. private _updateDevice;
  51070. /**
  51071. * Gets DeviceType from the device name
  51072. * @param deviceName Name of Device from DeviceInputSystem
  51073. * @returns DeviceType enum value
  51074. */
  51075. private _getGamepadDeviceType;
  51076. }
  51077. }
  51078. declare module BABYLON {
  51079. /**
  51080. * Type to handle enforcement of inputs
  51081. */
  51082. 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;
  51083. }
  51084. declare module BABYLON {
  51085. /**
  51086. * Class that handles all input for a specific device
  51087. */
  51088. export class DeviceSource<T extends DeviceType> {
  51089. /** Type of device */
  51090. readonly deviceType: DeviceType;
  51091. /** "Slot" or index that device is referenced in */
  51092. readonly deviceSlot: number;
  51093. /**
  51094. * Observable to handle device input changes per device
  51095. */
  51096. readonly onInputChangedObservable: Observable<{
  51097. inputIndex: DeviceInput<T>;
  51098. previousState: Nullable<number>;
  51099. currentState: Nullable<number>;
  51100. }>;
  51101. private readonly _deviceInputSystem;
  51102. /**
  51103. * Default Constructor
  51104. * @param deviceInputSystem Reference to DeviceInputSystem
  51105. * @param deviceType Type of device
  51106. * @param deviceSlot "Slot" or index that device is referenced in
  51107. */
  51108. constructor(deviceInputSystem: DeviceInputSystem,
  51109. /** Type of device */
  51110. deviceType: DeviceType,
  51111. /** "Slot" or index that device is referenced in */
  51112. deviceSlot?: number);
  51113. /**
  51114. * Get input for specific input
  51115. * @param inputIndex index of specific input on device
  51116. * @returns Input value from DeviceInputSystem
  51117. */
  51118. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  51119. }
  51120. /**
  51121. * Class to keep track of devices
  51122. */
  51123. export class DeviceSourceManager implements IDisposable {
  51124. /**
  51125. * Observable to be triggered when before a device is connected
  51126. */
  51127. readonly onBeforeDeviceConnectedObservable: Observable<{
  51128. deviceType: DeviceType;
  51129. deviceSlot: number;
  51130. }>;
  51131. /**
  51132. * Observable to be triggered when before a device is disconnected
  51133. */
  51134. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  51135. deviceType: DeviceType;
  51136. deviceSlot: number;
  51137. }>;
  51138. /**
  51139. * Observable to be triggered when after a device is connected
  51140. */
  51141. readonly onAfterDeviceConnectedObservable: Observable<{
  51142. deviceType: DeviceType;
  51143. deviceSlot: number;
  51144. }>;
  51145. /**
  51146. * Observable to be triggered when after a device is disconnected
  51147. */
  51148. readonly onAfterDeviceDisconnectedObservable: Observable<{
  51149. deviceType: DeviceType;
  51150. deviceSlot: number;
  51151. }>;
  51152. private readonly _devices;
  51153. private readonly _firstDevice;
  51154. private readonly _deviceInputSystem;
  51155. /**
  51156. * Default Constructor
  51157. * @param engine engine to pull input element from
  51158. */
  51159. constructor(engine: Engine);
  51160. /**
  51161. * Gets a DeviceSource, given a type and slot
  51162. * @param deviceType Enum specifying device type
  51163. * @param deviceSlot "Slot" or index that device is referenced in
  51164. * @returns DeviceSource object
  51165. */
  51166. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  51167. /**
  51168. * Gets an array of DeviceSource objects for a given device type
  51169. * @param deviceType Enum specifying device type
  51170. * @returns Array of DeviceSource objects
  51171. */
  51172. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  51173. /**
  51174. * Dispose of DeviceInputSystem and other parts
  51175. */
  51176. dispose(): void;
  51177. /**
  51178. * Function to add device name to device list
  51179. * @param deviceType Enum specifying device type
  51180. * @param deviceSlot "Slot" or index that device is referenced in
  51181. */
  51182. private _addDevice;
  51183. /**
  51184. * Function to remove device name to device list
  51185. * @param deviceType Enum specifying device type
  51186. * @param deviceSlot "Slot" or index that device is referenced in
  51187. */
  51188. private _removeDevice;
  51189. /**
  51190. * Updates array storing first connected device of each type
  51191. * @param type Type of Device
  51192. */
  51193. private _updateFirstDevices;
  51194. }
  51195. }
  51196. declare module BABYLON {
  51197. /**
  51198. * Options to create the null engine
  51199. */
  51200. export class NullEngineOptions {
  51201. /**
  51202. * Render width (Default: 512)
  51203. */
  51204. renderWidth: number;
  51205. /**
  51206. * Render height (Default: 256)
  51207. */
  51208. renderHeight: number;
  51209. /**
  51210. * Texture size (Default: 512)
  51211. */
  51212. textureSize: number;
  51213. /**
  51214. * If delta time between frames should be constant
  51215. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51216. */
  51217. deterministicLockstep: boolean;
  51218. /**
  51219. * Maximum about of steps between frames (Default: 4)
  51220. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51221. */
  51222. lockstepMaxSteps: number;
  51223. /**
  51224. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  51225. */
  51226. useHighPrecisionMatrix?: boolean;
  51227. }
  51228. /**
  51229. * The null engine class provides support for headless version of babylon.js.
  51230. * This can be used in server side scenario or for testing purposes
  51231. */
  51232. export class NullEngine extends Engine {
  51233. private _options;
  51234. /**
  51235. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  51236. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51237. * @returns true if engine is in deterministic lock step mode
  51238. */
  51239. isDeterministicLockStep(): boolean;
  51240. /**
  51241. * Gets the max steps when engine is running in deterministic lock step
  51242. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  51243. * @returns the max steps
  51244. */
  51245. getLockstepMaxSteps(): number;
  51246. /**
  51247. * Gets the current hardware scaling level.
  51248. * By default the hardware scaling level is computed from the window device ratio.
  51249. * 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.
  51250. * @returns a number indicating the current hardware scaling level
  51251. */
  51252. getHardwareScalingLevel(): number;
  51253. constructor(options?: NullEngineOptions);
  51254. /**
  51255. * Creates a vertex buffer
  51256. * @param vertices the data for the vertex buffer
  51257. * @returns the new WebGL static buffer
  51258. */
  51259. createVertexBuffer(vertices: FloatArray): DataBuffer;
  51260. /**
  51261. * Creates a new index buffer
  51262. * @param indices defines the content of the index buffer
  51263. * @param updatable defines if the index buffer must be updatable
  51264. * @returns a new webGL buffer
  51265. */
  51266. createIndexBuffer(indices: IndicesArray): DataBuffer;
  51267. /**
  51268. * Clear the current render buffer or the current render target (if any is set up)
  51269. * @param color defines the color to use
  51270. * @param backBuffer defines if the back buffer must be cleared
  51271. * @param depth defines if the depth buffer must be cleared
  51272. * @param stencil defines if the stencil buffer must be cleared
  51273. */
  51274. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  51275. /**
  51276. * Gets the current render width
  51277. * @param useScreen defines if screen size must be used (or the current render target if any)
  51278. * @returns a number defining the current render width
  51279. */
  51280. getRenderWidth(useScreen?: boolean): number;
  51281. /**
  51282. * Gets the current render height
  51283. * @param useScreen defines if screen size must be used (or the current render target if any)
  51284. * @returns a number defining the current render height
  51285. */
  51286. getRenderHeight(useScreen?: boolean): number;
  51287. /**
  51288. * Set the WebGL's viewport
  51289. * @param viewport defines the viewport element to be used
  51290. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  51291. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  51292. */
  51293. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  51294. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  51295. /**
  51296. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  51297. * @param pipelineContext defines the pipeline context to use
  51298. * @param uniformsNames defines the list of uniform names
  51299. * @returns an array of webGL uniform locations
  51300. */
  51301. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  51302. /**
  51303. * Gets the lsit of active attributes for a given webGL program
  51304. * @param pipelineContext defines the pipeline context to use
  51305. * @param attributesNames defines the list of attribute names to get
  51306. * @returns an array of indices indicating the offset of each attribute
  51307. */
  51308. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  51309. /**
  51310. * Binds an effect to the webGL context
  51311. * @param effect defines the effect to bind
  51312. */
  51313. bindSamplers(effect: Effect): void;
  51314. /**
  51315. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  51316. * @param effect defines the effect to activate
  51317. */
  51318. enableEffect(effect: Effect): void;
  51319. /**
  51320. * Set various states to the webGL context
  51321. * @param culling defines backface culling state
  51322. * @param zOffset defines the value to apply to zOffset (0 by default)
  51323. * @param force defines if states must be applied even if cache is up to date
  51324. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  51325. */
  51326. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  51327. /**
  51328. * Set the value of an uniform to an array of int32
  51329. * @param uniform defines the webGL uniform location where to store the value
  51330. * @param array defines the array of int32 to store
  51331. */
  51332. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  51333. /**
  51334. * Set the value of an uniform to an array of int32 (stored as vec2)
  51335. * @param uniform defines the webGL uniform location where to store the value
  51336. * @param array defines the array of int32 to store
  51337. */
  51338. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  51339. /**
  51340. * Set the value of an uniform to an array of int32 (stored as vec3)
  51341. * @param uniform defines the webGL uniform location where to store the value
  51342. * @param array defines the array of int32 to store
  51343. */
  51344. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  51345. /**
  51346. * Set the value of an uniform to an array of int32 (stored as vec4)
  51347. * @param uniform defines the webGL uniform location where to store the value
  51348. * @param array defines the array of int32 to store
  51349. */
  51350. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  51351. /**
  51352. * Set the value of an uniform to an array of float32
  51353. * @param uniform defines the webGL uniform location where to store the value
  51354. * @param array defines the array of float32 to store
  51355. */
  51356. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  51357. /**
  51358. * Set the value of an uniform to an array of float32 (stored as vec2)
  51359. * @param uniform defines the webGL uniform location where to store the value
  51360. * @param array defines the array of float32 to store
  51361. */
  51362. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  51363. /**
  51364. * Set the value of an uniform to an array of float32 (stored as vec3)
  51365. * @param uniform defines the webGL uniform location where to store the value
  51366. * @param array defines the array of float32 to store
  51367. */
  51368. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  51369. /**
  51370. * Set the value of an uniform to an array of float32 (stored as vec4)
  51371. * @param uniform defines the webGL uniform location where to store the value
  51372. * @param array defines the array of float32 to store
  51373. */
  51374. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  51375. /**
  51376. * Set the value of an uniform to an array of number
  51377. * @param uniform defines the webGL uniform location where to store the value
  51378. * @param array defines the array of number to store
  51379. */
  51380. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  51381. /**
  51382. * Set the value of an uniform to an array of number (stored as vec2)
  51383. * @param uniform defines the webGL uniform location where to store the value
  51384. * @param array defines the array of number to store
  51385. */
  51386. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  51387. /**
  51388. * Set the value of an uniform to an array of number (stored as vec3)
  51389. * @param uniform defines the webGL uniform location where to store the value
  51390. * @param array defines the array of number to store
  51391. */
  51392. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  51393. /**
  51394. * Set the value of an uniform to an array of number (stored as vec4)
  51395. * @param uniform defines the webGL uniform location where to store the value
  51396. * @param array defines the array of number to store
  51397. */
  51398. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  51399. /**
  51400. * Set the value of an uniform to an array of float32 (stored as matrices)
  51401. * @param uniform defines the webGL uniform location where to store the value
  51402. * @param matrices defines the array of float32 to store
  51403. */
  51404. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  51405. /**
  51406. * Set the value of an uniform to a matrix (3x3)
  51407. * @param uniform defines the webGL uniform location where to store the value
  51408. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  51409. */
  51410. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51411. /**
  51412. * Set the value of an uniform to a matrix (2x2)
  51413. * @param uniform defines the webGL uniform location where to store the value
  51414. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  51415. */
  51416. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  51417. /**
  51418. * Set the value of an uniform to a number (float)
  51419. * @param uniform defines the webGL uniform location where to store the value
  51420. * @param value defines the float number to store
  51421. */
  51422. setFloat(uniform: WebGLUniformLocation, value: number): void;
  51423. /**
  51424. * Set the value of an uniform to a vec2
  51425. * @param uniform defines the webGL uniform location where to store the value
  51426. * @param x defines the 1st component of the value
  51427. * @param y defines the 2nd component of the value
  51428. */
  51429. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  51430. /**
  51431. * Set the value of an uniform to a vec3
  51432. * @param uniform defines the webGL uniform location where to store the value
  51433. * @param x defines the 1st component of the value
  51434. * @param y defines the 2nd component of the value
  51435. * @param z defines the 3rd component of the value
  51436. */
  51437. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  51438. /**
  51439. * Set the value of an uniform to a boolean
  51440. * @param uniform defines the webGL uniform location where to store the value
  51441. * @param bool defines the boolean to store
  51442. */
  51443. setBool(uniform: WebGLUniformLocation, bool: number): void;
  51444. /**
  51445. * Set the value of an uniform to a vec4
  51446. * @param uniform defines the webGL uniform location where to store the value
  51447. * @param x defines the 1st component of the value
  51448. * @param y defines the 2nd component of the value
  51449. * @param z defines the 3rd component of the value
  51450. * @param w defines the 4th component of the value
  51451. */
  51452. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  51453. /**
  51454. * Sets the current alpha mode
  51455. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  51456. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  51457. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  51458. */
  51459. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  51460. /**
  51461. * Bind webGl buffers directly to the webGL context
  51462. * @param vertexBuffers defines the vertex buffer to bind
  51463. * @param indexBuffer defines the index buffer to bind
  51464. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  51465. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  51466. * @param effect defines the effect associated with the vertex buffer
  51467. */
  51468. bindBuffers(vertexBuffers: {
  51469. [key: string]: VertexBuffer;
  51470. }, indexBuffer: DataBuffer, effect: Effect): void;
  51471. /**
  51472. * Force the entire cache to be cleared
  51473. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  51474. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  51475. */
  51476. wipeCaches(bruteForce?: boolean): void;
  51477. /**
  51478. * Send a draw order
  51479. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  51480. * @param indexStart defines the starting index
  51481. * @param indexCount defines the number of index to draw
  51482. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51483. */
  51484. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  51485. /**
  51486. * Draw a list of indexed primitives
  51487. * @param fillMode defines the primitive to use
  51488. * @param indexStart defines the starting index
  51489. * @param indexCount defines the number of index to draw
  51490. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51491. */
  51492. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  51493. /**
  51494. * Draw a list of unindexed primitives
  51495. * @param fillMode defines the primitive to use
  51496. * @param verticesStart defines the index of first vertex to draw
  51497. * @param verticesCount defines the count of vertices to draw
  51498. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  51499. */
  51500. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  51501. /** @hidden */
  51502. _createTexture(): WebGLTexture;
  51503. /** @hidden */
  51504. _releaseTexture(texture: InternalTexture): void;
  51505. /**
  51506. * Usually called from Texture.ts.
  51507. * Passed information to create a WebGLTexture
  51508. * @param urlArg defines a value which contains one of the following:
  51509. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  51510. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  51511. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  51512. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  51513. * @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)
  51514. * @param scene needed for loading to the correct scene
  51515. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  51516. * @param onLoad optional callback to be called upon successful completion
  51517. * @param onError optional callback to be called upon failure
  51518. * @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
  51519. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  51520. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  51521. * @param forcedExtension defines the extension to use to pick the right loader
  51522. * @param mimeType defines an optional mime type
  51523. * @returns a InternalTexture for assignment back into BABYLON.Texture
  51524. */
  51525. 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;
  51526. /**
  51527. * Creates a new render target texture
  51528. * @param size defines the size of the texture
  51529. * @param options defines the options used to create the texture
  51530. * @returns a new render target texture stored in an InternalTexture
  51531. */
  51532. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  51533. /**
  51534. * Update the sampling mode of a given texture
  51535. * @param samplingMode defines the required sampling mode
  51536. * @param texture defines the texture to update
  51537. */
  51538. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  51539. /**
  51540. * Binds the frame buffer to the specified texture.
  51541. * @param texture The texture to render to or null for the default canvas
  51542. * @param faceIndex The face of the texture to render to in case of cube texture
  51543. * @param requiredWidth The width of the target to render to
  51544. * @param requiredHeight The height of the target to render to
  51545. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  51546. * @param lodLevel defines le lod level to bind to the frame buffer
  51547. */
  51548. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  51549. /**
  51550. * Unbind the current render target texture from the webGL context
  51551. * @param texture defines the render target texture to unbind
  51552. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  51553. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  51554. */
  51555. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  51556. /**
  51557. * Creates a dynamic vertex buffer
  51558. * @param vertices the data for the dynamic vertex buffer
  51559. * @returns the new WebGL dynamic buffer
  51560. */
  51561. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  51562. /**
  51563. * Update the content of a dynamic texture
  51564. * @param texture defines the texture to update
  51565. * @param canvas defines the canvas containing the source
  51566. * @param invertY defines if data must be stored with Y axis inverted
  51567. * @param premulAlpha defines if alpha is stored as premultiplied
  51568. * @param format defines the format of the data
  51569. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  51570. */
  51571. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  51572. /**
  51573. * Gets a boolean indicating if all created effects are ready
  51574. * @returns true if all effects are ready
  51575. */
  51576. areAllEffectsReady(): boolean;
  51577. /**
  51578. * @hidden
  51579. * Get the current error code of the webGL context
  51580. * @returns the error code
  51581. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  51582. */
  51583. getError(): number;
  51584. /** @hidden */
  51585. _getUnpackAlignement(): number;
  51586. /** @hidden */
  51587. _unpackFlipY(value: boolean): void;
  51588. /**
  51589. * Update a dynamic index buffer
  51590. * @param indexBuffer defines the target index buffer
  51591. * @param indices defines the data to update
  51592. * @param offset defines the offset in the target index buffer where update should start
  51593. */
  51594. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  51595. /**
  51596. * Updates a dynamic vertex buffer.
  51597. * @param vertexBuffer the vertex buffer to update
  51598. * @param vertices the data used to update the vertex buffer
  51599. * @param byteOffset the byte offset of the data (optional)
  51600. * @param byteLength the byte length of the data (optional)
  51601. */
  51602. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  51603. /** @hidden */
  51604. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  51605. /** @hidden */
  51606. _bindTexture(channel: number, texture: InternalTexture): void;
  51607. protected _deleteBuffer(buffer: WebGLBuffer): void;
  51608. /**
  51609. * 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
  51610. */
  51611. releaseEffects(): void;
  51612. displayLoadingUI(): void;
  51613. hideLoadingUI(): void;
  51614. /** @hidden */
  51615. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51616. /** @hidden */
  51617. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51618. /** @hidden */
  51619. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  51620. /** @hidden */
  51621. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  51622. }
  51623. }
  51624. declare module BABYLON {
  51625. /**
  51626. * @hidden
  51627. **/
  51628. export class _TimeToken {
  51629. _startTimeQuery: Nullable<WebGLQuery>;
  51630. _endTimeQuery: Nullable<WebGLQuery>;
  51631. _timeElapsedQuery: Nullable<WebGLQuery>;
  51632. _timeElapsedQueryEnded: boolean;
  51633. }
  51634. }
  51635. declare module BABYLON {
  51636. /** @hidden */
  51637. export class _OcclusionDataStorage {
  51638. /** @hidden */
  51639. occlusionInternalRetryCounter: number;
  51640. /** @hidden */
  51641. isOcclusionQueryInProgress: boolean;
  51642. /** @hidden */
  51643. isOccluded: boolean;
  51644. /** @hidden */
  51645. occlusionRetryCount: number;
  51646. /** @hidden */
  51647. occlusionType: number;
  51648. /** @hidden */
  51649. occlusionQueryAlgorithmType: number;
  51650. }
  51651. interface Engine {
  51652. /**
  51653. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  51654. * @return the new query
  51655. */
  51656. createQuery(): WebGLQuery;
  51657. /**
  51658. * Delete and release a webGL query
  51659. * @param query defines the query to delete
  51660. * @return the current engine
  51661. */
  51662. deleteQuery(query: WebGLQuery): Engine;
  51663. /**
  51664. * Check if a given query has resolved and got its value
  51665. * @param query defines the query to check
  51666. * @returns true if the query got its value
  51667. */
  51668. isQueryResultAvailable(query: WebGLQuery): boolean;
  51669. /**
  51670. * Gets the value of a given query
  51671. * @param query defines the query to check
  51672. * @returns the value of the query
  51673. */
  51674. getQueryResult(query: WebGLQuery): number;
  51675. /**
  51676. * Initiates an occlusion query
  51677. * @param algorithmType defines the algorithm to use
  51678. * @param query defines the query to use
  51679. * @returns the current engine
  51680. * @see https://doc.babylonjs.com/features/occlusionquery
  51681. */
  51682. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  51683. /**
  51684. * Ends an occlusion query
  51685. * @see https://doc.babylonjs.com/features/occlusionquery
  51686. * @param algorithmType defines the algorithm to use
  51687. * @returns the current engine
  51688. */
  51689. endOcclusionQuery(algorithmType: number): Engine;
  51690. /**
  51691. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  51692. * Please note that only one query can be issued at a time
  51693. * @returns a time token used to track the time span
  51694. */
  51695. startTimeQuery(): Nullable<_TimeToken>;
  51696. /**
  51697. * Ends a time query
  51698. * @param token defines the token used to measure the time span
  51699. * @returns the time spent (in ns)
  51700. */
  51701. endTimeQuery(token: _TimeToken): int;
  51702. /** @hidden */
  51703. _currentNonTimestampToken: Nullable<_TimeToken>;
  51704. /** @hidden */
  51705. _createTimeQuery(): WebGLQuery;
  51706. /** @hidden */
  51707. _deleteTimeQuery(query: WebGLQuery): void;
  51708. /** @hidden */
  51709. _getGlAlgorithmType(algorithmType: number): number;
  51710. /** @hidden */
  51711. _getTimeQueryResult(query: WebGLQuery): any;
  51712. /** @hidden */
  51713. _getTimeQueryAvailability(query: WebGLQuery): any;
  51714. }
  51715. interface AbstractMesh {
  51716. /**
  51717. * Backing filed
  51718. * @hidden
  51719. */
  51720. __occlusionDataStorage: _OcclusionDataStorage;
  51721. /**
  51722. * Access property
  51723. * @hidden
  51724. */
  51725. _occlusionDataStorage: _OcclusionDataStorage;
  51726. /**
  51727. * 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.
  51728. * The default value is -1 which means don't break the query and wait till the result
  51729. * @see https://doc.babylonjs.com/features/occlusionquery
  51730. */
  51731. occlusionRetryCount: number;
  51732. /**
  51733. * 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:
  51734. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  51735. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  51736. * * 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.
  51737. * @see https://doc.babylonjs.com/features/occlusionquery
  51738. */
  51739. occlusionType: number;
  51740. /**
  51741. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  51742. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  51743. * * 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.
  51744. * @see https://doc.babylonjs.com/features/occlusionquery
  51745. */
  51746. occlusionQueryAlgorithmType: number;
  51747. /**
  51748. * 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
  51749. * @see https://doc.babylonjs.com/features/occlusionquery
  51750. */
  51751. isOccluded: boolean;
  51752. /**
  51753. * Flag to check the progress status of the query
  51754. * @see https://doc.babylonjs.com/features/occlusionquery
  51755. */
  51756. isOcclusionQueryInProgress: boolean;
  51757. }
  51758. }
  51759. declare module BABYLON {
  51760. /** @hidden */
  51761. export var _forceTransformFeedbackToBundle: boolean;
  51762. interface Engine {
  51763. /**
  51764. * Creates a webGL transform feedback object
  51765. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  51766. * @returns the webGL transform feedback object
  51767. */
  51768. createTransformFeedback(): WebGLTransformFeedback;
  51769. /**
  51770. * Delete a webGL transform feedback object
  51771. * @param value defines the webGL transform feedback object to delete
  51772. */
  51773. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  51774. /**
  51775. * Bind a webGL transform feedback object to the webgl context
  51776. * @param value defines the webGL transform feedback object to bind
  51777. */
  51778. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  51779. /**
  51780. * Begins a transform feedback operation
  51781. * @param usePoints defines if points or triangles must be used
  51782. */
  51783. beginTransformFeedback(usePoints: boolean): void;
  51784. /**
  51785. * Ends a transform feedback operation
  51786. */
  51787. endTransformFeedback(): void;
  51788. /**
  51789. * Specify the varyings to use with transform feedback
  51790. * @param program defines the associated webGL program
  51791. * @param value defines the list of strings representing the varying names
  51792. */
  51793. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  51794. /**
  51795. * Bind a webGL buffer for a transform feedback operation
  51796. * @param value defines the webGL buffer to bind
  51797. */
  51798. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  51799. }
  51800. }
  51801. declare module BABYLON {
  51802. /**
  51803. * Class used to define an additional view for the engine
  51804. * @see https://doc.babylonjs.com/how_to/multi_canvases
  51805. */
  51806. export class EngineView {
  51807. /** Defines the canvas where to render the view */
  51808. target: HTMLCanvasElement;
  51809. /** Defines an optional camera used to render the view (will use active camera else) */
  51810. camera?: Camera;
  51811. }
  51812. interface Engine {
  51813. /**
  51814. * Gets or sets the HTML element to use for attaching events
  51815. */
  51816. inputElement: Nullable<HTMLElement>;
  51817. /**
  51818. * Gets the current engine view
  51819. * @see https://doc.babylonjs.com/how_to/multi_canvases
  51820. */
  51821. activeView: Nullable<EngineView>;
  51822. /** Gets or sets the list of views */
  51823. views: EngineView[];
  51824. /**
  51825. * Register a new child canvas
  51826. * @param canvas defines the canvas to register
  51827. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  51828. * @returns the associated view
  51829. */
  51830. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  51831. /**
  51832. * Remove a registered child canvas
  51833. * @param canvas defines the canvas to remove
  51834. * @returns the current engine
  51835. */
  51836. unRegisterView(canvas: HTMLCanvasElement): Engine;
  51837. }
  51838. }
  51839. declare module BABYLON {
  51840. interface Engine {
  51841. /** @hidden */
  51842. _excludedCompressedTextures: string[];
  51843. /** @hidden */
  51844. _textureFormatInUse: string;
  51845. /**
  51846. * Gets the list of texture formats supported
  51847. */
  51848. readonly texturesSupported: Array<string>;
  51849. /**
  51850. * Gets the texture format in use
  51851. */
  51852. readonly textureFormatInUse: Nullable<string>;
  51853. /**
  51854. * Set the compressed texture extensions or file names to skip.
  51855. *
  51856. * @param skippedFiles defines the list of those texture files you want to skip
  51857. * Example: [".dds", ".env", "myfile.png"]
  51858. */
  51859. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  51860. /**
  51861. * Set the compressed texture format to use, based on the formats you have, and the formats
  51862. * supported by the hardware / browser.
  51863. *
  51864. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  51865. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  51866. * to API arguments needed to compressed textures. This puts the burden on the container
  51867. * generator to house the arcane code for determining these for current & future formats.
  51868. *
  51869. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  51870. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  51871. *
  51872. * Note: The result of this call is not taken into account when a texture is base64.
  51873. *
  51874. * @param formatsAvailable defines the list of those format families you have created
  51875. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  51876. *
  51877. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  51878. * @returns The extension selected.
  51879. */
  51880. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  51881. }
  51882. }
  51883. declare module BABYLON {
  51884. /**
  51885. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  51886. */
  51887. export interface CubeMapInfo {
  51888. /**
  51889. * The pixel array for the front face.
  51890. * This is stored in format, left to right, up to down format.
  51891. */
  51892. front: Nullable<ArrayBufferView>;
  51893. /**
  51894. * The pixel array for the back face.
  51895. * This is stored in format, left to right, up to down format.
  51896. */
  51897. back: Nullable<ArrayBufferView>;
  51898. /**
  51899. * The pixel array for the left face.
  51900. * This is stored in format, left to right, up to down format.
  51901. */
  51902. left: Nullable<ArrayBufferView>;
  51903. /**
  51904. * The pixel array for the right face.
  51905. * This is stored in format, left to right, up to down format.
  51906. */
  51907. right: Nullable<ArrayBufferView>;
  51908. /**
  51909. * The pixel array for the up face.
  51910. * This is stored in format, left to right, up to down format.
  51911. */
  51912. up: Nullable<ArrayBufferView>;
  51913. /**
  51914. * The pixel array for the down face.
  51915. * This is stored in format, left to right, up to down format.
  51916. */
  51917. down: Nullable<ArrayBufferView>;
  51918. /**
  51919. * The size of the cubemap stored.
  51920. *
  51921. * Each faces will be size * size pixels.
  51922. */
  51923. size: number;
  51924. /**
  51925. * The format of the texture.
  51926. *
  51927. * RGBA, RGB.
  51928. */
  51929. format: number;
  51930. /**
  51931. * The type of the texture data.
  51932. *
  51933. * UNSIGNED_INT, FLOAT.
  51934. */
  51935. type: number;
  51936. /**
  51937. * Specifies whether the texture is in gamma space.
  51938. */
  51939. gammaSpace: boolean;
  51940. }
  51941. /**
  51942. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  51943. */
  51944. export class PanoramaToCubeMapTools {
  51945. private static FACE_LEFT;
  51946. private static FACE_RIGHT;
  51947. private static FACE_FRONT;
  51948. private static FACE_BACK;
  51949. private static FACE_DOWN;
  51950. private static FACE_UP;
  51951. /**
  51952. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  51953. *
  51954. * @param float32Array The source data.
  51955. * @param inputWidth The width of the input panorama.
  51956. * @param inputHeight The height of the input panorama.
  51957. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  51958. * @return The cubemap data
  51959. */
  51960. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  51961. private static CreateCubemapTexture;
  51962. private static CalcProjectionSpherical;
  51963. }
  51964. }
  51965. declare module BABYLON {
  51966. /**
  51967. * Helper class dealing with the extraction of spherical polynomial dataArray
  51968. * from a cube map.
  51969. */
  51970. export class CubeMapToSphericalPolynomialTools {
  51971. private static FileFaces;
  51972. /**
  51973. * Converts a texture to the according Spherical Polynomial data.
  51974. * This extracts the first 3 orders only as they are the only one used in the lighting.
  51975. *
  51976. * @param texture The texture to extract the information from.
  51977. * @return The Spherical Polynomial data.
  51978. */
  51979. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  51980. /**
  51981. * Converts a cubemap to the according Spherical Polynomial data.
  51982. * This extracts the first 3 orders only as they are the only one used in the lighting.
  51983. *
  51984. * @param cubeInfo The Cube map to extract the information from.
  51985. * @return The Spherical Polynomial data.
  51986. */
  51987. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  51988. }
  51989. }
  51990. declare module BABYLON {
  51991. interface BaseTexture {
  51992. /**
  51993. * Get the polynomial representation of the texture data.
  51994. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  51995. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  51996. */
  51997. sphericalPolynomial: Nullable<SphericalPolynomial>;
  51998. }
  51999. }
  52000. declare module BABYLON {
  52001. /** @hidden */
  52002. export var rgbdEncodePixelShader: {
  52003. name: string;
  52004. shader: string;
  52005. };
  52006. }
  52007. declare module BABYLON {
  52008. /** @hidden */
  52009. export var rgbdDecodePixelShader: {
  52010. name: string;
  52011. shader: string;
  52012. };
  52013. }
  52014. declare module BABYLON {
  52015. /**
  52016. * Raw texture data and descriptor sufficient for WebGL texture upload
  52017. */
  52018. export interface EnvironmentTextureInfo {
  52019. /**
  52020. * Version of the environment map
  52021. */
  52022. version: number;
  52023. /**
  52024. * Width of image
  52025. */
  52026. width: number;
  52027. /**
  52028. * Irradiance information stored in the file.
  52029. */
  52030. irradiance: any;
  52031. /**
  52032. * Specular information stored in the file.
  52033. */
  52034. specular: any;
  52035. }
  52036. /**
  52037. * Defines One Image in the file. It requires only the position in the file
  52038. * as well as the length.
  52039. */
  52040. interface BufferImageData {
  52041. /**
  52042. * Length of the image data.
  52043. */
  52044. length: number;
  52045. /**
  52046. * Position of the data from the null terminator delimiting the end of the JSON.
  52047. */
  52048. position: number;
  52049. }
  52050. /**
  52051. * Defines the specular data enclosed in the file.
  52052. * This corresponds to the version 1 of the data.
  52053. */
  52054. export interface EnvironmentTextureSpecularInfoV1 {
  52055. /**
  52056. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  52057. */
  52058. specularDataPosition?: number;
  52059. /**
  52060. * This contains all the images data needed to reconstruct the cubemap.
  52061. */
  52062. mipmaps: Array<BufferImageData>;
  52063. /**
  52064. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  52065. */
  52066. lodGenerationScale: number;
  52067. }
  52068. /**
  52069. * Sets of helpers addressing the serialization and deserialization of environment texture
  52070. * stored in a BabylonJS env file.
  52071. * Those files are usually stored as .env files.
  52072. */
  52073. export class EnvironmentTextureTools {
  52074. /**
  52075. * Magic number identifying the env file.
  52076. */
  52077. private static _MagicBytes;
  52078. /**
  52079. * Gets the environment info from an env file.
  52080. * @param data The array buffer containing the .env bytes.
  52081. * @returns the environment file info (the json header) if successfully parsed.
  52082. */
  52083. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  52084. /**
  52085. * Creates an environment texture from a loaded cube texture.
  52086. * @param texture defines the cube texture to convert in env file
  52087. * @return a promise containing the environment data if succesfull.
  52088. */
  52089. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  52090. /**
  52091. * Creates a JSON representation of the spherical data.
  52092. * @param texture defines the texture containing the polynomials
  52093. * @return the JSON representation of the spherical info
  52094. */
  52095. private static _CreateEnvTextureIrradiance;
  52096. /**
  52097. * Creates the ArrayBufferViews used for initializing environment texture image data.
  52098. * @param data the image data
  52099. * @param info parameters that determine what views will be created for accessing the underlying buffer
  52100. * @return the views described by info providing access to the underlying buffer
  52101. */
  52102. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  52103. /**
  52104. * Uploads the texture info contained in the env file to the GPU.
  52105. * @param texture defines the internal texture to upload to
  52106. * @param data defines the data to load
  52107. * @param info defines the texture info retrieved through the GetEnvInfo method
  52108. * @returns a promise
  52109. */
  52110. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  52111. private static _OnImageReadyAsync;
  52112. /**
  52113. * Uploads the levels of image data to the GPU.
  52114. * @param texture defines the internal texture to upload to
  52115. * @param imageData defines the array buffer views of image data [mipmap][face]
  52116. * @returns a promise
  52117. */
  52118. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  52119. /**
  52120. * Uploads spherical polynomials information to the texture.
  52121. * @param texture defines the texture we are trying to upload the information to
  52122. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  52123. */
  52124. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  52125. /** @hidden */
  52126. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52127. }
  52128. }
  52129. declare module BABYLON {
  52130. /**
  52131. * Class used to inline functions in shader code
  52132. */
  52133. export class ShaderCodeInliner {
  52134. private static readonly _RegexpFindFunctionNameAndType;
  52135. private _sourceCode;
  52136. private _functionDescr;
  52137. private _numMaxIterations;
  52138. /** Gets or sets the token used to mark the functions to inline */
  52139. inlineToken: string;
  52140. /** Gets or sets the debug mode */
  52141. debug: boolean;
  52142. /** Gets the code after the inlining process */
  52143. get code(): string;
  52144. /**
  52145. * Initializes the inliner
  52146. * @param sourceCode shader code source to inline
  52147. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  52148. */
  52149. constructor(sourceCode: string, numMaxIterations?: number);
  52150. /**
  52151. * Start the processing of the shader code
  52152. */
  52153. processCode(): void;
  52154. private _collectFunctions;
  52155. private _processInlining;
  52156. private _extractBetweenMarkers;
  52157. private _skipWhitespaces;
  52158. private _removeComments;
  52159. private _replaceFunctionCallsByCode;
  52160. private _findBackward;
  52161. private _escapeRegExp;
  52162. private _replaceNames;
  52163. }
  52164. }
  52165. declare module BABYLON {
  52166. /**
  52167. * Container for accessors for natively-stored mesh data buffers.
  52168. */
  52169. class NativeDataBuffer extends DataBuffer {
  52170. /**
  52171. * Accessor value used to identify/retrieve a natively-stored index buffer.
  52172. */
  52173. nativeIndexBuffer?: any;
  52174. /**
  52175. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  52176. */
  52177. nativeVertexBuffer?: any;
  52178. }
  52179. /** @hidden */
  52180. class NativeTexture extends InternalTexture {
  52181. getInternalTexture(): InternalTexture;
  52182. getViewCount(): number;
  52183. }
  52184. /** @hidden */
  52185. export class NativeEngine extends Engine {
  52186. private readonly _native;
  52187. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  52188. private readonly INVALID_HANDLE;
  52189. getHardwareScalingLevel(): number;
  52190. constructor();
  52191. dispose(): void;
  52192. /**
  52193. * Can be used to override the current requestAnimationFrame requester.
  52194. * @hidden
  52195. */
  52196. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  52197. /**
  52198. * Override default engine behavior.
  52199. * @param color
  52200. * @param backBuffer
  52201. * @param depth
  52202. * @param stencil
  52203. */
  52204. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  52205. /**
  52206. * Gets host document
  52207. * @returns the host document object
  52208. */
  52209. getHostDocument(): Nullable<Document>;
  52210. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  52211. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  52212. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  52213. recordVertexArrayObject(vertexBuffers: {
  52214. [key: string]: VertexBuffer;
  52215. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  52216. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  52217. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  52218. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  52219. /**
  52220. * Draw a list of indexed primitives
  52221. * @param fillMode defines the primitive to use
  52222. * @param indexStart defines the starting index
  52223. * @param indexCount defines the number of index to draw
  52224. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52225. */
  52226. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52227. /**
  52228. * Draw a list of unindexed primitives
  52229. * @param fillMode defines the primitive to use
  52230. * @param verticesStart defines the index of first vertex to draw
  52231. * @param verticesCount defines the count of vertices to draw
  52232. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52233. */
  52234. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52235. createPipelineContext(): IPipelineContext;
  52236. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  52237. /** @hidden */
  52238. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  52239. /** @hidden */
  52240. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  52241. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  52242. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  52243. protected _setProgram(program: WebGLProgram): void;
  52244. _releaseEffect(effect: Effect): void;
  52245. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  52246. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  52247. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  52248. bindSamplers(effect: Effect): void;
  52249. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  52250. getRenderWidth(useScreen?: boolean): number;
  52251. getRenderHeight(useScreen?: boolean): number;
  52252. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  52253. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52254. /**
  52255. * Set the z offset to apply to current rendering
  52256. * @param value defines the offset to apply
  52257. */
  52258. setZOffset(value: number): void;
  52259. /**
  52260. * Gets the current value of the zOffset
  52261. * @returns the current zOffset state
  52262. */
  52263. getZOffset(): number;
  52264. /**
  52265. * Enable or disable depth buffering
  52266. * @param enable defines the state to set
  52267. */
  52268. setDepthBuffer(enable: boolean): void;
  52269. /**
  52270. * Gets a boolean indicating if depth writing is enabled
  52271. * @returns the current depth writing state
  52272. */
  52273. getDepthWrite(): boolean;
  52274. /**
  52275. * Enable or disable depth writing
  52276. * @param enable defines the state to set
  52277. */
  52278. setDepthWrite(enable: boolean): void;
  52279. /**
  52280. * Enable or disable color writing
  52281. * @param enable defines the state to set
  52282. */
  52283. setColorWrite(enable: boolean): void;
  52284. /**
  52285. * Gets a boolean indicating if color writing is enabled
  52286. * @returns the current color writing state
  52287. */
  52288. getColorWrite(): boolean;
  52289. /**
  52290. * Sets alpha constants used by some alpha blending modes
  52291. * @param r defines the red component
  52292. * @param g defines the green component
  52293. * @param b defines the blue component
  52294. * @param a defines the alpha component
  52295. */
  52296. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  52297. /**
  52298. * Sets the current alpha mode
  52299. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  52300. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  52301. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52302. */
  52303. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  52304. /**
  52305. * Gets the current alpha mode
  52306. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52307. * @returns the current alpha mode
  52308. */
  52309. getAlphaMode(): number;
  52310. setInt(uniform: WebGLUniformLocation, int: number): void;
  52311. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  52312. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  52313. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  52314. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  52315. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  52316. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  52317. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  52318. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  52319. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  52320. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  52321. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  52322. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  52323. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  52324. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52325. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52326. setFloat(uniform: WebGLUniformLocation, value: number): void;
  52327. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  52328. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  52329. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  52330. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  52331. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  52332. wipeCaches(bruteForce?: boolean): void;
  52333. _createTexture(): WebGLTexture;
  52334. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  52335. /**
  52336. * Usually called from Texture.ts.
  52337. * Passed information to create a WebGLTexture
  52338. * @param url defines a value which contains one of the following:
  52339. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  52340. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  52341. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  52342. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  52343. * @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)
  52344. * @param scene needed for loading to the correct scene
  52345. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  52346. * @param onLoad optional callback to be called upon successful completion
  52347. * @param onError optional callback to be called upon failure
  52348. * @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
  52349. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  52350. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  52351. * @param forcedExtension defines the extension to use to pick the right loader
  52352. * @param mimeType defines an optional mime type
  52353. * @returns a InternalTexture for assignment back into BABYLON.Texture
  52354. */
  52355. 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;
  52356. /**
  52357. * Creates a cube texture
  52358. * @param rootUrl defines the url where the files to load is located
  52359. * @param scene defines the current scene
  52360. * @param files defines the list of files to load (1 per face)
  52361. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  52362. * @param onLoad defines an optional callback raised when the texture is loaded
  52363. * @param onError defines an optional callback raised if there is an issue to load the texture
  52364. * @param format defines the format of the data
  52365. * @param forcedExtension defines the extension to use to pick the right loader
  52366. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  52367. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52368. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52369. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  52370. * @returns the cube texture as an InternalTexture
  52371. */
  52372. 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;
  52373. private _getSamplingFilter;
  52374. private static _GetNativeTextureFormat;
  52375. createRenderTargetTexture(size: number | {
  52376. width: number;
  52377. height: number;
  52378. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  52379. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  52380. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  52381. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  52382. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  52383. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  52384. /**
  52385. * Updates a dynamic vertex buffer.
  52386. * @param vertexBuffer the vertex buffer to update
  52387. * @param data the data used to update the vertex buffer
  52388. * @param byteOffset the byte offset of the data (optional)
  52389. * @param byteLength the byte length of the data (optional)
  52390. */
  52391. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  52392. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  52393. private _updateAnisotropicLevel;
  52394. private _getAddressMode;
  52395. /** @hidden */
  52396. _bindTexture(channel: number, texture: InternalTexture): void;
  52397. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  52398. releaseEffects(): void;
  52399. /** @hidden */
  52400. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52401. /** @hidden */
  52402. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52403. /** @hidden */
  52404. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52405. /** @hidden */
  52406. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  52407. }
  52408. }
  52409. declare module BABYLON {
  52410. /**
  52411. * Gather the list of clipboard event types as constants.
  52412. */
  52413. export class ClipboardEventTypes {
  52414. /**
  52415. * The clipboard event is fired when a copy command is active (pressed).
  52416. */
  52417. static readonly COPY: number;
  52418. /**
  52419. * The clipboard event is fired when a cut command is active (pressed).
  52420. */
  52421. static readonly CUT: number;
  52422. /**
  52423. * The clipboard event is fired when a paste command is active (pressed).
  52424. */
  52425. static readonly PASTE: number;
  52426. }
  52427. /**
  52428. * This class is used to store clipboard related info for the onClipboardObservable event.
  52429. */
  52430. export class ClipboardInfo {
  52431. /**
  52432. * Defines the type of event (BABYLON.ClipboardEventTypes)
  52433. */
  52434. type: number;
  52435. /**
  52436. * Defines the related dom event
  52437. */
  52438. event: ClipboardEvent;
  52439. /**
  52440. *Creates an instance of ClipboardInfo.
  52441. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  52442. * @param event Defines the related dom event
  52443. */
  52444. constructor(
  52445. /**
  52446. * Defines the type of event (BABYLON.ClipboardEventTypes)
  52447. */
  52448. type: number,
  52449. /**
  52450. * Defines the related dom event
  52451. */
  52452. event: ClipboardEvent);
  52453. /**
  52454. * Get the clipboard event's type from the keycode.
  52455. * @param keyCode Defines the keyCode for the current keyboard event.
  52456. * @return {number}
  52457. */
  52458. static GetTypeFromCharacter(keyCode: number): number;
  52459. }
  52460. }
  52461. declare module BABYLON {
  52462. /**
  52463. * Google Daydream controller
  52464. */
  52465. export class DaydreamController extends WebVRController {
  52466. /**
  52467. * Base Url for the controller model.
  52468. */
  52469. static MODEL_BASE_URL: string;
  52470. /**
  52471. * File name for the controller model.
  52472. */
  52473. static MODEL_FILENAME: string;
  52474. /**
  52475. * Gamepad Id prefix used to identify Daydream Controller.
  52476. */
  52477. static readonly GAMEPAD_ID_PREFIX: string;
  52478. /**
  52479. * Creates a new DaydreamController from a gamepad
  52480. * @param vrGamepad the gamepad that the controller should be created from
  52481. */
  52482. constructor(vrGamepad: any);
  52483. /**
  52484. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52485. * @param scene scene in which to add meshes
  52486. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52487. */
  52488. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52489. /**
  52490. * Called once for each button that changed state since the last frame
  52491. * @param buttonIdx Which button index changed
  52492. * @param state New state of the button
  52493. * @param changes Which properties on the state changed since last frame
  52494. */
  52495. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52496. }
  52497. }
  52498. declare module BABYLON {
  52499. /**
  52500. * Gear VR Controller
  52501. */
  52502. export class GearVRController extends WebVRController {
  52503. /**
  52504. * Base Url for the controller model.
  52505. */
  52506. static MODEL_BASE_URL: string;
  52507. /**
  52508. * File name for the controller model.
  52509. */
  52510. static MODEL_FILENAME: string;
  52511. /**
  52512. * Gamepad Id prefix used to identify this controller.
  52513. */
  52514. static readonly GAMEPAD_ID_PREFIX: string;
  52515. private readonly _buttonIndexToObservableNameMap;
  52516. /**
  52517. * Creates a new GearVRController from a gamepad
  52518. * @param vrGamepad the gamepad that the controller should be created from
  52519. */
  52520. constructor(vrGamepad: any);
  52521. /**
  52522. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52523. * @param scene scene in which to add meshes
  52524. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52525. */
  52526. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52527. /**
  52528. * Called once for each button that changed state since the last frame
  52529. * @param buttonIdx Which button index changed
  52530. * @param state New state of the button
  52531. * @param changes Which properties on the state changed since last frame
  52532. */
  52533. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52534. }
  52535. }
  52536. declare module BABYLON {
  52537. /**
  52538. * Generic Controller
  52539. */
  52540. export class GenericController extends WebVRController {
  52541. /**
  52542. * Base Url for the controller model.
  52543. */
  52544. static readonly MODEL_BASE_URL: string;
  52545. /**
  52546. * File name for the controller model.
  52547. */
  52548. static readonly MODEL_FILENAME: string;
  52549. /**
  52550. * Creates a new GenericController from a gamepad
  52551. * @param vrGamepad the gamepad that the controller should be created from
  52552. */
  52553. constructor(vrGamepad: any);
  52554. /**
  52555. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52556. * @param scene scene in which to add meshes
  52557. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52558. */
  52559. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52560. /**
  52561. * Called once for each button that changed state since the last frame
  52562. * @param buttonIdx Which button index changed
  52563. * @param state New state of the button
  52564. * @param changes Which properties on the state changed since last frame
  52565. */
  52566. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52567. }
  52568. }
  52569. declare module BABYLON {
  52570. /**
  52571. * Oculus Touch Controller
  52572. */
  52573. export class OculusTouchController extends WebVRController {
  52574. /**
  52575. * Base Url for the controller model.
  52576. */
  52577. static MODEL_BASE_URL: string;
  52578. /**
  52579. * File name for the left controller model.
  52580. */
  52581. static MODEL_LEFT_FILENAME: string;
  52582. /**
  52583. * File name for the right controller model.
  52584. */
  52585. static MODEL_RIGHT_FILENAME: string;
  52586. /**
  52587. * Base Url for the Quest controller model.
  52588. */
  52589. static QUEST_MODEL_BASE_URL: string;
  52590. /**
  52591. * @hidden
  52592. * If the controllers are running on a device that needs the updated Quest controller models
  52593. */
  52594. static _IsQuest: boolean;
  52595. /**
  52596. * Fired when the secondary trigger on this controller is modified
  52597. */
  52598. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  52599. /**
  52600. * Fired when the thumb rest on this controller is modified
  52601. */
  52602. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  52603. /**
  52604. * Creates a new OculusTouchController from a gamepad
  52605. * @param vrGamepad the gamepad that the controller should be created from
  52606. */
  52607. constructor(vrGamepad: any);
  52608. /**
  52609. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52610. * @param scene scene in which to add meshes
  52611. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52612. */
  52613. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52614. /**
  52615. * Fired when the A button on this controller is modified
  52616. */
  52617. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52618. /**
  52619. * Fired when the B button on this controller is modified
  52620. */
  52621. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52622. /**
  52623. * Fired when the X button on this controller is modified
  52624. */
  52625. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52626. /**
  52627. * Fired when the Y button on this controller is modified
  52628. */
  52629. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52630. /**
  52631. * Called once for each button that changed state since the last frame
  52632. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  52633. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  52634. * 2) secondary trigger (same)
  52635. * 3) A (right) X (left), touch, pressed = value
  52636. * 4) B / Y
  52637. * 5) thumb rest
  52638. * @param buttonIdx Which button index changed
  52639. * @param state New state of the button
  52640. * @param changes Which properties on the state changed since last frame
  52641. */
  52642. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52643. }
  52644. }
  52645. declare module BABYLON {
  52646. /**
  52647. * Vive Controller
  52648. */
  52649. export class ViveController extends WebVRController {
  52650. /**
  52651. * Base Url for the controller model.
  52652. */
  52653. static MODEL_BASE_URL: string;
  52654. /**
  52655. * File name for the controller model.
  52656. */
  52657. static MODEL_FILENAME: string;
  52658. /**
  52659. * Creates a new ViveController from a gamepad
  52660. * @param vrGamepad the gamepad that the controller should be created from
  52661. */
  52662. constructor(vrGamepad: any);
  52663. /**
  52664. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52665. * @param scene scene in which to add meshes
  52666. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52667. */
  52668. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  52669. /**
  52670. * Fired when the left button on this controller is modified
  52671. */
  52672. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52673. /**
  52674. * Fired when the right button on this controller is modified
  52675. */
  52676. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52677. /**
  52678. * Fired when the menu button on this controller is modified
  52679. */
  52680. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52681. /**
  52682. * Called once for each button that changed state since the last frame
  52683. * Vive mapping:
  52684. * 0: touchpad
  52685. * 1: trigger
  52686. * 2: left AND right buttons
  52687. * 3: menu button
  52688. * @param buttonIdx Which button index changed
  52689. * @param state New state of the button
  52690. * @param changes Which properties on the state changed since last frame
  52691. */
  52692. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52693. }
  52694. }
  52695. declare module BABYLON {
  52696. /**
  52697. * Defines the WindowsMotionController object that the state of the windows motion controller
  52698. */
  52699. export class WindowsMotionController extends WebVRController {
  52700. /**
  52701. * The base url used to load the left and right controller models
  52702. */
  52703. static MODEL_BASE_URL: string;
  52704. /**
  52705. * The name of the left controller model file
  52706. */
  52707. static MODEL_LEFT_FILENAME: string;
  52708. /**
  52709. * The name of the right controller model file
  52710. */
  52711. static MODEL_RIGHT_FILENAME: string;
  52712. /**
  52713. * The controller name prefix for this controller type
  52714. */
  52715. static readonly GAMEPAD_ID_PREFIX: string;
  52716. /**
  52717. * The controller id pattern for this controller type
  52718. */
  52719. private static readonly GAMEPAD_ID_PATTERN;
  52720. private _loadedMeshInfo;
  52721. protected readonly _mapping: {
  52722. buttons: string[];
  52723. buttonMeshNames: {
  52724. trigger: string;
  52725. menu: string;
  52726. grip: string;
  52727. thumbstick: string;
  52728. trackpad: string;
  52729. };
  52730. buttonObservableNames: {
  52731. trigger: string;
  52732. menu: string;
  52733. grip: string;
  52734. thumbstick: string;
  52735. trackpad: string;
  52736. };
  52737. axisMeshNames: string[];
  52738. pointingPoseMeshName: string;
  52739. };
  52740. /**
  52741. * Fired when the trackpad on this controller is clicked
  52742. */
  52743. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  52744. /**
  52745. * Fired when the trackpad on this controller is modified
  52746. */
  52747. onTrackpadValuesChangedObservable: Observable<StickValues>;
  52748. /**
  52749. * The current x and y values of this controller's trackpad
  52750. */
  52751. trackpad: StickValues;
  52752. /**
  52753. * Creates a new WindowsMotionController from a gamepad
  52754. * @param vrGamepad the gamepad that the controller should be created from
  52755. */
  52756. constructor(vrGamepad: any);
  52757. /**
  52758. * Fired when the trigger on this controller is modified
  52759. */
  52760. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52761. /**
  52762. * Fired when the menu button on this controller is modified
  52763. */
  52764. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52765. /**
  52766. * Fired when the grip button on this controller is modified
  52767. */
  52768. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52769. /**
  52770. * Fired when the thumbstick button on this controller is modified
  52771. */
  52772. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52773. /**
  52774. * Fired when the touchpad button on this controller is modified
  52775. */
  52776. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52777. /**
  52778. * Fired when the touchpad values on this controller are modified
  52779. */
  52780. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  52781. protected _updateTrackpad(): void;
  52782. /**
  52783. * Called once per frame by the engine.
  52784. */
  52785. update(): void;
  52786. /**
  52787. * Called once for each button that changed state since the last frame
  52788. * @param buttonIdx Which button index changed
  52789. * @param state New state of the button
  52790. * @param changes Which properties on the state changed since last frame
  52791. */
  52792. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  52793. /**
  52794. * Moves the buttons on the controller mesh based on their current state
  52795. * @param buttonName the name of the button to move
  52796. * @param buttonValue the value of the button which determines the buttons new position
  52797. */
  52798. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  52799. /**
  52800. * Moves the axis on the controller mesh based on its current state
  52801. * @param axis the index of the axis
  52802. * @param axisValue the value of the axis which determines the meshes new position
  52803. * @hidden
  52804. */
  52805. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  52806. /**
  52807. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  52808. * @param scene scene in which to add meshes
  52809. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  52810. */
  52811. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  52812. /**
  52813. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  52814. * can be transformed by button presses and axes values, based on this._mapping.
  52815. *
  52816. * @param scene scene in which the meshes exist
  52817. * @param meshes list of meshes that make up the controller model to process
  52818. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  52819. */
  52820. private processModel;
  52821. private createMeshInfo;
  52822. /**
  52823. * Gets the ray of the controller in the direction the controller is pointing
  52824. * @param length the length the resulting ray should be
  52825. * @returns a ray in the direction the controller is pointing
  52826. */
  52827. getForwardRay(length?: number): Ray;
  52828. /**
  52829. * Disposes of the controller
  52830. */
  52831. dispose(): void;
  52832. }
  52833. /**
  52834. * This class represents a new windows motion controller in XR.
  52835. */
  52836. export class XRWindowsMotionController extends WindowsMotionController {
  52837. /**
  52838. * Changing the original WIndowsMotionController mapping to fir the new mapping
  52839. */
  52840. protected readonly _mapping: {
  52841. buttons: string[];
  52842. buttonMeshNames: {
  52843. trigger: string;
  52844. menu: string;
  52845. grip: string;
  52846. thumbstick: string;
  52847. trackpad: string;
  52848. };
  52849. buttonObservableNames: {
  52850. trigger: string;
  52851. menu: string;
  52852. grip: string;
  52853. thumbstick: string;
  52854. trackpad: string;
  52855. };
  52856. axisMeshNames: string[];
  52857. pointingPoseMeshName: string;
  52858. };
  52859. /**
  52860. * Construct a new XR-Based windows motion controller
  52861. *
  52862. * @param gamepadInfo the gamepad object from the browser
  52863. */
  52864. constructor(gamepadInfo: any);
  52865. /**
  52866. * holds the thumbstick values (X,Y)
  52867. */
  52868. thumbstickValues: StickValues;
  52869. /**
  52870. * Fired when the thumbstick on this controller is clicked
  52871. */
  52872. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  52873. /**
  52874. * Fired when the thumbstick on this controller is modified
  52875. */
  52876. onThumbstickValuesChangedObservable: Observable<StickValues>;
  52877. /**
  52878. * Fired when the touchpad button on this controller is modified
  52879. */
  52880. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  52881. /**
  52882. * Fired when the touchpad values on this controller are modified
  52883. */
  52884. onTrackpadValuesChangedObservable: Observable<StickValues>;
  52885. /**
  52886. * Fired when the thumbstick button on this controller is modified
  52887. * here to prevent breaking changes
  52888. */
  52889. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  52890. /**
  52891. * updating the thumbstick(!) and not the trackpad.
  52892. * This is named this way due to the difference between WebVR and XR and to avoid
  52893. * changing the parent class.
  52894. */
  52895. protected _updateTrackpad(): void;
  52896. /**
  52897. * Disposes the class with joy
  52898. */
  52899. dispose(): void;
  52900. }
  52901. }
  52902. declare module BABYLON {
  52903. /**
  52904. * Class containing static functions to help procedurally build meshes
  52905. */
  52906. export class PolyhedronBuilder {
  52907. /**
  52908. * Creates a polyhedron mesh
  52909. * * 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
  52910. * * The parameter `size` (positive float, default 1) sets the polygon size
  52911. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  52912. * * 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`
  52913. * * 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
  52914. * * 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)`)
  52915. * * 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
  52916. * * 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
  52917. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52918. * * 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
  52919. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52920. * @param name defines the name of the mesh
  52921. * @param options defines the options used to create the mesh
  52922. * @param scene defines the hosting scene
  52923. * @returns the polyhedron mesh
  52924. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  52925. */
  52926. static CreatePolyhedron(name: string, options: {
  52927. type?: number;
  52928. size?: number;
  52929. sizeX?: number;
  52930. sizeY?: number;
  52931. sizeZ?: number;
  52932. custom?: any;
  52933. faceUV?: Vector4[];
  52934. faceColors?: Color4[];
  52935. flat?: boolean;
  52936. updatable?: boolean;
  52937. sideOrientation?: number;
  52938. frontUVs?: Vector4;
  52939. backUVs?: Vector4;
  52940. }, scene?: Nullable<Scene>): Mesh;
  52941. }
  52942. }
  52943. declare module BABYLON {
  52944. /**
  52945. * Gizmo that enables scaling a mesh along 3 axis
  52946. */
  52947. export class ScaleGizmo extends Gizmo {
  52948. /**
  52949. * Internal gizmo used for interactions on the x axis
  52950. */
  52951. xGizmo: AxisScaleGizmo;
  52952. /**
  52953. * Internal gizmo used for interactions on the y axis
  52954. */
  52955. yGizmo: AxisScaleGizmo;
  52956. /**
  52957. * Internal gizmo used for interactions on the z axis
  52958. */
  52959. zGizmo: AxisScaleGizmo;
  52960. /**
  52961. * Internal gizmo used to scale all axis equally
  52962. */
  52963. uniformScaleGizmo: AxisScaleGizmo;
  52964. private _meshAttached;
  52965. private _nodeAttached;
  52966. private _updateGizmoRotationToMatchAttachedMesh;
  52967. private _snapDistance;
  52968. private _scaleRatio;
  52969. private _uniformScalingMesh;
  52970. private _octahedron;
  52971. private _sensitivity;
  52972. /** Fires an event when any of it's sub gizmos are dragged */
  52973. onDragStartObservable: Observable<unknown>;
  52974. /** Fires an event when any of it's sub gizmos are released from dragging */
  52975. onDragEndObservable: Observable<unknown>;
  52976. get attachedMesh(): Nullable<AbstractMesh>;
  52977. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52978. get attachedNode(): Nullable<Node>;
  52979. set attachedNode(node: Nullable<Node>);
  52980. /**
  52981. * Creates a ScaleGizmo
  52982. * @param gizmoLayer The utility layer the gizmo will be added to
  52983. * @param thickness display gizmo axis thickness
  52984. */
  52985. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  52986. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52987. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52988. /**
  52989. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52990. */
  52991. set snapDistance(value: number);
  52992. get snapDistance(): number;
  52993. /**
  52994. * Ratio for the scale of the gizmo (Default: 1)
  52995. */
  52996. set scaleRatio(value: number);
  52997. get scaleRatio(): number;
  52998. /**
  52999. * Sensitivity factor for dragging (Default: 1)
  53000. */
  53001. set sensitivity(value: number);
  53002. get sensitivity(): number;
  53003. /**
  53004. * Disposes of the gizmo
  53005. */
  53006. dispose(): void;
  53007. }
  53008. }
  53009. declare module BABYLON {
  53010. /**
  53011. * Single axis scale gizmo
  53012. */
  53013. export class AxisScaleGizmo extends Gizmo {
  53014. /**
  53015. * Drag behavior responsible for the gizmos dragging interactions
  53016. */
  53017. dragBehavior: PointerDragBehavior;
  53018. private _pointerObserver;
  53019. /**
  53020. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53021. */
  53022. snapDistance: number;
  53023. /**
  53024. * Event that fires each time the gizmo snaps to a new location.
  53025. * * snapDistance is the the change in distance
  53026. */
  53027. onSnapObservable: Observable<{
  53028. snapDistance: number;
  53029. }>;
  53030. /**
  53031. * If the scaling operation should be done on all axis (default: false)
  53032. */
  53033. uniformScaling: boolean;
  53034. /**
  53035. * Custom sensitivity value for the drag strength
  53036. */
  53037. sensitivity: number;
  53038. private _isEnabled;
  53039. private _parent;
  53040. private _arrow;
  53041. private _coloredMaterial;
  53042. private _hoverMaterial;
  53043. /**
  53044. * Creates an AxisScaleGizmo
  53045. * @param gizmoLayer The utility layer the gizmo will be added to
  53046. * @param dragAxis The axis which the gizmo will be able to scale on
  53047. * @param color The color of the gizmo
  53048. * @param thickness display gizmo axis thickness
  53049. */
  53050. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  53051. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53052. /**
  53053. * If the gizmo is enabled
  53054. */
  53055. set isEnabled(value: boolean);
  53056. get isEnabled(): boolean;
  53057. /**
  53058. * Disposes of the gizmo
  53059. */
  53060. dispose(): void;
  53061. /**
  53062. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  53063. * @param mesh The mesh to replace the default mesh of the gizmo
  53064. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  53065. */
  53066. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  53067. }
  53068. }
  53069. declare module BABYLON {
  53070. /**
  53071. * Bounding box gizmo
  53072. */
  53073. export class BoundingBoxGizmo extends Gizmo {
  53074. private _lineBoundingBox;
  53075. private _rotateSpheresParent;
  53076. private _scaleBoxesParent;
  53077. private _boundingDimensions;
  53078. private _renderObserver;
  53079. private _pointerObserver;
  53080. private _scaleDragSpeed;
  53081. private _tmpQuaternion;
  53082. private _tmpVector;
  53083. private _tmpRotationMatrix;
  53084. /**
  53085. * 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)
  53086. */
  53087. ignoreChildren: boolean;
  53088. /**
  53089. * 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)
  53090. */
  53091. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  53092. /**
  53093. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  53094. */
  53095. rotationSphereSize: number;
  53096. /**
  53097. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  53098. */
  53099. scaleBoxSize: number;
  53100. /**
  53101. * 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)
  53102. */
  53103. fixedDragMeshScreenSize: boolean;
  53104. /**
  53105. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  53106. */
  53107. fixedDragMeshScreenSizeDistanceFactor: number;
  53108. /**
  53109. * Fired when a rotation sphere or scale box is dragged
  53110. */
  53111. onDragStartObservable: Observable<{}>;
  53112. /**
  53113. * Fired when a scale box is dragged
  53114. */
  53115. onScaleBoxDragObservable: Observable<{}>;
  53116. /**
  53117. * Fired when a scale box drag is ended
  53118. */
  53119. onScaleBoxDragEndObservable: Observable<{}>;
  53120. /**
  53121. * Fired when a rotation sphere is dragged
  53122. */
  53123. onRotationSphereDragObservable: Observable<{}>;
  53124. /**
  53125. * Fired when a rotation sphere drag is ended
  53126. */
  53127. onRotationSphereDragEndObservable: Observable<{}>;
  53128. /**
  53129. * 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)
  53130. */
  53131. scalePivot: Nullable<Vector3>;
  53132. /**
  53133. * Mesh used as a pivot to rotate the attached node
  53134. */
  53135. private _anchorMesh;
  53136. private _existingMeshScale;
  53137. private _dragMesh;
  53138. private pointerDragBehavior;
  53139. private coloredMaterial;
  53140. private hoverColoredMaterial;
  53141. /**
  53142. * Sets the color of the bounding box gizmo
  53143. * @param color the color to set
  53144. */
  53145. setColor(color: Color3): void;
  53146. /**
  53147. * Creates an BoundingBoxGizmo
  53148. * @param gizmoLayer The utility layer the gizmo will be added to
  53149. * @param color The color of the gizmo
  53150. */
  53151. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  53152. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  53153. private _selectNode;
  53154. /**
  53155. * Updates the bounding box information for the Gizmo
  53156. */
  53157. updateBoundingBox(): void;
  53158. private _updateRotationSpheres;
  53159. private _updateScaleBoxes;
  53160. /**
  53161. * Enables rotation on the specified axis and disables rotation on the others
  53162. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  53163. */
  53164. setEnabledRotationAxis(axis: string): void;
  53165. /**
  53166. * Enables/disables scaling
  53167. * @param enable if scaling should be enabled
  53168. * @param homogeneousScaling defines if scaling should only be homogeneous
  53169. */
  53170. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  53171. private _updateDummy;
  53172. /**
  53173. * Enables a pointer drag behavior on the bounding box of the gizmo
  53174. */
  53175. enableDragBehavior(): void;
  53176. /**
  53177. * Disposes of the gizmo
  53178. */
  53179. dispose(): void;
  53180. /**
  53181. * 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)
  53182. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  53183. * @returns the bounding box mesh with the passed in mesh as a child
  53184. */
  53185. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  53186. /**
  53187. * CustomMeshes are not supported by this gizmo
  53188. * @param mesh The mesh to replace the default mesh of the gizmo
  53189. */
  53190. setCustomMesh(mesh: Mesh): void;
  53191. }
  53192. }
  53193. declare module BABYLON {
  53194. /**
  53195. * Single plane rotation gizmo
  53196. */
  53197. export class PlaneRotationGizmo extends Gizmo {
  53198. /**
  53199. * Drag behavior responsible for the gizmos dragging interactions
  53200. */
  53201. dragBehavior: PointerDragBehavior;
  53202. private _pointerObserver;
  53203. /**
  53204. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  53205. */
  53206. snapDistance: number;
  53207. /**
  53208. * Event that fires each time the gizmo snaps to a new location.
  53209. * * snapDistance is the the change in distance
  53210. */
  53211. onSnapObservable: Observable<{
  53212. snapDistance: number;
  53213. }>;
  53214. private _isEnabled;
  53215. private _parent;
  53216. /**
  53217. * Creates a PlaneRotationGizmo
  53218. * @param gizmoLayer The utility layer the gizmo will be added to
  53219. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  53220. * @param color The color of the gizmo
  53221. * @param tessellation Amount of tessellation to be used when creating rotation circles
  53222. * @param useEulerRotation Use and update Euler angle instead of quaternion
  53223. * @param thickness display gizmo axis thickness
  53224. */
  53225. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  53226. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53227. /**
  53228. * If the gizmo is enabled
  53229. */
  53230. set isEnabled(value: boolean);
  53231. get isEnabled(): boolean;
  53232. /**
  53233. * Disposes of the gizmo
  53234. */
  53235. dispose(): void;
  53236. }
  53237. }
  53238. declare module BABYLON {
  53239. /**
  53240. * Gizmo that enables rotating a mesh along 3 axis
  53241. */
  53242. export class RotationGizmo extends Gizmo {
  53243. /**
  53244. * Internal gizmo used for interactions on the x axis
  53245. */
  53246. xGizmo: PlaneRotationGizmo;
  53247. /**
  53248. * Internal gizmo used for interactions on the y axis
  53249. */
  53250. yGizmo: PlaneRotationGizmo;
  53251. /**
  53252. * Internal gizmo used for interactions on the z axis
  53253. */
  53254. zGizmo: PlaneRotationGizmo;
  53255. /** Fires an event when any of it's sub gizmos are dragged */
  53256. onDragStartObservable: Observable<unknown>;
  53257. /** Fires an event when any of it's sub gizmos are released from dragging */
  53258. onDragEndObservable: Observable<unknown>;
  53259. private _meshAttached;
  53260. private _nodeAttached;
  53261. get attachedMesh(): Nullable<AbstractMesh>;
  53262. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53263. get attachedNode(): Nullable<Node>;
  53264. set attachedNode(node: Nullable<Node>);
  53265. /**
  53266. * Creates a RotationGizmo
  53267. * @param gizmoLayer The utility layer the gizmo will be added to
  53268. * @param tessellation Amount of tessellation to be used when creating rotation circles
  53269. * @param useEulerRotation Use and update Euler angle instead of quaternion
  53270. * @param thickness display gizmo axis thickness
  53271. */
  53272. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  53273. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53274. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53275. /**
  53276. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53277. */
  53278. set snapDistance(value: number);
  53279. get snapDistance(): number;
  53280. /**
  53281. * Ratio for the scale of the gizmo (Default: 1)
  53282. */
  53283. set scaleRatio(value: number);
  53284. get scaleRatio(): number;
  53285. /**
  53286. * Disposes of the gizmo
  53287. */
  53288. dispose(): void;
  53289. /**
  53290. * CustomMeshes are not supported by this gizmo
  53291. * @param mesh The mesh to replace the default mesh of the gizmo
  53292. */
  53293. setCustomMesh(mesh: Mesh): void;
  53294. }
  53295. }
  53296. declare module BABYLON {
  53297. /**
  53298. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  53299. */
  53300. export class GizmoManager implements IDisposable {
  53301. private scene;
  53302. /**
  53303. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  53304. */
  53305. gizmos: {
  53306. positionGizmo: Nullable<PositionGizmo>;
  53307. rotationGizmo: Nullable<RotationGizmo>;
  53308. scaleGizmo: Nullable<ScaleGizmo>;
  53309. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  53310. };
  53311. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  53312. clearGizmoOnEmptyPointerEvent: boolean;
  53313. /** Fires an event when the manager is attached to a mesh */
  53314. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  53315. private _gizmosEnabled;
  53316. private _pointerObserver;
  53317. private _attachedMesh;
  53318. private _boundingBoxColor;
  53319. private _defaultUtilityLayer;
  53320. private _defaultKeepDepthUtilityLayer;
  53321. private _thickness;
  53322. /**
  53323. * When bounding box gizmo is enabled, this can be used to track drag/end events
  53324. */
  53325. boundingBoxDragBehavior: SixDofDragBehavior;
  53326. /**
  53327. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  53328. */
  53329. attachableMeshes: Nullable<Array<AbstractMesh>>;
  53330. /**
  53331. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  53332. */
  53333. usePointerToAttachGizmos: boolean;
  53334. /**
  53335. * Utility layer that the bounding box gizmo belongs to
  53336. */
  53337. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  53338. /**
  53339. * Utility layer that all gizmos besides bounding box belong to
  53340. */
  53341. get utilityLayer(): UtilityLayerRenderer;
  53342. /**
  53343. * Instatiates a gizmo manager
  53344. * @param scene the scene to overlay the gizmos on top of
  53345. * @param thickness display gizmo axis thickness
  53346. */
  53347. constructor(scene: Scene, thickness?: number);
  53348. /**
  53349. * Attaches a set of gizmos to the specified mesh
  53350. * @param mesh The mesh the gizmo's should be attached to
  53351. */
  53352. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53353. /**
  53354. * If the position gizmo is enabled
  53355. */
  53356. set positionGizmoEnabled(value: boolean);
  53357. get positionGizmoEnabled(): boolean;
  53358. /**
  53359. * If the rotation gizmo is enabled
  53360. */
  53361. set rotationGizmoEnabled(value: boolean);
  53362. get rotationGizmoEnabled(): boolean;
  53363. /**
  53364. * If the scale gizmo is enabled
  53365. */
  53366. set scaleGizmoEnabled(value: boolean);
  53367. get scaleGizmoEnabled(): boolean;
  53368. /**
  53369. * If the boundingBox gizmo is enabled
  53370. */
  53371. set boundingBoxGizmoEnabled(value: boolean);
  53372. get boundingBoxGizmoEnabled(): boolean;
  53373. /**
  53374. * Disposes of the gizmo manager
  53375. */
  53376. dispose(): void;
  53377. }
  53378. }
  53379. declare module BABYLON {
  53380. /**
  53381. * A directional light is defined by a direction (what a surprise!).
  53382. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  53383. * 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.
  53384. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53385. */
  53386. export class DirectionalLight extends ShadowLight {
  53387. private _shadowFrustumSize;
  53388. /**
  53389. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  53390. */
  53391. get shadowFrustumSize(): number;
  53392. /**
  53393. * Specifies a fix frustum size for the shadow generation.
  53394. */
  53395. set shadowFrustumSize(value: number);
  53396. private _shadowOrthoScale;
  53397. /**
  53398. * Gets the shadow projection scale against the optimal computed one.
  53399. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  53400. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  53401. */
  53402. get shadowOrthoScale(): number;
  53403. /**
  53404. * Sets the shadow projection scale against the optimal computed one.
  53405. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  53406. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  53407. */
  53408. set shadowOrthoScale(value: number);
  53409. /**
  53410. * Automatically compute the projection matrix to best fit (including all the casters)
  53411. * on each frame.
  53412. */
  53413. autoUpdateExtends: boolean;
  53414. /**
  53415. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  53416. * on each frame. autoUpdateExtends must be set to true for this to work
  53417. */
  53418. autoCalcShadowZBounds: boolean;
  53419. private _orthoLeft;
  53420. private _orthoRight;
  53421. private _orthoTop;
  53422. private _orthoBottom;
  53423. /**
  53424. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  53425. * The directional light is emitted from everywhere in the given direction.
  53426. * It can cast shadows.
  53427. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53428. * @param name The friendly name of the light
  53429. * @param direction The direction of the light
  53430. * @param scene The scene the light belongs to
  53431. */
  53432. constructor(name: string, direction: Vector3, scene: Scene);
  53433. /**
  53434. * Returns the string "DirectionalLight".
  53435. * @return The class name
  53436. */
  53437. getClassName(): string;
  53438. /**
  53439. * Returns the integer 1.
  53440. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53441. */
  53442. getTypeID(): number;
  53443. /**
  53444. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  53445. * Returns the DirectionalLight Shadow projection matrix.
  53446. */
  53447. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53448. /**
  53449. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  53450. * Returns the DirectionalLight Shadow projection matrix.
  53451. */
  53452. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  53453. /**
  53454. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  53455. * Returns the DirectionalLight Shadow projection matrix.
  53456. */
  53457. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53458. protected _buildUniformLayout(): void;
  53459. /**
  53460. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  53461. * @param effect The effect to update
  53462. * @param lightIndex The index of the light in the effect to update
  53463. * @returns The directional light
  53464. */
  53465. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  53466. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  53467. /**
  53468. * Gets the minZ used for shadow according to both the scene and the light.
  53469. *
  53470. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  53471. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  53472. * @param activeCamera The camera we are returning the min for
  53473. * @returns the depth min z
  53474. */
  53475. getDepthMinZ(activeCamera: Camera): number;
  53476. /**
  53477. * Gets the maxZ used for shadow according to both the scene and the light.
  53478. *
  53479. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  53480. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  53481. * @param activeCamera The camera we are returning the max for
  53482. * @returns the depth max z
  53483. */
  53484. getDepthMaxZ(activeCamera: Camera): number;
  53485. /**
  53486. * Prepares the list of defines specific to the light type.
  53487. * @param defines the list of defines
  53488. * @param lightIndex defines the index of the light for the effect
  53489. */
  53490. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53491. }
  53492. }
  53493. declare module BABYLON {
  53494. /**
  53495. * Class containing static functions to help procedurally build meshes
  53496. */
  53497. export class HemisphereBuilder {
  53498. /**
  53499. * Creates a hemisphere mesh
  53500. * @param name defines the name of the mesh
  53501. * @param options defines the options used to create the mesh
  53502. * @param scene defines the hosting scene
  53503. * @returns the hemisphere mesh
  53504. */
  53505. static CreateHemisphere(name: string, options: {
  53506. segments?: number;
  53507. diameter?: number;
  53508. sideOrientation?: number;
  53509. }, scene: any): Mesh;
  53510. }
  53511. }
  53512. declare module BABYLON {
  53513. /**
  53514. * A spot light is defined by a position, a direction, an angle, and an exponent.
  53515. * These values define a cone of light starting from the position, emitting toward the direction.
  53516. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  53517. * and the exponent defines the speed of the decay of the light with distance (reach).
  53518. * Documentation: https://doc.babylonjs.com/babylon101/lights
  53519. */
  53520. export class SpotLight extends ShadowLight {
  53521. private _angle;
  53522. private _innerAngle;
  53523. private _cosHalfAngle;
  53524. private _lightAngleScale;
  53525. private _lightAngleOffset;
  53526. /**
  53527. * Gets the cone angle of the spot light in Radians.
  53528. */
  53529. get angle(): number;
  53530. /**
  53531. * Sets the cone angle of the spot light in Radians.
  53532. */
  53533. set angle(value: number);
  53534. /**
  53535. * Only used in gltf falloff mode, this defines the angle where
  53536. * the directional falloff will start before cutting at angle which could be seen
  53537. * as outer angle.
  53538. */
  53539. get innerAngle(): number;
  53540. /**
  53541. * Only used in gltf falloff mode, this defines the angle where
  53542. * the directional falloff will start before cutting at angle which could be seen
  53543. * as outer angle.
  53544. */
  53545. set innerAngle(value: number);
  53546. private _shadowAngleScale;
  53547. /**
  53548. * Allows scaling the angle of the light for shadow generation only.
  53549. */
  53550. get shadowAngleScale(): number;
  53551. /**
  53552. * Allows scaling the angle of the light for shadow generation only.
  53553. */
  53554. set shadowAngleScale(value: number);
  53555. /**
  53556. * The light decay speed with the distance from the emission spot.
  53557. */
  53558. exponent: number;
  53559. private _projectionTextureMatrix;
  53560. /**
  53561. * Allows reading the projecton texture
  53562. */
  53563. get projectionTextureMatrix(): Matrix;
  53564. protected _projectionTextureLightNear: number;
  53565. /**
  53566. * Gets the near clip of the Spotlight for texture projection.
  53567. */
  53568. get projectionTextureLightNear(): number;
  53569. /**
  53570. * Sets the near clip of the Spotlight for texture projection.
  53571. */
  53572. set projectionTextureLightNear(value: number);
  53573. protected _projectionTextureLightFar: number;
  53574. /**
  53575. * Gets the far clip of the Spotlight for texture projection.
  53576. */
  53577. get projectionTextureLightFar(): number;
  53578. /**
  53579. * Sets the far clip of the Spotlight for texture projection.
  53580. */
  53581. set projectionTextureLightFar(value: number);
  53582. protected _projectionTextureUpDirection: Vector3;
  53583. /**
  53584. * Gets the Up vector of the Spotlight for texture projection.
  53585. */
  53586. get projectionTextureUpDirection(): Vector3;
  53587. /**
  53588. * Sets the Up vector of the Spotlight for texture projection.
  53589. */
  53590. set projectionTextureUpDirection(value: Vector3);
  53591. private _projectionTexture;
  53592. /**
  53593. * Gets the projection texture of the light.
  53594. */
  53595. get projectionTexture(): Nullable<BaseTexture>;
  53596. /**
  53597. * Sets the projection texture of the light.
  53598. */
  53599. set projectionTexture(value: Nullable<BaseTexture>);
  53600. private _projectionTextureViewLightDirty;
  53601. private _projectionTextureProjectionLightDirty;
  53602. private _projectionTextureDirty;
  53603. private _projectionTextureViewTargetVector;
  53604. private _projectionTextureViewLightMatrix;
  53605. private _projectionTextureProjectionLightMatrix;
  53606. private _projectionTextureScalingMatrix;
  53607. /**
  53608. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  53609. * It can cast shadows.
  53610. * Documentation : https://doc.babylonjs.com/babylon101/lights
  53611. * @param name The light friendly name
  53612. * @param position The position of the spot light in the scene
  53613. * @param direction The direction of the light in the scene
  53614. * @param angle The cone angle of the light in Radians
  53615. * @param exponent The light decay speed with the distance from the emission spot
  53616. * @param scene The scene the lights belongs to
  53617. */
  53618. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  53619. /**
  53620. * Returns the string "SpotLight".
  53621. * @returns the class name
  53622. */
  53623. getClassName(): string;
  53624. /**
  53625. * Returns the integer 2.
  53626. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  53627. */
  53628. getTypeID(): number;
  53629. /**
  53630. * Overrides the direction setter to recompute the projection texture view light Matrix.
  53631. */
  53632. protected _setDirection(value: Vector3): void;
  53633. /**
  53634. * Overrides the position setter to recompute the projection texture view light Matrix.
  53635. */
  53636. protected _setPosition(value: Vector3): void;
  53637. /**
  53638. * 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.
  53639. * Returns the SpotLight.
  53640. */
  53641. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  53642. protected _computeProjectionTextureViewLightMatrix(): void;
  53643. protected _computeProjectionTextureProjectionLightMatrix(): void;
  53644. /**
  53645. * Main function for light texture projection matrix computing.
  53646. */
  53647. protected _computeProjectionTextureMatrix(): void;
  53648. protected _buildUniformLayout(): void;
  53649. private _computeAngleValues;
  53650. /**
  53651. * Sets the passed Effect "effect" with the Light textures.
  53652. * @param effect The effect to update
  53653. * @param lightIndex The index of the light in the effect to update
  53654. * @returns The light
  53655. */
  53656. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  53657. /**
  53658. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  53659. * @param effect The effect to update
  53660. * @param lightIndex The index of the light in the effect to update
  53661. * @returns The spot light
  53662. */
  53663. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  53664. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  53665. /**
  53666. * Disposes the light and the associated resources.
  53667. */
  53668. dispose(): void;
  53669. /**
  53670. * Prepares the list of defines specific to the light type.
  53671. * @param defines the list of defines
  53672. * @param lightIndex defines the index of the light for the effect
  53673. */
  53674. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  53675. }
  53676. }
  53677. declare module BABYLON {
  53678. /**
  53679. * Gizmo that enables viewing a light
  53680. */
  53681. export class LightGizmo extends Gizmo {
  53682. private _lightMesh;
  53683. private _material;
  53684. private _cachedPosition;
  53685. private _cachedForward;
  53686. private _attachedMeshParent;
  53687. /**
  53688. * Creates a LightGizmo
  53689. * @param gizmoLayer The utility layer the gizmo will be added to
  53690. */
  53691. constructor(gizmoLayer?: UtilityLayerRenderer);
  53692. private _light;
  53693. /**
  53694. * The light that the gizmo is attached to
  53695. */
  53696. set light(light: Nullable<Light>);
  53697. get light(): Nullable<Light>;
  53698. /**
  53699. * Gets the material used to render the light gizmo
  53700. */
  53701. get material(): StandardMaterial;
  53702. /**
  53703. * @hidden
  53704. * Updates the gizmo to match the attached mesh's position/rotation
  53705. */
  53706. protected _update(): void;
  53707. private static _Scale;
  53708. /**
  53709. * Creates the lines for a light mesh
  53710. */
  53711. private static _CreateLightLines;
  53712. /**
  53713. * Disposes of the light gizmo
  53714. */
  53715. dispose(): void;
  53716. private static _CreateHemisphericLightMesh;
  53717. private static _CreatePointLightMesh;
  53718. private static _CreateSpotLightMesh;
  53719. private static _CreateDirectionalLightMesh;
  53720. }
  53721. }
  53722. declare module BABYLON {
  53723. /** @hidden */
  53724. export var backgroundFragmentDeclaration: {
  53725. name: string;
  53726. shader: string;
  53727. };
  53728. }
  53729. declare module BABYLON {
  53730. /** @hidden */
  53731. export var backgroundUboDeclaration: {
  53732. name: string;
  53733. shader: string;
  53734. };
  53735. }
  53736. declare module BABYLON {
  53737. /** @hidden */
  53738. export var backgroundPixelShader: {
  53739. name: string;
  53740. shader: string;
  53741. };
  53742. }
  53743. declare module BABYLON {
  53744. /** @hidden */
  53745. export var backgroundVertexDeclaration: {
  53746. name: string;
  53747. shader: string;
  53748. };
  53749. }
  53750. declare module BABYLON {
  53751. /** @hidden */
  53752. export var backgroundVertexShader: {
  53753. name: string;
  53754. shader: string;
  53755. };
  53756. }
  53757. declare module BABYLON {
  53758. /**
  53759. * Background material used to create an efficient environement around your scene.
  53760. */
  53761. export class BackgroundMaterial extends PushMaterial {
  53762. /**
  53763. * Standard reflectance value at parallel view angle.
  53764. */
  53765. static StandardReflectance0: number;
  53766. /**
  53767. * Standard reflectance value at grazing angle.
  53768. */
  53769. static StandardReflectance90: number;
  53770. protected _primaryColor: Color3;
  53771. /**
  53772. * Key light Color (multiply against the environement texture)
  53773. */
  53774. primaryColor: Color3;
  53775. protected __perceptualColor: Nullable<Color3>;
  53776. /**
  53777. * Experimental Internal Use Only.
  53778. *
  53779. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  53780. * This acts as a helper to set the primary color to a more "human friendly" value.
  53781. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  53782. * output color as close as possible from the chosen value.
  53783. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  53784. * part of lighting setup.)
  53785. */
  53786. get _perceptualColor(): Nullable<Color3>;
  53787. set _perceptualColor(value: Nullable<Color3>);
  53788. protected _primaryColorShadowLevel: float;
  53789. /**
  53790. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  53791. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  53792. */
  53793. get primaryColorShadowLevel(): float;
  53794. set primaryColorShadowLevel(value: float);
  53795. protected _primaryColorHighlightLevel: float;
  53796. /**
  53797. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  53798. * The primary color is used at the level chosen to define what the white area would look.
  53799. */
  53800. get primaryColorHighlightLevel(): float;
  53801. set primaryColorHighlightLevel(value: float);
  53802. protected _reflectionTexture: Nullable<BaseTexture>;
  53803. /**
  53804. * Reflection Texture used in the material.
  53805. * Should be author in a specific way for the best result (refer to the documentation).
  53806. */
  53807. reflectionTexture: Nullable<BaseTexture>;
  53808. protected _reflectionBlur: float;
  53809. /**
  53810. * Reflection Texture level of blur.
  53811. *
  53812. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  53813. * texture twice.
  53814. */
  53815. reflectionBlur: float;
  53816. protected _diffuseTexture: Nullable<BaseTexture>;
  53817. /**
  53818. * Diffuse Texture used in the material.
  53819. * Should be author in a specific way for the best result (refer to the documentation).
  53820. */
  53821. diffuseTexture: Nullable<BaseTexture>;
  53822. protected _shadowLights: Nullable<IShadowLight[]>;
  53823. /**
  53824. * Specify the list of lights casting shadow on the material.
  53825. * All scene shadow lights will be included if null.
  53826. */
  53827. shadowLights: Nullable<IShadowLight[]>;
  53828. protected _shadowLevel: float;
  53829. /**
  53830. * Helps adjusting the shadow to a softer level if required.
  53831. * 0 means black shadows and 1 means no shadows.
  53832. */
  53833. shadowLevel: float;
  53834. protected _sceneCenter: Vector3;
  53835. /**
  53836. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  53837. * It is usually zero but might be interesting to modify according to your setup.
  53838. */
  53839. sceneCenter: Vector3;
  53840. protected _opacityFresnel: boolean;
  53841. /**
  53842. * This helps specifying that the material is falling off to the sky box at grazing angle.
  53843. * This helps ensuring a nice transition when the camera goes under the ground.
  53844. */
  53845. opacityFresnel: boolean;
  53846. protected _reflectionFresnel: boolean;
  53847. /**
  53848. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  53849. * This helps adding a mirror texture on the ground.
  53850. */
  53851. reflectionFresnel: boolean;
  53852. protected _reflectionFalloffDistance: number;
  53853. /**
  53854. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  53855. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  53856. */
  53857. reflectionFalloffDistance: number;
  53858. protected _reflectionAmount: number;
  53859. /**
  53860. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  53861. */
  53862. reflectionAmount: number;
  53863. protected _reflectionReflectance0: number;
  53864. /**
  53865. * This specifies the weight of the reflection at grazing angle.
  53866. */
  53867. reflectionReflectance0: number;
  53868. protected _reflectionReflectance90: number;
  53869. /**
  53870. * This specifies the weight of the reflection at a perpendicular point of view.
  53871. */
  53872. reflectionReflectance90: number;
  53873. /**
  53874. * Sets the reflection reflectance fresnel values according to the default standard
  53875. * empirically know to work well :-)
  53876. */
  53877. set reflectionStandardFresnelWeight(value: number);
  53878. protected _useRGBColor: boolean;
  53879. /**
  53880. * Helps to directly use the maps channels instead of their level.
  53881. */
  53882. useRGBColor: boolean;
  53883. protected _enableNoise: boolean;
  53884. /**
  53885. * This helps reducing the banding effect that could occur on the background.
  53886. */
  53887. enableNoise: boolean;
  53888. /**
  53889. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  53890. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  53891. * Recommended to be keep at 1.0 except for special cases.
  53892. */
  53893. get fovMultiplier(): number;
  53894. set fovMultiplier(value: number);
  53895. private _fovMultiplier;
  53896. /**
  53897. * Enable the FOV adjustment feature controlled by fovMultiplier.
  53898. */
  53899. useEquirectangularFOV: boolean;
  53900. private _maxSimultaneousLights;
  53901. /**
  53902. * Number of Simultaneous lights allowed on the material.
  53903. */
  53904. maxSimultaneousLights: int;
  53905. private _shadowOnly;
  53906. /**
  53907. * Make the material only render shadows
  53908. */
  53909. shadowOnly: boolean;
  53910. /**
  53911. * Default configuration related to image processing available in the Background Material.
  53912. */
  53913. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53914. /**
  53915. * Keep track of the image processing observer to allow dispose and replace.
  53916. */
  53917. private _imageProcessingObserver;
  53918. /**
  53919. * Attaches a new image processing configuration to the PBR Material.
  53920. * @param configuration (if null the scene configuration will be use)
  53921. */
  53922. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53923. /**
  53924. * Gets the image processing configuration used either in this material.
  53925. */
  53926. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  53927. /**
  53928. * Sets the Default image processing configuration used either in the this material.
  53929. *
  53930. * If sets to null, the scene one is in use.
  53931. */
  53932. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  53933. /**
  53934. * Gets wether the color curves effect is enabled.
  53935. */
  53936. get cameraColorCurvesEnabled(): boolean;
  53937. /**
  53938. * Sets wether the color curves effect is enabled.
  53939. */
  53940. set cameraColorCurvesEnabled(value: boolean);
  53941. /**
  53942. * Gets wether the color grading effect is enabled.
  53943. */
  53944. get cameraColorGradingEnabled(): boolean;
  53945. /**
  53946. * Gets wether the color grading effect is enabled.
  53947. */
  53948. set cameraColorGradingEnabled(value: boolean);
  53949. /**
  53950. * Gets wether tonemapping is enabled or not.
  53951. */
  53952. get cameraToneMappingEnabled(): boolean;
  53953. /**
  53954. * Sets wether tonemapping is enabled or not
  53955. */
  53956. set cameraToneMappingEnabled(value: boolean);
  53957. /**
  53958. * The camera exposure used on this material.
  53959. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53960. * This corresponds to a photographic exposure.
  53961. */
  53962. get cameraExposure(): float;
  53963. /**
  53964. * The camera exposure used on this material.
  53965. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53966. * This corresponds to a photographic exposure.
  53967. */
  53968. set cameraExposure(value: float);
  53969. /**
  53970. * Gets The camera contrast used on this material.
  53971. */
  53972. get cameraContrast(): float;
  53973. /**
  53974. * Sets The camera contrast used on this material.
  53975. */
  53976. set cameraContrast(value: float);
  53977. /**
  53978. * Gets the Color Grading 2D Lookup Texture.
  53979. */
  53980. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  53981. /**
  53982. * Sets the Color Grading 2D Lookup Texture.
  53983. */
  53984. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  53985. /**
  53986. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53987. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53988. * 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;
  53989. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53990. */
  53991. get cameraColorCurves(): Nullable<ColorCurves>;
  53992. /**
  53993. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53994. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53995. * 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;
  53996. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53997. */
  53998. set cameraColorCurves(value: Nullable<ColorCurves>);
  53999. /**
  54000. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  54001. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  54002. */
  54003. switchToBGR: boolean;
  54004. private _renderTargets;
  54005. private _reflectionControls;
  54006. private _white;
  54007. private _primaryShadowColor;
  54008. private _primaryHighlightColor;
  54009. /**
  54010. * Instantiates a Background Material in the given scene
  54011. * @param name The friendly name of the material
  54012. * @param scene The scene to add the material to
  54013. */
  54014. constructor(name: string, scene: Scene);
  54015. /**
  54016. * Gets a boolean indicating that current material needs to register RTT
  54017. */
  54018. get hasRenderTargetTextures(): boolean;
  54019. /**
  54020. * The entire material has been created in order to prevent overdraw.
  54021. * @returns false
  54022. */
  54023. needAlphaTesting(): boolean;
  54024. /**
  54025. * The entire material has been created in order to prevent overdraw.
  54026. * @returns true if blending is enable
  54027. */
  54028. needAlphaBlending(): boolean;
  54029. /**
  54030. * Checks wether the material is ready to be rendered for a given mesh.
  54031. * @param mesh The mesh to render
  54032. * @param subMesh The submesh to check against
  54033. * @param useInstances Specify wether or not the material is used with instances
  54034. * @returns true if all the dependencies are ready (Textures, Effects...)
  54035. */
  54036. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54037. /**
  54038. * Compute the primary color according to the chosen perceptual color.
  54039. */
  54040. private _computePrimaryColorFromPerceptualColor;
  54041. /**
  54042. * Compute the highlights and shadow colors according to their chosen levels.
  54043. */
  54044. private _computePrimaryColors;
  54045. /**
  54046. * Build the uniform buffer used in the material.
  54047. */
  54048. buildUniformLayout(): void;
  54049. /**
  54050. * Unbind the material.
  54051. */
  54052. unbind(): void;
  54053. /**
  54054. * Bind only the world matrix to the material.
  54055. * @param world The world matrix to bind.
  54056. */
  54057. bindOnlyWorldMatrix(world: Matrix): void;
  54058. /**
  54059. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  54060. * @param world The world matrix to bind.
  54061. * @param subMesh The submesh to bind for.
  54062. */
  54063. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54064. /**
  54065. * Checks to see if a texture is used in the material.
  54066. * @param texture - Base texture to use.
  54067. * @returns - Boolean specifying if a texture is used in the material.
  54068. */
  54069. hasTexture(texture: BaseTexture): boolean;
  54070. /**
  54071. * Dispose the material.
  54072. * @param forceDisposeEffect Force disposal of the associated effect.
  54073. * @param forceDisposeTextures Force disposal of the associated textures.
  54074. */
  54075. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  54076. /**
  54077. * Clones the material.
  54078. * @param name The cloned name.
  54079. * @returns The cloned material.
  54080. */
  54081. clone(name: string): BackgroundMaterial;
  54082. /**
  54083. * Serializes the current material to its JSON representation.
  54084. * @returns The JSON representation.
  54085. */
  54086. serialize(): any;
  54087. /**
  54088. * Gets the class name of the material
  54089. * @returns "BackgroundMaterial"
  54090. */
  54091. getClassName(): string;
  54092. /**
  54093. * Parse a JSON input to create back a background material.
  54094. * @param source The JSON data to parse
  54095. * @param scene The scene to create the parsed material in
  54096. * @param rootUrl The root url of the assets the material depends upon
  54097. * @returns the instantiated BackgroundMaterial.
  54098. */
  54099. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  54100. }
  54101. }
  54102. declare module BABYLON {
  54103. /**
  54104. * Represents the different options available during the creation of
  54105. * a Environment helper.
  54106. *
  54107. * This can control the default ground, skybox and image processing setup of your scene.
  54108. */
  54109. export interface IEnvironmentHelperOptions {
  54110. /**
  54111. * Specifies whether or not to create a ground.
  54112. * True by default.
  54113. */
  54114. createGround: boolean;
  54115. /**
  54116. * Specifies the ground size.
  54117. * 15 by default.
  54118. */
  54119. groundSize: number;
  54120. /**
  54121. * The texture used on the ground for the main color.
  54122. * Comes from the BabylonJS CDN by default.
  54123. *
  54124. * Remarks: Can be either a texture or a url.
  54125. */
  54126. groundTexture: string | BaseTexture;
  54127. /**
  54128. * The color mixed in the ground texture by default.
  54129. * BabylonJS clearColor by default.
  54130. */
  54131. groundColor: Color3;
  54132. /**
  54133. * Specifies the ground opacity.
  54134. * 1 by default.
  54135. */
  54136. groundOpacity: number;
  54137. /**
  54138. * Enables the ground to receive shadows.
  54139. * True by default.
  54140. */
  54141. enableGroundShadow: boolean;
  54142. /**
  54143. * Helps preventing the shadow to be fully black on the ground.
  54144. * 0.5 by default.
  54145. */
  54146. groundShadowLevel: number;
  54147. /**
  54148. * Creates a mirror texture attach to the ground.
  54149. * false by default.
  54150. */
  54151. enableGroundMirror: boolean;
  54152. /**
  54153. * Specifies the ground mirror size ratio.
  54154. * 0.3 by default as the default kernel is 64.
  54155. */
  54156. groundMirrorSizeRatio: number;
  54157. /**
  54158. * Specifies the ground mirror blur kernel size.
  54159. * 64 by default.
  54160. */
  54161. groundMirrorBlurKernel: number;
  54162. /**
  54163. * Specifies the ground mirror visibility amount.
  54164. * 1 by default
  54165. */
  54166. groundMirrorAmount: number;
  54167. /**
  54168. * Specifies the ground mirror reflectance weight.
  54169. * This uses the standard weight of the background material to setup the fresnel effect
  54170. * of the mirror.
  54171. * 1 by default.
  54172. */
  54173. groundMirrorFresnelWeight: number;
  54174. /**
  54175. * Specifies the ground mirror Falloff distance.
  54176. * This can helps reducing the size of the reflection.
  54177. * 0 by Default.
  54178. */
  54179. groundMirrorFallOffDistance: number;
  54180. /**
  54181. * Specifies the ground mirror texture type.
  54182. * Unsigned Int by Default.
  54183. */
  54184. groundMirrorTextureType: number;
  54185. /**
  54186. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  54187. * the shown objects.
  54188. */
  54189. groundYBias: number;
  54190. /**
  54191. * Specifies whether or not to create a skybox.
  54192. * True by default.
  54193. */
  54194. createSkybox: boolean;
  54195. /**
  54196. * Specifies the skybox size.
  54197. * 20 by default.
  54198. */
  54199. skyboxSize: number;
  54200. /**
  54201. * The texture used on the skybox for the main color.
  54202. * Comes from the BabylonJS CDN by default.
  54203. *
  54204. * Remarks: Can be either a texture or a url.
  54205. */
  54206. skyboxTexture: string | BaseTexture;
  54207. /**
  54208. * The color mixed in the skybox texture by default.
  54209. * BabylonJS clearColor by default.
  54210. */
  54211. skyboxColor: Color3;
  54212. /**
  54213. * The background rotation around the Y axis of the scene.
  54214. * This helps aligning the key lights of your scene with the background.
  54215. * 0 by default.
  54216. */
  54217. backgroundYRotation: number;
  54218. /**
  54219. * Compute automatically the size of the elements to best fit with the scene.
  54220. */
  54221. sizeAuto: boolean;
  54222. /**
  54223. * Default position of the rootMesh if autoSize is not true.
  54224. */
  54225. rootPosition: Vector3;
  54226. /**
  54227. * Sets up the image processing in the scene.
  54228. * true by default.
  54229. */
  54230. setupImageProcessing: boolean;
  54231. /**
  54232. * The texture used as your environment texture in the scene.
  54233. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  54234. *
  54235. * Remarks: Can be either a texture or a url.
  54236. */
  54237. environmentTexture: string | BaseTexture;
  54238. /**
  54239. * The value of the exposure to apply to the scene.
  54240. * 0.6 by default if setupImageProcessing is true.
  54241. */
  54242. cameraExposure: number;
  54243. /**
  54244. * The value of the contrast to apply to the scene.
  54245. * 1.6 by default if setupImageProcessing is true.
  54246. */
  54247. cameraContrast: number;
  54248. /**
  54249. * Specifies whether or not tonemapping should be enabled in the scene.
  54250. * true by default if setupImageProcessing is true.
  54251. */
  54252. toneMappingEnabled: boolean;
  54253. }
  54254. /**
  54255. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  54256. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  54257. * It also helps with the default setup of your imageProcessing configuration.
  54258. */
  54259. export class EnvironmentHelper {
  54260. /**
  54261. * Default ground texture URL.
  54262. */
  54263. private static _groundTextureCDNUrl;
  54264. /**
  54265. * Default skybox texture URL.
  54266. */
  54267. private static _skyboxTextureCDNUrl;
  54268. /**
  54269. * Default environment texture URL.
  54270. */
  54271. private static _environmentTextureCDNUrl;
  54272. /**
  54273. * Creates the default options for the helper.
  54274. */
  54275. private static _getDefaultOptions;
  54276. private _rootMesh;
  54277. /**
  54278. * Gets the root mesh created by the helper.
  54279. */
  54280. get rootMesh(): Mesh;
  54281. private _skybox;
  54282. /**
  54283. * Gets the skybox created by the helper.
  54284. */
  54285. get skybox(): Nullable<Mesh>;
  54286. private _skyboxTexture;
  54287. /**
  54288. * Gets the skybox texture created by the helper.
  54289. */
  54290. get skyboxTexture(): Nullable<BaseTexture>;
  54291. private _skyboxMaterial;
  54292. /**
  54293. * Gets the skybox material created by the helper.
  54294. */
  54295. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  54296. private _ground;
  54297. /**
  54298. * Gets the ground mesh created by the helper.
  54299. */
  54300. get ground(): Nullable<Mesh>;
  54301. private _groundTexture;
  54302. /**
  54303. * Gets the ground texture created by the helper.
  54304. */
  54305. get groundTexture(): Nullable<BaseTexture>;
  54306. private _groundMirror;
  54307. /**
  54308. * Gets the ground mirror created by the helper.
  54309. */
  54310. get groundMirror(): Nullable<MirrorTexture>;
  54311. /**
  54312. * Gets the ground mirror render list to helps pushing the meshes
  54313. * you wish in the ground reflection.
  54314. */
  54315. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  54316. private _groundMaterial;
  54317. /**
  54318. * Gets the ground material created by the helper.
  54319. */
  54320. get groundMaterial(): Nullable<BackgroundMaterial>;
  54321. /**
  54322. * Stores the creation options.
  54323. */
  54324. private readonly _scene;
  54325. private _options;
  54326. /**
  54327. * This observable will be notified with any error during the creation of the environment,
  54328. * mainly texture creation errors.
  54329. */
  54330. onErrorObservable: Observable<{
  54331. message?: string;
  54332. exception?: any;
  54333. }>;
  54334. /**
  54335. * constructor
  54336. * @param options Defines the options we want to customize the helper
  54337. * @param scene The scene to add the material to
  54338. */
  54339. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  54340. /**
  54341. * Updates the background according to the new options
  54342. * @param options
  54343. */
  54344. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  54345. /**
  54346. * Sets the primary color of all the available elements.
  54347. * @param color the main color to affect to the ground and the background
  54348. */
  54349. setMainColor(color: Color3): void;
  54350. /**
  54351. * Setup the image processing according to the specified options.
  54352. */
  54353. private _setupImageProcessing;
  54354. /**
  54355. * Setup the environment texture according to the specified options.
  54356. */
  54357. private _setupEnvironmentTexture;
  54358. /**
  54359. * Setup the background according to the specified options.
  54360. */
  54361. private _setupBackground;
  54362. /**
  54363. * Get the scene sizes according to the setup.
  54364. */
  54365. private _getSceneSize;
  54366. /**
  54367. * Setup the ground according to the specified options.
  54368. */
  54369. private _setupGround;
  54370. /**
  54371. * Setup the ground material according to the specified options.
  54372. */
  54373. private _setupGroundMaterial;
  54374. /**
  54375. * Setup the ground diffuse texture according to the specified options.
  54376. */
  54377. private _setupGroundDiffuseTexture;
  54378. /**
  54379. * Setup the ground mirror texture according to the specified options.
  54380. */
  54381. private _setupGroundMirrorTexture;
  54382. /**
  54383. * Setup the ground to receive the mirror texture.
  54384. */
  54385. private _setupMirrorInGroundMaterial;
  54386. /**
  54387. * Setup the skybox according to the specified options.
  54388. */
  54389. private _setupSkybox;
  54390. /**
  54391. * Setup the skybox material according to the specified options.
  54392. */
  54393. private _setupSkyboxMaterial;
  54394. /**
  54395. * Setup the skybox reflection texture according to the specified options.
  54396. */
  54397. private _setupSkyboxReflectionTexture;
  54398. private _errorHandler;
  54399. /**
  54400. * Dispose all the elements created by the Helper.
  54401. */
  54402. dispose(): void;
  54403. }
  54404. }
  54405. declare module BABYLON {
  54406. /**
  54407. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  54408. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  54409. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  54410. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  54411. */
  54412. export class PhotoDome extends TransformNode {
  54413. /**
  54414. * Define the image as a Monoscopic panoramic 360 image.
  54415. */
  54416. static readonly MODE_MONOSCOPIC: number;
  54417. /**
  54418. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  54419. */
  54420. static readonly MODE_TOPBOTTOM: number;
  54421. /**
  54422. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  54423. */
  54424. static readonly MODE_SIDEBYSIDE: number;
  54425. private _useDirectMapping;
  54426. /**
  54427. * The texture being displayed on the sphere
  54428. */
  54429. protected _photoTexture: Texture;
  54430. /**
  54431. * Gets or sets the texture being displayed on the sphere
  54432. */
  54433. get photoTexture(): Texture;
  54434. set photoTexture(value: Texture);
  54435. /**
  54436. * Observable raised when an error occured while loading the 360 image
  54437. */
  54438. onLoadErrorObservable: Observable<string>;
  54439. /**
  54440. * The skybox material
  54441. */
  54442. protected _material: BackgroundMaterial;
  54443. /**
  54444. * The surface used for the skybox
  54445. */
  54446. protected _mesh: Mesh;
  54447. /**
  54448. * Gets the mesh used for the skybox.
  54449. */
  54450. get mesh(): Mesh;
  54451. /**
  54452. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54453. * Also see the options.resolution property.
  54454. */
  54455. get fovMultiplier(): number;
  54456. set fovMultiplier(value: number);
  54457. private _imageMode;
  54458. /**
  54459. * Gets or set the current video mode for the video. It can be:
  54460. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  54461. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  54462. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  54463. */
  54464. get imageMode(): number;
  54465. set imageMode(value: number);
  54466. /**
  54467. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  54468. * @param name Element's name, child elements will append suffixes for their own names.
  54469. * @param urlsOfPhoto defines the url of the photo to display
  54470. * @param options defines an object containing optional or exposed sub element properties
  54471. * @param onError defines a callback called when an error occured while loading the texture
  54472. */
  54473. constructor(name: string, urlOfPhoto: string, options: {
  54474. resolution?: number;
  54475. size?: number;
  54476. useDirectMapping?: boolean;
  54477. faceForward?: boolean;
  54478. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  54479. private _onBeforeCameraRenderObserver;
  54480. private _changeImageMode;
  54481. /**
  54482. * Releases resources associated with this node.
  54483. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  54484. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  54485. */
  54486. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  54487. }
  54488. }
  54489. declare module BABYLON {
  54490. /**
  54491. * Class used to host RGBD texture specific utilities
  54492. */
  54493. export class RGBDTextureTools {
  54494. /**
  54495. * Expand the RGBD Texture from RGBD to Half Float if possible.
  54496. * @param texture the texture to expand.
  54497. */
  54498. static ExpandRGBDTexture(texture: Texture): void;
  54499. }
  54500. }
  54501. declare module BABYLON {
  54502. /**
  54503. * Class used to host texture specific utilities
  54504. */
  54505. export class BRDFTextureTools {
  54506. /**
  54507. * Prevents texture cache collision
  54508. */
  54509. private static _instanceNumber;
  54510. /**
  54511. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  54512. * @param scene defines the hosting scene
  54513. * @returns the environment BRDF texture
  54514. */
  54515. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  54516. private static _environmentBRDFBase64Texture;
  54517. }
  54518. }
  54519. declare module BABYLON {
  54520. /**
  54521. * @hidden
  54522. */
  54523. export interface IMaterialClearCoatDefines {
  54524. CLEARCOAT: boolean;
  54525. CLEARCOAT_DEFAULTIOR: boolean;
  54526. CLEARCOAT_TEXTURE: boolean;
  54527. CLEARCOAT_TEXTUREDIRECTUV: number;
  54528. CLEARCOAT_BUMP: boolean;
  54529. CLEARCOAT_BUMPDIRECTUV: number;
  54530. CLEARCOAT_TINT: boolean;
  54531. CLEARCOAT_TINT_TEXTURE: boolean;
  54532. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  54533. /** @hidden */
  54534. _areTexturesDirty: boolean;
  54535. }
  54536. /**
  54537. * Define the code related to the clear coat parameters of the pbr material.
  54538. */
  54539. export class PBRClearCoatConfiguration {
  54540. /**
  54541. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  54542. * The default fits with a polyurethane material.
  54543. */
  54544. private static readonly _DefaultIndexOfRefraction;
  54545. private _isEnabled;
  54546. /**
  54547. * Defines if the clear coat is enabled in the material.
  54548. */
  54549. isEnabled: boolean;
  54550. /**
  54551. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  54552. */
  54553. intensity: number;
  54554. /**
  54555. * Defines the clear coat layer roughness.
  54556. */
  54557. roughness: number;
  54558. private _indexOfRefraction;
  54559. /**
  54560. * Defines the index of refraction of the clear coat.
  54561. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  54562. * The default fits with a polyurethane material.
  54563. * Changing the default value is more performance intensive.
  54564. */
  54565. indexOfRefraction: number;
  54566. private _texture;
  54567. /**
  54568. * Stores the clear coat values in a texture.
  54569. */
  54570. texture: Nullable<BaseTexture>;
  54571. private _bumpTexture;
  54572. /**
  54573. * Define the clear coat specific bump texture.
  54574. */
  54575. bumpTexture: Nullable<BaseTexture>;
  54576. private _isTintEnabled;
  54577. /**
  54578. * Defines if the clear coat tint is enabled in the material.
  54579. */
  54580. isTintEnabled: boolean;
  54581. /**
  54582. * Defines the clear coat tint of the material.
  54583. * This is only use if tint is enabled
  54584. */
  54585. tintColor: Color3;
  54586. /**
  54587. * Defines the distance at which the tint color should be found in the
  54588. * clear coat media.
  54589. * This is only use if tint is enabled
  54590. */
  54591. tintColorAtDistance: number;
  54592. /**
  54593. * Defines the clear coat layer thickness.
  54594. * This is only use if tint is enabled
  54595. */
  54596. tintThickness: number;
  54597. private _tintTexture;
  54598. /**
  54599. * Stores the clear tint values in a texture.
  54600. * rgb is tint
  54601. * a is a thickness factor
  54602. */
  54603. tintTexture: Nullable<BaseTexture>;
  54604. /** @hidden */
  54605. private _internalMarkAllSubMeshesAsTexturesDirty;
  54606. /** @hidden */
  54607. _markAllSubMeshesAsTexturesDirty(): void;
  54608. /**
  54609. * Instantiate a new istance of clear coat configuration.
  54610. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54611. */
  54612. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54613. /**
  54614. * Gets wehter the submesh is ready to be used or not.
  54615. * @param defines the list of "defines" to update.
  54616. * @param scene defines the scene the material belongs to.
  54617. * @param engine defines the engine the material belongs to.
  54618. * @param disableBumpMap defines wether the material disables bump or not.
  54619. * @returns - boolean indicating that the submesh is ready or not.
  54620. */
  54621. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  54622. /**
  54623. * Checks to see if a texture is used in the material.
  54624. * @param defines the list of "defines" to update.
  54625. * @param scene defines the scene to the material belongs to.
  54626. */
  54627. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  54628. /**
  54629. * Binds the material data.
  54630. * @param uniformBuffer defines the Uniform buffer to fill in.
  54631. * @param scene defines the scene the material belongs to.
  54632. * @param engine defines the engine the material belongs to.
  54633. * @param disableBumpMap defines wether the material disables bump or not.
  54634. * @param isFrozen defines wether the material is frozen or not.
  54635. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  54636. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  54637. */
  54638. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  54639. /**
  54640. * Checks to see if a texture is used in the material.
  54641. * @param texture - Base texture to use.
  54642. * @returns - Boolean specifying if a texture is used in the material.
  54643. */
  54644. hasTexture(texture: BaseTexture): boolean;
  54645. /**
  54646. * Returns an array of the actively used textures.
  54647. * @param activeTextures Array of BaseTextures
  54648. */
  54649. getActiveTextures(activeTextures: BaseTexture[]): void;
  54650. /**
  54651. * Returns the animatable textures.
  54652. * @param animatables Array of animatable textures.
  54653. */
  54654. getAnimatables(animatables: IAnimatable[]): void;
  54655. /**
  54656. * Disposes the resources of the material.
  54657. * @param forceDisposeTextures - Forces the disposal of all textures.
  54658. */
  54659. dispose(forceDisposeTextures?: boolean): void;
  54660. /**
  54661. * Get the current class name of the texture useful for serialization or dynamic coding.
  54662. * @returns "PBRClearCoatConfiguration"
  54663. */
  54664. getClassName(): string;
  54665. /**
  54666. * Add fallbacks to the effect fallbacks list.
  54667. * @param defines defines the Base texture to use.
  54668. * @param fallbacks defines the current fallback list.
  54669. * @param currentRank defines the current fallback rank.
  54670. * @returns the new fallback rank.
  54671. */
  54672. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54673. /**
  54674. * Add the required uniforms to the current list.
  54675. * @param uniforms defines the current uniform list.
  54676. */
  54677. static AddUniforms(uniforms: string[]): void;
  54678. /**
  54679. * Add the required samplers to the current list.
  54680. * @param samplers defines the current sampler list.
  54681. */
  54682. static AddSamplers(samplers: string[]): void;
  54683. /**
  54684. * Add the required uniforms to the current buffer.
  54685. * @param uniformBuffer defines the current uniform buffer.
  54686. */
  54687. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54688. /**
  54689. * Makes a duplicate of the current configuration into another one.
  54690. * @param clearCoatConfiguration define the config where to copy the info
  54691. */
  54692. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  54693. /**
  54694. * Serializes this clear coat configuration.
  54695. * @returns - An object with the serialized config.
  54696. */
  54697. serialize(): any;
  54698. /**
  54699. * Parses a anisotropy Configuration from a serialized object.
  54700. * @param source - Serialized object.
  54701. * @param scene Defines the scene we are parsing for
  54702. * @param rootUrl Defines the rootUrl to load from
  54703. */
  54704. parse(source: any, scene: Scene, rootUrl: string): void;
  54705. }
  54706. }
  54707. declare module BABYLON {
  54708. /**
  54709. * @hidden
  54710. */
  54711. export interface IMaterialAnisotropicDefines {
  54712. ANISOTROPIC: boolean;
  54713. ANISOTROPIC_TEXTURE: boolean;
  54714. ANISOTROPIC_TEXTUREDIRECTUV: number;
  54715. MAINUV1: boolean;
  54716. _areTexturesDirty: boolean;
  54717. _needUVs: boolean;
  54718. }
  54719. /**
  54720. * Define the code related to the anisotropic parameters of the pbr material.
  54721. */
  54722. export class PBRAnisotropicConfiguration {
  54723. private _isEnabled;
  54724. /**
  54725. * Defines if the anisotropy is enabled in the material.
  54726. */
  54727. isEnabled: boolean;
  54728. /**
  54729. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  54730. */
  54731. intensity: number;
  54732. /**
  54733. * Defines if the effect is along the tangents, bitangents or in between.
  54734. * By default, the effect is "strectching" the highlights along the tangents.
  54735. */
  54736. direction: Vector2;
  54737. private _texture;
  54738. /**
  54739. * Stores the anisotropy values in a texture.
  54740. * rg is direction (like normal from -1 to 1)
  54741. * b is a intensity
  54742. */
  54743. texture: Nullable<BaseTexture>;
  54744. /** @hidden */
  54745. private _internalMarkAllSubMeshesAsTexturesDirty;
  54746. /** @hidden */
  54747. _markAllSubMeshesAsTexturesDirty(): void;
  54748. /**
  54749. * Instantiate a new istance of anisotropy configuration.
  54750. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  54751. */
  54752. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  54753. /**
  54754. * Specifies that the submesh is ready to be used.
  54755. * @param defines the list of "defines" to update.
  54756. * @param scene defines the scene the material belongs to.
  54757. * @returns - boolean indicating that the submesh is ready or not.
  54758. */
  54759. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  54760. /**
  54761. * Checks to see if a texture is used in the material.
  54762. * @param defines the list of "defines" to update.
  54763. * @param mesh the mesh we are preparing the defines for.
  54764. * @param scene defines the scene the material belongs to.
  54765. */
  54766. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  54767. /**
  54768. * Binds the material data.
  54769. * @param uniformBuffer defines the Uniform buffer to fill in.
  54770. * @param scene defines the scene the material belongs to.
  54771. * @param isFrozen defines wether the material is frozen or not.
  54772. */
  54773. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  54774. /**
  54775. * Checks to see if a texture is used in the material.
  54776. * @param texture - Base texture to use.
  54777. * @returns - Boolean specifying if a texture is used in the material.
  54778. */
  54779. hasTexture(texture: BaseTexture): boolean;
  54780. /**
  54781. * Returns an array of the actively used textures.
  54782. * @param activeTextures Array of BaseTextures
  54783. */
  54784. getActiveTextures(activeTextures: BaseTexture[]): void;
  54785. /**
  54786. * Returns the animatable textures.
  54787. * @param animatables Array of animatable textures.
  54788. */
  54789. getAnimatables(animatables: IAnimatable[]): void;
  54790. /**
  54791. * Disposes the resources of the material.
  54792. * @param forceDisposeTextures - Forces the disposal of all textures.
  54793. */
  54794. dispose(forceDisposeTextures?: boolean): void;
  54795. /**
  54796. * Get the current class name of the texture useful for serialization or dynamic coding.
  54797. * @returns "PBRAnisotropicConfiguration"
  54798. */
  54799. getClassName(): string;
  54800. /**
  54801. * Add fallbacks to the effect fallbacks list.
  54802. * @param defines defines the Base texture to use.
  54803. * @param fallbacks defines the current fallback list.
  54804. * @param currentRank defines the current fallback rank.
  54805. * @returns the new fallback rank.
  54806. */
  54807. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  54808. /**
  54809. * Add the required uniforms to the current list.
  54810. * @param uniforms defines the current uniform list.
  54811. */
  54812. static AddUniforms(uniforms: string[]): void;
  54813. /**
  54814. * Add the required uniforms to the current buffer.
  54815. * @param uniformBuffer defines the current uniform buffer.
  54816. */
  54817. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  54818. /**
  54819. * Add the required samplers to the current list.
  54820. * @param samplers defines the current sampler list.
  54821. */
  54822. static AddSamplers(samplers: string[]): void;
  54823. /**
  54824. * Makes a duplicate of the current configuration into another one.
  54825. * @param anisotropicConfiguration define the config where to copy the info
  54826. */
  54827. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  54828. /**
  54829. * Serializes this anisotropy configuration.
  54830. * @returns - An object with the serialized config.
  54831. */
  54832. serialize(): any;
  54833. /**
  54834. * Parses a anisotropy Configuration from a serialized object.
  54835. * @param source - Serialized object.
  54836. * @param scene Defines the scene we are parsing for
  54837. * @param rootUrl Defines the rootUrl to load from
  54838. */
  54839. parse(source: any, scene: Scene, rootUrl: string): void;
  54840. }
  54841. }
  54842. declare module BABYLON {
  54843. /**
  54844. * @hidden
  54845. */
  54846. export interface IMaterialBRDFDefines {
  54847. BRDF_V_HEIGHT_CORRELATED: boolean;
  54848. MS_BRDF_ENERGY_CONSERVATION: boolean;
  54849. SPHERICAL_HARMONICS: boolean;
  54850. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  54851. /** @hidden */
  54852. _areMiscDirty: boolean;
  54853. }
  54854. /**
  54855. * Define the code related to the BRDF parameters of the pbr material.
  54856. */
  54857. export class PBRBRDFConfiguration {
  54858. /**
  54859. * Default value used for the energy conservation.
  54860. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  54861. */
  54862. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  54863. /**
  54864. * Default value used for the Smith Visibility Height Correlated mode.
  54865. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  54866. */
  54867. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  54868. /**
  54869. * Default value used for the IBL diffuse part.
  54870. * This can help switching back to the polynomials mode globally which is a tiny bit
  54871. * less GPU intensive at the drawback of a lower quality.
  54872. */
  54873. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  54874. /**
  54875. * Default value used for activating energy conservation for the specular workflow.
  54876. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  54877. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  54878. */
  54879. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  54880. private _useEnergyConservation;
  54881. /**
  54882. * Defines if the material uses energy conservation.
  54883. */
  54884. useEnergyConservation: boolean;
  54885. private _useSmithVisibilityHeightCorrelated;
  54886. /**
  54887. * LEGACY Mode set to false
  54888. * Defines if the material uses height smith correlated visibility term.
  54889. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  54890. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  54891. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  54892. * Not relying on height correlated will also disable energy conservation.
  54893. */
  54894. useSmithVisibilityHeightCorrelated: boolean;
  54895. private _useSphericalHarmonics;
  54896. /**
  54897. * LEGACY Mode set to false
  54898. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  54899. * diffuse part of the IBL.
  54900. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  54901. * to the ground truth.
  54902. */
  54903. useSphericalHarmonics: boolean;
  54904. private _useSpecularGlossinessInputEnergyConservation;
  54905. /**
  54906. * Defines if the material uses energy conservation, when the specular workflow is active.
  54907. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  54908. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  54909. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  54910. */
  54911. useSpecularGlossinessInputEnergyConservation: boolean;
  54912. /** @hidden */
  54913. private _internalMarkAllSubMeshesAsMiscDirty;
  54914. /** @hidden */
  54915. _markAllSubMeshesAsMiscDirty(): void;
  54916. /**
  54917. * Instantiate a new istance of clear coat configuration.
  54918. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  54919. */
  54920. constructor(markAllSubMeshesAsMiscDirty: () => void);
  54921. /**
  54922. * Checks to see if a texture is used in the material.
  54923. * @param defines the list of "defines" to update.
  54924. */
  54925. prepareDefines(defines: IMaterialBRDFDefines): 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. * Makes a duplicate of the current configuration into another one.
  54933. * @param brdfConfiguration define the config where to copy the info
  54934. */
  54935. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  54936. /**
  54937. * Serializes this BRDF configuration.
  54938. * @returns - An object with the serialized config.
  54939. */
  54940. serialize(): any;
  54941. /**
  54942. * Parses a anisotropy Configuration from a serialized object.
  54943. * @param source - Serialized object.
  54944. * @param scene Defines the scene we are parsing for
  54945. * @param rootUrl Defines the rootUrl to load from
  54946. */
  54947. parse(source: any, scene: Scene, rootUrl: string): void;
  54948. }
  54949. }
  54950. declare module BABYLON {
  54951. /**
  54952. * @hidden
  54953. */
  54954. export interface IMaterialSheenDefines {
  54955. SHEEN: boolean;
  54956. SHEEN_TEXTURE: boolean;
  54957. SHEEN_TEXTUREDIRECTUV: number;
  54958. SHEEN_LINKWITHALBEDO: boolean;
  54959. SHEEN_ROUGHNESS: boolean;
  54960. SHEEN_ALBEDOSCALING: boolean;
  54961. /** @hidden */
  54962. _areTexturesDirty: boolean;
  54963. }
  54964. /**
  54965. * Define the code related to the Sheen parameters of the pbr material.
  54966. */
  54967. export class PBRSheenConfiguration {
  54968. private _isEnabled;
  54969. /**
  54970. * Defines if the material uses sheen.
  54971. */
  54972. isEnabled: boolean;
  54973. private _linkSheenWithAlbedo;
  54974. /**
  54975. * Defines if the sheen is linked to the sheen color.
  54976. */
  54977. linkSheenWithAlbedo: boolean;
  54978. /**
  54979. * Defines the sheen intensity.
  54980. */
  54981. intensity: number;
  54982. /**
  54983. * Defines the sheen color.
  54984. */
  54985. color: Color3;
  54986. private _texture;
  54987. /**
  54988. * Stores the sheen tint values in a texture.
  54989. * rgb is tint
  54990. * a is a intensity or roughness if roughness has been defined
  54991. */
  54992. texture: Nullable<BaseTexture>;
  54993. private _roughness;
  54994. /**
  54995. * Defines the sheen roughness.
  54996. * It is not taken into account if linkSheenWithAlbedo is true.
  54997. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  54998. */
  54999. roughness: Nullable<number>;
  55000. private _albedoScaling;
  55001. /**
  55002. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  55003. * It allows the strength of the sheen effect to not depend on the base color of the material,
  55004. * making it easier to setup and tweak the effect
  55005. */
  55006. albedoScaling: boolean;
  55007. /** @hidden */
  55008. private _internalMarkAllSubMeshesAsTexturesDirty;
  55009. /** @hidden */
  55010. _markAllSubMeshesAsTexturesDirty(): void;
  55011. /**
  55012. * Instantiate a new istance of clear coat configuration.
  55013. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55014. */
  55015. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55016. /**
  55017. * Specifies that the submesh is ready to be used.
  55018. * @param defines the list of "defines" to update.
  55019. * @param scene defines the scene the material belongs to.
  55020. * @returns - boolean indicating that the submesh is ready or not.
  55021. */
  55022. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  55023. /**
  55024. * Checks to see if a texture is used in the material.
  55025. * @param defines the list of "defines" to update.
  55026. * @param scene defines the scene the material belongs to.
  55027. */
  55028. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  55029. /**
  55030. * Binds the material data.
  55031. * @param uniformBuffer defines the Uniform buffer to fill in.
  55032. * @param scene defines the scene the material belongs to.
  55033. * @param isFrozen defines wether the material is frozen or not.
  55034. */
  55035. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  55036. /**
  55037. * Checks to see if a texture is used in the material.
  55038. * @param texture - Base texture to use.
  55039. * @returns - Boolean specifying if a texture is used in the material.
  55040. */
  55041. hasTexture(texture: BaseTexture): boolean;
  55042. /**
  55043. * Returns an array of the actively used textures.
  55044. * @param activeTextures Array of BaseTextures
  55045. */
  55046. getActiveTextures(activeTextures: BaseTexture[]): void;
  55047. /**
  55048. * Returns the animatable textures.
  55049. * @param animatables Array of animatable textures.
  55050. */
  55051. getAnimatables(animatables: IAnimatable[]): void;
  55052. /**
  55053. * Disposes the resources of the material.
  55054. * @param forceDisposeTextures - Forces the disposal of all textures.
  55055. */
  55056. dispose(forceDisposeTextures?: boolean): void;
  55057. /**
  55058. * Get the current class name of the texture useful for serialization or dynamic coding.
  55059. * @returns "PBRSheenConfiguration"
  55060. */
  55061. getClassName(): string;
  55062. /**
  55063. * Add fallbacks to the effect fallbacks list.
  55064. * @param defines defines the Base texture to use.
  55065. * @param fallbacks defines the current fallback list.
  55066. * @param currentRank defines the current fallback rank.
  55067. * @returns the new fallback rank.
  55068. */
  55069. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55070. /**
  55071. * Add the required uniforms to the current list.
  55072. * @param uniforms defines the current uniform list.
  55073. */
  55074. static AddUniforms(uniforms: string[]): void;
  55075. /**
  55076. * Add the required uniforms to the current buffer.
  55077. * @param uniformBuffer defines the current uniform buffer.
  55078. */
  55079. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55080. /**
  55081. * Add the required samplers to the current list.
  55082. * @param samplers defines the current sampler list.
  55083. */
  55084. static AddSamplers(samplers: string[]): void;
  55085. /**
  55086. * Makes a duplicate of the current configuration into another one.
  55087. * @param sheenConfiguration define the config where to copy the info
  55088. */
  55089. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  55090. /**
  55091. * Serializes this BRDF configuration.
  55092. * @returns - An object with the serialized config.
  55093. */
  55094. serialize(): any;
  55095. /**
  55096. * Parses a anisotropy Configuration from a serialized object.
  55097. * @param source - Serialized object.
  55098. * @param scene Defines the scene we are parsing for
  55099. * @param rootUrl Defines the rootUrl to load from
  55100. */
  55101. parse(source: any, scene: Scene, rootUrl: string): void;
  55102. }
  55103. }
  55104. declare module BABYLON {
  55105. /**
  55106. * @hidden
  55107. */
  55108. export interface IMaterialSubSurfaceDefines {
  55109. SUBSURFACE: boolean;
  55110. SS_REFRACTION: boolean;
  55111. SS_TRANSLUCENCY: boolean;
  55112. SS_SCATTERING: boolean;
  55113. SS_THICKNESSANDMASK_TEXTURE: boolean;
  55114. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  55115. SS_REFRACTIONMAP_3D: boolean;
  55116. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  55117. SS_LODINREFRACTIONALPHA: boolean;
  55118. SS_GAMMAREFRACTION: boolean;
  55119. SS_RGBDREFRACTION: boolean;
  55120. SS_LINEARSPECULARREFRACTION: boolean;
  55121. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  55122. SS_ALBEDOFORREFRACTIONTINT: boolean;
  55123. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  55124. /** @hidden */
  55125. _areTexturesDirty: boolean;
  55126. }
  55127. /**
  55128. * Define the code related to the sub surface parameters of the pbr material.
  55129. */
  55130. export class PBRSubSurfaceConfiguration {
  55131. private _isRefractionEnabled;
  55132. /**
  55133. * Defines if the refraction is enabled in the material.
  55134. */
  55135. isRefractionEnabled: boolean;
  55136. private _isTranslucencyEnabled;
  55137. /**
  55138. * Defines if the translucency is enabled in the material.
  55139. */
  55140. isTranslucencyEnabled: boolean;
  55141. private _isScatteringEnabled;
  55142. /**
  55143. * Defines if the sub surface scattering is enabled in the material.
  55144. */
  55145. isScatteringEnabled: boolean;
  55146. private _scatteringDiffusionProfileIndex;
  55147. /**
  55148. * Diffusion profile for subsurface scattering.
  55149. * Useful for better scattering in the skins or foliages.
  55150. */
  55151. get scatteringDiffusionProfile(): Nullable<Color3>;
  55152. set scatteringDiffusionProfile(c: Nullable<Color3>);
  55153. /**
  55154. * Defines the refraction intensity of the material.
  55155. * The refraction when enabled replaces the Diffuse part of the material.
  55156. * The intensity helps transitionning between diffuse and refraction.
  55157. */
  55158. refractionIntensity: number;
  55159. /**
  55160. * Defines the translucency intensity of the material.
  55161. * When translucency has been enabled, this defines how much of the "translucency"
  55162. * is addded to the diffuse part of the material.
  55163. */
  55164. translucencyIntensity: number;
  55165. /**
  55166. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  55167. */
  55168. useAlbedoToTintRefraction: boolean;
  55169. private _thicknessTexture;
  55170. /**
  55171. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  55172. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  55173. * 0 would mean minimumThickness
  55174. * 1 would mean maximumThickness
  55175. * The other channels might be use as a mask to vary the different effects intensity.
  55176. */
  55177. thicknessTexture: Nullable<BaseTexture>;
  55178. private _refractionTexture;
  55179. /**
  55180. * Defines the texture to use for refraction.
  55181. */
  55182. refractionTexture: Nullable<BaseTexture>;
  55183. private _indexOfRefraction;
  55184. /**
  55185. * Index of refraction of the material base layer.
  55186. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55187. *
  55188. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  55189. *
  55190. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  55191. */
  55192. indexOfRefraction: number;
  55193. private _volumeIndexOfRefraction;
  55194. /**
  55195. * Index of refraction of the material's volume.
  55196. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  55197. *
  55198. * This ONLY impacts refraction. If not provided or given a non-valid value,
  55199. * the volume will use the same IOR as the surface.
  55200. */
  55201. get volumeIndexOfRefraction(): number;
  55202. set volumeIndexOfRefraction(value: number);
  55203. private _invertRefractionY;
  55204. /**
  55205. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  55206. */
  55207. invertRefractionY: boolean;
  55208. private _linkRefractionWithTransparency;
  55209. /**
  55210. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  55211. * Materials half opaque for instance using refraction could benefit from this control.
  55212. */
  55213. linkRefractionWithTransparency: boolean;
  55214. /**
  55215. * Defines the minimum thickness stored in the thickness map.
  55216. * If no thickness map is defined, this value will be used to simulate thickness.
  55217. */
  55218. minimumThickness: number;
  55219. /**
  55220. * Defines the maximum thickness stored in the thickness map.
  55221. */
  55222. maximumThickness: number;
  55223. /**
  55224. * Defines the volume tint of the material.
  55225. * This is used for both translucency and scattering.
  55226. */
  55227. tintColor: Color3;
  55228. /**
  55229. * Defines the distance at which the tint color should be found in the media.
  55230. * This is used for refraction only.
  55231. */
  55232. tintColorAtDistance: number;
  55233. /**
  55234. * Defines how far each channel transmit through the media.
  55235. * It is defined as a color to simplify it selection.
  55236. */
  55237. diffusionDistance: Color3;
  55238. private _useMaskFromThicknessTexture;
  55239. /**
  55240. * Stores the intensity of the different subsurface effects in the thickness texture.
  55241. * * the green channel is the translucency intensity.
  55242. * * the blue channel is the scattering intensity.
  55243. * * the alpha channel is the refraction intensity.
  55244. */
  55245. useMaskFromThicknessTexture: boolean;
  55246. private _scene;
  55247. /** @hidden */
  55248. private _internalMarkAllSubMeshesAsTexturesDirty;
  55249. private _internalMarkScenePrePassDirty;
  55250. /** @hidden */
  55251. _markAllSubMeshesAsTexturesDirty(): void;
  55252. /** @hidden */
  55253. _markScenePrePassDirty(): void;
  55254. /**
  55255. * Instantiate a new istance of sub surface configuration.
  55256. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55257. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  55258. * @param scene The scene
  55259. */
  55260. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  55261. /**
  55262. * Gets wehter the submesh is ready to be used or not.
  55263. * @param defines the list of "defines" to update.
  55264. * @param scene defines the scene the material belongs to.
  55265. * @returns - boolean indicating that the submesh is ready or not.
  55266. */
  55267. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  55268. /**
  55269. * Checks to see if a texture is used in the material.
  55270. * @param defines the list of "defines" to update.
  55271. * @param scene defines the scene to the material belongs to.
  55272. */
  55273. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  55274. /**
  55275. * Binds the material data.
  55276. * @param uniformBuffer defines the Uniform buffer to fill in.
  55277. * @param scene defines the scene the material belongs to.
  55278. * @param engine defines the engine the material belongs to.
  55279. * @param isFrozen defines whether the material is frozen or not.
  55280. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  55281. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  55282. */
  55283. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  55284. /**
  55285. * Unbinds the material from the mesh.
  55286. * @param activeEffect defines the effect that should be unbound from.
  55287. * @returns true if unbound, otherwise false
  55288. */
  55289. unbind(activeEffect: Effect): boolean;
  55290. /**
  55291. * Returns the texture used for refraction or null if none is used.
  55292. * @param scene defines the scene the material belongs to.
  55293. * @returns - Refraction texture if present. If no refraction texture and refraction
  55294. * is linked with transparency, returns environment texture. Otherwise, returns null.
  55295. */
  55296. private _getRefractionTexture;
  55297. /**
  55298. * Returns true if alpha blending should be disabled.
  55299. */
  55300. get disableAlphaBlending(): boolean;
  55301. /**
  55302. * Fills the list of render target textures.
  55303. * @param renderTargets the list of render targets to update
  55304. */
  55305. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  55306. /**
  55307. * Checks to see if a texture is used in the material.
  55308. * @param texture - Base texture to use.
  55309. * @returns - Boolean specifying if a texture is used in the material.
  55310. */
  55311. hasTexture(texture: BaseTexture): boolean;
  55312. /**
  55313. * Gets a boolean indicating that current material needs to register RTT
  55314. * @returns true if this uses a render target otherwise false.
  55315. */
  55316. hasRenderTargetTextures(): boolean;
  55317. /**
  55318. * Returns an array of the actively used textures.
  55319. * @param activeTextures Array of BaseTextures
  55320. */
  55321. getActiveTextures(activeTextures: BaseTexture[]): void;
  55322. /**
  55323. * Returns the animatable textures.
  55324. * @param animatables Array of animatable textures.
  55325. */
  55326. getAnimatables(animatables: IAnimatable[]): void;
  55327. /**
  55328. * Disposes the resources of the material.
  55329. * @param forceDisposeTextures - Forces the disposal of all textures.
  55330. */
  55331. dispose(forceDisposeTextures?: boolean): void;
  55332. /**
  55333. * Get the current class name of the texture useful for serialization or dynamic coding.
  55334. * @returns "PBRSubSurfaceConfiguration"
  55335. */
  55336. getClassName(): string;
  55337. /**
  55338. * Add fallbacks to the effect fallbacks list.
  55339. * @param defines defines the Base texture to use.
  55340. * @param fallbacks defines the current fallback list.
  55341. * @param currentRank defines the current fallback rank.
  55342. * @returns the new fallback rank.
  55343. */
  55344. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55345. /**
  55346. * Add the required uniforms to the current list.
  55347. * @param uniforms defines the current uniform list.
  55348. */
  55349. static AddUniforms(uniforms: string[]): void;
  55350. /**
  55351. * Add the required samplers to the current list.
  55352. * @param samplers defines the current sampler list.
  55353. */
  55354. static AddSamplers(samplers: string[]): void;
  55355. /**
  55356. * Add the required uniforms to the current buffer.
  55357. * @param uniformBuffer defines the current uniform buffer.
  55358. */
  55359. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55360. /**
  55361. * Makes a duplicate of the current configuration into another one.
  55362. * @param configuration define the config where to copy the info
  55363. */
  55364. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  55365. /**
  55366. * Serializes this Sub Surface configuration.
  55367. * @returns - An object with the serialized config.
  55368. */
  55369. serialize(): any;
  55370. /**
  55371. * Parses a anisotropy Configuration from a serialized object.
  55372. * @param source - Serialized object.
  55373. * @param scene Defines the scene we are parsing for
  55374. * @param rootUrl Defines the rootUrl to load from
  55375. */
  55376. parse(source: any, scene: Scene, rootUrl: string): void;
  55377. }
  55378. }
  55379. declare module BABYLON {
  55380. /** @hidden */
  55381. export var pbrFragmentDeclaration: {
  55382. name: string;
  55383. shader: string;
  55384. };
  55385. }
  55386. declare module BABYLON {
  55387. /** @hidden */
  55388. export var pbrUboDeclaration: {
  55389. name: string;
  55390. shader: string;
  55391. };
  55392. }
  55393. declare module BABYLON {
  55394. /** @hidden */
  55395. export var pbrFragmentExtraDeclaration: {
  55396. name: string;
  55397. shader: string;
  55398. };
  55399. }
  55400. declare module BABYLON {
  55401. /** @hidden */
  55402. export var pbrFragmentSamplersDeclaration: {
  55403. name: string;
  55404. shader: string;
  55405. };
  55406. }
  55407. declare module BABYLON {
  55408. /** @hidden */
  55409. export var importanceSampling: {
  55410. name: string;
  55411. shader: string;
  55412. };
  55413. }
  55414. declare module BABYLON {
  55415. /** @hidden */
  55416. export var pbrHelperFunctions: {
  55417. name: string;
  55418. shader: string;
  55419. };
  55420. }
  55421. declare module BABYLON {
  55422. /** @hidden */
  55423. export var harmonicsFunctions: {
  55424. name: string;
  55425. shader: string;
  55426. };
  55427. }
  55428. declare module BABYLON {
  55429. /** @hidden */
  55430. export var pbrDirectLightingSetupFunctions: {
  55431. name: string;
  55432. shader: string;
  55433. };
  55434. }
  55435. declare module BABYLON {
  55436. /** @hidden */
  55437. export var pbrDirectLightingFalloffFunctions: {
  55438. name: string;
  55439. shader: string;
  55440. };
  55441. }
  55442. declare module BABYLON {
  55443. /** @hidden */
  55444. export var pbrBRDFFunctions: {
  55445. name: string;
  55446. shader: string;
  55447. };
  55448. }
  55449. declare module BABYLON {
  55450. /** @hidden */
  55451. export var hdrFilteringFunctions: {
  55452. name: string;
  55453. shader: string;
  55454. };
  55455. }
  55456. declare module BABYLON {
  55457. /** @hidden */
  55458. export var pbrDirectLightingFunctions: {
  55459. name: string;
  55460. shader: string;
  55461. };
  55462. }
  55463. declare module BABYLON {
  55464. /** @hidden */
  55465. export var pbrIBLFunctions: {
  55466. name: string;
  55467. shader: string;
  55468. };
  55469. }
  55470. declare module BABYLON {
  55471. /** @hidden */
  55472. export var pbrBlockAlbedoOpacity: {
  55473. name: string;
  55474. shader: string;
  55475. };
  55476. }
  55477. declare module BABYLON {
  55478. /** @hidden */
  55479. export var pbrBlockReflectivity: {
  55480. name: string;
  55481. shader: string;
  55482. };
  55483. }
  55484. declare module BABYLON {
  55485. /** @hidden */
  55486. export var pbrBlockAmbientOcclusion: {
  55487. name: string;
  55488. shader: string;
  55489. };
  55490. }
  55491. declare module BABYLON {
  55492. /** @hidden */
  55493. export var pbrBlockAlphaFresnel: {
  55494. name: string;
  55495. shader: string;
  55496. };
  55497. }
  55498. declare module BABYLON {
  55499. /** @hidden */
  55500. export var pbrBlockAnisotropic: {
  55501. name: string;
  55502. shader: string;
  55503. };
  55504. }
  55505. declare module BABYLON {
  55506. /** @hidden */
  55507. export var pbrBlockReflection: {
  55508. name: string;
  55509. shader: string;
  55510. };
  55511. }
  55512. declare module BABYLON {
  55513. /** @hidden */
  55514. export var pbrBlockSheen: {
  55515. name: string;
  55516. shader: string;
  55517. };
  55518. }
  55519. declare module BABYLON {
  55520. /** @hidden */
  55521. export var pbrBlockClearcoat: {
  55522. name: string;
  55523. shader: string;
  55524. };
  55525. }
  55526. declare module BABYLON {
  55527. /** @hidden */
  55528. export var pbrBlockSubSurface: {
  55529. name: string;
  55530. shader: string;
  55531. };
  55532. }
  55533. declare module BABYLON {
  55534. /** @hidden */
  55535. export var pbrBlockNormalGeometric: {
  55536. name: string;
  55537. shader: string;
  55538. };
  55539. }
  55540. declare module BABYLON {
  55541. /** @hidden */
  55542. export var pbrBlockNormalFinal: {
  55543. name: string;
  55544. shader: string;
  55545. };
  55546. }
  55547. declare module BABYLON {
  55548. /** @hidden */
  55549. export var pbrBlockLightmapInit: {
  55550. name: string;
  55551. shader: string;
  55552. };
  55553. }
  55554. declare module BABYLON {
  55555. /** @hidden */
  55556. export var pbrBlockGeometryInfo: {
  55557. name: string;
  55558. shader: string;
  55559. };
  55560. }
  55561. declare module BABYLON {
  55562. /** @hidden */
  55563. export var pbrBlockReflectance0: {
  55564. name: string;
  55565. shader: string;
  55566. };
  55567. }
  55568. declare module BABYLON {
  55569. /** @hidden */
  55570. export var pbrBlockReflectance: {
  55571. name: string;
  55572. shader: string;
  55573. };
  55574. }
  55575. declare module BABYLON {
  55576. /** @hidden */
  55577. export var pbrBlockDirectLighting: {
  55578. name: string;
  55579. shader: string;
  55580. };
  55581. }
  55582. declare module BABYLON {
  55583. /** @hidden */
  55584. export var pbrBlockFinalLitComponents: {
  55585. name: string;
  55586. shader: string;
  55587. };
  55588. }
  55589. declare module BABYLON {
  55590. /** @hidden */
  55591. export var pbrBlockFinalUnlitComponents: {
  55592. name: string;
  55593. shader: string;
  55594. };
  55595. }
  55596. declare module BABYLON {
  55597. /** @hidden */
  55598. export var pbrBlockFinalColorComposition: {
  55599. name: string;
  55600. shader: string;
  55601. };
  55602. }
  55603. declare module BABYLON {
  55604. /** @hidden */
  55605. export var pbrBlockImageProcessing: {
  55606. name: string;
  55607. shader: string;
  55608. };
  55609. }
  55610. declare module BABYLON {
  55611. /** @hidden */
  55612. export var pbrDebug: {
  55613. name: string;
  55614. shader: string;
  55615. };
  55616. }
  55617. declare module BABYLON {
  55618. /** @hidden */
  55619. export var pbrPixelShader: {
  55620. name: string;
  55621. shader: string;
  55622. };
  55623. }
  55624. declare module BABYLON {
  55625. /** @hidden */
  55626. export var pbrVertexDeclaration: {
  55627. name: string;
  55628. shader: string;
  55629. };
  55630. }
  55631. declare module BABYLON {
  55632. /** @hidden */
  55633. export var pbrVertexShader: {
  55634. name: string;
  55635. shader: string;
  55636. };
  55637. }
  55638. declare module BABYLON {
  55639. /**
  55640. * Manages the defines for the PBR Material.
  55641. * @hidden
  55642. */
  55643. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  55644. PBR: boolean;
  55645. NUM_SAMPLES: string;
  55646. REALTIME_FILTERING: boolean;
  55647. MAINUV1: boolean;
  55648. MAINUV2: boolean;
  55649. UV1: boolean;
  55650. UV2: boolean;
  55651. ALBEDO: boolean;
  55652. GAMMAALBEDO: boolean;
  55653. ALBEDODIRECTUV: number;
  55654. VERTEXCOLOR: boolean;
  55655. DETAIL: boolean;
  55656. DETAILDIRECTUV: number;
  55657. DETAIL_NORMALBLENDMETHOD: number;
  55658. AMBIENT: boolean;
  55659. AMBIENTDIRECTUV: number;
  55660. AMBIENTINGRAYSCALE: boolean;
  55661. OPACITY: boolean;
  55662. VERTEXALPHA: boolean;
  55663. OPACITYDIRECTUV: number;
  55664. OPACITYRGB: boolean;
  55665. ALPHATEST: boolean;
  55666. DEPTHPREPASS: boolean;
  55667. ALPHABLEND: boolean;
  55668. ALPHAFROMALBEDO: boolean;
  55669. ALPHATESTVALUE: string;
  55670. SPECULAROVERALPHA: boolean;
  55671. RADIANCEOVERALPHA: boolean;
  55672. ALPHAFRESNEL: boolean;
  55673. LINEARALPHAFRESNEL: boolean;
  55674. PREMULTIPLYALPHA: boolean;
  55675. EMISSIVE: boolean;
  55676. EMISSIVEDIRECTUV: number;
  55677. REFLECTIVITY: boolean;
  55678. REFLECTIVITYDIRECTUV: number;
  55679. SPECULARTERM: boolean;
  55680. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  55681. MICROSURFACEAUTOMATIC: boolean;
  55682. LODBASEDMICROSFURACE: boolean;
  55683. MICROSURFACEMAP: boolean;
  55684. MICROSURFACEMAPDIRECTUV: number;
  55685. METALLICWORKFLOW: boolean;
  55686. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  55687. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  55688. METALLNESSSTOREINMETALMAPBLUE: boolean;
  55689. AOSTOREINMETALMAPRED: boolean;
  55690. METALLIC_REFLECTANCE: boolean;
  55691. METALLIC_REFLECTANCEDIRECTUV: number;
  55692. ENVIRONMENTBRDF: boolean;
  55693. ENVIRONMENTBRDF_RGBD: boolean;
  55694. NORMAL: boolean;
  55695. TANGENT: boolean;
  55696. BUMP: boolean;
  55697. BUMPDIRECTUV: number;
  55698. OBJECTSPACE_NORMALMAP: boolean;
  55699. PARALLAX: boolean;
  55700. PARALLAXOCCLUSION: boolean;
  55701. NORMALXYSCALE: boolean;
  55702. LIGHTMAP: boolean;
  55703. LIGHTMAPDIRECTUV: number;
  55704. USELIGHTMAPASSHADOWMAP: boolean;
  55705. GAMMALIGHTMAP: boolean;
  55706. RGBDLIGHTMAP: boolean;
  55707. REFLECTION: boolean;
  55708. REFLECTIONMAP_3D: boolean;
  55709. REFLECTIONMAP_SPHERICAL: boolean;
  55710. REFLECTIONMAP_PLANAR: boolean;
  55711. REFLECTIONMAP_CUBIC: boolean;
  55712. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  55713. REFLECTIONMAP_PROJECTION: boolean;
  55714. REFLECTIONMAP_SKYBOX: boolean;
  55715. REFLECTIONMAP_EXPLICIT: boolean;
  55716. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  55717. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  55718. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  55719. INVERTCUBICMAP: boolean;
  55720. USESPHERICALFROMREFLECTIONMAP: boolean;
  55721. USEIRRADIANCEMAP: boolean;
  55722. SPHERICAL_HARMONICS: boolean;
  55723. USESPHERICALINVERTEX: boolean;
  55724. REFLECTIONMAP_OPPOSITEZ: boolean;
  55725. LODINREFLECTIONALPHA: boolean;
  55726. GAMMAREFLECTION: boolean;
  55727. RGBDREFLECTION: boolean;
  55728. LINEARSPECULARREFLECTION: boolean;
  55729. RADIANCEOCCLUSION: boolean;
  55730. HORIZONOCCLUSION: boolean;
  55731. INSTANCES: boolean;
  55732. THIN_INSTANCES: boolean;
  55733. PREPASS: boolean;
  55734. SCENE_MRT_COUNT: number;
  55735. NUM_BONE_INFLUENCERS: number;
  55736. BonesPerMesh: number;
  55737. BONETEXTURE: boolean;
  55738. NONUNIFORMSCALING: boolean;
  55739. MORPHTARGETS: boolean;
  55740. MORPHTARGETS_NORMAL: boolean;
  55741. MORPHTARGETS_TANGENT: boolean;
  55742. MORPHTARGETS_UV: boolean;
  55743. NUM_MORPH_INFLUENCERS: number;
  55744. IMAGEPROCESSING: boolean;
  55745. VIGNETTE: boolean;
  55746. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55747. VIGNETTEBLENDMODEOPAQUE: boolean;
  55748. TONEMAPPING: boolean;
  55749. TONEMAPPING_ACES: boolean;
  55750. CONTRAST: boolean;
  55751. COLORCURVES: boolean;
  55752. COLORGRADING: boolean;
  55753. COLORGRADING3D: boolean;
  55754. SAMPLER3DGREENDEPTH: boolean;
  55755. SAMPLER3DBGRMAP: boolean;
  55756. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55757. EXPOSURE: boolean;
  55758. MULTIVIEW: boolean;
  55759. USEPHYSICALLIGHTFALLOFF: boolean;
  55760. USEGLTFLIGHTFALLOFF: boolean;
  55761. TWOSIDEDLIGHTING: boolean;
  55762. SHADOWFLOAT: boolean;
  55763. CLIPPLANE: boolean;
  55764. CLIPPLANE2: boolean;
  55765. CLIPPLANE3: boolean;
  55766. CLIPPLANE4: boolean;
  55767. CLIPPLANE5: boolean;
  55768. CLIPPLANE6: boolean;
  55769. POINTSIZE: boolean;
  55770. FOG: boolean;
  55771. LOGARITHMICDEPTH: boolean;
  55772. FORCENORMALFORWARD: boolean;
  55773. SPECULARAA: boolean;
  55774. CLEARCOAT: boolean;
  55775. CLEARCOAT_DEFAULTIOR: boolean;
  55776. CLEARCOAT_TEXTURE: boolean;
  55777. CLEARCOAT_TEXTUREDIRECTUV: number;
  55778. CLEARCOAT_BUMP: boolean;
  55779. CLEARCOAT_BUMPDIRECTUV: number;
  55780. CLEARCOAT_TINT: boolean;
  55781. CLEARCOAT_TINT_TEXTURE: boolean;
  55782. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  55783. ANISOTROPIC: boolean;
  55784. ANISOTROPIC_TEXTURE: boolean;
  55785. ANISOTROPIC_TEXTUREDIRECTUV: number;
  55786. BRDF_V_HEIGHT_CORRELATED: boolean;
  55787. MS_BRDF_ENERGY_CONSERVATION: boolean;
  55788. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  55789. SHEEN: boolean;
  55790. SHEEN_TEXTURE: boolean;
  55791. SHEEN_TEXTUREDIRECTUV: number;
  55792. SHEEN_LINKWITHALBEDO: boolean;
  55793. SHEEN_ROUGHNESS: boolean;
  55794. SHEEN_ALBEDOSCALING: boolean;
  55795. SUBSURFACE: boolean;
  55796. SS_REFRACTION: boolean;
  55797. SS_TRANSLUCENCY: boolean;
  55798. SS_SCATTERING: boolean;
  55799. SS_THICKNESSANDMASK_TEXTURE: boolean;
  55800. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  55801. SS_REFRACTIONMAP_3D: boolean;
  55802. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  55803. SS_LODINREFRACTIONALPHA: boolean;
  55804. SS_GAMMAREFRACTION: boolean;
  55805. SS_RGBDREFRACTION: boolean;
  55806. SS_LINEARSPECULARREFRACTION: boolean;
  55807. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  55808. SS_ALBEDOFORREFRACTIONTINT: boolean;
  55809. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  55810. UNLIT: boolean;
  55811. DEBUGMODE: number;
  55812. /**
  55813. * Initializes the PBR Material defines.
  55814. */
  55815. constructor();
  55816. /**
  55817. * Resets the PBR Material defines.
  55818. */
  55819. reset(): void;
  55820. }
  55821. /**
  55822. * The Physically based material base class of BJS.
  55823. *
  55824. * This offers the main features of a standard PBR material.
  55825. * For more information, please refer to the documentation :
  55826. * https://doc.babylonjs.com/how_to/physically_based_rendering
  55827. */
  55828. export abstract class PBRBaseMaterial extends PushMaterial {
  55829. /**
  55830. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  55831. */
  55832. static readonly PBRMATERIAL_OPAQUE: number;
  55833. /**
  55834. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  55835. */
  55836. static readonly PBRMATERIAL_ALPHATEST: number;
  55837. /**
  55838. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55839. */
  55840. static readonly PBRMATERIAL_ALPHABLEND: number;
  55841. /**
  55842. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  55843. * They are also discarded below the alpha cutoff threshold to improve performances.
  55844. */
  55845. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  55846. /**
  55847. * Defines the default value of how much AO map is occluding the analytical lights
  55848. * (point spot...).
  55849. */
  55850. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  55851. /**
  55852. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  55853. */
  55854. static readonly LIGHTFALLOFF_PHYSICAL: number;
  55855. /**
  55856. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  55857. * to enhance interoperability with other engines.
  55858. */
  55859. static readonly LIGHTFALLOFF_GLTF: number;
  55860. /**
  55861. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  55862. * to enhance interoperability with other materials.
  55863. */
  55864. static readonly LIGHTFALLOFF_STANDARD: number;
  55865. /**
  55866. * Intensity of the direct lights e.g. the four lights available in your scene.
  55867. * This impacts both the direct diffuse and specular highlights.
  55868. */
  55869. protected _directIntensity: number;
  55870. /**
  55871. * Intensity of the emissive part of the material.
  55872. * This helps controlling the emissive effect without modifying the emissive color.
  55873. */
  55874. protected _emissiveIntensity: number;
  55875. /**
  55876. * Intensity of the environment e.g. how much the environment will light the object
  55877. * either through harmonics for rough material or through the refelction for shiny ones.
  55878. */
  55879. protected _environmentIntensity: number;
  55880. /**
  55881. * This is a special control allowing the reduction of the specular highlights coming from the
  55882. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  55883. */
  55884. protected _specularIntensity: number;
  55885. /**
  55886. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  55887. */
  55888. private _lightingInfos;
  55889. /**
  55890. * Debug Control allowing disabling the bump map on this material.
  55891. */
  55892. protected _disableBumpMap: boolean;
  55893. /**
  55894. * AKA Diffuse Texture in standard nomenclature.
  55895. */
  55896. protected _albedoTexture: Nullable<BaseTexture>;
  55897. /**
  55898. * AKA Occlusion Texture in other nomenclature.
  55899. */
  55900. protected _ambientTexture: Nullable<BaseTexture>;
  55901. /**
  55902. * AKA Occlusion Texture Intensity in other nomenclature.
  55903. */
  55904. protected _ambientTextureStrength: number;
  55905. /**
  55906. * Defines how much the AO map is occluding the analytical lights (point spot...).
  55907. * 1 means it completely occludes it
  55908. * 0 mean it has no impact
  55909. */
  55910. protected _ambientTextureImpactOnAnalyticalLights: number;
  55911. /**
  55912. * Stores the alpha values in a texture.
  55913. */
  55914. protected _opacityTexture: Nullable<BaseTexture>;
  55915. /**
  55916. * Stores the reflection values in a texture.
  55917. */
  55918. protected _reflectionTexture: Nullable<BaseTexture>;
  55919. /**
  55920. * Stores the emissive values in a texture.
  55921. */
  55922. protected _emissiveTexture: Nullable<BaseTexture>;
  55923. /**
  55924. * AKA Specular texture in other nomenclature.
  55925. */
  55926. protected _reflectivityTexture: Nullable<BaseTexture>;
  55927. /**
  55928. * Used to switch from specular/glossiness to metallic/roughness workflow.
  55929. */
  55930. protected _metallicTexture: Nullable<BaseTexture>;
  55931. /**
  55932. * Specifies the metallic scalar of the metallic/roughness workflow.
  55933. * Can also be used to scale the metalness values of the metallic texture.
  55934. */
  55935. protected _metallic: Nullable<number>;
  55936. /**
  55937. * Specifies the roughness scalar of the metallic/roughness workflow.
  55938. * Can also be used to scale the roughness values of the metallic texture.
  55939. */
  55940. protected _roughness: Nullable<number>;
  55941. /**
  55942. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  55943. * By default the indexOfrefraction is used to compute F0;
  55944. *
  55945. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  55946. *
  55947. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  55948. * F90 = metallicReflectanceColor;
  55949. */
  55950. protected _metallicF0Factor: number;
  55951. /**
  55952. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  55953. * By default the F90 is always 1;
  55954. *
  55955. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  55956. *
  55957. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  55958. * F90 = metallicReflectanceColor;
  55959. */
  55960. protected _metallicReflectanceColor: Color3;
  55961. /**
  55962. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  55963. * This is multiply against the scalar values defined in the material.
  55964. */
  55965. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  55966. /**
  55967. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  55968. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  55969. */
  55970. protected _microSurfaceTexture: Nullable<BaseTexture>;
  55971. /**
  55972. * Stores surface normal data used to displace a mesh in a texture.
  55973. */
  55974. protected _bumpTexture: Nullable<BaseTexture>;
  55975. /**
  55976. * Stores the pre-calculated light information of a mesh in a texture.
  55977. */
  55978. protected _lightmapTexture: Nullable<BaseTexture>;
  55979. /**
  55980. * The color of a material in ambient lighting.
  55981. */
  55982. protected _ambientColor: Color3;
  55983. /**
  55984. * AKA Diffuse Color in other nomenclature.
  55985. */
  55986. protected _albedoColor: Color3;
  55987. /**
  55988. * AKA Specular Color in other nomenclature.
  55989. */
  55990. protected _reflectivityColor: Color3;
  55991. /**
  55992. * The color applied when light is reflected from a material.
  55993. */
  55994. protected _reflectionColor: Color3;
  55995. /**
  55996. * The color applied when light is emitted from a material.
  55997. */
  55998. protected _emissiveColor: Color3;
  55999. /**
  56000. * AKA Glossiness in other nomenclature.
  56001. */
  56002. protected _microSurface: number;
  56003. /**
  56004. * Specifies that the material will use the light map as a show map.
  56005. */
  56006. protected _useLightmapAsShadowmap: boolean;
  56007. /**
  56008. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  56009. * makes the reflect vector face the model (under horizon).
  56010. */
  56011. protected _useHorizonOcclusion: boolean;
  56012. /**
  56013. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  56014. * too much the area relying on ambient texture to define their ambient occlusion.
  56015. */
  56016. protected _useRadianceOcclusion: boolean;
  56017. /**
  56018. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  56019. */
  56020. protected _useAlphaFromAlbedoTexture: boolean;
  56021. /**
  56022. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  56023. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  56024. */
  56025. protected _useSpecularOverAlpha: boolean;
  56026. /**
  56027. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  56028. */
  56029. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  56030. /**
  56031. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  56032. */
  56033. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  56034. /**
  56035. * Specifies if the metallic texture contains the roughness information in its green channel.
  56036. */
  56037. protected _useRoughnessFromMetallicTextureGreen: boolean;
  56038. /**
  56039. * Specifies if the metallic texture contains the metallness information in its blue channel.
  56040. */
  56041. protected _useMetallnessFromMetallicTextureBlue: boolean;
  56042. /**
  56043. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  56044. */
  56045. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  56046. /**
  56047. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  56048. */
  56049. protected _useAmbientInGrayScale: boolean;
  56050. /**
  56051. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  56052. * The material will try to infer what glossiness each pixel should be.
  56053. */
  56054. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  56055. /**
  56056. * Defines the falloff type used in this material.
  56057. * It by default is Physical.
  56058. */
  56059. protected _lightFalloff: number;
  56060. /**
  56061. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  56062. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  56063. */
  56064. protected _useRadianceOverAlpha: boolean;
  56065. /**
  56066. * Allows using an object space normal map (instead of tangent space).
  56067. */
  56068. protected _useObjectSpaceNormalMap: boolean;
  56069. /**
  56070. * Allows using the bump map in parallax mode.
  56071. */
  56072. protected _useParallax: boolean;
  56073. /**
  56074. * Allows using the bump map in parallax occlusion mode.
  56075. */
  56076. protected _useParallaxOcclusion: boolean;
  56077. /**
  56078. * Controls the scale bias of the parallax mode.
  56079. */
  56080. protected _parallaxScaleBias: number;
  56081. /**
  56082. * If sets to true, disables all the lights affecting the material.
  56083. */
  56084. protected _disableLighting: boolean;
  56085. /**
  56086. * Number of Simultaneous lights allowed on the material.
  56087. */
  56088. protected _maxSimultaneousLights: number;
  56089. /**
  56090. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  56091. */
  56092. protected _invertNormalMapX: boolean;
  56093. /**
  56094. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  56095. */
  56096. protected _invertNormalMapY: boolean;
  56097. /**
  56098. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56099. */
  56100. protected _twoSidedLighting: boolean;
  56101. /**
  56102. * Defines the alpha limits in alpha test mode.
  56103. */
  56104. protected _alphaCutOff: number;
  56105. /**
  56106. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  56107. */
  56108. protected _forceAlphaTest: boolean;
  56109. /**
  56110. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56111. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  56112. */
  56113. protected _useAlphaFresnel: boolean;
  56114. /**
  56115. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56116. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  56117. */
  56118. protected _useLinearAlphaFresnel: boolean;
  56119. /**
  56120. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  56121. * from cos thetav and roughness:
  56122. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  56123. */
  56124. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  56125. /**
  56126. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  56127. */
  56128. protected _forceIrradianceInFragment: boolean;
  56129. private _realTimeFiltering;
  56130. /**
  56131. * Enables realtime filtering on the texture.
  56132. */
  56133. get realTimeFiltering(): boolean;
  56134. set realTimeFiltering(b: boolean);
  56135. private _realTimeFilteringQuality;
  56136. /**
  56137. * Quality switch for realtime filtering
  56138. */
  56139. get realTimeFilteringQuality(): number;
  56140. set realTimeFilteringQuality(n: number);
  56141. /**
  56142. * Can this material render to several textures at once
  56143. */
  56144. get canRenderToMRT(): boolean;
  56145. /**
  56146. * Force normal to face away from face.
  56147. */
  56148. protected _forceNormalForward: boolean;
  56149. /**
  56150. * Enables specular anti aliasing in the PBR shader.
  56151. * It will both interacts on the Geometry for analytical and IBL lighting.
  56152. * It also prefilter the roughness map based on the bump values.
  56153. */
  56154. protected _enableSpecularAntiAliasing: boolean;
  56155. /**
  56156. * Default configuration related to image processing available in the PBR Material.
  56157. */
  56158. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  56159. /**
  56160. * Keep track of the image processing observer to allow dispose and replace.
  56161. */
  56162. private _imageProcessingObserver;
  56163. /**
  56164. * Attaches a new image processing configuration to the PBR Material.
  56165. * @param configuration
  56166. */
  56167. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  56168. /**
  56169. * Stores the available render targets.
  56170. */
  56171. private _renderTargets;
  56172. /**
  56173. * Sets the global ambient color for the material used in lighting calculations.
  56174. */
  56175. private _globalAmbientColor;
  56176. /**
  56177. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  56178. */
  56179. private _useLogarithmicDepth;
  56180. /**
  56181. * If set to true, no lighting calculations will be applied.
  56182. */
  56183. private _unlit;
  56184. private _debugMode;
  56185. /**
  56186. * @hidden
  56187. * This is reserved for the inspector.
  56188. * Defines the material debug mode.
  56189. * It helps seeing only some components of the material while troubleshooting.
  56190. */
  56191. debugMode: number;
  56192. /**
  56193. * @hidden
  56194. * This is reserved for the inspector.
  56195. * Specify from where on screen the debug mode should start.
  56196. * The value goes from -1 (full screen) to 1 (not visible)
  56197. * It helps with side by side comparison against the final render
  56198. * This defaults to -1
  56199. */
  56200. private debugLimit;
  56201. /**
  56202. * @hidden
  56203. * This is reserved for the inspector.
  56204. * As the default viewing range might not be enough (if the ambient is really small for instance)
  56205. * You can use the factor to better multiply the final value.
  56206. */
  56207. private debugFactor;
  56208. /**
  56209. * Defines the clear coat layer parameters for the material.
  56210. */
  56211. readonly clearCoat: PBRClearCoatConfiguration;
  56212. /**
  56213. * Defines the anisotropic parameters for the material.
  56214. */
  56215. readonly anisotropy: PBRAnisotropicConfiguration;
  56216. /**
  56217. * Defines the BRDF parameters for the material.
  56218. */
  56219. readonly brdf: PBRBRDFConfiguration;
  56220. /**
  56221. * Defines the Sheen parameters for the material.
  56222. */
  56223. readonly sheen: PBRSheenConfiguration;
  56224. /**
  56225. * Defines the SubSurface parameters for the material.
  56226. */
  56227. readonly subSurface: PBRSubSurfaceConfiguration;
  56228. /**
  56229. * Defines the detail map parameters for the material.
  56230. */
  56231. readonly detailMap: DetailMapConfiguration;
  56232. protected _rebuildInParallel: boolean;
  56233. /**
  56234. * Instantiates a new PBRMaterial instance.
  56235. *
  56236. * @param name The material name
  56237. * @param scene The scene the material will be use in.
  56238. */
  56239. constructor(name: string, scene: Scene);
  56240. /**
  56241. * Gets a boolean indicating that current material needs to register RTT
  56242. */
  56243. get hasRenderTargetTextures(): boolean;
  56244. /**
  56245. * Gets the name of the material class.
  56246. */
  56247. getClassName(): string;
  56248. /**
  56249. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  56250. */
  56251. get useLogarithmicDepth(): boolean;
  56252. /**
  56253. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  56254. */
  56255. set useLogarithmicDepth(value: boolean);
  56256. /**
  56257. * Returns true if alpha blending should be disabled.
  56258. */
  56259. protected get _disableAlphaBlending(): boolean;
  56260. /**
  56261. * Specifies whether or not this material should be rendered in alpha blend mode.
  56262. */
  56263. needAlphaBlending(): boolean;
  56264. /**
  56265. * Specifies whether or not this material should be rendered in alpha test mode.
  56266. */
  56267. needAlphaTesting(): boolean;
  56268. /**
  56269. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  56270. */
  56271. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  56272. /**
  56273. * Gets the texture used for the alpha test.
  56274. */
  56275. getAlphaTestTexture(): Nullable<BaseTexture>;
  56276. /**
  56277. * Specifies that the submesh is ready to be used.
  56278. * @param mesh - BJS mesh.
  56279. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  56280. * @param useInstances - Specifies that instances should be used.
  56281. * @returns - boolean indicating that the submesh is ready or not.
  56282. */
  56283. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  56284. /**
  56285. * Specifies if the material uses metallic roughness workflow.
  56286. * @returns boolean specifiying if the material uses metallic roughness workflow.
  56287. */
  56288. isMetallicWorkflow(): boolean;
  56289. private _prepareEffect;
  56290. private _prepareDefines;
  56291. /**
  56292. * Force shader compilation
  56293. */
  56294. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  56295. /**
  56296. * Initializes the uniform buffer layout for the shader.
  56297. */
  56298. buildUniformLayout(): void;
  56299. /**
  56300. * Unbinds the material from the mesh
  56301. */
  56302. unbind(): void;
  56303. /**
  56304. * Binds the submesh data.
  56305. * @param world - The world matrix.
  56306. * @param mesh - The BJS mesh.
  56307. * @param subMesh - A submesh of the BJS mesh.
  56308. */
  56309. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  56310. /**
  56311. * Returns the animatable textures.
  56312. * @returns - Array of animatable textures.
  56313. */
  56314. getAnimatables(): IAnimatable[];
  56315. /**
  56316. * Returns the texture used for reflections.
  56317. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  56318. */
  56319. private _getReflectionTexture;
  56320. /**
  56321. * Returns an array of the actively used textures.
  56322. * @returns - Array of BaseTextures
  56323. */
  56324. getActiveTextures(): BaseTexture[];
  56325. /**
  56326. * Checks to see if a texture is used in the material.
  56327. * @param texture - Base texture to use.
  56328. * @returns - Boolean specifying if a texture is used in the material.
  56329. */
  56330. hasTexture(texture: BaseTexture): boolean;
  56331. /**
  56332. * Sets the required values to the prepass renderer.
  56333. * @param prePassRenderer defines the prepass renderer to setup
  56334. */
  56335. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  56336. /**
  56337. * Disposes the resources of the material.
  56338. * @param forceDisposeEffect - Forces the disposal of effects.
  56339. * @param forceDisposeTextures - Forces the disposal of all textures.
  56340. */
  56341. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  56342. }
  56343. }
  56344. declare module BABYLON {
  56345. /**
  56346. * The Physically based material of BJS.
  56347. *
  56348. * This offers the main features of a standard PBR material.
  56349. * For more information, please refer to the documentation :
  56350. * https://doc.babylonjs.com/how_to/physically_based_rendering
  56351. */
  56352. export class PBRMaterial extends PBRBaseMaterial {
  56353. /**
  56354. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  56355. */
  56356. static readonly PBRMATERIAL_OPAQUE: number;
  56357. /**
  56358. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  56359. */
  56360. static readonly PBRMATERIAL_ALPHATEST: number;
  56361. /**
  56362. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56363. */
  56364. static readonly PBRMATERIAL_ALPHABLEND: number;
  56365. /**
  56366. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56367. * They are also discarded below the alpha cutoff threshold to improve performances.
  56368. */
  56369. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  56370. /**
  56371. * Defines the default value of how much AO map is occluding the analytical lights
  56372. * (point spot...).
  56373. */
  56374. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  56375. /**
  56376. * Intensity of the direct lights e.g. the four lights available in your scene.
  56377. * This impacts both the direct diffuse and specular highlights.
  56378. */
  56379. directIntensity: number;
  56380. /**
  56381. * Intensity of the emissive part of the material.
  56382. * This helps controlling the emissive effect without modifying the emissive color.
  56383. */
  56384. emissiveIntensity: number;
  56385. /**
  56386. * Intensity of the environment e.g. how much the environment will light the object
  56387. * either through harmonics for rough material or through the refelction for shiny ones.
  56388. */
  56389. environmentIntensity: number;
  56390. /**
  56391. * This is a special control allowing the reduction of the specular highlights coming from the
  56392. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  56393. */
  56394. specularIntensity: number;
  56395. /**
  56396. * Debug Control allowing disabling the bump map on this material.
  56397. */
  56398. disableBumpMap: boolean;
  56399. /**
  56400. * AKA Diffuse Texture in standard nomenclature.
  56401. */
  56402. albedoTexture: BaseTexture;
  56403. /**
  56404. * AKA Occlusion Texture in other nomenclature.
  56405. */
  56406. ambientTexture: BaseTexture;
  56407. /**
  56408. * AKA Occlusion Texture Intensity in other nomenclature.
  56409. */
  56410. ambientTextureStrength: number;
  56411. /**
  56412. * Defines how much the AO map is occluding the analytical lights (point spot...).
  56413. * 1 means it completely occludes it
  56414. * 0 mean it has no impact
  56415. */
  56416. ambientTextureImpactOnAnalyticalLights: number;
  56417. /**
  56418. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  56419. */
  56420. opacityTexture: BaseTexture;
  56421. /**
  56422. * Stores the reflection values in a texture.
  56423. */
  56424. reflectionTexture: Nullable<BaseTexture>;
  56425. /**
  56426. * Stores the emissive values in a texture.
  56427. */
  56428. emissiveTexture: BaseTexture;
  56429. /**
  56430. * AKA Specular texture in other nomenclature.
  56431. */
  56432. reflectivityTexture: BaseTexture;
  56433. /**
  56434. * Used to switch from specular/glossiness to metallic/roughness workflow.
  56435. */
  56436. metallicTexture: BaseTexture;
  56437. /**
  56438. * Specifies the metallic scalar of the metallic/roughness workflow.
  56439. * Can also be used to scale the metalness values of the metallic texture.
  56440. */
  56441. metallic: Nullable<number>;
  56442. /**
  56443. * Specifies the roughness scalar of the metallic/roughness workflow.
  56444. * Can also be used to scale the roughness values of the metallic texture.
  56445. */
  56446. roughness: Nullable<number>;
  56447. /**
  56448. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  56449. * By default the indexOfrefraction is used to compute F0;
  56450. *
  56451. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  56452. *
  56453. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  56454. * F90 = metallicReflectanceColor;
  56455. */
  56456. metallicF0Factor: number;
  56457. /**
  56458. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  56459. * By default the F90 is always 1;
  56460. *
  56461. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  56462. *
  56463. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  56464. * F90 = metallicReflectanceColor;
  56465. */
  56466. metallicReflectanceColor: Color3;
  56467. /**
  56468. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  56469. * This is multiply against the scalar values defined in the material.
  56470. */
  56471. metallicReflectanceTexture: Nullable<BaseTexture>;
  56472. /**
  56473. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  56474. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  56475. */
  56476. microSurfaceTexture: BaseTexture;
  56477. /**
  56478. * Stores surface normal data used to displace a mesh in a texture.
  56479. */
  56480. bumpTexture: BaseTexture;
  56481. /**
  56482. * Stores the pre-calculated light information of a mesh in a texture.
  56483. */
  56484. lightmapTexture: BaseTexture;
  56485. /**
  56486. * Stores the refracted light information in a texture.
  56487. */
  56488. get refractionTexture(): Nullable<BaseTexture>;
  56489. set refractionTexture(value: Nullable<BaseTexture>);
  56490. /**
  56491. * The color of a material in ambient lighting.
  56492. */
  56493. ambientColor: Color3;
  56494. /**
  56495. * AKA Diffuse Color in other nomenclature.
  56496. */
  56497. albedoColor: Color3;
  56498. /**
  56499. * AKA Specular Color in other nomenclature.
  56500. */
  56501. reflectivityColor: Color3;
  56502. /**
  56503. * The color reflected from the material.
  56504. */
  56505. reflectionColor: Color3;
  56506. /**
  56507. * The color emitted from the material.
  56508. */
  56509. emissiveColor: Color3;
  56510. /**
  56511. * AKA Glossiness in other nomenclature.
  56512. */
  56513. microSurface: number;
  56514. /**
  56515. * Index of refraction of the material base layer.
  56516. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  56517. *
  56518. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  56519. *
  56520. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  56521. */
  56522. get indexOfRefraction(): number;
  56523. set indexOfRefraction(value: number);
  56524. /**
  56525. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  56526. */
  56527. get invertRefractionY(): boolean;
  56528. set invertRefractionY(value: boolean);
  56529. /**
  56530. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  56531. * Materials half opaque for instance using refraction could benefit from this control.
  56532. */
  56533. get linkRefractionWithTransparency(): boolean;
  56534. set linkRefractionWithTransparency(value: boolean);
  56535. /**
  56536. * If true, the light map contains occlusion information instead of lighting info.
  56537. */
  56538. useLightmapAsShadowmap: boolean;
  56539. /**
  56540. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  56541. */
  56542. useAlphaFromAlbedoTexture: boolean;
  56543. /**
  56544. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  56545. */
  56546. forceAlphaTest: boolean;
  56547. /**
  56548. * Defines the alpha limits in alpha test mode.
  56549. */
  56550. alphaCutOff: number;
  56551. /**
  56552. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  56553. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  56554. */
  56555. useSpecularOverAlpha: boolean;
  56556. /**
  56557. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  56558. */
  56559. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  56560. /**
  56561. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  56562. */
  56563. useRoughnessFromMetallicTextureAlpha: boolean;
  56564. /**
  56565. * Specifies if the metallic texture contains the roughness information in its green channel.
  56566. */
  56567. useRoughnessFromMetallicTextureGreen: boolean;
  56568. /**
  56569. * Specifies if the metallic texture contains the metallness information in its blue channel.
  56570. */
  56571. useMetallnessFromMetallicTextureBlue: boolean;
  56572. /**
  56573. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  56574. */
  56575. useAmbientOcclusionFromMetallicTextureRed: boolean;
  56576. /**
  56577. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  56578. */
  56579. useAmbientInGrayScale: boolean;
  56580. /**
  56581. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  56582. * The material will try to infer what glossiness each pixel should be.
  56583. */
  56584. useAutoMicroSurfaceFromReflectivityMap: boolean;
  56585. /**
  56586. * BJS is using an harcoded light falloff based on a manually sets up range.
  56587. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  56588. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  56589. */
  56590. get usePhysicalLightFalloff(): boolean;
  56591. /**
  56592. * BJS is using an harcoded light falloff based on a manually sets up range.
  56593. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  56594. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  56595. */
  56596. set usePhysicalLightFalloff(value: boolean);
  56597. /**
  56598. * In order to support the falloff compatibility with gltf, a special mode has been added
  56599. * to reproduce the gltf light falloff.
  56600. */
  56601. get useGLTFLightFalloff(): boolean;
  56602. /**
  56603. * In order to support the falloff compatibility with gltf, a special mode has been added
  56604. * to reproduce the gltf light falloff.
  56605. */
  56606. set useGLTFLightFalloff(value: boolean);
  56607. /**
  56608. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  56609. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  56610. */
  56611. useRadianceOverAlpha: boolean;
  56612. /**
  56613. * Allows using an object space normal map (instead of tangent space).
  56614. */
  56615. useObjectSpaceNormalMap: boolean;
  56616. /**
  56617. * Allows using the bump map in parallax mode.
  56618. */
  56619. useParallax: boolean;
  56620. /**
  56621. * Allows using the bump map in parallax occlusion mode.
  56622. */
  56623. useParallaxOcclusion: boolean;
  56624. /**
  56625. * Controls the scale bias of the parallax mode.
  56626. */
  56627. parallaxScaleBias: number;
  56628. /**
  56629. * If sets to true, disables all the lights affecting the material.
  56630. */
  56631. disableLighting: boolean;
  56632. /**
  56633. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  56634. */
  56635. forceIrradianceInFragment: boolean;
  56636. /**
  56637. * Number of Simultaneous lights allowed on the material.
  56638. */
  56639. maxSimultaneousLights: number;
  56640. /**
  56641. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  56642. */
  56643. invertNormalMapX: boolean;
  56644. /**
  56645. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  56646. */
  56647. invertNormalMapY: boolean;
  56648. /**
  56649. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  56650. */
  56651. twoSidedLighting: boolean;
  56652. /**
  56653. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56654. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  56655. */
  56656. useAlphaFresnel: boolean;
  56657. /**
  56658. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  56659. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  56660. */
  56661. useLinearAlphaFresnel: boolean;
  56662. /**
  56663. * Let user defines the brdf lookup texture used for IBL.
  56664. * A default 8bit version is embedded but you could point at :
  56665. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  56666. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  56667. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  56668. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  56669. */
  56670. environmentBRDFTexture: Nullable<BaseTexture>;
  56671. /**
  56672. * Force normal to face away from face.
  56673. */
  56674. forceNormalForward: boolean;
  56675. /**
  56676. * Enables specular anti aliasing in the PBR shader.
  56677. * It will both interacts on the Geometry for analytical and IBL lighting.
  56678. * It also prefilter the roughness map based on the bump values.
  56679. */
  56680. enableSpecularAntiAliasing: boolean;
  56681. /**
  56682. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  56683. * makes the reflect vector face the model (under horizon).
  56684. */
  56685. useHorizonOcclusion: boolean;
  56686. /**
  56687. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  56688. * too much the area relying on ambient texture to define their ambient occlusion.
  56689. */
  56690. useRadianceOcclusion: boolean;
  56691. /**
  56692. * If set to true, no lighting calculations will be applied.
  56693. */
  56694. unlit: boolean;
  56695. /**
  56696. * Gets the image processing configuration used either in this material.
  56697. */
  56698. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  56699. /**
  56700. * Sets the Default image processing configuration used either in the this material.
  56701. *
  56702. * If sets to null, the scene one is in use.
  56703. */
  56704. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  56705. /**
  56706. * Gets wether the color curves effect is enabled.
  56707. */
  56708. get cameraColorCurvesEnabled(): boolean;
  56709. /**
  56710. * Sets wether the color curves effect is enabled.
  56711. */
  56712. set cameraColorCurvesEnabled(value: boolean);
  56713. /**
  56714. * Gets wether the color grading effect is enabled.
  56715. */
  56716. get cameraColorGradingEnabled(): boolean;
  56717. /**
  56718. * Gets wether the color grading effect is enabled.
  56719. */
  56720. set cameraColorGradingEnabled(value: boolean);
  56721. /**
  56722. * Gets wether tonemapping is enabled or not.
  56723. */
  56724. get cameraToneMappingEnabled(): boolean;
  56725. /**
  56726. * Sets wether tonemapping is enabled or not
  56727. */
  56728. set cameraToneMappingEnabled(value: boolean);
  56729. /**
  56730. * The camera exposure used on this material.
  56731. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56732. * This corresponds to a photographic exposure.
  56733. */
  56734. get cameraExposure(): number;
  56735. /**
  56736. * The camera exposure used on this material.
  56737. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  56738. * This corresponds to a photographic exposure.
  56739. */
  56740. set cameraExposure(value: number);
  56741. /**
  56742. * Gets The camera contrast used on this material.
  56743. */
  56744. get cameraContrast(): number;
  56745. /**
  56746. * Sets The camera contrast used on this material.
  56747. */
  56748. set cameraContrast(value: number);
  56749. /**
  56750. * Gets the Color Grading 2D Lookup Texture.
  56751. */
  56752. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  56753. /**
  56754. * Sets the Color Grading 2D Lookup Texture.
  56755. */
  56756. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  56757. /**
  56758. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56759. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56760. * 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;
  56761. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56762. */
  56763. get cameraColorCurves(): Nullable<ColorCurves>;
  56764. /**
  56765. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  56766. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  56767. * 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;
  56768. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  56769. */
  56770. set cameraColorCurves(value: Nullable<ColorCurves>);
  56771. /**
  56772. * Instantiates a new PBRMaterial instance.
  56773. *
  56774. * @param name The material name
  56775. * @param scene The scene the material will be use in.
  56776. */
  56777. constructor(name: string, scene: Scene);
  56778. /**
  56779. * Returns the name of this material class.
  56780. */
  56781. getClassName(): string;
  56782. /**
  56783. * Makes a duplicate of the current material.
  56784. * @param name - name to use for the new material.
  56785. */
  56786. clone(name: string): PBRMaterial;
  56787. /**
  56788. * Serializes this PBR Material.
  56789. * @returns - An object with the serialized material.
  56790. */
  56791. serialize(): any;
  56792. /**
  56793. * Parses a PBR Material from a serialized object.
  56794. * @param source - Serialized object.
  56795. * @param scene - BJS scene instance.
  56796. * @param rootUrl - url for the scene object
  56797. * @returns - PBRMaterial
  56798. */
  56799. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  56800. }
  56801. }
  56802. declare module BABYLON {
  56803. /**
  56804. * Direct draw surface info
  56805. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  56806. */
  56807. export interface DDSInfo {
  56808. /**
  56809. * Width of the texture
  56810. */
  56811. width: number;
  56812. /**
  56813. * Width of the texture
  56814. */
  56815. height: number;
  56816. /**
  56817. * Number of Mipmaps for the texture
  56818. * @see https://en.wikipedia.org/wiki/Mipmap
  56819. */
  56820. mipmapCount: number;
  56821. /**
  56822. * If the textures format is a known fourCC format
  56823. * @see https://www.fourcc.org/
  56824. */
  56825. isFourCC: boolean;
  56826. /**
  56827. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  56828. */
  56829. isRGB: boolean;
  56830. /**
  56831. * If the texture is a lumincance format
  56832. */
  56833. isLuminance: boolean;
  56834. /**
  56835. * If this is a cube texture
  56836. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  56837. */
  56838. isCube: boolean;
  56839. /**
  56840. * If the texture is a compressed format eg. FOURCC_DXT1
  56841. */
  56842. isCompressed: boolean;
  56843. /**
  56844. * The dxgiFormat of the texture
  56845. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  56846. */
  56847. dxgiFormat: number;
  56848. /**
  56849. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  56850. */
  56851. textureType: number;
  56852. /**
  56853. * Sphericle polynomial created for the dds texture
  56854. */
  56855. sphericalPolynomial?: SphericalPolynomial;
  56856. }
  56857. /**
  56858. * Class used to provide DDS decompression tools
  56859. */
  56860. export class DDSTools {
  56861. /**
  56862. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  56863. */
  56864. static StoreLODInAlphaChannel: boolean;
  56865. /**
  56866. * Gets DDS information from an array buffer
  56867. * @param data defines the array buffer view to read data from
  56868. * @returns the DDS information
  56869. */
  56870. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  56871. private static _FloatView;
  56872. private static _Int32View;
  56873. private static _ToHalfFloat;
  56874. private static _FromHalfFloat;
  56875. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  56876. private static _GetHalfFloatRGBAArrayBuffer;
  56877. private static _GetFloatRGBAArrayBuffer;
  56878. private static _GetFloatAsUIntRGBAArrayBuffer;
  56879. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  56880. private static _GetRGBAArrayBuffer;
  56881. private static _ExtractLongWordOrder;
  56882. private static _GetRGBArrayBuffer;
  56883. private static _GetLuminanceArrayBuffer;
  56884. /**
  56885. * Uploads DDS Levels to a Babylon Texture
  56886. * @hidden
  56887. */
  56888. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  56889. }
  56890. interface ThinEngine {
  56891. /**
  56892. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  56893. * @param rootUrl defines the url where the file to load is located
  56894. * @param scene defines the current scene
  56895. * @param lodScale defines scale to apply to the mip map selection
  56896. * @param lodOffset defines offset to apply to the mip map selection
  56897. * @param onLoad defines an optional callback raised when the texture is loaded
  56898. * @param onError defines an optional callback raised if there is an issue to load the texture
  56899. * @param format defines the format of the data
  56900. * @param forcedExtension defines the extension to use to pick the right loader
  56901. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  56902. * @returns the cube texture as an InternalTexture
  56903. */
  56904. 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;
  56905. }
  56906. }
  56907. declare module BABYLON {
  56908. /**
  56909. * Implementation of the DDS Texture Loader.
  56910. * @hidden
  56911. */
  56912. export class _DDSTextureLoader implements IInternalTextureLoader {
  56913. /**
  56914. * Defines wether the loader supports cascade loading the different faces.
  56915. */
  56916. readonly supportCascades: boolean;
  56917. /**
  56918. * This returns if the loader support the current file information.
  56919. * @param extension defines the file extension of the file being loaded
  56920. * @returns true if the loader can load the specified file
  56921. */
  56922. canLoad(extension: string): boolean;
  56923. /**
  56924. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56925. * @param data contains the texture data
  56926. * @param texture defines the BabylonJS internal texture
  56927. * @param createPolynomials will be true if polynomials have been requested
  56928. * @param onLoad defines the callback to trigger once the texture is ready
  56929. * @param onError defines the callback to trigger in case of error
  56930. */
  56931. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56932. /**
  56933. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56934. * @param data contains the texture data
  56935. * @param texture defines the BabylonJS internal texture
  56936. * @param callback defines the method to call once ready to upload
  56937. */
  56938. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56939. }
  56940. }
  56941. declare module BABYLON {
  56942. /**
  56943. * Implementation of the ENV Texture Loader.
  56944. * @hidden
  56945. */
  56946. export class _ENVTextureLoader implements IInternalTextureLoader {
  56947. /**
  56948. * Defines wether the loader supports cascade loading the different faces.
  56949. */
  56950. readonly supportCascades: boolean;
  56951. /**
  56952. * This returns if the loader support the current file information.
  56953. * @param extension defines the file extension of the file being loaded
  56954. * @returns true if the loader can load the specified file
  56955. */
  56956. canLoad(extension: string): boolean;
  56957. /**
  56958. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  56959. * @param data contains the texture data
  56960. * @param texture defines the BabylonJS internal texture
  56961. * @param createPolynomials will be true if polynomials have been requested
  56962. * @param onLoad defines the callback to trigger once the texture is ready
  56963. * @param onError defines the callback to trigger in case of error
  56964. */
  56965. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  56966. /**
  56967. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  56968. * @param data contains the texture data
  56969. * @param texture defines the BabylonJS internal texture
  56970. * @param callback defines the method to call once ready to upload
  56971. */
  56972. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  56973. }
  56974. }
  56975. declare module BABYLON {
  56976. /**
  56977. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  56978. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  56979. */
  56980. export class KhronosTextureContainer {
  56981. /** contents of the KTX container file */
  56982. data: ArrayBufferView;
  56983. private static HEADER_LEN;
  56984. private static COMPRESSED_2D;
  56985. private static COMPRESSED_3D;
  56986. private static TEX_2D;
  56987. private static TEX_3D;
  56988. /**
  56989. * Gets the openGL type
  56990. */
  56991. glType: number;
  56992. /**
  56993. * Gets the openGL type size
  56994. */
  56995. glTypeSize: number;
  56996. /**
  56997. * Gets the openGL format
  56998. */
  56999. glFormat: number;
  57000. /**
  57001. * Gets the openGL internal format
  57002. */
  57003. glInternalFormat: number;
  57004. /**
  57005. * Gets the base internal format
  57006. */
  57007. glBaseInternalFormat: number;
  57008. /**
  57009. * Gets image width in pixel
  57010. */
  57011. pixelWidth: number;
  57012. /**
  57013. * Gets image height in pixel
  57014. */
  57015. pixelHeight: number;
  57016. /**
  57017. * Gets image depth in pixels
  57018. */
  57019. pixelDepth: number;
  57020. /**
  57021. * Gets the number of array elements
  57022. */
  57023. numberOfArrayElements: number;
  57024. /**
  57025. * Gets the number of faces
  57026. */
  57027. numberOfFaces: number;
  57028. /**
  57029. * Gets the number of mipmap levels
  57030. */
  57031. numberOfMipmapLevels: number;
  57032. /**
  57033. * Gets the bytes of key value data
  57034. */
  57035. bytesOfKeyValueData: number;
  57036. /**
  57037. * Gets the load type
  57038. */
  57039. loadType: number;
  57040. /**
  57041. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  57042. */
  57043. isInvalid: boolean;
  57044. /**
  57045. * Creates a new KhronosTextureContainer
  57046. * @param data contents of the KTX container file
  57047. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  57048. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  57049. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  57050. */
  57051. constructor(
  57052. /** contents of the KTX container file */
  57053. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  57054. /**
  57055. * Uploads KTX content to a Babylon Texture.
  57056. * It is assumed that the texture has already been created & is currently bound
  57057. * @hidden
  57058. */
  57059. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  57060. private _upload2DCompressedLevels;
  57061. /**
  57062. * Checks if the given data starts with a KTX file identifier.
  57063. * @param data the data to check
  57064. * @returns true if the data is a KTX file or false otherwise
  57065. */
  57066. static IsValid(data: ArrayBufferView): boolean;
  57067. }
  57068. }
  57069. declare module BABYLON {
  57070. /**
  57071. * Class for loading KTX2 files
  57072. * !!! Experimental Extension Subject to Changes !!!
  57073. * @hidden
  57074. */
  57075. export class KhronosTextureContainer2 {
  57076. private static _ModulePromise;
  57077. private static _TranscodeFormat;
  57078. constructor(engine: ThinEngine);
  57079. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  57080. private _determineTranscodeFormat;
  57081. /**
  57082. * Checks if the given data starts with a KTX2 file identifier.
  57083. * @param data the data to check
  57084. * @returns true if the data is a KTX2 file or false otherwise
  57085. */
  57086. static IsValid(data: ArrayBufferView): boolean;
  57087. }
  57088. }
  57089. declare module BABYLON {
  57090. /**
  57091. * Implementation of the KTX Texture Loader.
  57092. * @hidden
  57093. */
  57094. export class _KTXTextureLoader implements IInternalTextureLoader {
  57095. /**
  57096. * Defines wether the loader supports cascade loading the different faces.
  57097. */
  57098. readonly supportCascades: boolean;
  57099. /**
  57100. * This returns if the loader support the current file information.
  57101. * @param extension defines the file extension of the file being loaded
  57102. * @param mimeType defines the optional mime type of the file being loaded
  57103. * @returns true if the loader can load the specified file
  57104. */
  57105. canLoad(extension: string, mimeType?: string): boolean;
  57106. /**
  57107. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57108. * @param data contains the texture data
  57109. * @param texture defines the BabylonJS internal texture
  57110. * @param createPolynomials will be true if polynomials have been requested
  57111. * @param onLoad defines the callback to trigger once the texture is ready
  57112. * @param onError defines the callback to trigger in case of error
  57113. */
  57114. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57115. /**
  57116. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57117. * @param data contains the texture data
  57118. * @param texture defines the BabylonJS internal texture
  57119. * @param callback defines the method to call once ready to upload
  57120. */
  57121. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  57122. }
  57123. }
  57124. declare module BABYLON {
  57125. /** @hidden */
  57126. export var _forceSceneHelpersToBundle: boolean;
  57127. interface Scene {
  57128. /**
  57129. * Creates a default light for the scene.
  57130. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  57131. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  57132. */
  57133. createDefaultLight(replace?: boolean): void;
  57134. /**
  57135. * Creates a default camera for the scene.
  57136. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  57137. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  57138. * @param replace has default false, when true replaces the active camera in the scene
  57139. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  57140. */
  57141. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  57142. /**
  57143. * Creates a default camera and a default light.
  57144. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  57145. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  57146. * @param replace has the default false, when true replaces the active camera/light in the scene
  57147. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  57148. */
  57149. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  57150. /**
  57151. * Creates a new sky box
  57152. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  57153. * @param environmentTexture defines the texture to use as environment texture
  57154. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  57155. * @param scale defines the overall scale of the skybox
  57156. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  57157. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  57158. * @returns a new mesh holding the sky box
  57159. */
  57160. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  57161. /**
  57162. * Creates a new environment
  57163. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  57164. * @param options defines the options you can use to configure the environment
  57165. * @returns the new EnvironmentHelper
  57166. */
  57167. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  57168. /**
  57169. * Creates a new VREXperienceHelper
  57170. * @see https://doc.babylonjs.com/how_to/webvr_helper
  57171. * @param webVROptions defines the options used to create the new VREXperienceHelper
  57172. * @returns a new VREXperienceHelper
  57173. */
  57174. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  57175. /**
  57176. * Creates a new WebXRDefaultExperience
  57177. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  57178. * @param options experience options
  57179. * @returns a promise for a new WebXRDefaultExperience
  57180. */
  57181. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  57182. }
  57183. }
  57184. declare module BABYLON {
  57185. /**
  57186. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  57187. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  57188. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  57189. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57190. */
  57191. export class VideoDome extends TransformNode {
  57192. /**
  57193. * Define the video source as a Monoscopic panoramic 360 video.
  57194. */
  57195. static readonly MODE_MONOSCOPIC: number;
  57196. /**
  57197. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  57198. */
  57199. static readonly MODE_TOPBOTTOM: number;
  57200. /**
  57201. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  57202. */
  57203. static readonly MODE_SIDEBYSIDE: number;
  57204. private _halfDome;
  57205. private _useDirectMapping;
  57206. /**
  57207. * The video texture being displayed on the sphere
  57208. */
  57209. protected _videoTexture: VideoTexture;
  57210. /**
  57211. * Gets the video texture being displayed on the sphere
  57212. */
  57213. get videoTexture(): VideoTexture;
  57214. /**
  57215. * The skybox material
  57216. */
  57217. protected _material: BackgroundMaterial;
  57218. /**
  57219. * The surface used for the video dome
  57220. */
  57221. protected _mesh: Mesh;
  57222. /**
  57223. * Gets the mesh used for the video dome.
  57224. */
  57225. get mesh(): Mesh;
  57226. /**
  57227. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  57228. */
  57229. private _halfDomeMask;
  57230. /**
  57231. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57232. * Also see the options.resolution property.
  57233. */
  57234. get fovMultiplier(): number;
  57235. set fovMultiplier(value: number);
  57236. private _videoMode;
  57237. /**
  57238. * Gets or set the current video mode for the video. It can be:
  57239. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  57240. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  57241. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  57242. */
  57243. get videoMode(): number;
  57244. set videoMode(value: number);
  57245. /**
  57246. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  57247. *
  57248. */
  57249. get halfDome(): boolean;
  57250. /**
  57251. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  57252. */
  57253. set halfDome(enabled: boolean);
  57254. /**
  57255. * Oberserver used in Stereoscopic VR Mode.
  57256. */
  57257. private _onBeforeCameraRenderObserver;
  57258. /**
  57259. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  57260. * @param name Element's name, child elements will append suffixes for their own names.
  57261. * @param urlsOrVideo defines the url(s) or the video element to use
  57262. * @param options An object containing optional or exposed sub element properties
  57263. */
  57264. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  57265. resolution?: number;
  57266. clickToPlay?: boolean;
  57267. autoPlay?: boolean;
  57268. loop?: boolean;
  57269. size?: number;
  57270. poster?: string;
  57271. faceForward?: boolean;
  57272. useDirectMapping?: boolean;
  57273. halfDomeMode?: boolean;
  57274. }, scene: Scene);
  57275. private _changeVideoMode;
  57276. /**
  57277. * Releases resources associated with this node.
  57278. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  57279. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  57280. */
  57281. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  57282. }
  57283. }
  57284. declare module BABYLON {
  57285. /**
  57286. * This class can be used to get instrumentation data from a Babylon engine
  57287. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  57288. */
  57289. export class EngineInstrumentation implements IDisposable {
  57290. /**
  57291. * Define the instrumented engine.
  57292. */
  57293. engine: Engine;
  57294. private _captureGPUFrameTime;
  57295. private _gpuFrameTimeToken;
  57296. private _gpuFrameTime;
  57297. private _captureShaderCompilationTime;
  57298. private _shaderCompilationTime;
  57299. private _onBeginFrameObserver;
  57300. private _onEndFrameObserver;
  57301. private _onBeforeShaderCompilationObserver;
  57302. private _onAfterShaderCompilationObserver;
  57303. /**
  57304. * Gets the perf counter used for GPU frame time
  57305. */
  57306. get gpuFrameTimeCounter(): PerfCounter;
  57307. /**
  57308. * Gets the GPU frame time capture status
  57309. */
  57310. get captureGPUFrameTime(): boolean;
  57311. /**
  57312. * Enable or disable the GPU frame time capture
  57313. */
  57314. set captureGPUFrameTime(value: boolean);
  57315. /**
  57316. * Gets the perf counter used for shader compilation time
  57317. */
  57318. get shaderCompilationTimeCounter(): PerfCounter;
  57319. /**
  57320. * Gets the shader compilation time capture status
  57321. */
  57322. get captureShaderCompilationTime(): boolean;
  57323. /**
  57324. * Enable or disable the shader compilation time capture
  57325. */
  57326. set captureShaderCompilationTime(value: boolean);
  57327. /**
  57328. * Instantiates a new engine instrumentation.
  57329. * This class can be used to get instrumentation data from a Babylon engine
  57330. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  57331. * @param engine Defines the engine to instrument
  57332. */
  57333. constructor(
  57334. /**
  57335. * Define the instrumented engine.
  57336. */
  57337. engine: Engine);
  57338. /**
  57339. * Dispose and release associated resources.
  57340. */
  57341. dispose(): void;
  57342. }
  57343. }
  57344. declare module BABYLON {
  57345. /**
  57346. * This class can be used to get instrumentation data from a Babylon engine
  57347. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  57348. */
  57349. export class SceneInstrumentation implements IDisposable {
  57350. /**
  57351. * Defines the scene to instrument
  57352. */
  57353. scene: Scene;
  57354. private _captureActiveMeshesEvaluationTime;
  57355. private _activeMeshesEvaluationTime;
  57356. private _captureRenderTargetsRenderTime;
  57357. private _renderTargetsRenderTime;
  57358. private _captureFrameTime;
  57359. private _frameTime;
  57360. private _captureRenderTime;
  57361. private _renderTime;
  57362. private _captureInterFrameTime;
  57363. private _interFrameTime;
  57364. private _captureParticlesRenderTime;
  57365. private _particlesRenderTime;
  57366. private _captureSpritesRenderTime;
  57367. private _spritesRenderTime;
  57368. private _capturePhysicsTime;
  57369. private _physicsTime;
  57370. private _captureAnimationsTime;
  57371. private _animationsTime;
  57372. private _captureCameraRenderTime;
  57373. private _cameraRenderTime;
  57374. private _onBeforeActiveMeshesEvaluationObserver;
  57375. private _onAfterActiveMeshesEvaluationObserver;
  57376. private _onBeforeRenderTargetsRenderObserver;
  57377. private _onAfterRenderTargetsRenderObserver;
  57378. private _onAfterRenderObserver;
  57379. private _onBeforeDrawPhaseObserver;
  57380. private _onAfterDrawPhaseObserver;
  57381. private _onBeforeAnimationsObserver;
  57382. private _onBeforeParticlesRenderingObserver;
  57383. private _onAfterParticlesRenderingObserver;
  57384. private _onBeforeSpritesRenderingObserver;
  57385. private _onAfterSpritesRenderingObserver;
  57386. private _onBeforePhysicsObserver;
  57387. private _onAfterPhysicsObserver;
  57388. private _onAfterAnimationsObserver;
  57389. private _onBeforeCameraRenderObserver;
  57390. private _onAfterCameraRenderObserver;
  57391. /**
  57392. * Gets the perf counter used for active meshes evaluation time
  57393. */
  57394. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  57395. /**
  57396. * Gets the active meshes evaluation time capture status
  57397. */
  57398. get captureActiveMeshesEvaluationTime(): boolean;
  57399. /**
  57400. * Enable or disable the active meshes evaluation time capture
  57401. */
  57402. set captureActiveMeshesEvaluationTime(value: boolean);
  57403. /**
  57404. * Gets the perf counter used for render targets render time
  57405. */
  57406. get renderTargetsRenderTimeCounter(): PerfCounter;
  57407. /**
  57408. * Gets the render targets render time capture status
  57409. */
  57410. get captureRenderTargetsRenderTime(): boolean;
  57411. /**
  57412. * Enable or disable the render targets render time capture
  57413. */
  57414. set captureRenderTargetsRenderTime(value: boolean);
  57415. /**
  57416. * Gets the perf counter used for particles render time
  57417. */
  57418. get particlesRenderTimeCounter(): PerfCounter;
  57419. /**
  57420. * Gets the particles render time capture status
  57421. */
  57422. get captureParticlesRenderTime(): boolean;
  57423. /**
  57424. * Enable or disable the particles render time capture
  57425. */
  57426. set captureParticlesRenderTime(value: boolean);
  57427. /**
  57428. * Gets the perf counter used for sprites render time
  57429. */
  57430. get spritesRenderTimeCounter(): PerfCounter;
  57431. /**
  57432. * Gets the sprites render time capture status
  57433. */
  57434. get captureSpritesRenderTime(): boolean;
  57435. /**
  57436. * Enable or disable the sprites render time capture
  57437. */
  57438. set captureSpritesRenderTime(value: boolean);
  57439. /**
  57440. * Gets the perf counter used for physics time
  57441. */
  57442. get physicsTimeCounter(): PerfCounter;
  57443. /**
  57444. * Gets the physics time capture status
  57445. */
  57446. get capturePhysicsTime(): boolean;
  57447. /**
  57448. * Enable or disable the physics time capture
  57449. */
  57450. set capturePhysicsTime(value: boolean);
  57451. /**
  57452. * Gets the perf counter used for animations time
  57453. */
  57454. get animationsTimeCounter(): PerfCounter;
  57455. /**
  57456. * Gets the animations time capture status
  57457. */
  57458. get captureAnimationsTime(): boolean;
  57459. /**
  57460. * Enable or disable the animations time capture
  57461. */
  57462. set captureAnimationsTime(value: boolean);
  57463. /**
  57464. * Gets the perf counter used for frame time capture
  57465. */
  57466. get frameTimeCounter(): PerfCounter;
  57467. /**
  57468. * Gets the frame time capture status
  57469. */
  57470. get captureFrameTime(): boolean;
  57471. /**
  57472. * Enable or disable the frame time capture
  57473. */
  57474. set captureFrameTime(value: boolean);
  57475. /**
  57476. * Gets the perf counter used for inter-frames time capture
  57477. */
  57478. get interFrameTimeCounter(): PerfCounter;
  57479. /**
  57480. * Gets the inter-frames time capture status
  57481. */
  57482. get captureInterFrameTime(): boolean;
  57483. /**
  57484. * Enable or disable the inter-frames time capture
  57485. */
  57486. set captureInterFrameTime(value: boolean);
  57487. /**
  57488. * Gets the perf counter used for render time capture
  57489. */
  57490. get renderTimeCounter(): PerfCounter;
  57491. /**
  57492. * Gets the render time capture status
  57493. */
  57494. get captureRenderTime(): boolean;
  57495. /**
  57496. * Enable or disable the render time capture
  57497. */
  57498. set captureRenderTime(value: boolean);
  57499. /**
  57500. * Gets the perf counter used for camera render time capture
  57501. */
  57502. get cameraRenderTimeCounter(): PerfCounter;
  57503. /**
  57504. * Gets the camera render time capture status
  57505. */
  57506. get captureCameraRenderTime(): boolean;
  57507. /**
  57508. * Enable or disable the camera render time capture
  57509. */
  57510. set captureCameraRenderTime(value: boolean);
  57511. /**
  57512. * Gets the perf counter used for draw calls
  57513. */
  57514. get drawCallsCounter(): PerfCounter;
  57515. /**
  57516. * Instantiates a new scene instrumentation.
  57517. * This class can be used to get instrumentation data from a Babylon engine
  57518. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  57519. * @param scene Defines the scene to instrument
  57520. */
  57521. constructor(
  57522. /**
  57523. * Defines the scene to instrument
  57524. */
  57525. scene: Scene);
  57526. /**
  57527. * Dispose and release associated resources.
  57528. */
  57529. dispose(): void;
  57530. }
  57531. }
  57532. declare module BABYLON {
  57533. /** @hidden */
  57534. export var glowMapGenerationPixelShader: {
  57535. name: string;
  57536. shader: string;
  57537. };
  57538. }
  57539. declare module BABYLON {
  57540. /** @hidden */
  57541. export var glowMapGenerationVertexShader: {
  57542. name: string;
  57543. shader: string;
  57544. };
  57545. }
  57546. declare module BABYLON {
  57547. /**
  57548. * Effect layer options. This helps customizing the behaviour
  57549. * of the effect layer.
  57550. */
  57551. export interface IEffectLayerOptions {
  57552. /**
  57553. * Multiplication factor apply to the canvas size to compute the render target size
  57554. * used to generated the objects (the smaller the faster).
  57555. */
  57556. mainTextureRatio: number;
  57557. /**
  57558. * Enforces a fixed size texture to ensure effect stability across devices.
  57559. */
  57560. mainTextureFixedSize?: number;
  57561. /**
  57562. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  57563. */
  57564. alphaBlendingMode: number;
  57565. /**
  57566. * The camera attached to the layer.
  57567. */
  57568. camera: Nullable<Camera>;
  57569. /**
  57570. * The rendering group to draw the layer in.
  57571. */
  57572. renderingGroupId: number;
  57573. }
  57574. /**
  57575. * The effect layer Helps adding post process effect blended with the main pass.
  57576. *
  57577. * This can be for instance use to generate glow or higlight effects on the scene.
  57578. *
  57579. * The effect layer class can not be used directly and is intented to inherited from to be
  57580. * customized per effects.
  57581. */
  57582. export abstract class EffectLayer {
  57583. private _vertexBuffers;
  57584. private _indexBuffer;
  57585. private _cachedDefines;
  57586. private _effectLayerMapGenerationEffect;
  57587. private _effectLayerOptions;
  57588. private _mergeEffect;
  57589. protected _scene: Scene;
  57590. protected _engine: Engine;
  57591. protected _maxSize: number;
  57592. protected _mainTextureDesiredSize: ISize;
  57593. protected _mainTexture: RenderTargetTexture;
  57594. protected _shouldRender: boolean;
  57595. protected _postProcesses: PostProcess[];
  57596. protected _textures: BaseTexture[];
  57597. protected _emissiveTextureAndColor: {
  57598. texture: Nullable<BaseTexture>;
  57599. color: Color4;
  57600. };
  57601. /**
  57602. * The name of the layer
  57603. */
  57604. name: string;
  57605. /**
  57606. * The clear color of the texture used to generate the glow map.
  57607. */
  57608. neutralColor: Color4;
  57609. /**
  57610. * Specifies whether the highlight layer is enabled or not.
  57611. */
  57612. isEnabled: boolean;
  57613. /**
  57614. * Gets the camera attached to the layer.
  57615. */
  57616. get camera(): Nullable<Camera>;
  57617. /**
  57618. * Gets the rendering group id the layer should render in.
  57619. */
  57620. get renderingGroupId(): number;
  57621. set renderingGroupId(renderingGroupId: number);
  57622. /**
  57623. * An event triggered when the effect layer has been disposed.
  57624. */
  57625. onDisposeObservable: Observable<EffectLayer>;
  57626. /**
  57627. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  57628. */
  57629. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  57630. /**
  57631. * An event triggered when the generated texture is being merged in the scene.
  57632. */
  57633. onBeforeComposeObservable: Observable<EffectLayer>;
  57634. /**
  57635. * An event triggered when the mesh is rendered into the effect render target.
  57636. */
  57637. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  57638. /**
  57639. * An event triggered after the mesh has been rendered into the effect render target.
  57640. */
  57641. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  57642. /**
  57643. * An event triggered when the generated texture has been merged in the scene.
  57644. */
  57645. onAfterComposeObservable: Observable<EffectLayer>;
  57646. /**
  57647. * An event triggered when the efffect layer changes its size.
  57648. */
  57649. onSizeChangedObservable: Observable<EffectLayer>;
  57650. /** @hidden */
  57651. static _SceneComponentInitialization: (scene: Scene) => void;
  57652. /**
  57653. * Instantiates a new effect Layer and references it in the scene.
  57654. * @param name The name of the layer
  57655. * @param scene The scene to use the layer in
  57656. */
  57657. constructor(
  57658. /** The Friendly of the effect in the scene */
  57659. name: string, scene: Scene);
  57660. /**
  57661. * Get the effect name of the layer.
  57662. * @return The effect name
  57663. */
  57664. abstract getEffectName(): string;
  57665. /**
  57666. * Checks for the readiness of the element composing the layer.
  57667. * @param subMesh the mesh to check for
  57668. * @param useInstances specify whether or not to use instances to render the mesh
  57669. * @return true if ready otherwise, false
  57670. */
  57671. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57672. /**
  57673. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  57674. * @returns true if the effect requires stencil during the main canvas render pass.
  57675. */
  57676. abstract needStencil(): boolean;
  57677. /**
  57678. * Create the merge effect. This is the shader use to blit the information back
  57679. * to the main canvas at the end of the scene rendering.
  57680. * @returns The effect containing the shader used to merge the effect on the main canvas
  57681. */
  57682. protected abstract _createMergeEffect(): Effect;
  57683. /**
  57684. * Creates the render target textures and post processes used in the effect layer.
  57685. */
  57686. protected abstract _createTextureAndPostProcesses(): void;
  57687. /**
  57688. * Implementation specific of rendering the generating effect on the main canvas.
  57689. * @param effect The effect used to render through
  57690. */
  57691. protected abstract _internalRender(effect: Effect): void;
  57692. /**
  57693. * Sets the required values for both the emissive texture and and the main color.
  57694. */
  57695. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  57696. /**
  57697. * Free any resources and references associated to a mesh.
  57698. * Internal use
  57699. * @param mesh The mesh to free.
  57700. */
  57701. abstract _disposeMesh(mesh: Mesh): void;
  57702. /**
  57703. * Serializes this layer (Glow or Highlight for example)
  57704. * @returns a serialized layer object
  57705. */
  57706. abstract serialize?(): any;
  57707. /**
  57708. * Initializes the effect layer with the required options.
  57709. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  57710. */
  57711. protected _init(options: Partial<IEffectLayerOptions>): void;
  57712. /**
  57713. * Generates the index buffer of the full screen quad blending to the main canvas.
  57714. */
  57715. private _generateIndexBuffer;
  57716. /**
  57717. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  57718. */
  57719. private _generateVertexBuffer;
  57720. /**
  57721. * Sets the main texture desired size which is the closest power of two
  57722. * of the engine canvas size.
  57723. */
  57724. private _setMainTextureSize;
  57725. /**
  57726. * Creates the main texture for the effect layer.
  57727. */
  57728. protected _createMainTexture(): void;
  57729. /**
  57730. * Adds specific effects defines.
  57731. * @param defines The defines to add specifics to.
  57732. */
  57733. protected _addCustomEffectDefines(defines: string[]): void;
  57734. /**
  57735. * Checks for the readiness of the element composing the layer.
  57736. * @param subMesh the mesh to check for
  57737. * @param useInstances specify whether or not to use instances to render the mesh
  57738. * @param emissiveTexture the associated emissive texture used to generate the glow
  57739. * @return true if ready otherwise, false
  57740. */
  57741. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  57742. /**
  57743. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  57744. */
  57745. render(): void;
  57746. /**
  57747. * Determine if a given mesh will be used in the current effect.
  57748. * @param mesh mesh to test
  57749. * @returns true if the mesh will be used
  57750. */
  57751. hasMesh(mesh: AbstractMesh): boolean;
  57752. /**
  57753. * Returns true if the layer contains information to display, otherwise false.
  57754. * @returns true if the glow layer should be rendered
  57755. */
  57756. shouldRender(): boolean;
  57757. /**
  57758. * Returns true if the mesh should render, otherwise false.
  57759. * @param mesh The mesh to render
  57760. * @returns true if it should render otherwise false
  57761. */
  57762. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  57763. /**
  57764. * Returns true if the mesh can be rendered, otherwise false.
  57765. * @param mesh The mesh to render
  57766. * @param material The material used on the mesh
  57767. * @returns true if it can be rendered otherwise false
  57768. */
  57769. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  57770. /**
  57771. * Returns true if the mesh should render, otherwise false.
  57772. * @param mesh The mesh to render
  57773. * @returns true if it should render otherwise false
  57774. */
  57775. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  57776. /**
  57777. * Renders the submesh passed in parameter to the generation map.
  57778. */
  57779. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  57780. /**
  57781. * Defines whether the current material of the mesh should be use to render the effect.
  57782. * @param mesh defines the current mesh to render
  57783. */
  57784. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  57785. /**
  57786. * Rebuild the required buffers.
  57787. * @hidden Internal use only.
  57788. */
  57789. _rebuild(): void;
  57790. /**
  57791. * Dispose only the render target textures and post process.
  57792. */
  57793. private _disposeTextureAndPostProcesses;
  57794. /**
  57795. * Dispose the highlight layer and free resources.
  57796. */
  57797. dispose(): void;
  57798. /**
  57799. * Gets the class name of the effect layer
  57800. * @returns the string with the class name of the effect layer
  57801. */
  57802. getClassName(): string;
  57803. /**
  57804. * Creates an effect layer from parsed effect layer data
  57805. * @param parsedEffectLayer defines effect layer data
  57806. * @param scene defines the current scene
  57807. * @param rootUrl defines the root URL containing the effect layer information
  57808. * @returns a parsed effect Layer
  57809. */
  57810. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  57811. }
  57812. }
  57813. declare module BABYLON {
  57814. interface AbstractScene {
  57815. /**
  57816. * The list of effect layers (highlights/glow) added to the scene
  57817. * @see https://doc.babylonjs.com/how_to/highlight_layer
  57818. * @see https://doc.babylonjs.com/how_to/glow_layer
  57819. */
  57820. effectLayers: Array<EffectLayer>;
  57821. /**
  57822. * Removes the given effect layer from this scene.
  57823. * @param toRemove defines the effect layer to remove
  57824. * @returns the index of the removed effect layer
  57825. */
  57826. removeEffectLayer(toRemove: EffectLayer): number;
  57827. /**
  57828. * Adds the given effect layer to this scene
  57829. * @param newEffectLayer defines the effect layer to add
  57830. */
  57831. addEffectLayer(newEffectLayer: EffectLayer): void;
  57832. }
  57833. /**
  57834. * Defines the layer scene component responsible to manage any effect layers
  57835. * in a given scene.
  57836. */
  57837. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  57838. /**
  57839. * The component name helpfull to identify the component in the list of scene components.
  57840. */
  57841. readonly name: string;
  57842. /**
  57843. * The scene the component belongs to.
  57844. */
  57845. scene: Scene;
  57846. private _engine;
  57847. private _renderEffects;
  57848. private _needStencil;
  57849. private _previousStencilState;
  57850. /**
  57851. * Creates a new instance of the component for the given scene
  57852. * @param scene Defines the scene to register the component in
  57853. */
  57854. constructor(scene: Scene);
  57855. /**
  57856. * Registers the component in a given scene
  57857. */
  57858. register(): void;
  57859. /**
  57860. * Rebuilds the elements related to this component in case of
  57861. * context lost for instance.
  57862. */
  57863. rebuild(): void;
  57864. /**
  57865. * Serializes the component data to the specified json object
  57866. * @param serializationObject The object to serialize to
  57867. */
  57868. serialize(serializationObject: any): void;
  57869. /**
  57870. * Adds all the elements from the container to the scene
  57871. * @param container the container holding the elements
  57872. */
  57873. addFromContainer(container: AbstractScene): void;
  57874. /**
  57875. * Removes all the elements in the container from the scene
  57876. * @param container contains the elements to remove
  57877. * @param dispose if the removed element should be disposed (default: false)
  57878. */
  57879. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57880. /**
  57881. * Disposes the component and the associated ressources.
  57882. */
  57883. dispose(): void;
  57884. private _isReadyForMesh;
  57885. private _renderMainTexture;
  57886. private _setStencil;
  57887. private _setStencilBack;
  57888. private _draw;
  57889. private _drawCamera;
  57890. private _drawRenderingGroup;
  57891. }
  57892. }
  57893. declare module BABYLON {
  57894. /** @hidden */
  57895. export var glowMapMergePixelShader: {
  57896. name: string;
  57897. shader: string;
  57898. };
  57899. }
  57900. declare module BABYLON {
  57901. /** @hidden */
  57902. export var glowMapMergeVertexShader: {
  57903. name: string;
  57904. shader: string;
  57905. };
  57906. }
  57907. declare module BABYLON {
  57908. interface AbstractScene {
  57909. /**
  57910. * Return a the first highlight layer of the scene with a given name.
  57911. * @param name The name of the highlight layer to look for.
  57912. * @return The highlight layer if found otherwise null.
  57913. */
  57914. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  57915. }
  57916. /**
  57917. * Glow layer options. This helps customizing the behaviour
  57918. * of the glow layer.
  57919. */
  57920. export interface IGlowLayerOptions {
  57921. /**
  57922. * Multiplication factor apply to the canvas size to compute the render target size
  57923. * used to generated the glowing objects (the smaller the faster).
  57924. */
  57925. mainTextureRatio: number;
  57926. /**
  57927. * Enforces a fixed size texture to ensure resize independant blur.
  57928. */
  57929. mainTextureFixedSize?: number;
  57930. /**
  57931. * How big is the kernel of the blur texture.
  57932. */
  57933. blurKernelSize: number;
  57934. /**
  57935. * The camera attached to the layer.
  57936. */
  57937. camera: Nullable<Camera>;
  57938. /**
  57939. * Enable MSAA by chosing the number of samples.
  57940. */
  57941. mainTextureSamples?: number;
  57942. /**
  57943. * The rendering group to draw the layer in.
  57944. */
  57945. renderingGroupId: number;
  57946. }
  57947. /**
  57948. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  57949. *
  57950. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  57951. *
  57952. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  57953. */
  57954. export class GlowLayer extends EffectLayer {
  57955. /**
  57956. * Effect Name of the layer.
  57957. */
  57958. static readonly EffectName: string;
  57959. /**
  57960. * The default blur kernel size used for the glow.
  57961. */
  57962. static DefaultBlurKernelSize: number;
  57963. /**
  57964. * The default texture size ratio used for the glow.
  57965. */
  57966. static DefaultTextureRatio: number;
  57967. /**
  57968. * Sets the kernel size of the blur.
  57969. */
  57970. set blurKernelSize(value: number);
  57971. /**
  57972. * Gets the kernel size of the blur.
  57973. */
  57974. get blurKernelSize(): number;
  57975. /**
  57976. * Sets the glow intensity.
  57977. */
  57978. set intensity(value: number);
  57979. /**
  57980. * Gets the glow intensity.
  57981. */
  57982. get intensity(): number;
  57983. private _options;
  57984. private _intensity;
  57985. private _horizontalBlurPostprocess1;
  57986. private _verticalBlurPostprocess1;
  57987. private _horizontalBlurPostprocess2;
  57988. private _verticalBlurPostprocess2;
  57989. private _blurTexture1;
  57990. private _blurTexture2;
  57991. private _postProcesses1;
  57992. private _postProcesses2;
  57993. private _includedOnlyMeshes;
  57994. private _excludedMeshes;
  57995. private _meshesUsingTheirOwnMaterials;
  57996. /**
  57997. * Callback used to let the user override the color selection on a per mesh basis
  57998. */
  57999. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  58000. /**
  58001. * Callback used to let the user override the texture selection on a per mesh basis
  58002. */
  58003. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  58004. /**
  58005. * Instantiates a new glow Layer and references it to the scene.
  58006. * @param name The name of the layer
  58007. * @param scene The scene to use the layer in
  58008. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  58009. */
  58010. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  58011. /**
  58012. * Get the effect name of the layer.
  58013. * @return The effect name
  58014. */
  58015. getEffectName(): string;
  58016. /**
  58017. * Create the merge effect. This is the shader use to blit the information back
  58018. * to the main canvas at the end of the scene rendering.
  58019. */
  58020. protected _createMergeEffect(): Effect;
  58021. /**
  58022. * Creates the render target textures and post processes used in the glow layer.
  58023. */
  58024. protected _createTextureAndPostProcesses(): void;
  58025. /**
  58026. * Checks for the readiness of the element composing the layer.
  58027. * @param subMesh the mesh to check for
  58028. * @param useInstances specify wether or not to use instances to render the mesh
  58029. * @param emissiveTexture the associated emissive texture used to generate the glow
  58030. * @return true if ready otherwise, false
  58031. */
  58032. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58033. /**
  58034. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  58035. */
  58036. needStencil(): boolean;
  58037. /**
  58038. * Returns true if the mesh can be rendered, otherwise false.
  58039. * @param mesh The mesh to render
  58040. * @param material The material used on the mesh
  58041. * @returns true if it can be rendered otherwise false
  58042. */
  58043. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58044. /**
  58045. * Implementation specific of rendering the generating effect on the main canvas.
  58046. * @param effect The effect used to render through
  58047. */
  58048. protected _internalRender(effect: Effect): void;
  58049. /**
  58050. * Sets the required values for both the emissive texture and and the main color.
  58051. */
  58052. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58053. /**
  58054. * Returns true if the mesh should render, otherwise false.
  58055. * @param mesh The mesh to render
  58056. * @returns true if it should render otherwise false
  58057. */
  58058. protected _shouldRenderMesh(mesh: Mesh): boolean;
  58059. /**
  58060. * Adds specific effects defines.
  58061. * @param defines The defines to add specifics to.
  58062. */
  58063. protected _addCustomEffectDefines(defines: string[]): void;
  58064. /**
  58065. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  58066. * @param mesh The mesh to exclude from the glow layer
  58067. */
  58068. addExcludedMesh(mesh: Mesh): void;
  58069. /**
  58070. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  58071. * @param mesh The mesh to remove
  58072. */
  58073. removeExcludedMesh(mesh: Mesh): void;
  58074. /**
  58075. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  58076. * @param mesh The mesh to include in the glow layer
  58077. */
  58078. addIncludedOnlyMesh(mesh: Mesh): void;
  58079. /**
  58080. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  58081. * @param mesh The mesh to remove
  58082. */
  58083. removeIncludedOnlyMesh(mesh: Mesh): void;
  58084. /**
  58085. * Determine if a given mesh will be used in the glow layer
  58086. * @param mesh The mesh to test
  58087. * @returns true if the mesh will be highlighted by the current glow layer
  58088. */
  58089. hasMesh(mesh: AbstractMesh): boolean;
  58090. /**
  58091. * Defines whether the current material of the mesh should be use to render the effect.
  58092. * @param mesh defines the current mesh to render
  58093. */
  58094. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  58095. /**
  58096. * Add a mesh to be rendered through its own material and not with emissive only.
  58097. * @param mesh The mesh for which we need to use its material
  58098. */
  58099. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  58100. /**
  58101. * Remove a mesh from being rendered through its own material and not with emissive only.
  58102. * @param mesh The mesh for which we need to not use its material
  58103. */
  58104. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  58105. /**
  58106. * Free any resources and references associated to a mesh.
  58107. * Internal use
  58108. * @param mesh The mesh to free.
  58109. * @hidden
  58110. */
  58111. _disposeMesh(mesh: Mesh): void;
  58112. /**
  58113. * Gets the class name of the effect layer
  58114. * @returns the string with the class name of the effect layer
  58115. */
  58116. getClassName(): string;
  58117. /**
  58118. * Serializes this glow layer
  58119. * @returns a serialized glow layer object
  58120. */
  58121. serialize(): any;
  58122. /**
  58123. * Creates a Glow Layer from parsed glow layer data
  58124. * @param parsedGlowLayer defines glow layer data
  58125. * @param scene defines the current scene
  58126. * @param rootUrl defines the root URL containing the glow layer information
  58127. * @returns a parsed Glow Layer
  58128. */
  58129. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  58130. }
  58131. }
  58132. declare module BABYLON {
  58133. /** @hidden */
  58134. export var glowBlurPostProcessPixelShader: {
  58135. name: string;
  58136. shader: string;
  58137. };
  58138. }
  58139. declare module BABYLON {
  58140. interface AbstractScene {
  58141. /**
  58142. * Return a the first highlight layer of the scene with a given name.
  58143. * @param name The name of the highlight layer to look for.
  58144. * @return The highlight layer if found otherwise null.
  58145. */
  58146. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  58147. }
  58148. /**
  58149. * Highlight layer options. This helps customizing the behaviour
  58150. * of the highlight layer.
  58151. */
  58152. export interface IHighlightLayerOptions {
  58153. /**
  58154. * Multiplication factor apply to the canvas size to compute the render target size
  58155. * used to generated the glowing objects (the smaller the faster).
  58156. */
  58157. mainTextureRatio: number;
  58158. /**
  58159. * Enforces a fixed size texture to ensure resize independant blur.
  58160. */
  58161. mainTextureFixedSize?: number;
  58162. /**
  58163. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  58164. * of the picture to blur (the smaller the faster).
  58165. */
  58166. blurTextureSizeRatio: number;
  58167. /**
  58168. * How big in texel of the blur texture is the vertical blur.
  58169. */
  58170. blurVerticalSize: number;
  58171. /**
  58172. * How big in texel of the blur texture is the horizontal blur.
  58173. */
  58174. blurHorizontalSize: number;
  58175. /**
  58176. * Alpha blending mode used to apply the blur. Default is combine.
  58177. */
  58178. alphaBlendingMode: number;
  58179. /**
  58180. * The camera attached to the layer.
  58181. */
  58182. camera: Nullable<Camera>;
  58183. /**
  58184. * Should we display highlight as a solid stroke?
  58185. */
  58186. isStroke?: boolean;
  58187. /**
  58188. * The rendering group to draw the layer in.
  58189. */
  58190. renderingGroupId: number;
  58191. }
  58192. /**
  58193. * The highlight layer Helps adding a glow effect around a mesh.
  58194. *
  58195. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  58196. * glowy meshes to your scene.
  58197. *
  58198. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  58199. */
  58200. export class HighlightLayer extends EffectLayer {
  58201. name: string;
  58202. /**
  58203. * Effect Name of the highlight layer.
  58204. */
  58205. static readonly EffectName: string;
  58206. /**
  58207. * The neutral color used during the preparation of the glow effect.
  58208. * This is black by default as the blend operation is a blend operation.
  58209. */
  58210. static NeutralColor: Color4;
  58211. /**
  58212. * Stencil value used for glowing meshes.
  58213. */
  58214. static GlowingMeshStencilReference: number;
  58215. /**
  58216. * Stencil value used for the other meshes in the scene.
  58217. */
  58218. static NormalMeshStencilReference: number;
  58219. /**
  58220. * Specifies whether or not the inner glow is ACTIVE in the layer.
  58221. */
  58222. innerGlow: boolean;
  58223. /**
  58224. * Specifies whether or not the outer glow is ACTIVE in the layer.
  58225. */
  58226. outerGlow: boolean;
  58227. /**
  58228. * Specifies the horizontal size of the blur.
  58229. */
  58230. set blurHorizontalSize(value: number);
  58231. /**
  58232. * Specifies the vertical size of the blur.
  58233. */
  58234. set blurVerticalSize(value: number);
  58235. /**
  58236. * Gets the horizontal size of the blur.
  58237. */
  58238. get blurHorizontalSize(): number;
  58239. /**
  58240. * Gets the vertical size of the blur.
  58241. */
  58242. get blurVerticalSize(): number;
  58243. /**
  58244. * An event triggered when the highlight layer is being blurred.
  58245. */
  58246. onBeforeBlurObservable: Observable<HighlightLayer>;
  58247. /**
  58248. * An event triggered when the highlight layer has been blurred.
  58249. */
  58250. onAfterBlurObservable: Observable<HighlightLayer>;
  58251. private _instanceGlowingMeshStencilReference;
  58252. private _options;
  58253. private _downSamplePostprocess;
  58254. private _horizontalBlurPostprocess;
  58255. private _verticalBlurPostprocess;
  58256. private _blurTexture;
  58257. private _meshes;
  58258. private _excludedMeshes;
  58259. /**
  58260. * Instantiates a new highlight Layer and references it to the scene..
  58261. * @param name The name of the layer
  58262. * @param scene The scene to use the layer in
  58263. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  58264. */
  58265. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  58266. /**
  58267. * Get the effect name of the layer.
  58268. * @return The effect name
  58269. */
  58270. getEffectName(): string;
  58271. /**
  58272. * Create the merge effect. This is the shader use to blit the information back
  58273. * to the main canvas at the end of the scene rendering.
  58274. */
  58275. protected _createMergeEffect(): Effect;
  58276. /**
  58277. * Creates the render target textures and post processes used in the highlight layer.
  58278. */
  58279. protected _createTextureAndPostProcesses(): void;
  58280. /**
  58281. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  58282. */
  58283. needStencil(): boolean;
  58284. /**
  58285. * Checks for the readiness of the element composing the layer.
  58286. * @param subMesh the mesh to check for
  58287. * @param useInstances specify wether or not to use instances to render the mesh
  58288. * @param emissiveTexture the associated emissive texture used to generate the glow
  58289. * @return true if ready otherwise, false
  58290. */
  58291. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58292. /**
  58293. * Implementation specific of rendering the generating effect on the main canvas.
  58294. * @param effect The effect used to render through
  58295. */
  58296. protected _internalRender(effect: Effect): void;
  58297. /**
  58298. * Returns true if the layer contains information to display, otherwise false.
  58299. */
  58300. shouldRender(): boolean;
  58301. /**
  58302. * Returns true if the mesh should render, otherwise false.
  58303. * @param mesh The mesh to render
  58304. * @returns true if it should render otherwise false
  58305. */
  58306. protected _shouldRenderMesh(mesh: Mesh): boolean;
  58307. /**
  58308. * Returns true if the mesh can be rendered, otherwise false.
  58309. * @param mesh The mesh to render
  58310. * @param material The material used on the mesh
  58311. * @returns true if it can be rendered otherwise false
  58312. */
  58313. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58314. /**
  58315. * Adds specific effects defines.
  58316. * @param defines The defines to add specifics to.
  58317. */
  58318. protected _addCustomEffectDefines(defines: string[]): void;
  58319. /**
  58320. * Sets the required values for both the emissive texture and and the main color.
  58321. */
  58322. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58323. /**
  58324. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  58325. * @param mesh The mesh to exclude from the highlight layer
  58326. */
  58327. addExcludedMesh(mesh: Mesh): void;
  58328. /**
  58329. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  58330. * @param mesh The mesh to highlight
  58331. */
  58332. removeExcludedMesh(mesh: Mesh): void;
  58333. /**
  58334. * Determine if a given mesh will be highlighted by the current HighlightLayer
  58335. * @param mesh mesh to test
  58336. * @returns true if the mesh will be highlighted by the current HighlightLayer
  58337. */
  58338. hasMesh(mesh: AbstractMesh): boolean;
  58339. /**
  58340. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  58341. * @param mesh The mesh to highlight
  58342. * @param color The color of the highlight
  58343. * @param glowEmissiveOnly Extract the glow from the emissive texture
  58344. */
  58345. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  58346. /**
  58347. * Remove a mesh from the highlight layer in order to make it stop glowing.
  58348. * @param mesh The mesh to highlight
  58349. */
  58350. removeMesh(mesh: Mesh): void;
  58351. /**
  58352. * Remove all the meshes currently referenced in the highlight layer
  58353. */
  58354. removeAllMeshes(): void;
  58355. /**
  58356. * Force the stencil to the normal expected value for none glowing parts
  58357. */
  58358. private _defaultStencilReference;
  58359. /**
  58360. * Free any resources and references associated to a mesh.
  58361. * Internal use
  58362. * @param mesh The mesh to free.
  58363. * @hidden
  58364. */
  58365. _disposeMesh(mesh: Mesh): void;
  58366. /**
  58367. * Dispose the highlight layer and free resources.
  58368. */
  58369. dispose(): void;
  58370. /**
  58371. * Gets the class name of the effect layer
  58372. * @returns the string with the class name of the effect layer
  58373. */
  58374. getClassName(): string;
  58375. /**
  58376. * Serializes this Highlight layer
  58377. * @returns a serialized Highlight layer object
  58378. */
  58379. serialize(): any;
  58380. /**
  58381. * Creates a Highlight layer from parsed Highlight layer data
  58382. * @param parsedHightlightLayer defines the Highlight layer data
  58383. * @param scene defines the current scene
  58384. * @param rootUrl defines the root URL containing the Highlight layer information
  58385. * @returns a parsed Highlight layer
  58386. */
  58387. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  58388. }
  58389. }
  58390. declare module BABYLON {
  58391. interface AbstractScene {
  58392. /**
  58393. * The list of layers (background and foreground) of the scene
  58394. */
  58395. layers: Array<Layer>;
  58396. }
  58397. /**
  58398. * Defines the layer scene component responsible to manage any layers
  58399. * in a given scene.
  58400. */
  58401. export class LayerSceneComponent implements ISceneComponent {
  58402. /**
  58403. * The component name helpfull to identify the component in the list of scene components.
  58404. */
  58405. readonly name: string;
  58406. /**
  58407. * The scene the component belongs to.
  58408. */
  58409. scene: Scene;
  58410. private _engine;
  58411. /**
  58412. * Creates a new instance of the component for the given scene
  58413. * @param scene Defines the scene to register the component in
  58414. */
  58415. constructor(scene: Scene);
  58416. /**
  58417. * Registers the component in a given scene
  58418. */
  58419. register(): void;
  58420. /**
  58421. * Rebuilds the elements related to this component in case of
  58422. * context lost for instance.
  58423. */
  58424. rebuild(): void;
  58425. /**
  58426. * Disposes the component and the associated ressources.
  58427. */
  58428. dispose(): void;
  58429. private _draw;
  58430. private _drawCameraPredicate;
  58431. private _drawCameraBackground;
  58432. private _drawCameraForeground;
  58433. private _drawRenderTargetPredicate;
  58434. private _drawRenderTargetBackground;
  58435. private _drawRenderTargetForeground;
  58436. /**
  58437. * Adds all the elements from the container to the scene
  58438. * @param container the container holding the elements
  58439. */
  58440. addFromContainer(container: AbstractScene): void;
  58441. /**
  58442. * Removes all the elements in the container from the scene
  58443. * @param container contains the elements to remove
  58444. * @param dispose if the removed element should be disposed (default: false)
  58445. */
  58446. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58447. }
  58448. }
  58449. declare module BABYLON {
  58450. /** @hidden */
  58451. export var layerPixelShader: {
  58452. name: string;
  58453. shader: string;
  58454. };
  58455. }
  58456. declare module BABYLON {
  58457. /** @hidden */
  58458. export var layerVertexShader: {
  58459. name: string;
  58460. shader: string;
  58461. };
  58462. }
  58463. declare module BABYLON {
  58464. /**
  58465. * This represents a full screen 2d layer.
  58466. * This can be useful to display a picture in the background of your scene for instance.
  58467. * @see https://www.babylonjs-playground.com/#08A2BS#1
  58468. */
  58469. export class Layer {
  58470. /**
  58471. * Define the name of the layer.
  58472. */
  58473. name: string;
  58474. /**
  58475. * Define the texture the layer should display.
  58476. */
  58477. texture: Nullable<Texture>;
  58478. /**
  58479. * Is the layer in background or foreground.
  58480. */
  58481. isBackground: boolean;
  58482. /**
  58483. * Define the color of the layer (instead of texture).
  58484. */
  58485. color: Color4;
  58486. /**
  58487. * Define the scale of the layer in order to zoom in out of the texture.
  58488. */
  58489. scale: Vector2;
  58490. /**
  58491. * Define an offset for the layer in order to shift the texture.
  58492. */
  58493. offset: Vector2;
  58494. /**
  58495. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  58496. */
  58497. alphaBlendingMode: number;
  58498. /**
  58499. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  58500. * Alpha test will not mix with the background color in case of transparency.
  58501. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  58502. */
  58503. alphaTest: boolean;
  58504. /**
  58505. * Define a mask to restrict the layer to only some of the scene cameras.
  58506. */
  58507. layerMask: number;
  58508. /**
  58509. * Define the list of render target the layer is visible into.
  58510. */
  58511. renderTargetTextures: RenderTargetTexture[];
  58512. /**
  58513. * Define if the layer is only used in renderTarget or if it also
  58514. * renders in the main frame buffer of the canvas.
  58515. */
  58516. renderOnlyInRenderTargetTextures: boolean;
  58517. private _scene;
  58518. private _vertexBuffers;
  58519. private _indexBuffer;
  58520. private _effect;
  58521. private _previousDefines;
  58522. /**
  58523. * An event triggered when the layer is disposed.
  58524. */
  58525. onDisposeObservable: Observable<Layer>;
  58526. private _onDisposeObserver;
  58527. /**
  58528. * Back compatibility with callback before the onDisposeObservable existed.
  58529. * The set callback will be triggered when the layer has been disposed.
  58530. */
  58531. set onDispose(callback: () => void);
  58532. /**
  58533. * An event triggered before rendering the scene
  58534. */
  58535. onBeforeRenderObservable: Observable<Layer>;
  58536. private _onBeforeRenderObserver;
  58537. /**
  58538. * Back compatibility with callback before the onBeforeRenderObservable existed.
  58539. * The set callback will be triggered just before rendering the layer.
  58540. */
  58541. set onBeforeRender(callback: () => void);
  58542. /**
  58543. * An event triggered after rendering the scene
  58544. */
  58545. onAfterRenderObservable: Observable<Layer>;
  58546. private _onAfterRenderObserver;
  58547. /**
  58548. * Back compatibility with callback before the onAfterRenderObservable existed.
  58549. * The set callback will be triggered just after rendering the layer.
  58550. */
  58551. set onAfterRender(callback: () => void);
  58552. /**
  58553. * Instantiates a new layer.
  58554. * This represents a full screen 2d layer.
  58555. * This can be useful to display a picture in the background of your scene for instance.
  58556. * @see https://www.babylonjs-playground.com/#08A2BS#1
  58557. * @param name Define the name of the layer in the scene
  58558. * @param imgUrl Define the url of the texture to display in the layer
  58559. * @param scene Define the scene the layer belongs to
  58560. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  58561. * @param color Defines a color for the layer
  58562. */
  58563. constructor(
  58564. /**
  58565. * Define the name of the layer.
  58566. */
  58567. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  58568. private _createIndexBuffer;
  58569. /** @hidden */
  58570. _rebuild(): void;
  58571. /**
  58572. * Renders the layer in the scene.
  58573. */
  58574. render(): void;
  58575. /**
  58576. * Disposes and releases the associated ressources.
  58577. */
  58578. dispose(): void;
  58579. }
  58580. }
  58581. declare module BABYLON {
  58582. /** @hidden */
  58583. export var lensFlarePixelShader: {
  58584. name: string;
  58585. shader: string;
  58586. };
  58587. }
  58588. declare module BABYLON {
  58589. /** @hidden */
  58590. export var lensFlareVertexShader: {
  58591. name: string;
  58592. shader: string;
  58593. };
  58594. }
  58595. declare module BABYLON {
  58596. /**
  58597. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  58598. * It is usually composed of several `lensFlare`.
  58599. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58600. */
  58601. export class LensFlareSystem {
  58602. /**
  58603. * Define the name of the lens flare system
  58604. */
  58605. name: string;
  58606. /**
  58607. * List of lens flares used in this system.
  58608. */
  58609. lensFlares: LensFlare[];
  58610. /**
  58611. * Define a limit from the border the lens flare can be visible.
  58612. */
  58613. borderLimit: number;
  58614. /**
  58615. * Define a viewport border we do not want to see the lens flare in.
  58616. */
  58617. viewportBorder: number;
  58618. /**
  58619. * Define a predicate which could limit the list of meshes able to occlude the effect.
  58620. */
  58621. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  58622. /**
  58623. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  58624. */
  58625. layerMask: number;
  58626. /**
  58627. * Define the id of the lens flare system in the scene.
  58628. * (equal to name by default)
  58629. */
  58630. id: string;
  58631. private _scene;
  58632. private _emitter;
  58633. private _vertexBuffers;
  58634. private _indexBuffer;
  58635. private _effect;
  58636. private _positionX;
  58637. private _positionY;
  58638. private _isEnabled;
  58639. /** @hidden */
  58640. static _SceneComponentInitialization: (scene: Scene) => void;
  58641. /**
  58642. * Instantiates a lens flare system.
  58643. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  58644. * It is usually composed of several `lensFlare`.
  58645. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58646. * @param name Define the name of the lens flare system in the scene
  58647. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  58648. * @param scene Define the scene the lens flare system belongs to
  58649. */
  58650. constructor(
  58651. /**
  58652. * Define the name of the lens flare system
  58653. */
  58654. name: string, emitter: any, scene: Scene);
  58655. /**
  58656. * Define if the lens flare system is enabled.
  58657. */
  58658. get isEnabled(): boolean;
  58659. set isEnabled(value: boolean);
  58660. /**
  58661. * Get the scene the effects belongs to.
  58662. * @returns the scene holding the lens flare system
  58663. */
  58664. getScene(): Scene;
  58665. /**
  58666. * Get the emitter of the lens flare system.
  58667. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  58668. * @returns the emitter of the lens flare system
  58669. */
  58670. getEmitter(): any;
  58671. /**
  58672. * Set the emitter of the lens flare system.
  58673. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  58674. * @param newEmitter Define the new emitter of the system
  58675. */
  58676. setEmitter(newEmitter: any): void;
  58677. /**
  58678. * Get the lens flare system emitter position.
  58679. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  58680. * @returns the position
  58681. */
  58682. getEmitterPosition(): Vector3;
  58683. /**
  58684. * @hidden
  58685. */
  58686. computeEffectivePosition(globalViewport: Viewport): boolean;
  58687. /** @hidden */
  58688. _isVisible(): boolean;
  58689. /**
  58690. * @hidden
  58691. */
  58692. render(): boolean;
  58693. /**
  58694. * Dispose and release the lens flare with its associated resources.
  58695. */
  58696. dispose(): void;
  58697. /**
  58698. * Parse a lens flare system from a JSON repressentation
  58699. * @param parsedLensFlareSystem Define the JSON to parse
  58700. * @param scene Define the scene the parsed system should be instantiated in
  58701. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  58702. * @returns the parsed system
  58703. */
  58704. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  58705. /**
  58706. * Serialize the current Lens Flare System into a JSON representation.
  58707. * @returns the serialized JSON
  58708. */
  58709. serialize(): any;
  58710. }
  58711. }
  58712. declare module BABYLON {
  58713. /**
  58714. * This represents one of the lens effect in a `lensFlareSystem`.
  58715. * It controls one of the indiviual texture used in the effect.
  58716. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58717. */
  58718. export class LensFlare {
  58719. /**
  58720. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  58721. */
  58722. size: number;
  58723. /**
  58724. * 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.
  58725. */
  58726. position: number;
  58727. /**
  58728. * Define the lens color.
  58729. */
  58730. color: Color3;
  58731. /**
  58732. * Define the lens texture.
  58733. */
  58734. texture: Nullable<Texture>;
  58735. /**
  58736. * Define the alpha mode to render this particular lens.
  58737. */
  58738. alphaMode: number;
  58739. private _system;
  58740. /**
  58741. * Creates a new Lens Flare.
  58742. * This represents one of the lens effect in a `lensFlareSystem`.
  58743. * It controls one of the indiviual texture used in the effect.
  58744. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58745. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  58746. * @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.
  58747. * @param color Define the lens color
  58748. * @param imgUrl Define the lens texture url
  58749. * @param system Define the `lensFlareSystem` this flare is part of
  58750. * @returns The newly created Lens Flare
  58751. */
  58752. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  58753. /**
  58754. * Instantiates a new Lens Flare.
  58755. * This represents one of the lens effect in a `lensFlareSystem`.
  58756. * It controls one of the indiviual texture used in the effect.
  58757. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58758. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  58759. * @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.
  58760. * @param color Define the lens color
  58761. * @param imgUrl Define the lens texture url
  58762. * @param system Define the `lensFlareSystem` this flare is part of
  58763. */
  58764. constructor(
  58765. /**
  58766. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  58767. */
  58768. size: number,
  58769. /**
  58770. * 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.
  58771. */
  58772. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  58773. /**
  58774. * Dispose and release the lens flare with its associated resources.
  58775. */
  58776. dispose(): void;
  58777. }
  58778. }
  58779. declare module BABYLON {
  58780. interface AbstractScene {
  58781. /**
  58782. * The list of lens flare system added to the scene
  58783. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  58784. */
  58785. lensFlareSystems: Array<LensFlareSystem>;
  58786. /**
  58787. * Removes the given lens flare system from this scene.
  58788. * @param toRemove The lens flare system to remove
  58789. * @returns The index of the removed lens flare system
  58790. */
  58791. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  58792. /**
  58793. * Adds the given lens flare system to this scene
  58794. * @param newLensFlareSystem The lens flare system to add
  58795. */
  58796. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  58797. /**
  58798. * Gets a lens flare system using its name
  58799. * @param name defines the name to look for
  58800. * @returns the lens flare system or null if not found
  58801. */
  58802. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  58803. /**
  58804. * Gets a lens flare system using its id
  58805. * @param id defines the id to look for
  58806. * @returns the lens flare system or null if not found
  58807. */
  58808. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  58809. }
  58810. /**
  58811. * Defines the lens flare scene component responsible to manage any lens flares
  58812. * in a given scene.
  58813. */
  58814. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  58815. /**
  58816. * The component name helpfull to identify the component in the list of scene components.
  58817. */
  58818. readonly name: string;
  58819. /**
  58820. * The scene the component belongs to.
  58821. */
  58822. scene: Scene;
  58823. /**
  58824. * Creates a new instance of the component for the given scene
  58825. * @param scene Defines the scene to register the component in
  58826. */
  58827. constructor(scene: Scene);
  58828. /**
  58829. * Registers the component in a given scene
  58830. */
  58831. register(): void;
  58832. /**
  58833. * Rebuilds the elements related to this component in case of
  58834. * context lost for instance.
  58835. */
  58836. rebuild(): void;
  58837. /**
  58838. * Adds all the elements from the container to the scene
  58839. * @param container the container holding the elements
  58840. */
  58841. addFromContainer(container: AbstractScene): void;
  58842. /**
  58843. * Removes all the elements in the container from the scene
  58844. * @param container contains the elements to remove
  58845. * @param dispose if the removed element should be disposed (default: false)
  58846. */
  58847. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58848. /**
  58849. * Serializes the component data to the specified json object
  58850. * @param serializationObject The object to serialize to
  58851. */
  58852. serialize(serializationObject: any): void;
  58853. /**
  58854. * Disposes the component and the associated ressources.
  58855. */
  58856. dispose(): void;
  58857. private _draw;
  58858. }
  58859. }
  58860. declare module BABYLON {
  58861. /** @hidden */
  58862. export var depthPixelShader: {
  58863. name: string;
  58864. shader: string;
  58865. };
  58866. }
  58867. declare module BABYLON {
  58868. /** @hidden */
  58869. export var depthVertexShader: {
  58870. name: string;
  58871. shader: string;
  58872. };
  58873. }
  58874. declare module BABYLON {
  58875. /**
  58876. * This represents a depth renderer in Babylon.
  58877. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  58878. */
  58879. export class DepthRenderer {
  58880. private _scene;
  58881. private _depthMap;
  58882. private _effect;
  58883. private readonly _storeNonLinearDepth;
  58884. private readonly _clearColor;
  58885. /** Get if the depth renderer is using packed depth or not */
  58886. readonly isPacked: boolean;
  58887. private _cachedDefines;
  58888. private _camera;
  58889. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  58890. enabled: boolean;
  58891. /**
  58892. * Specifiess that the depth renderer will only be used within
  58893. * the camera it is created for.
  58894. * This can help forcing its rendering during the camera processing.
  58895. */
  58896. useOnlyInActiveCamera: boolean;
  58897. /** @hidden */
  58898. static _SceneComponentInitialization: (scene: Scene) => void;
  58899. /**
  58900. * Instantiates a depth renderer
  58901. * @param scene The scene the renderer belongs to
  58902. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  58903. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  58904. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  58905. */
  58906. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  58907. /**
  58908. * Creates the depth rendering effect and checks if the effect is ready.
  58909. * @param subMesh The submesh to be used to render the depth map of
  58910. * @param useInstances If multiple world instances should be used
  58911. * @returns if the depth renderer is ready to render the depth map
  58912. */
  58913. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58914. /**
  58915. * Gets the texture which the depth map will be written to.
  58916. * @returns The depth map texture
  58917. */
  58918. getDepthMap(): RenderTargetTexture;
  58919. /**
  58920. * Disposes of the depth renderer.
  58921. */
  58922. dispose(): void;
  58923. }
  58924. }
  58925. declare module BABYLON {
  58926. /** @hidden */
  58927. export var minmaxReduxPixelShader: {
  58928. name: string;
  58929. shader: string;
  58930. };
  58931. }
  58932. declare module BABYLON {
  58933. /**
  58934. * This class computes a min/max reduction from a texture: it means it computes the minimum
  58935. * and maximum values from all values of the texture.
  58936. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  58937. * The source values are read from the red channel of the texture.
  58938. */
  58939. export class MinMaxReducer {
  58940. /**
  58941. * Observable triggered when the computation has been performed
  58942. */
  58943. onAfterReductionPerformed: Observable<{
  58944. min: number;
  58945. max: number;
  58946. }>;
  58947. protected _camera: Camera;
  58948. protected _sourceTexture: Nullable<RenderTargetTexture>;
  58949. protected _reductionSteps: Nullable<Array<PostProcess>>;
  58950. protected _postProcessManager: PostProcessManager;
  58951. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  58952. protected _forceFullscreenViewport: boolean;
  58953. /**
  58954. * Creates a min/max reducer
  58955. * @param camera The camera to use for the post processes
  58956. */
  58957. constructor(camera: Camera);
  58958. /**
  58959. * Gets the texture used to read the values from.
  58960. */
  58961. get sourceTexture(): Nullable<RenderTargetTexture>;
  58962. /**
  58963. * Sets the source texture to read the values from.
  58964. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  58965. * because in such textures '1' value must not be taken into account to compute the maximum
  58966. * as this value is used to clear the texture.
  58967. * Note that the computation is not activated by calling this function, you must call activate() for that!
  58968. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  58969. * @param depthRedux Indicates if the texture is a depth texture or not
  58970. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  58971. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  58972. */
  58973. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  58974. /**
  58975. * Defines the refresh rate of the computation.
  58976. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  58977. */
  58978. get refreshRate(): number;
  58979. set refreshRate(value: number);
  58980. protected _activated: boolean;
  58981. /**
  58982. * Gets the activation status of the reducer
  58983. */
  58984. get activated(): boolean;
  58985. /**
  58986. * Activates the reduction computation.
  58987. * When activated, the observers registered in onAfterReductionPerformed are
  58988. * called after the compuation is performed
  58989. */
  58990. activate(): void;
  58991. /**
  58992. * Deactivates the reduction computation.
  58993. */
  58994. deactivate(): void;
  58995. /**
  58996. * Disposes the min/max reducer
  58997. * @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.
  58998. */
  58999. dispose(disposeAll?: boolean): void;
  59000. }
  59001. }
  59002. declare module BABYLON {
  59003. /**
  59004. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  59005. */
  59006. export class DepthReducer extends MinMaxReducer {
  59007. private _depthRenderer;
  59008. private _depthRendererId;
  59009. /**
  59010. * Gets the depth renderer used for the computation.
  59011. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  59012. */
  59013. get depthRenderer(): Nullable<DepthRenderer>;
  59014. /**
  59015. * Creates a depth reducer
  59016. * @param camera The camera used to render the depth texture
  59017. */
  59018. constructor(camera: Camera);
  59019. /**
  59020. * Sets the depth renderer to use to generate the depth map
  59021. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  59022. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  59023. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  59024. */
  59025. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  59026. /** @hidden */
  59027. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  59028. /**
  59029. * Activates the reduction computation.
  59030. * When activated, the observers registered in onAfterReductionPerformed are
  59031. * called after the compuation is performed
  59032. */
  59033. activate(): void;
  59034. /**
  59035. * Deactivates the reduction computation.
  59036. */
  59037. deactivate(): void;
  59038. /**
  59039. * Disposes the depth reducer
  59040. * @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.
  59041. */
  59042. dispose(disposeAll?: boolean): void;
  59043. }
  59044. }
  59045. declare module BABYLON {
  59046. /**
  59047. * A CSM implementation allowing casting shadows on large scenes.
  59048. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  59049. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  59050. */
  59051. export class CascadedShadowGenerator extends ShadowGenerator {
  59052. private static readonly frustumCornersNDCSpace;
  59053. /**
  59054. * Name of the CSM class
  59055. */
  59056. static CLASSNAME: string;
  59057. /**
  59058. * Defines the default number of cascades used by the CSM.
  59059. */
  59060. static readonly DEFAULT_CASCADES_COUNT: number;
  59061. /**
  59062. * Defines the minimum number of cascades used by the CSM.
  59063. */
  59064. static readonly MIN_CASCADES_COUNT: number;
  59065. /**
  59066. * Defines the maximum number of cascades used by the CSM.
  59067. */
  59068. static readonly MAX_CASCADES_COUNT: number;
  59069. protected _validateFilter(filter: number): number;
  59070. /**
  59071. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  59072. */
  59073. penumbraDarkness: number;
  59074. private _numCascades;
  59075. /**
  59076. * Gets or set the number of cascades used by the CSM.
  59077. */
  59078. get numCascades(): number;
  59079. set numCascades(value: number);
  59080. /**
  59081. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  59082. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  59083. */
  59084. stabilizeCascades: boolean;
  59085. private _freezeShadowCastersBoundingInfo;
  59086. private _freezeShadowCastersBoundingInfoObservable;
  59087. /**
  59088. * Enables or disables the shadow casters bounding info computation.
  59089. * If your shadow casters don't move, you can disable this feature.
  59090. * If it is enabled, the bounding box computation is done every frame.
  59091. */
  59092. get freezeShadowCastersBoundingInfo(): boolean;
  59093. set freezeShadowCastersBoundingInfo(freeze: boolean);
  59094. private _scbiMin;
  59095. private _scbiMax;
  59096. protected _computeShadowCastersBoundingInfo(): void;
  59097. protected _shadowCastersBoundingInfo: BoundingInfo;
  59098. /**
  59099. * Gets or sets the shadow casters bounding info.
  59100. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  59101. * so that the system won't overwrite the bounds you provide
  59102. */
  59103. get shadowCastersBoundingInfo(): BoundingInfo;
  59104. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  59105. protected _breaksAreDirty: boolean;
  59106. protected _minDistance: number;
  59107. protected _maxDistance: number;
  59108. /**
  59109. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  59110. *
  59111. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  59112. * If you don't know these values, simply leave them to their defaults and don't call this function.
  59113. * @param min minimal distance for the breaks (default to 0.)
  59114. * @param max maximal distance for the breaks (default to 1.)
  59115. */
  59116. setMinMaxDistance(min: number, max: number): void;
  59117. /** Gets the minimal distance used in the cascade break computation */
  59118. get minDistance(): number;
  59119. /** Gets the maximal distance used in the cascade break computation */
  59120. get maxDistance(): number;
  59121. /**
  59122. * Gets the class name of that object
  59123. * @returns "CascadedShadowGenerator"
  59124. */
  59125. getClassName(): string;
  59126. private _cascadeMinExtents;
  59127. private _cascadeMaxExtents;
  59128. /**
  59129. * Gets a cascade minimum extents
  59130. * @param cascadeIndex index of the cascade
  59131. * @returns the minimum cascade extents
  59132. */
  59133. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  59134. /**
  59135. * Gets a cascade maximum extents
  59136. * @param cascadeIndex index of the cascade
  59137. * @returns the maximum cascade extents
  59138. */
  59139. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  59140. private _cascades;
  59141. private _currentLayer;
  59142. private _viewSpaceFrustumsZ;
  59143. private _viewMatrices;
  59144. private _projectionMatrices;
  59145. private _transformMatrices;
  59146. private _transformMatricesAsArray;
  59147. private _frustumLengths;
  59148. private _lightSizeUVCorrection;
  59149. private _depthCorrection;
  59150. private _frustumCornersWorldSpace;
  59151. private _frustumCenter;
  59152. private _shadowCameraPos;
  59153. private _shadowMaxZ;
  59154. /**
  59155. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  59156. * It defaults to camera.maxZ
  59157. */
  59158. get shadowMaxZ(): number;
  59159. /**
  59160. * Sets the shadow max z distance.
  59161. */
  59162. set shadowMaxZ(value: number);
  59163. protected _debug: boolean;
  59164. /**
  59165. * Gets or sets the debug flag.
  59166. * When enabled, the cascades are materialized by different colors on the screen.
  59167. */
  59168. get debug(): boolean;
  59169. set debug(dbg: boolean);
  59170. private _depthClamp;
  59171. /**
  59172. * Gets or sets the depth clamping value.
  59173. *
  59174. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  59175. * to account for the shadow casters far away.
  59176. *
  59177. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  59178. */
  59179. get depthClamp(): boolean;
  59180. set depthClamp(value: boolean);
  59181. private _cascadeBlendPercentage;
  59182. /**
  59183. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  59184. * It defaults to 0.1 (10% blending).
  59185. */
  59186. get cascadeBlendPercentage(): number;
  59187. set cascadeBlendPercentage(value: number);
  59188. private _lambda;
  59189. /**
  59190. * Gets or set the lambda parameter.
  59191. * This parameter is used to split the camera frustum and create the cascades.
  59192. * 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.
  59193. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  59194. */
  59195. get lambda(): number;
  59196. set lambda(value: number);
  59197. /**
  59198. * Gets the view matrix corresponding to a given cascade
  59199. * @param cascadeNum cascade to retrieve the view matrix from
  59200. * @returns the cascade view matrix
  59201. */
  59202. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  59203. /**
  59204. * Gets the projection matrix corresponding to a given cascade
  59205. * @param cascadeNum cascade to retrieve the projection matrix from
  59206. * @returns the cascade projection matrix
  59207. */
  59208. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  59209. /**
  59210. * Gets the transformation matrix corresponding to a given cascade
  59211. * @param cascadeNum cascade to retrieve the transformation matrix from
  59212. * @returns the cascade transformation matrix
  59213. */
  59214. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  59215. private _depthRenderer;
  59216. /**
  59217. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  59218. *
  59219. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  59220. *
  59221. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  59222. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  59223. * @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
  59224. */
  59225. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  59226. private _depthReducer;
  59227. private _autoCalcDepthBounds;
  59228. /**
  59229. * Gets or sets the autoCalcDepthBounds property.
  59230. *
  59231. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  59232. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  59233. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  59234. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  59235. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  59236. */
  59237. get autoCalcDepthBounds(): boolean;
  59238. set autoCalcDepthBounds(value: boolean);
  59239. /**
  59240. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  59241. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  59242. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  59243. * for setting the refresh rate on the renderer yourself!
  59244. */
  59245. get autoCalcDepthBoundsRefreshRate(): number;
  59246. set autoCalcDepthBoundsRefreshRate(value: number);
  59247. /**
  59248. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  59249. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  59250. * you change the camera near/far planes!
  59251. */
  59252. splitFrustum(): void;
  59253. private _splitFrustum;
  59254. private _computeMatrices;
  59255. private _computeFrustumInWorldSpace;
  59256. private _computeCascadeFrustum;
  59257. /**
  59258. * Support test.
  59259. */
  59260. static get IsSupported(): boolean;
  59261. /** @hidden */
  59262. static _SceneComponentInitialization: (scene: Scene) => void;
  59263. /**
  59264. * Creates a Cascaded Shadow Generator object.
  59265. * A ShadowGenerator is the required tool to use the shadows.
  59266. * Each directional light casting shadows needs to use its own ShadowGenerator.
  59267. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  59268. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  59269. * @param light The directional light object generating the shadows.
  59270. * @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.
  59271. */
  59272. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  59273. protected _initializeGenerator(): void;
  59274. protected _createTargetRenderTexture(): void;
  59275. protected _initializeShadowMap(): void;
  59276. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  59277. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  59278. /**
  59279. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  59280. * @param defines Defines of the material we want to update
  59281. * @param lightIndex Index of the light in the enabled light list of the material
  59282. */
  59283. prepareDefines(defines: any, lightIndex: number): void;
  59284. /**
  59285. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  59286. * defined in the generator but impacting the effect).
  59287. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  59288. * @param effect The effect we are binfing the information for
  59289. */
  59290. bindShadowLight(lightIndex: string, effect: Effect): void;
  59291. /**
  59292. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  59293. * (eq to view projection * shadow projection matrices)
  59294. * @returns The transform matrix used to create the shadow map
  59295. */
  59296. getTransformMatrix(): Matrix;
  59297. /**
  59298. * Disposes the ShadowGenerator.
  59299. * Returns nothing.
  59300. */
  59301. dispose(): void;
  59302. /**
  59303. * Serializes the shadow generator setup to a json object.
  59304. * @returns The serialized JSON object
  59305. */
  59306. serialize(): any;
  59307. /**
  59308. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  59309. * @param parsedShadowGenerator The JSON object to parse
  59310. * @param scene The scene to create the shadow map for
  59311. * @returns The parsed shadow generator
  59312. */
  59313. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  59314. }
  59315. }
  59316. declare module BABYLON {
  59317. /**
  59318. * Defines the shadow generator component responsible to manage any shadow generators
  59319. * in a given scene.
  59320. */
  59321. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  59322. /**
  59323. * The component name helpfull to identify the component in the list of scene components.
  59324. */
  59325. readonly name: string;
  59326. /**
  59327. * The scene the component belongs to.
  59328. */
  59329. scene: Scene;
  59330. /**
  59331. * Creates a new instance of the component for the given scene
  59332. * @param scene Defines the scene to register the component in
  59333. */
  59334. constructor(scene: Scene);
  59335. /**
  59336. * Registers the component in a given scene
  59337. */
  59338. register(): void;
  59339. /**
  59340. * Rebuilds the elements related to this component in case of
  59341. * context lost for instance.
  59342. */
  59343. rebuild(): void;
  59344. /**
  59345. * Serializes the component data to the specified json object
  59346. * @param serializationObject The object to serialize to
  59347. */
  59348. serialize(serializationObject: any): void;
  59349. /**
  59350. * Adds all the elements from the container to the scene
  59351. * @param container the container holding the elements
  59352. */
  59353. addFromContainer(container: AbstractScene): void;
  59354. /**
  59355. * Removes all the elements in the container from the scene
  59356. * @param container contains the elements to remove
  59357. * @param dispose if the removed element should be disposed (default: false)
  59358. */
  59359. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59360. /**
  59361. * Rebuilds the elements related to this component in case of
  59362. * context lost for instance.
  59363. */
  59364. dispose(): void;
  59365. private _gatherRenderTargets;
  59366. }
  59367. }
  59368. declare module BABYLON {
  59369. /**
  59370. * A point light is a light defined by an unique point in world space.
  59371. * The light is emitted in every direction from this point.
  59372. * A good example of a point light is a standard light bulb.
  59373. * Documentation: https://doc.babylonjs.com/babylon101/lights
  59374. */
  59375. export class PointLight extends ShadowLight {
  59376. private _shadowAngle;
  59377. /**
  59378. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59379. * This specifies what angle the shadow will use to be created.
  59380. *
  59381. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  59382. */
  59383. get shadowAngle(): number;
  59384. /**
  59385. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59386. * This specifies what angle the shadow will use to be created.
  59387. *
  59388. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  59389. */
  59390. set shadowAngle(value: number);
  59391. /**
  59392. * Gets the direction if it has been set.
  59393. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59394. */
  59395. get direction(): Vector3;
  59396. /**
  59397. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  59398. */
  59399. set direction(value: Vector3);
  59400. /**
  59401. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  59402. * A PointLight emits the light in every direction.
  59403. * It can cast shadows.
  59404. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  59405. * ```javascript
  59406. * var pointLight = new PointLight("pl", camera.position, scene);
  59407. * ```
  59408. * Documentation : https://doc.babylonjs.com/babylon101/lights
  59409. * @param name The light friendly name
  59410. * @param position The position of the point light in the scene
  59411. * @param scene The scene the lights belongs to
  59412. */
  59413. constructor(name: string, position: Vector3, scene: Scene);
  59414. /**
  59415. * Returns the string "PointLight"
  59416. * @returns the class name
  59417. */
  59418. getClassName(): string;
  59419. /**
  59420. * Returns the integer 0.
  59421. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  59422. */
  59423. getTypeID(): number;
  59424. /**
  59425. * Specifies wether or not the shadowmap should be a cube texture.
  59426. * @returns true if the shadowmap needs to be a cube texture.
  59427. */
  59428. needCube(): boolean;
  59429. /**
  59430. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  59431. * @param faceIndex The index of the face we are computed the direction to generate shadow
  59432. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  59433. */
  59434. getShadowDirection(faceIndex?: number): Vector3;
  59435. /**
  59436. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  59437. * - fov = PI / 2
  59438. * - aspect ratio : 1.0
  59439. * - z-near and far equal to the active camera minZ and maxZ.
  59440. * Returns the PointLight.
  59441. */
  59442. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59443. protected _buildUniformLayout(): void;
  59444. /**
  59445. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  59446. * @param effect The effect to update
  59447. * @param lightIndex The index of the light in the effect to update
  59448. * @returns The point light
  59449. */
  59450. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  59451. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  59452. /**
  59453. * Prepares the list of defines specific to the light type.
  59454. * @param defines the list of defines
  59455. * @param lightIndex defines the index of the light for the effect
  59456. */
  59457. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  59458. }
  59459. }
  59460. declare module BABYLON {
  59461. /**
  59462. * Header information of HDR texture files.
  59463. */
  59464. export interface HDRInfo {
  59465. /**
  59466. * The height of the texture in pixels.
  59467. */
  59468. height: number;
  59469. /**
  59470. * The width of the texture in pixels.
  59471. */
  59472. width: number;
  59473. /**
  59474. * The index of the beginning of the data in the binary file.
  59475. */
  59476. dataPosition: number;
  59477. }
  59478. /**
  59479. * This groups tools to convert HDR texture to native colors array.
  59480. */
  59481. export class HDRTools {
  59482. private static Ldexp;
  59483. private static Rgbe2float;
  59484. private static readStringLine;
  59485. /**
  59486. * Reads header information from an RGBE texture stored in a native array.
  59487. * More information on this format are available here:
  59488. * https://en.wikipedia.org/wiki/RGBE_image_format
  59489. *
  59490. * @param uint8array The binary file stored in native array.
  59491. * @return The header information.
  59492. */
  59493. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  59494. /**
  59495. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  59496. * This RGBE texture needs to store the information as a panorama.
  59497. *
  59498. * More information on this format are available here:
  59499. * https://en.wikipedia.org/wiki/RGBE_image_format
  59500. *
  59501. * @param buffer The binary file stored in an array buffer.
  59502. * @param size The expected size of the extracted cubemap.
  59503. * @return The Cube Map information.
  59504. */
  59505. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  59506. /**
  59507. * Returns the pixels data extracted from an RGBE texture.
  59508. * This pixels will be stored left to right up to down in the R G B order in one array.
  59509. *
  59510. * More information on this format are available here:
  59511. * https://en.wikipedia.org/wiki/RGBE_image_format
  59512. *
  59513. * @param uint8array The binary file stored in an array buffer.
  59514. * @param hdrInfo The header information of the file.
  59515. * @return The pixels data in RGB right to left up to down order.
  59516. */
  59517. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  59518. private static RGBE_ReadPixels_RLE;
  59519. private static RGBE_ReadPixels_NOT_RLE;
  59520. }
  59521. }
  59522. declare module BABYLON {
  59523. /**
  59524. * Effect Render Options
  59525. */
  59526. export interface IEffectRendererOptions {
  59527. /**
  59528. * Defines the vertices positions.
  59529. */
  59530. positions?: number[];
  59531. /**
  59532. * Defines the indices.
  59533. */
  59534. indices?: number[];
  59535. }
  59536. /**
  59537. * Helper class to render one or more effects.
  59538. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  59539. */
  59540. export class EffectRenderer {
  59541. private engine;
  59542. private static _DefaultOptions;
  59543. private _vertexBuffers;
  59544. private _indexBuffer;
  59545. private _fullscreenViewport;
  59546. /**
  59547. * Creates an effect renderer
  59548. * @param engine the engine to use for rendering
  59549. * @param options defines the options of the effect renderer
  59550. */
  59551. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  59552. /**
  59553. * Sets the current viewport in normalized coordinates 0-1
  59554. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  59555. */
  59556. setViewport(viewport?: Viewport): void;
  59557. /**
  59558. * Binds the embedded attributes buffer to the effect.
  59559. * @param effect Defines the effect to bind the attributes for
  59560. */
  59561. bindBuffers(effect: Effect): void;
  59562. /**
  59563. * Sets the current effect wrapper to use during draw.
  59564. * The effect needs to be ready before calling this api.
  59565. * This also sets the default full screen position attribute.
  59566. * @param effectWrapper Defines the effect to draw with
  59567. */
  59568. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  59569. /**
  59570. * Restores engine states
  59571. */
  59572. restoreStates(): void;
  59573. /**
  59574. * Draws a full screen quad.
  59575. */
  59576. draw(): void;
  59577. private isRenderTargetTexture;
  59578. /**
  59579. * renders one or more effects to a specified texture
  59580. * @param effectWrapper the effect to renderer
  59581. * @param outputTexture texture to draw to, if null it will render to the screen.
  59582. */
  59583. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  59584. /**
  59585. * Disposes of the effect renderer
  59586. */
  59587. dispose(): void;
  59588. }
  59589. /**
  59590. * Options to create an EffectWrapper
  59591. */
  59592. interface EffectWrapperCreationOptions {
  59593. /**
  59594. * Engine to use to create the effect
  59595. */
  59596. engine: ThinEngine;
  59597. /**
  59598. * Fragment shader for the effect
  59599. */
  59600. fragmentShader: string;
  59601. /**
  59602. * Use the shader store instead of direct source code
  59603. */
  59604. useShaderStore?: boolean;
  59605. /**
  59606. * Vertex shader for the effect
  59607. */
  59608. vertexShader?: string;
  59609. /**
  59610. * Attributes to use in the shader
  59611. */
  59612. attributeNames?: Array<string>;
  59613. /**
  59614. * Uniforms to use in the shader
  59615. */
  59616. uniformNames?: Array<string>;
  59617. /**
  59618. * Texture sampler names to use in the shader
  59619. */
  59620. samplerNames?: Array<string>;
  59621. /**
  59622. * Defines to use in the shader
  59623. */
  59624. defines?: Array<string>;
  59625. /**
  59626. * Callback when effect is compiled
  59627. */
  59628. onCompiled?: Nullable<(effect: Effect) => void>;
  59629. /**
  59630. * The friendly name of the effect displayed in Spector.
  59631. */
  59632. name?: string;
  59633. }
  59634. /**
  59635. * Wraps an effect to be used for rendering
  59636. */
  59637. export class EffectWrapper {
  59638. /**
  59639. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  59640. */
  59641. onApplyObservable: Observable<{}>;
  59642. /**
  59643. * The underlying effect
  59644. */
  59645. effect: Effect;
  59646. /**
  59647. * Creates an effect to be renderer
  59648. * @param creationOptions options to create the effect
  59649. */
  59650. constructor(creationOptions: EffectWrapperCreationOptions);
  59651. /**
  59652. * Disposes of the effect wrapper
  59653. */
  59654. dispose(): void;
  59655. }
  59656. }
  59657. declare module BABYLON {
  59658. /** @hidden */
  59659. export var hdrFilteringVertexShader: {
  59660. name: string;
  59661. shader: string;
  59662. };
  59663. }
  59664. declare module BABYLON {
  59665. /** @hidden */
  59666. export var hdrFilteringPixelShader: {
  59667. name: string;
  59668. shader: string;
  59669. };
  59670. }
  59671. declare module BABYLON {
  59672. /**
  59673. * Options for texture filtering
  59674. */
  59675. interface IHDRFilteringOptions {
  59676. /**
  59677. * Scales pixel intensity for the input HDR map.
  59678. */
  59679. hdrScale?: number;
  59680. /**
  59681. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  59682. */
  59683. quality?: number;
  59684. }
  59685. /**
  59686. * Filters HDR maps to get correct renderings of PBR reflections
  59687. */
  59688. export class HDRFiltering {
  59689. private _engine;
  59690. private _effectRenderer;
  59691. private _effectWrapper;
  59692. private _lodGenerationOffset;
  59693. private _lodGenerationScale;
  59694. /**
  59695. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  59696. * you care about baking speed.
  59697. */
  59698. quality: number;
  59699. /**
  59700. * Scales pixel intensity for the input HDR map.
  59701. */
  59702. hdrScale: number;
  59703. /**
  59704. * Instantiates HDR filter for reflection maps
  59705. *
  59706. * @param engine Thin engine
  59707. * @param options Options
  59708. */
  59709. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  59710. private _createRenderTarget;
  59711. private _prefilterInternal;
  59712. private _createEffect;
  59713. /**
  59714. * Get a value indicating if the filter is ready to be used
  59715. * @param texture Texture to filter
  59716. * @returns true if the filter is ready
  59717. */
  59718. isReady(texture: BaseTexture): boolean;
  59719. /**
  59720. * Prefilters a cube texture to have mipmap levels representing roughness values.
  59721. * Prefiltering will be invoked at the end of next rendering pass.
  59722. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  59723. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  59724. * @param texture Texture to filter
  59725. * @param onFinished Callback when filtering is done
  59726. * @return Promise called when prefiltering is done
  59727. */
  59728. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  59729. }
  59730. }
  59731. declare module BABYLON {
  59732. /**
  59733. * This represents a texture coming from an HDR input.
  59734. *
  59735. * The only supported format is currently panorama picture stored in RGBE format.
  59736. * Example of such files can be found on HDRLib: http://hdrlib.com/
  59737. */
  59738. export class HDRCubeTexture extends BaseTexture {
  59739. private static _facesMapping;
  59740. private _generateHarmonics;
  59741. private _noMipmap;
  59742. private _prefilterOnLoad;
  59743. private _textureMatrix;
  59744. private _size;
  59745. private _onLoad;
  59746. private _onError;
  59747. /**
  59748. * The texture URL.
  59749. */
  59750. url: string;
  59751. /**
  59752. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  59753. */
  59754. coordinatesMode: number;
  59755. protected _isBlocking: boolean;
  59756. /**
  59757. * Sets wether or not the texture is blocking during loading.
  59758. */
  59759. set isBlocking(value: boolean);
  59760. /**
  59761. * Gets wether or not the texture is blocking during loading.
  59762. */
  59763. get isBlocking(): boolean;
  59764. protected _rotationY: number;
  59765. /**
  59766. * Sets texture matrix rotation angle around Y axis in radians.
  59767. */
  59768. set rotationY(value: number);
  59769. /**
  59770. * Gets texture matrix rotation angle around Y axis radians.
  59771. */
  59772. get rotationY(): number;
  59773. /**
  59774. * Gets or sets the center of the bounding box associated with the cube texture
  59775. * It must define where the camera used to render the texture was set
  59776. */
  59777. boundingBoxPosition: Vector3;
  59778. private _boundingBoxSize;
  59779. /**
  59780. * Gets or sets the size of the bounding box associated with the cube texture
  59781. * When defined, the cubemap will switch to local mode
  59782. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  59783. * @example https://www.babylonjs-playground.com/#RNASML
  59784. */
  59785. set boundingBoxSize(value: Vector3);
  59786. get boundingBoxSize(): Vector3;
  59787. /**
  59788. * Instantiates an HDRTexture from the following parameters.
  59789. *
  59790. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  59791. * @param sceneOrEngine The scene or engine the texture will be used in
  59792. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  59793. * @param noMipmap Forces to not generate the mipmap if true
  59794. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  59795. * @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)
  59796. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  59797. */
  59798. 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>);
  59799. /**
  59800. * Get the current class name of the texture useful for serialization or dynamic coding.
  59801. * @returns "HDRCubeTexture"
  59802. */
  59803. getClassName(): string;
  59804. /**
  59805. * Occurs when the file is raw .hdr file.
  59806. */
  59807. private loadTexture;
  59808. clone(): HDRCubeTexture;
  59809. delayLoad(): void;
  59810. /**
  59811. * Get the texture reflection matrix used to rotate/transform the reflection.
  59812. * @returns the reflection matrix
  59813. */
  59814. getReflectionTextureMatrix(): Matrix;
  59815. /**
  59816. * Set the texture reflection matrix used to rotate/transform the reflection.
  59817. * @param value Define the reflection matrix to set
  59818. */
  59819. setReflectionTextureMatrix(value: Matrix): void;
  59820. /**
  59821. * Parses a JSON representation of an HDR Texture in order to create the texture
  59822. * @param parsedTexture Define the JSON representation
  59823. * @param scene Define the scene the texture should be created in
  59824. * @param rootUrl Define the root url in case we need to load relative dependencies
  59825. * @returns the newly created texture after parsing
  59826. */
  59827. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  59828. serialize(): any;
  59829. }
  59830. }
  59831. declare module BABYLON {
  59832. /**
  59833. * Class used to control physics engine
  59834. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  59835. */
  59836. export class PhysicsEngine implements IPhysicsEngine {
  59837. private _physicsPlugin;
  59838. /**
  59839. * Global value used to control the smallest number supported by the simulation
  59840. */
  59841. static Epsilon: number;
  59842. private _impostors;
  59843. private _joints;
  59844. private _subTimeStep;
  59845. /**
  59846. * Gets the gravity vector used by the simulation
  59847. */
  59848. gravity: Vector3;
  59849. /**
  59850. * Factory used to create the default physics plugin.
  59851. * @returns The default physics plugin
  59852. */
  59853. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  59854. /**
  59855. * Creates a new Physics Engine
  59856. * @param gravity defines the gravity vector used by the simulation
  59857. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  59858. */
  59859. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  59860. /**
  59861. * Sets the gravity vector used by the simulation
  59862. * @param gravity defines the gravity vector to use
  59863. */
  59864. setGravity(gravity: Vector3): void;
  59865. /**
  59866. * Set the time step of the physics engine.
  59867. * Default is 1/60.
  59868. * To slow it down, enter 1/600 for example.
  59869. * To speed it up, 1/30
  59870. * @param newTimeStep defines the new timestep to apply to this world.
  59871. */
  59872. setTimeStep(newTimeStep?: number): void;
  59873. /**
  59874. * Get the time step of the physics engine.
  59875. * @returns the current time step
  59876. */
  59877. getTimeStep(): number;
  59878. /**
  59879. * Set the sub time step of the physics engine.
  59880. * Default is 0 meaning there is no sub steps
  59881. * To increase physics resolution precision, set a small value (like 1 ms)
  59882. * @param subTimeStep defines the new sub timestep used for physics resolution.
  59883. */
  59884. setSubTimeStep(subTimeStep?: number): void;
  59885. /**
  59886. * Get the sub time step of the physics engine.
  59887. * @returns the current sub time step
  59888. */
  59889. getSubTimeStep(): number;
  59890. /**
  59891. * Release all resources
  59892. */
  59893. dispose(): void;
  59894. /**
  59895. * Gets the name of the current physics plugin
  59896. * @returns the name of the plugin
  59897. */
  59898. getPhysicsPluginName(): string;
  59899. /**
  59900. * Adding a new impostor for the impostor tracking.
  59901. * This will be done by the impostor itself.
  59902. * @param impostor the impostor to add
  59903. */
  59904. addImpostor(impostor: PhysicsImpostor): void;
  59905. /**
  59906. * Remove an impostor from the engine.
  59907. * This impostor and its mesh will not longer be updated by the physics engine.
  59908. * @param impostor the impostor to remove
  59909. */
  59910. removeImpostor(impostor: PhysicsImpostor): void;
  59911. /**
  59912. * Add a joint to the physics engine
  59913. * @param mainImpostor defines the main impostor to which the joint is added.
  59914. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  59915. * @param joint defines the joint that will connect both impostors.
  59916. */
  59917. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  59918. /**
  59919. * Removes a joint from the simulation
  59920. * @param mainImpostor defines the impostor used with the joint
  59921. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  59922. * @param joint defines the joint to remove
  59923. */
  59924. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  59925. /**
  59926. * Called by the scene. No need to call it.
  59927. * @param delta defines the timespam between frames
  59928. */
  59929. _step(delta: number): void;
  59930. /**
  59931. * Gets the current plugin used to run the simulation
  59932. * @returns current plugin
  59933. */
  59934. getPhysicsPlugin(): IPhysicsEnginePlugin;
  59935. /**
  59936. * Gets the list of physic impostors
  59937. * @returns an array of PhysicsImpostor
  59938. */
  59939. getImpostors(): Array<PhysicsImpostor>;
  59940. /**
  59941. * Gets the impostor for a physics enabled object
  59942. * @param object defines the object impersonated by the impostor
  59943. * @returns the PhysicsImpostor or null if not found
  59944. */
  59945. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  59946. /**
  59947. * Gets the impostor for a physics body object
  59948. * @param body defines physics body used by the impostor
  59949. * @returns the PhysicsImpostor or null if not found
  59950. */
  59951. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  59952. /**
  59953. * Does a raycast in the physics world
  59954. * @param from when should the ray start?
  59955. * @param to when should the ray end?
  59956. * @returns PhysicsRaycastResult
  59957. */
  59958. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  59959. }
  59960. }
  59961. declare module BABYLON {
  59962. /** @hidden */
  59963. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  59964. private _useDeltaForWorldStep;
  59965. world: any;
  59966. name: string;
  59967. private _physicsMaterials;
  59968. private _fixedTimeStep;
  59969. private _cannonRaycastResult;
  59970. private _raycastResult;
  59971. private _physicsBodysToRemoveAfterStep;
  59972. private _firstFrame;
  59973. BJSCANNON: any;
  59974. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  59975. setGravity(gravity: Vector3): void;
  59976. setTimeStep(timeStep: number): void;
  59977. getTimeStep(): number;
  59978. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  59979. private _removeMarkedPhysicsBodiesFromWorld;
  59980. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59981. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  59982. generatePhysicsBody(impostor: PhysicsImpostor): void;
  59983. private _processChildMeshes;
  59984. removePhysicsBody(impostor: PhysicsImpostor): void;
  59985. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  59986. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  59987. private _addMaterial;
  59988. private _checkWithEpsilon;
  59989. private _createShape;
  59990. private _createHeightmap;
  59991. private _minus90X;
  59992. private _plus90X;
  59993. private _tmpPosition;
  59994. private _tmpDeltaPosition;
  59995. private _tmpUnityRotation;
  59996. private _updatePhysicsBodyTransformation;
  59997. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  59998. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  59999. isSupported(): boolean;
  60000. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60001. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60002. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60003. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60004. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60005. getBodyMass(impostor: PhysicsImpostor): number;
  60006. getBodyFriction(impostor: PhysicsImpostor): number;
  60007. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60008. getBodyRestitution(impostor: PhysicsImpostor): number;
  60009. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60010. sleepBody(impostor: PhysicsImpostor): void;
  60011. wakeUpBody(impostor: PhysicsImpostor): void;
  60012. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  60013. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  60014. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  60015. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60016. getRadius(impostor: PhysicsImpostor): number;
  60017. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60018. dispose(): void;
  60019. private _extendNamespace;
  60020. /**
  60021. * Does a raycast in the physics world
  60022. * @param from when should the ray start?
  60023. * @param to when should the ray end?
  60024. * @returns PhysicsRaycastResult
  60025. */
  60026. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60027. }
  60028. }
  60029. declare module BABYLON {
  60030. /** @hidden */
  60031. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  60032. private _useDeltaForWorldStep;
  60033. world: any;
  60034. name: string;
  60035. BJSOIMO: any;
  60036. private _raycastResult;
  60037. private _fixedTimeStep;
  60038. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  60039. setGravity(gravity: Vector3): void;
  60040. setTimeStep(timeStep: number): void;
  60041. getTimeStep(): number;
  60042. private _tmpImpostorsArray;
  60043. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60044. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60045. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60046. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60047. private _tmpPositionVector;
  60048. removePhysicsBody(impostor: PhysicsImpostor): void;
  60049. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60050. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60051. isSupported(): boolean;
  60052. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60053. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60054. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60055. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60056. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60057. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60058. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60059. getBodyMass(impostor: PhysicsImpostor): number;
  60060. getBodyFriction(impostor: PhysicsImpostor): number;
  60061. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60062. getBodyRestitution(impostor: PhysicsImpostor): number;
  60063. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60064. sleepBody(impostor: PhysicsImpostor): void;
  60065. wakeUpBody(impostor: PhysicsImpostor): void;
  60066. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  60067. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  60068. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  60069. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60070. getRadius(impostor: PhysicsImpostor): number;
  60071. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60072. dispose(): void;
  60073. /**
  60074. * Does a raycast in the physics world
  60075. * @param from when should the ray start?
  60076. * @param to when should the ray end?
  60077. * @returns PhysicsRaycastResult
  60078. */
  60079. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60080. }
  60081. }
  60082. declare module BABYLON {
  60083. /**
  60084. * Class containing static functions to help procedurally build meshes
  60085. */
  60086. export class RibbonBuilder {
  60087. /**
  60088. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  60089. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  60090. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  60091. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  60092. * * 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
  60093. * * 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
  60094. * * 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
  60095. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60096. * * 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
  60097. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60098. * * 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
  60099. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  60100. * * 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
  60101. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  60102. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60103. * @param name defines the name of the mesh
  60104. * @param options defines the options used to create the mesh
  60105. * @param scene defines the hosting scene
  60106. * @returns the ribbon mesh
  60107. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  60108. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60109. */
  60110. static CreateRibbon(name: string, options: {
  60111. pathArray: Vector3[][];
  60112. closeArray?: boolean;
  60113. closePath?: boolean;
  60114. offset?: number;
  60115. updatable?: boolean;
  60116. sideOrientation?: number;
  60117. frontUVs?: Vector4;
  60118. backUVs?: Vector4;
  60119. instance?: Mesh;
  60120. invertUV?: boolean;
  60121. uvs?: Vector2[];
  60122. colors?: Color4[];
  60123. }, scene?: Nullable<Scene>): Mesh;
  60124. }
  60125. }
  60126. declare module BABYLON {
  60127. /**
  60128. * Class containing static functions to help procedurally build meshes
  60129. */
  60130. export class ShapeBuilder {
  60131. /**
  60132. * 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.
  60133. * * 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.
  60134. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  60135. * * 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.
  60136. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  60137. * * 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
  60138. * * 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
  60139. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  60140. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60141. * * 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
  60142. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  60143. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  60144. * @param name defines the name of the mesh
  60145. * @param options defines the options used to create the mesh
  60146. * @param scene defines the hosting scene
  60147. * @returns the extruded shape mesh
  60148. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60149. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  60150. */
  60151. static ExtrudeShape(name: string, options: {
  60152. shape: Vector3[];
  60153. path: Vector3[];
  60154. scale?: number;
  60155. rotation?: number;
  60156. cap?: number;
  60157. updatable?: boolean;
  60158. sideOrientation?: number;
  60159. frontUVs?: Vector4;
  60160. backUVs?: Vector4;
  60161. instance?: Mesh;
  60162. invertUV?: boolean;
  60163. }, scene?: Nullable<Scene>): Mesh;
  60164. /**
  60165. * Creates an custom extruded shape mesh.
  60166. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  60167. * * 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.
  60168. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  60169. * * 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
  60170. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  60171. * * 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
  60172. * * It must returns a float value that will be the scale value applied to the shape on each path point
  60173. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  60174. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  60175. * * 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
  60176. * * 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
  60177. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  60178. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  60179. * * 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
  60180. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  60181. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  60182. * @param name defines the name of the mesh
  60183. * @param options defines the options used to create the mesh
  60184. * @param scene defines the hosting scene
  60185. * @returns the custom extruded shape mesh
  60186. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  60187. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  60188. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  60189. */
  60190. static ExtrudeShapeCustom(name: string, options: {
  60191. shape: Vector3[];
  60192. path: Vector3[];
  60193. scaleFunction?: any;
  60194. rotationFunction?: any;
  60195. ribbonCloseArray?: boolean;
  60196. ribbonClosePath?: boolean;
  60197. cap?: number;
  60198. updatable?: boolean;
  60199. sideOrientation?: number;
  60200. frontUVs?: Vector4;
  60201. backUVs?: Vector4;
  60202. instance?: Mesh;
  60203. invertUV?: boolean;
  60204. }, scene?: Nullable<Scene>): Mesh;
  60205. private static _ExtrudeShapeGeneric;
  60206. }
  60207. }
  60208. declare module BABYLON {
  60209. /**
  60210. * AmmoJS Physics plugin
  60211. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  60212. * @see https://github.com/kripken/ammo.js/
  60213. */
  60214. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  60215. private _useDeltaForWorldStep;
  60216. /**
  60217. * Reference to the Ammo library
  60218. */
  60219. bjsAMMO: any;
  60220. /**
  60221. * Created ammoJS world which physics bodies are added to
  60222. */
  60223. world: any;
  60224. /**
  60225. * Name of the plugin
  60226. */
  60227. name: string;
  60228. private _timeStep;
  60229. private _fixedTimeStep;
  60230. private _maxSteps;
  60231. private _tmpQuaternion;
  60232. private _tmpAmmoTransform;
  60233. private _tmpAmmoQuaternion;
  60234. private _tmpAmmoConcreteContactResultCallback;
  60235. private _collisionConfiguration;
  60236. private _dispatcher;
  60237. private _overlappingPairCache;
  60238. private _solver;
  60239. private _softBodySolver;
  60240. private _tmpAmmoVectorA;
  60241. private _tmpAmmoVectorB;
  60242. private _tmpAmmoVectorC;
  60243. private _tmpAmmoVectorD;
  60244. private _tmpContactCallbackResult;
  60245. private _tmpAmmoVectorRCA;
  60246. private _tmpAmmoVectorRCB;
  60247. private _raycastResult;
  60248. private static readonly DISABLE_COLLISION_FLAG;
  60249. private static readonly KINEMATIC_FLAG;
  60250. private static readonly DISABLE_DEACTIVATION_FLAG;
  60251. /**
  60252. * Initializes the ammoJS plugin
  60253. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  60254. * @param ammoInjection can be used to inject your own ammo reference
  60255. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  60256. */
  60257. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  60258. /**
  60259. * Sets the gravity of the physics world (m/(s^2))
  60260. * @param gravity Gravity to set
  60261. */
  60262. setGravity(gravity: Vector3): void;
  60263. /**
  60264. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  60265. * @param timeStep timestep to use in seconds
  60266. */
  60267. setTimeStep(timeStep: number): void;
  60268. /**
  60269. * 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)
  60270. * @param fixedTimeStep fixedTimeStep to use in seconds
  60271. */
  60272. setFixedTimeStep(fixedTimeStep: number): void;
  60273. /**
  60274. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  60275. * @param maxSteps the maximum number of steps by the physics engine per frame
  60276. */
  60277. setMaxSteps(maxSteps: number): void;
  60278. /**
  60279. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  60280. * @returns the current timestep in seconds
  60281. */
  60282. getTimeStep(): number;
  60283. /**
  60284. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  60285. */
  60286. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  60287. private _isImpostorInContact;
  60288. private _isImpostorPairInContact;
  60289. private _stepSimulation;
  60290. /**
  60291. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  60292. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  60293. * After the step the babylon meshes are set to the position of the physics imposters
  60294. * @param delta amount of time to step forward
  60295. * @param impostors array of imposters to update before/after the step
  60296. */
  60297. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60298. /**
  60299. * Update babylon mesh to match physics world object
  60300. * @param impostor imposter to match
  60301. */
  60302. private _afterSoftStep;
  60303. /**
  60304. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  60305. * @param impostor imposter to match
  60306. */
  60307. private _ropeStep;
  60308. /**
  60309. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  60310. * @param impostor imposter to match
  60311. */
  60312. private _softbodyOrClothStep;
  60313. private _tmpMatrix;
  60314. /**
  60315. * Applies an impulse on the imposter
  60316. * @param impostor imposter to apply impulse to
  60317. * @param force amount of force to be applied to the imposter
  60318. * @param contactPoint the location to apply the impulse on the imposter
  60319. */
  60320. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60321. /**
  60322. * Applies a force on the imposter
  60323. * @param impostor imposter to apply force
  60324. * @param force amount of force to be applied to the imposter
  60325. * @param contactPoint the location to apply the force on the imposter
  60326. */
  60327. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60328. /**
  60329. * Creates a physics body using the plugin
  60330. * @param impostor the imposter to create the physics body on
  60331. */
  60332. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60333. /**
  60334. * Removes the physics body from the imposter and disposes of the body's memory
  60335. * @param impostor imposter to remove the physics body from
  60336. */
  60337. removePhysicsBody(impostor: PhysicsImpostor): void;
  60338. /**
  60339. * Generates a joint
  60340. * @param impostorJoint the imposter joint to create the joint with
  60341. */
  60342. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60343. /**
  60344. * Removes a joint
  60345. * @param impostorJoint the imposter joint to remove the joint from
  60346. */
  60347. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60348. private _addMeshVerts;
  60349. /**
  60350. * Initialise the soft body vertices to match its object's (mesh) vertices
  60351. * Softbody vertices (nodes) are in world space and to match this
  60352. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  60353. * @param impostor to create the softbody for
  60354. */
  60355. private _softVertexData;
  60356. /**
  60357. * Create an impostor's soft body
  60358. * @param impostor to create the softbody for
  60359. */
  60360. private _createSoftbody;
  60361. /**
  60362. * Create cloth for an impostor
  60363. * @param impostor to create the softbody for
  60364. */
  60365. private _createCloth;
  60366. /**
  60367. * Create rope for an impostor
  60368. * @param impostor to create the softbody for
  60369. */
  60370. private _createRope;
  60371. /**
  60372. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  60373. * @param impostor to create the custom physics shape for
  60374. */
  60375. private _createCustom;
  60376. private _addHullVerts;
  60377. private _createShape;
  60378. /**
  60379. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  60380. * @param impostor imposter containing the physics body and babylon object
  60381. */
  60382. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  60383. /**
  60384. * Sets the babylon object's position/rotation from the physics body's position/rotation
  60385. * @param impostor imposter containing the physics body and babylon object
  60386. * @param newPosition new position
  60387. * @param newRotation new rotation
  60388. */
  60389. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  60390. /**
  60391. * If this plugin is supported
  60392. * @returns true if its supported
  60393. */
  60394. isSupported(): boolean;
  60395. /**
  60396. * Sets the linear velocity of the physics body
  60397. * @param impostor imposter to set the velocity on
  60398. * @param velocity velocity to set
  60399. */
  60400. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60401. /**
  60402. * Sets the angular velocity of the physics body
  60403. * @param impostor imposter to set the velocity on
  60404. * @param velocity velocity to set
  60405. */
  60406. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  60407. /**
  60408. * gets the linear velocity
  60409. * @param impostor imposter to get linear velocity from
  60410. * @returns linear velocity
  60411. */
  60412. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60413. /**
  60414. * gets the angular velocity
  60415. * @param impostor imposter to get angular velocity from
  60416. * @returns angular velocity
  60417. */
  60418. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  60419. /**
  60420. * Sets the mass of physics body
  60421. * @param impostor imposter to set the mass on
  60422. * @param mass mass to set
  60423. */
  60424. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  60425. /**
  60426. * Gets the mass of the physics body
  60427. * @param impostor imposter to get the mass from
  60428. * @returns mass
  60429. */
  60430. getBodyMass(impostor: PhysicsImpostor): number;
  60431. /**
  60432. * Gets friction of the impostor
  60433. * @param impostor impostor to get friction from
  60434. * @returns friction value
  60435. */
  60436. getBodyFriction(impostor: PhysicsImpostor): number;
  60437. /**
  60438. * Sets friction of the impostor
  60439. * @param impostor impostor to set friction on
  60440. * @param friction friction value
  60441. */
  60442. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  60443. /**
  60444. * Gets restitution of the impostor
  60445. * @param impostor impostor to get restitution from
  60446. * @returns restitution value
  60447. */
  60448. getBodyRestitution(impostor: PhysicsImpostor): number;
  60449. /**
  60450. * Sets resitution of the impostor
  60451. * @param impostor impostor to set resitution on
  60452. * @param restitution resitution value
  60453. */
  60454. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  60455. /**
  60456. * Gets pressure inside the impostor
  60457. * @param impostor impostor to get pressure from
  60458. * @returns pressure value
  60459. */
  60460. getBodyPressure(impostor: PhysicsImpostor): number;
  60461. /**
  60462. * Sets pressure inside a soft body impostor
  60463. * Cloth and rope must remain 0 pressure
  60464. * @param impostor impostor to set pressure on
  60465. * @param pressure pressure value
  60466. */
  60467. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  60468. /**
  60469. * Gets stiffness of the impostor
  60470. * @param impostor impostor to get stiffness from
  60471. * @returns pressure value
  60472. */
  60473. getBodyStiffness(impostor: PhysicsImpostor): number;
  60474. /**
  60475. * Sets stiffness of the impostor
  60476. * @param impostor impostor to set stiffness on
  60477. * @param stiffness stiffness value from 0 to 1
  60478. */
  60479. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  60480. /**
  60481. * Gets velocityIterations of the impostor
  60482. * @param impostor impostor to get velocity iterations from
  60483. * @returns velocityIterations value
  60484. */
  60485. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  60486. /**
  60487. * Sets velocityIterations of the impostor
  60488. * @param impostor impostor to set velocity iterations on
  60489. * @param velocityIterations velocityIterations value
  60490. */
  60491. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  60492. /**
  60493. * Gets positionIterations of the impostor
  60494. * @param impostor impostor to get position iterations from
  60495. * @returns positionIterations value
  60496. */
  60497. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  60498. /**
  60499. * Sets positionIterations of the impostor
  60500. * @param impostor impostor to set position on
  60501. * @param positionIterations positionIterations value
  60502. */
  60503. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  60504. /**
  60505. * Append an anchor to a cloth object
  60506. * @param impostor is the cloth impostor to add anchor to
  60507. * @param otherImpostor is the rigid impostor to anchor to
  60508. * @param width ratio across width from 0 to 1
  60509. * @param height ratio up height from 0 to 1
  60510. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  60511. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  60512. */
  60513. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  60514. /**
  60515. * Append an hook to a rope object
  60516. * @param impostor is the rope impostor to add hook to
  60517. * @param otherImpostor is the rigid impostor to hook to
  60518. * @param length ratio along the rope from 0 to 1
  60519. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  60520. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  60521. */
  60522. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  60523. /**
  60524. * Sleeps the physics body and stops it from being active
  60525. * @param impostor impostor to sleep
  60526. */
  60527. sleepBody(impostor: PhysicsImpostor): void;
  60528. /**
  60529. * Activates the physics body
  60530. * @param impostor impostor to activate
  60531. */
  60532. wakeUpBody(impostor: PhysicsImpostor): void;
  60533. /**
  60534. * Updates the distance parameters of the joint
  60535. * @param joint joint to update
  60536. * @param maxDistance maximum distance of the joint
  60537. * @param minDistance minimum distance of the joint
  60538. */
  60539. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  60540. /**
  60541. * Sets a motor on the joint
  60542. * @param joint joint to set motor on
  60543. * @param speed speed of the motor
  60544. * @param maxForce maximum force of the motor
  60545. * @param motorIndex index of the motor
  60546. */
  60547. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  60548. /**
  60549. * Sets the motors limit
  60550. * @param joint joint to set limit on
  60551. * @param upperLimit upper limit
  60552. * @param lowerLimit lower limit
  60553. */
  60554. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  60555. /**
  60556. * Syncs the position and rotation of a mesh with the impostor
  60557. * @param mesh mesh to sync
  60558. * @param impostor impostor to update the mesh with
  60559. */
  60560. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  60561. /**
  60562. * Gets the radius of the impostor
  60563. * @param impostor impostor to get radius from
  60564. * @returns the radius
  60565. */
  60566. getRadius(impostor: PhysicsImpostor): number;
  60567. /**
  60568. * Gets the box size of the impostor
  60569. * @param impostor impostor to get box size from
  60570. * @param result the resulting box size
  60571. */
  60572. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  60573. /**
  60574. * Disposes of the impostor
  60575. */
  60576. dispose(): void;
  60577. /**
  60578. * Does a raycast in the physics world
  60579. * @param from when should the ray start?
  60580. * @param to when should the ray end?
  60581. * @returns PhysicsRaycastResult
  60582. */
  60583. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60584. }
  60585. }
  60586. declare module BABYLON {
  60587. interface AbstractScene {
  60588. /**
  60589. * The list of reflection probes added to the scene
  60590. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  60591. */
  60592. reflectionProbes: Array<ReflectionProbe>;
  60593. /**
  60594. * Removes the given reflection probe from this scene.
  60595. * @param toRemove The reflection probe to remove
  60596. * @returns The index of the removed reflection probe
  60597. */
  60598. removeReflectionProbe(toRemove: ReflectionProbe): number;
  60599. /**
  60600. * Adds the given reflection probe to this scene.
  60601. * @param newReflectionProbe The reflection probe to add
  60602. */
  60603. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  60604. }
  60605. /**
  60606. * Class used to generate realtime reflection / refraction cube textures
  60607. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  60608. */
  60609. export class ReflectionProbe {
  60610. /** defines the name of the probe */
  60611. name: string;
  60612. private _scene;
  60613. private _renderTargetTexture;
  60614. private _projectionMatrix;
  60615. private _viewMatrix;
  60616. private _target;
  60617. private _add;
  60618. private _attachedMesh;
  60619. private _invertYAxis;
  60620. /** Gets or sets probe position (center of the cube map) */
  60621. position: Vector3;
  60622. /**
  60623. * Creates a new reflection probe
  60624. * @param name defines the name of the probe
  60625. * @param size defines the texture resolution (for each face)
  60626. * @param scene defines the hosting scene
  60627. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  60628. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  60629. */
  60630. constructor(
  60631. /** defines the name of the probe */
  60632. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  60633. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  60634. get samples(): number;
  60635. set samples(value: number);
  60636. /** Gets or sets the refresh rate to use (on every frame by default) */
  60637. get refreshRate(): number;
  60638. set refreshRate(value: number);
  60639. /**
  60640. * Gets the hosting scene
  60641. * @returns a Scene
  60642. */
  60643. getScene(): Scene;
  60644. /** Gets the internal CubeTexture used to render to */
  60645. get cubeTexture(): RenderTargetTexture;
  60646. /** Gets the list of meshes to render */
  60647. get renderList(): Nullable<AbstractMesh[]>;
  60648. /**
  60649. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  60650. * @param mesh defines the mesh to attach to
  60651. */
  60652. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  60653. /**
  60654. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  60655. * @param renderingGroupId The rendering group id corresponding to its index
  60656. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  60657. */
  60658. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  60659. /**
  60660. * Clean all associated resources
  60661. */
  60662. dispose(): void;
  60663. /**
  60664. * Converts the reflection probe information to a readable string for debug purpose.
  60665. * @param fullDetails Supports for multiple levels of logging within scene loading
  60666. * @returns the human readable reflection probe info
  60667. */
  60668. toString(fullDetails?: boolean): string;
  60669. /**
  60670. * Get the class name of the relfection probe.
  60671. * @returns "ReflectionProbe"
  60672. */
  60673. getClassName(): string;
  60674. /**
  60675. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  60676. * @returns The JSON representation of the texture
  60677. */
  60678. serialize(): any;
  60679. /**
  60680. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  60681. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  60682. * @param scene Define the scene the parsed reflection probe should be instantiated in
  60683. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  60684. * @returns The parsed reflection probe if successful
  60685. */
  60686. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  60687. }
  60688. }
  60689. declare module BABYLON {
  60690. /** @hidden */
  60691. export var _BabylonLoaderRegistered: boolean;
  60692. /**
  60693. * Helps setting up some configuration for the babylon file loader.
  60694. */
  60695. export class BabylonFileLoaderConfiguration {
  60696. /**
  60697. * The loader does not allow injecting custom physix engine into the plugins.
  60698. * Unfortunately in ES6, we need to manually inject them into the plugin.
  60699. * So you could set this variable to your engine import to make it work.
  60700. */
  60701. static LoaderInjectedPhysicsEngine: any;
  60702. }
  60703. }
  60704. declare module BABYLON {
  60705. /**
  60706. * The Physically based simple base material of BJS.
  60707. *
  60708. * This enables better naming and convention enforcements on top of the pbrMaterial.
  60709. * It is used as the base class for both the specGloss and metalRough conventions.
  60710. */
  60711. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  60712. /**
  60713. * Number of Simultaneous lights allowed on the material.
  60714. */
  60715. maxSimultaneousLights: number;
  60716. /**
  60717. * If sets to true, disables all the lights affecting the material.
  60718. */
  60719. disableLighting: boolean;
  60720. /**
  60721. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  60722. */
  60723. environmentTexture: BaseTexture;
  60724. /**
  60725. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  60726. */
  60727. invertNormalMapX: boolean;
  60728. /**
  60729. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  60730. */
  60731. invertNormalMapY: boolean;
  60732. /**
  60733. * Normal map used in the model.
  60734. */
  60735. normalTexture: BaseTexture;
  60736. /**
  60737. * Emissivie color used to self-illuminate the model.
  60738. */
  60739. emissiveColor: Color3;
  60740. /**
  60741. * Emissivie texture used to self-illuminate the model.
  60742. */
  60743. emissiveTexture: BaseTexture;
  60744. /**
  60745. * Occlusion Channel Strenght.
  60746. */
  60747. occlusionStrength: number;
  60748. /**
  60749. * Occlusion Texture of the material (adding extra occlusion effects).
  60750. */
  60751. occlusionTexture: BaseTexture;
  60752. /**
  60753. * Defines the alpha limits in alpha test mode.
  60754. */
  60755. alphaCutOff: number;
  60756. /**
  60757. * Gets the current double sided mode.
  60758. */
  60759. get doubleSided(): boolean;
  60760. /**
  60761. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  60762. */
  60763. set doubleSided(value: boolean);
  60764. /**
  60765. * Stores the pre-calculated light information of a mesh in a texture.
  60766. */
  60767. lightmapTexture: BaseTexture;
  60768. /**
  60769. * If true, the light map contains occlusion information instead of lighting info.
  60770. */
  60771. useLightmapAsShadowmap: boolean;
  60772. /**
  60773. * Instantiates a new PBRMaterial instance.
  60774. *
  60775. * @param name The material name
  60776. * @param scene The scene the material will be use in.
  60777. */
  60778. constructor(name: string, scene: Scene);
  60779. getClassName(): string;
  60780. }
  60781. }
  60782. declare module BABYLON {
  60783. /**
  60784. * The PBR material of BJS following the metal roughness convention.
  60785. *
  60786. * This fits to the PBR convention in the GLTF definition:
  60787. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  60788. */
  60789. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  60790. /**
  60791. * The base color has two different interpretations depending on the value of metalness.
  60792. * When the material is a metal, the base color is the specific measured reflectance value
  60793. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  60794. * of the material.
  60795. */
  60796. baseColor: Color3;
  60797. /**
  60798. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  60799. * well as opacity information in the alpha channel.
  60800. */
  60801. baseTexture: BaseTexture;
  60802. /**
  60803. * Specifies the metallic scalar value of the material.
  60804. * Can also be used to scale the metalness values of the metallic texture.
  60805. */
  60806. metallic: number;
  60807. /**
  60808. * Specifies the roughness scalar value of the material.
  60809. * Can also be used to scale the roughness values of the metallic texture.
  60810. */
  60811. roughness: number;
  60812. /**
  60813. * Texture containing both the metallic value in the B channel and the
  60814. * roughness value in the G channel to keep better precision.
  60815. */
  60816. metallicRoughnessTexture: BaseTexture;
  60817. /**
  60818. * Instantiates a new PBRMetalRoughnessMaterial instance.
  60819. *
  60820. * @param name The material name
  60821. * @param scene The scene the material will be use in.
  60822. */
  60823. constructor(name: string, scene: Scene);
  60824. /**
  60825. * Return the currrent class name of the material.
  60826. */
  60827. getClassName(): string;
  60828. /**
  60829. * Makes a duplicate of the current material.
  60830. * @param name - name to use for the new material.
  60831. */
  60832. clone(name: string): PBRMetallicRoughnessMaterial;
  60833. /**
  60834. * Serialize the material to a parsable JSON object.
  60835. */
  60836. serialize(): any;
  60837. /**
  60838. * Parses a JSON object correponding to the serialize function.
  60839. */
  60840. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  60841. }
  60842. }
  60843. declare module BABYLON {
  60844. /**
  60845. * The PBR material of BJS following the specular glossiness convention.
  60846. *
  60847. * This fits to the PBR convention in the GLTF definition:
  60848. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  60849. */
  60850. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  60851. /**
  60852. * Specifies the diffuse color of the material.
  60853. */
  60854. diffuseColor: Color3;
  60855. /**
  60856. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  60857. * channel.
  60858. */
  60859. diffuseTexture: BaseTexture;
  60860. /**
  60861. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  60862. */
  60863. specularColor: Color3;
  60864. /**
  60865. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  60866. */
  60867. glossiness: number;
  60868. /**
  60869. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  60870. */
  60871. specularGlossinessTexture: BaseTexture;
  60872. /**
  60873. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  60874. *
  60875. * @param name The material name
  60876. * @param scene The scene the material will be use in.
  60877. */
  60878. constructor(name: string, scene: Scene);
  60879. /**
  60880. * Return the currrent class name of the material.
  60881. */
  60882. getClassName(): string;
  60883. /**
  60884. * Makes a duplicate of the current material.
  60885. * @param name - name to use for the new material.
  60886. */
  60887. clone(name: string): PBRSpecularGlossinessMaterial;
  60888. /**
  60889. * Serialize the material to a parsable JSON object.
  60890. */
  60891. serialize(): any;
  60892. /**
  60893. * Parses a JSON object correponding to the serialize function.
  60894. */
  60895. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  60896. }
  60897. }
  60898. declare module BABYLON {
  60899. /**
  60900. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  60901. * It can help converting any input color in a desired output one. This can then be used to create effects
  60902. * from sepia, black and white to sixties or futuristic rendering...
  60903. *
  60904. * The only supported format is currently 3dl.
  60905. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  60906. */
  60907. export class ColorGradingTexture extends BaseTexture {
  60908. /**
  60909. * The texture URL.
  60910. */
  60911. url: string;
  60912. /**
  60913. * Empty line regex stored for GC.
  60914. */
  60915. private static _noneEmptyLineRegex;
  60916. private _textureMatrix;
  60917. private _onLoad;
  60918. /**
  60919. * Instantiates a ColorGradingTexture from the following parameters.
  60920. *
  60921. * @param url The location of the color gradind data (currently only supporting 3dl)
  60922. * @param sceneOrEngine The scene or engine the texture will be used in
  60923. * @param onLoad defines a callback triggered when the texture has been loaded
  60924. */
  60925. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  60926. /**
  60927. * Fires the onload event from the constructor if requested.
  60928. */
  60929. private _triggerOnLoad;
  60930. /**
  60931. * Returns the texture matrix used in most of the material.
  60932. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  60933. */
  60934. getTextureMatrix(): Matrix;
  60935. /**
  60936. * Occurs when the file being loaded is a .3dl LUT file.
  60937. */
  60938. private load3dlTexture;
  60939. /**
  60940. * Starts the loading process of the texture.
  60941. */
  60942. private loadTexture;
  60943. /**
  60944. * Clones the color gradind texture.
  60945. */
  60946. clone(): ColorGradingTexture;
  60947. /**
  60948. * Called during delayed load for textures.
  60949. */
  60950. delayLoad(): void;
  60951. /**
  60952. * Parses a color grading texture serialized by Babylon.
  60953. * @param parsedTexture The texture information being parsedTexture
  60954. * @param scene The scene to load the texture in
  60955. * @param rootUrl The root url of the data assets to load
  60956. * @return A color gradind texture
  60957. */
  60958. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  60959. /**
  60960. * Serializes the LUT texture to json format.
  60961. */
  60962. serialize(): any;
  60963. }
  60964. }
  60965. declare module BABYLON {
  60966. /**
  60967. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  60968. */
  60969. export class EquiRectangularCubeTexture extends BaseTexture {
  60970. /** The six faces of the cube. */
  60971. private static _FacesMapping;
  60972. private _noMipmap;
  60973. private _onLoad;
  60974. private _onError;
  60975. /** The size of the cubemap. */
  60976. private _size;
  60977. /** The buffer of the image. */
  60978. private _buffer;
  60979. /** The width of the input image. */
  60980. private _width;
  60981. /** The height of the input image. */
  60982. private _height;
  60983. /** The URL to the image. */
  60984. url: string;
  60985. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  60986. coordinatesMode: number;
  60987. /**
  60988. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  60989. * @param url The location of the image
  60990. * @param scene The scene the texture will be used in
  60991. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  60992. * @param noMipmap Forces to not generate the mipmap if true
  60993. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  60994. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  60995. * @param onLoad — defines a callback called when texture is loaded
  60996. * @param onError — defines a callback called if there is an error
  60997. */
  60998. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  60999. /**
  61000. * Load the image data, by putting the image on a canvas and extracting its buffer.
  61001. */
  61002. private loadImage;
  61003. /**
  61004. * Convert the image buffer into a cubemap and create a CubeTexture.
  61005. */
  61006. private loadTexture;
  61007. /**
  61008. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  61009. * @param buffer The ArrayBuffer that should be converted.
  61010. * @returns The buffer as Float32Array.
  61011. */
  61012. private getFloat32ArrayFromArrayBuffer;
  61013. /**
  61014. * Get the current class name of the texture useful for serialization or dynamic coding.
  61015. * @returns "EquiRectangularCubeTexture"
  61016. */
  61017. getClassName(): string;
  61018. /**
  61019. * Create a clone of the current EquiRectangularCubeTexture and return it.
  61020. * @returns A clone of the current EquiRectangularCubeTexture.
  61021. */
  61022. clone(): EquiRectangularCubeTexture;
  61023. }
  61024. }
  61025. declare module BABYLON {
  61026. /**
  61027. * Defines the options related to the creation of an HtmlElementTexture
  61028. */
  61029. export interface IHtmlElementTextureOptions {
  61030. /**
  61031. * Defines wether mip maps should be created or not.
  61032. */
  61033. generateMipMaps?: boolean;
  61034. /**
  61035. * Defines the sampling mode of the texture.
  61036. */
  61037. samplingMode?: number;
  61038. /**
  61039. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  61040. */
  61041. engine: Nullable<ThinEngine>;
  61042. /**
  61043. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  61044. */
  61045. scene: Nullable<Scene>;
  61046. }
  61047. /**
  61048. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  61049. * To be as efficient as possible depending on your constraints nothing aside the first upload
  61050. * is automatically managed.
  61051. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  61052. * in your application.
  61053. *
  61054. * As the update is not automatic, you need to call them manually.
  61055. */
  61056. export class HtmlElementTexture extends BaseTexture {
  61057. /**
  61058. * The texture URL.
  61059. */
  61060. element: HTMLVideoElement | HTMLCanvasElement;
  61061. private static readonly DefaultOptions;
  61062. private _textureMatrix;
  61063. private _isVideo;
  61064. private _generateMipMaps;
  61065. private _samplingMode;
  61066. /**
  61067. * Instantiates a HtmlElementTexture from the following parameters.
  61068. *
  61069. * @param name Defines the name of the texture
  61070. * @param element Defines the video or canvas the texture is filled with
  61071. * @param options Defines the other none mandatory texture creation options
  61072. */
  61073. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  61074. private _createInternalTexture;
  61075. /**
  61076. * Returns the texture matrix used in most of the material.
  61077. */
  61078. getTextureMatrix(): Matrix;
  61079. /**
  61080. * Updates the content of the texture.
  61081. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  61082. */
  61083. update(invertY?: Nullable<boolean>): void;
  61084. }
  61085. }
  61086. declare module BABYLON {
  61087. /**
  61088. * Based on jsTGALoader - Javascript loader for TGA file
  61089. * By Vincent Thibault
  61090. * @see http://blog.robrowser.com/javascript-tga-loader.html
  61091. */
  61092. export class TGATools {
  61093. private static _TYPE_INDEXED;
  61094. private static _TYPE_RGB;
  61095. private static _TYPE_GREY;
  61096. private static _TYPE_RLE_INDEXED;
  61097. private static _TYPE_RLE_RGB;
  61098. private static _TYPE_RLE_GREY;
  61099. private static _ORIGIN_MASK;
  61100. private static _ORIGIN_SHIFT;
  61101. private static _ORIGIN_BL;
  61102. private static _ORIGIN_BR;
  61103. private static _ORIGIN_UL;
  61104. private static _ORIGIN_UR;
  61105. /**
  61106. * Gets the header of a TGA file
  61107. * @param data defines the TGA data
  61108. * @returns the header
  61109. */
  61110. static GetTGAHeader(data: Uint8Array): any;
  61111. /**
  61112. * Uploads TGA content to a Babylon Texture
  61113. * @hidden
  61114. */
  61115. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  61116. /** @hidden */
  61117. 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;
  61118. /** @hidden */
  61119. 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;
  61120. /** @hidden */
  61121. 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;
  61122. /** @hidden */
  61123. 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;
  61124. /** @hidden */
  61125. 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;
  61126. /** @hidden */
  61127. 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;
  61128. }
  61129. }
  61130. declare module BABYLON {
  61131. /**
  61132. * Implementation of the TGA Texture Loader.
  61133. * @hidden
  61134. */
  61135. export class _TGATextureLoader implements IInternalTextureLoader {
  61136. /**
  61137. * Defines wether the loader supports cascade loading the different faces.
  61138. */
  61139. readonly supportCascades: boolean;
  61140. /**
  61141. * This returns if the loader support the current file information.
  61142. * @param extension defines the file extension of the file being loaded
  61143. * @returns true if the loader can load the specified file
  61144. */
  61145. canLoad(extension: string): boolean;
  61146. /**
  61147. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61148. * @param data contains the texture data
  61149. * @param texture defines the BabylonJS internal texture
  61150. * @param createPolynomials will be true if polynomials have been requested
  61151. * @param onLoad defines the callback to trigger once the texture is ready
  61152. * @param onError defines the callback to trigger in case of error
  61153. */
  61154. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61155. /**
  61156. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61157. * @param data contains the texture data
  61158. * @param texture defines the BabylonJS internal texture
  61159. * @param callback defines the method to call once ready to upload
  61160. */
  61161. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61162. }
  61163. }
  61164. declare module BABYLON {
  61165. /**
  61166. * Info about the .basis files
  61167. */
  61168. class BasisFileInfo {
  61169. /**
  61170. * If the file has alpha
  61171. */
  61172. hasAlpha: boolean;
  61173. /**
  61174. * Info about each image of the basis file
  61175. */
  61176. images: Array<{
  61177. levels: Array<{
  61178. width: number;
  61179. height: number;
  61180. transcodedPixels: ArrayBufferView;
  61181. }>;
  61182. }>;
  61183. }
  61184. /**
  61185. * Result of transcoding a basis file
  61186. */
  61187. class TranscodeResult {
  61188. /**
  61189. * Info about the .basis file
  61190. */
  61191. fileInfo: BasisFileInfo;
  61192. /**
  61193. * Format to use when loading the file
  61194. */
  61195. format: number;
  61196. }
  61197. /**
  61198. * Configuration options for the Basis transcoder
  61199. */
  61200. export class BasisTranscodeConfiguration {
  61201. /**
  61202. * Supported compression formats used to determine the supported output format of the transcoder
  61203. */
  61204. supportedCompressionFormats?: {
  61205. /**
  61206. * etc1 compression format
  61207. */
  61208. etc1?: boolean;
  61209. /**
  61210. * s3tc compression format
  61211. */
  61212. s3tc?: boolean;
  61213. /**
  61214. * pvrtc compression format
  61215. */
  61216. pvrtc?: boolean;
  61217. /**
  61218. * etc2 compression format
  61219. */
  61220. etc2?: boolean;
  61221. };
  61222. /**
  61223. * If mipmap levels should be loaded for transcoded images (Default: true)
  61224. */
  61225. loadMipmapLevels?: boolean;
  61226. /**
  61227. * Index of a single image to load (Default: all images)
  61228. */
  61229. loadSingleImage?: number;
  61230. }
  61231. /**
  61232. * Used to load .Basis files
  61233. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  61234. */
  61235. export class BasisTools {
  61236. private static _IgnoreSupportedFormats;
  61237. /**
  61238. * URL to use when loading the basis transcoder
  61239. */
  61240. static JSModuleURL: string;
  61241. /**
  61242. * URL to use when loading the wasm module for the transcoder
  61243. */
  61244. static WasmModuleURL: string;
  61245. /**
  61246. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  61247. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  61248. * @returns internal format corresponding to the Basis format
  61249. */
  61250. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  61251. private static _WorkerPromise;
  61252. private static _Worker;
  61253. private static _actionId;
  61254. private static _CreateWorkerAsync;
  61255. /**
  61256. * Transcodes a loaded image file to compressed pixel data
  61257. * @param data image data to transcode
  61258. * @param config configuration options for the transcoding
  61259. * @returns a promise resulting in the transcoded image
  61260. */
  61261. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  61262. /**
  61263. * Loads a texture from the transcode result
  61264. * @param texture texture load to
  61265. * @param transcodeResult the result of transcoding the basis file to load from
  61266. */
  61267. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  61268. }
  61269. }
  61270. declare module BABYLON {
  61271. /**
  61272. * Loader for .basis file format
  61273. */
  61274. export class _BasisTextureLoader implements IInternalTextureLoader {
  61275. /**
  61276. * Defines whether the loader supports cascade loading the different faces.
  61277. */
  61278. readonly supportCascades: boolean;
  61279. /**
  61280. * This returns if the loader support the current file information.
  61281. * @param extension defines the file extension of the file being loaded
  61282. * @returns true if the loader can load the specified file
  61283. */
  61284. canLoad(extension: string): boolean;
  61285. /**
  61286. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61287. * @param data contains the texture data
  61288. * @param texture defines the BabylonJS internal texture
  61289. * @param createPolynomials will be true if polynomials have been requested
  61290. * @param onLoad defines the callback to trigger once the texture is ready
  61291. * @param onError defines the callback to trigger in case of error
  61292. */
  61293. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61294. /**
  61295. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61296. * @param data contains the texture data
  61297. * @param texture defines the BabylonJS internal texture
  61298. * @param callback defines the method to call once ready to upload
  61299. */
  61300. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61301. }
  61302. }
  61303. declare module BABYLON {
  61304. /**
  61305. * Defines the basic options interface of a TexturePacker Frame
  61306. */
  61307. export interface ITexturePackerFrame {
  61308. /**
  61309. * The frame ID
  61310. */
  61311. id: number;
  61312. /**
  61313. * The frames Scale
  61314. */
  61315. scale: Vector2;
  61316. /**
  61317. * The Frames offset
  61318. */
  61319. offset: Vector2;
  61320. }
  61321. /**
  61322. * This is a support class for frame Data on texture packer sets.
  61323. */
  61324. export class TexturePackerFrame implements ITexturePackerFrame {
  61325. /**
  61326. * The frame ID
  61327. */
  61328. id: number;
  61329. /**
  61330. * The frames Scale
  61331. */
  61332. scale: Vector2;
  61333. /**
  61334. * The Frames offset
  61335. */
  61336. offset: Vector2;
  61337. /**
  61338. * Initializes a texture package frame.
  61339. * @param id The numerical frame identifier
  61340. * @param scale Scalar Vector2 for UV frame
  61341. * @param offset Vector2 for the frame position in UV units.
  61342. * @returns TexturePackerFrame
  61343. */
  61344. constructor(id: number, scale: Vector2, offset: Vector2);
  61345. }
  61346. }
  61347. declare module BABYLON {
  61348. /**
  61349. * Defines the basic options interface of a TexturePacker
  61350. */
  61351. export interface ITexturePackerOptions {
  61352. /**
  61353. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  61354. */
  61355. map?: string[];
  61356. /**
  61357. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  61358. */
  61359. uvsIn?: string;
  61360. /**
  61361. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  61362. */
  61363. uvsOut?: string;
  61364. /**
  61365. * number representing the layout style. Defaults to LAYOUT_STRIP
  61366. */
  61367. layout?: number;
  61368. /**
  61369. * number of columns if using custom column count layout(2). This defaults to 4.
  61370. */
  61371. colnum?: number;
  61372. /**
  61373. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  61374. */
  61375. updateInputMeshes?: boolean;
  61376. /**
  61377. * boolean flag to dispose all the source textures. Defaults to true.
  61378. */
  61379. disposeSources?: boolean;
  61380. /**
  61381. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  61382. */
  61383. fillBlanks?: boolean;
  61384. /**
  61385. * string value representing the context fill style color. Defaults to 'black'.
  61386. */
  61387. customFillColor?: string;
  61388. /**
  61389. * Width and Height Value of each Frame in the TexturePacker Sets
  61390. */
  61391. frameSize?: number;
  61392. /**
  61393. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  61394. */
  61395. paddingRatio?: number;
  61396. /**
  61397. * Number that declares the fill method for the padding gutter.
  61398. */
  61399. paddingMode?: number;
  61400. /**
  61401. * If in SUBUV_COLOR padding mode what color to use.
  61402. */
  61403. paddingColor?: Color3 | Color4;
  61404. }
  61405. /**
  61406. * Defines the basic interface of a TexturePacker JSON File
  61407. */
  61408. export interface ITexturePackerJSON {
  61409. /**
  61410. * The frame ID
  61411. */
  61412. name: string;
  61413. /**
  61414. * The base64 channel data
  61415. */
  61416. sets: any;
  61417. /**
  61418. * The options of the Packer
  61419. */
  61420. options: ITexturePackerOptions;
  61421. /**
  61422. * The frame data of the Packer
  61423. */
  61424. frames: Array<number>;
  61425. }
  61426. /**
  61427. * This is a support class that generates a series of packed texture sets.
  61428. * @see https://doc.babylonjs.com/babylon101/materials
  61429. */
  61430. export class TexturePacker {
  61431. /** Packer Layout Constant 0 */
  61432. static readonly LAYOUT_STRIP: number;
  61433. /** Packer Layout Constant 1 */
  61434. static readonly LAYOUT_POWER2: number;
  61435. /** Packer Layout Constant 2 */
  61436. static readonly LAYOUT_COLNUM: number;
  61437. /** Packer Layout Constant 0 */
  61438. static readonly SUBUV_WRAP: number;
  61439. /** Packer Layout Constant 1 */
  61440. static readonly SUBUV_EXTEND: number;
  61441. /** Packer Layout Constant 2 */
  61442. static readonly SUBUV_COLOR: number;
  61443. /** The Name of the Texture Package */
  61444. name: string;
  61445. /** The scene scope of the TexturePacker */
  61446. scene: Scene;
  61447. /** The Meshes to target */
  61448. meshes: AbstractMesh[];
  61449. /** Arguments passed with the Constructor */
  61450. options: ITexturePackerOptions;
  61451. /** The promise that is started upon initialization */
  61452. promise: Nullable<Promise<TexturePacker | string>>;
  61453. /** The Container object for the channel sets that are generated */
  61454. sets: object;
  61455. /** The Container array for the frames that are generated */
  61456. frames: TexturePackerFrame[];
  61457. /** The expected number of textures the system is parsing. */
  61458. private _expecting;
  61459. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  61460. private _paddingValue;
  61461. /**
  61462. * Initializes a texture package series from an array of meshes or a single mesh.
  61463. * @param name The name of the package
  61464. * @param meshes The target meshes to compose the package from
  61465. * @param options The arguments that texture packer should follow while building.
  61466. * @param scene The scene which the textures are scoped to.
  61467. * @returns TexturePacker
  61468. */
  61469. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  61470. /**
  61471. * Starts the package process
  61472. * @param resolve The promises resolution function
  61473. * @returns TexturePacker
  61474. */
  61475. private _createFrames;
  61476. /**
  61477. * Calculates the Size of the Channel Sets
  61478. * @returns Vector2
  61479. */
  61480. private _calculateSize;
  61481. /**
  61482. * Calculates the UV data for the frames.
  61483. * @param baseSize the base frameSize
  61484. * @param padding the base frame padding
  61485. * @param dtSize size of the Dynamic Texture for that channel
  61486. * @param dtUnits is 1/dtSize
  61487. * @param update flag to update the input meshes
  61488. */
  61489. private _calculateMeshUVFrames;
  61490. /**
  61491. * Calculates the frames Offset.
  61492. * @param index of the frame
  61493. * @returns Vector2
  61494. */
  61495. private _getFrameOffset;
  61496. /**
  61497. * Updates a Mesh to the frame data
  61498. * @param mesh that is the target
  61499. * @param frameID or the frame index
  61500. */
  61501. private _updateMeshUV;
  61502. /**
  61503. * Updates a Meshes materials to use the texture packer channels
  61504. * @param m is the mesh to target
  61505. * @param force all channels on the packer to be set.
  61506. */
  61507. private _updateTextureReferences;
  61508. /**
  61509. * Public method to set a Mesh to a frame
  61510. * @param m that is the target
  61511. * @param frameID or the frame index
  61512. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  61513. */
  61514. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  61515. /**
  61516. * Starts the async promise to compile the texture packer.
  61517. * @returns Promise<void>
  61518. */
  61519. processAsync(): Promise<void>;
  61520. /**
  61521. * Disposes all textures associated with this packer
  61522. */
  61523. dispose(): void;
  61524. /**
  61525. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  61526. * @param imageType is the image type to use.
  61527. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  61528. */
  61529. download(imageType?: string, quality?: number): void;
  61530. /**
  61531. * Public method to load a texturePacker JSON file.
  61532. * @param data of the JSON file in string format.
  61533. */
  61534. updateFromJSON(data: string): void;
  61535. }
  61536. }
  61537. declare module BABYLON {
  61538. /**
  61539. * 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.
  61540. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  61541. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  61542. */
  61543. export class CustomProceduralTexture extends ProceduralTexture {
  61544. private _animate;
  61545. private _time;
  61546. private _config;
  61547. private _texturePath;
  61548. /**
  61549. * Instantiates a new Custom Procedural Texture.
  61550. * 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.
  61551. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  61552. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  61553. * @param name Define the name of the texture
  61554. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  61555. * @param size Define the size of the texture to create
  61556. * @param scene Define the scene the texture belongs to
  61557. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  61558. * @param generateMipMaps Define if the texture should creates mip maps or not
  61559. */
  61560. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  61561. private _loadJson;
  61562. /**
  61563. * Is the texture ready to be used ? (rendered at least once)
  61564. * @returns true if ready, otherwise, false.
  61565. */
  61566. isReady(): boolean;
  61567. /**
  61568. * Render the texture to its associated render target.
  61569. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  61570. */
  61571. render(useCameraPostProcess?: boolean): void;
  61572. /**
  61573. * Update the list of dependant textures samplers in the shader.
  61574. */
  61575. updateTextures(): void;
  61576. /**
  61577. * Update the uniform values of the procedural texture in the shader.
  61578. */
  61579. updateShaderUniforms(): void;
  61580. /**
  61581. * Define if the texture animates or not.
  61582. */
  61583. get animate(): boolean;
  61584. set animate(value: boolean);
  61585. }
  61586. }
  61587. declare module BABYLON {
  61588. /** @hidden */
  61589. export var noisePixelShader: {
  61590. name: string;
  61591. shader: string;
  61592. };
  61593. }
  61594. declare module BABYLON {
  61595. /**
  61596. * Class used to generate noise procedural textures
  61597. */
  61598. export class NoiseProceduralTexture extends ProceduralTexture {
  61599. private _time;
  61600. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  61601. brightness: number;
  61602. /** Defines the number of octaves to process */
  61603. octaves: number;
  61604. /** Defines the level of persistence (0.8 by default) */
  61605. persistence: number;
  61606. /** Gets or sets animation speed factor (default is 1) */
  61607. animationSpeedFactor: number;
  61608. /**
  61609. * Creates a new NoiseProceduralTexture
  61610. * @param name defines the name fo the texture
  61611. * @param size defines the size of the texture (default is 256)
  61612. * @param scene defines the hosting scene
  61613. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  61614. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  61615. */
  61616. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  61617. private _updateShaderUniforms;
  61618. protected _getDefines(): string;
  61619. /** Generate the current state of the procedural texture */
  61620. render(useCameraPostProcess?: boolean): void;
  61621. /**
  61622. * Serializes this noise procedural texture
  61623. * @returns a serialized noise procedural texture object
  61624. */
  61625. serialize(): any;
  61626. /**
  61627. * Clone the texture.
  61628. * @returns the cloned texture
  61629. */
  61630. clone(): NoiseProceduralTexture;
  61631. /**
  61632. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  61633. * @param parsedTexture defines parsed texture data
  61634. * @param scene defines the current scene
  61635. * @param rootUrl defines the root URL containing noise procedural texture information
  61636. * @returns a parsed NoiseProceduralTexture
  61637. */
  61638. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  61639. }
  61640. }
  61641. declare module BABYLON {
  61642. /**
  61643. * Raw cube texture where the raw buffers are passed in
  61644. */
  61645. export class RawCubeTexture extends CubeTexture {
  61646. /**
  61647. * Creates a cube texture where the raw buffers are passed in.
  61648. * @param scene defines the scene the texture is attached to
  61649. * @param data defines the array of data to use to create each face
  61650. * @param size defines the size of the textures
  61651. * @param format defines the format of the data
  61652. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  61653. * @param generateMipMaps defines if the engine should generate the mip levels
  61654. * @param invertY defines if data must be stored with Y axis inverted
  61655. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  61656. * @param compression defines the compression used (null by default)
  61657. */
  61658. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  61659. /**
  61660. * Updates the raw cube texture.
  61661. * @param data defines the data to store
  61662. * @param format defines the data format
  61663. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  61664. * @param invertY defines if data must be stored with Y axis inverted
  61665. * @param compression defines the compression used (null by default)
  61666. * @param level defines which level of the texture to update
  61667. */
  61668. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  61669. /**
  61670. * Updates a raw cube texture with RGBD encoded data.
  61671. * @param data defines the array of data [mipmap][face] to use to create each face
  61672. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  61673. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  61674. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  61675. * @returns a promsie that resolves when the operation is complete
  61676. */
  61677. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  61678. /**
  61679. * Clones the raw cube texture.
  61680. * @return a new cube texture
  61681. */
  61682. clone(): CubeTexture;
  61683. /** @hidden */
  61684. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  61685. }
  61686. }
  61687. declare module BABYLON {
  61688. /**
  61689. * Class used to store 2D array textures containing user data
  61690. */
  61691. export class RawTexture2DArray extends Texture {
  61692. /** Gets or sets the texture format to use */
  61693. format: number;
  61694. /**
  61695. * Create a new RawTexture2DArray
  61696. * @param data defines the data of the texture
  61697. * @param width defines the width of the texture
  61698. * @param height defines the height of the texture
  61699. * @param depth defines the number of layers of the texture
  61700. * @param format defines the texture format to use
  61701. * @param scene defines the hosting scene
  61702. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  61703. * @param invertY defines if texture must be stored with Y axis inverted
  61704. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61705. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  61706. */
  61707. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  61708. /** Gets or sets the texture format to use */
  61709. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  61710. /**
  61711. * Update the texture with new data
  61712. * @param data defines the data to store in the texture
  61713. */
  61714. update(data: ArrayBufferView): void;
  61715. }
  61716. }
  61717. declare module BABYLON {
  61718. /**
  61719. * Class used to store 3D textures containing user data
  61720. */
  61721. export class RawTexture3D extends Texture {
  61722. /** Gets or sets the texture format to use */
  61723. format: number;
  61724. /**
  61725. * Create a new RawTexture3D
  61726. * @param data defines the data of the texture
  61727. * @param width defines the width of the texture
  61728. * @param height defines the height of the texture
  61729. * @param depth defines the depth of the texture
  61730. * @param format defines the texture format to use
  61731. * @param scene defines the hosting scene
  61732. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  61733. * @param invertY defines if texture must be stored with Y axis inverted
  61734. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  61735. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  61736. */
  61737. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  61738. /** Gets or sets the texture format to use */
  61739. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  61740. /**
  61741. * Update the texture with new data
  61742. * @param data defines the data to store in the texture
  61743. */
  61744. update(data: ArrayBufferView): void;
  61745. }
  61746. }
  61747. declare module BABYLON {
  61748. /**
  61749. * Creates a refraction texture used by refraction channel of the standard material.
  61750. * It is like a mirror but to see through a material.
  61751. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61752. */
  61753. export class RefractionTexture extends RenderTargetTexture {
  61754. /**
  61755. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  61756. * 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.
  61757. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61758. */
  61759. refractionPlane: Plane;
  61760. /**
  61761. * Define how deep under the surface we should see.
  61762. */
  61763. depth: number;
  61764. /**
  61765. * Creates a refraction texture used by refraction channel of the standard material.
  61766. * It is like a mirror but to see through a material.
  61767. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  61768. * @param name Define the texture name
  61769. * @param size Define the size of the underlying texture
  61770. * @param scene Define the scene the refraction belongs to
  61771. * @param generateMipMaps Define if we need to generate mips level for the refraction
  61772. */
  61773. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  61774. /**
  61775. * Clone the refraction texture.
  61776. * @returns the cloned texture
  61777. */
  61778. clone(): RefractionTexture;
  61779. /**
  61780. * Serialize the texture to a JSON representation you could use in Parse later on
  61781. * @returns the serialized JSON representation
  61782. */
  61783. serialize(): any;
  61784. }
  61785. }
  61786. declare module BABYLON {
  61787. /**
  61788. * Block used to add support for vertex skinning (bones)
  61789. */
  61790. export class BonesBlock extends NodeMaterialBlock {
  61791. /**
  61792. * Creates a new BonesBlock
  61793. * @param name defines the block name
  61794. */
  61795. constructor(name: string);
  61796. /**
  61797. * Initialize the block and prepare the context for build
  61798. * @param state defines the state that will be used for the build
  61799. */
  61800. initialize(state: NodeMaterialBuildState): void;
  61801. /**
  61802. * Gets the current class name
  61803. * @returns the class name
  61804. */
  61805. getClassName(): string;
  61806. /**
  61807. * Gets the matrix indices input component
  61808. */
  61809. get matricesIndices(): NodeMaterialConnectionPoint;
  61810. /**
  61811. * Gets the matrix weights input component
  61812. */
  61813. get matricesWeights(): NodeMaterialConnectionPoint;
  61814. /**
  61815. * Gets the extra matrix indices input component
  61816. */
  61817. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  61818. /**
  61819. * Gets the extra matrix weights input component
  61820. */
  61821. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  61822. /**
  61823. * Gets the world input component
  61824. */
  61825. get world(): NodeMaterialConnectionPoint;
  61826. /**
  61827. * Gets the output component
  61828. */
  61829. get output(): NodeMaterialConnectionPoint;
  61830. autoConfigure(material: NodeMaterial): void;
  61831. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  61832. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61833. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61834. protected _buildBlock(state: NodeMaterialBuildState): this;
  61835. }
  61836. }
  61837. declare module BABYLON {
  61838. /**
  61839. * Block used to add support for instances
  61840. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  61841. */
  61842. export class InstancesBlock extends NodeMaterialBlock {
  61843. /**
  61844. * Creates a new InstancesBlock
  61845. * @param name defines the block name
  61846. */
  61847. constructor(name: string);
  61848. /**
  61849. * Gets the current class name
  61850. * @returns the class name
  61851. */
  61852. getClassName(): string;
  61853. /**
  61854. * Gets the first world row input component
  61855. */
  61856. get world0(): NodeMaterialConnectionPoint;
  61857. /**
  61858. * Gets the second world row input component
  61859. */
  61860. get world1(): NodeMaterialConnectionPoint;
  61861. /**
  61862. * Gets the third world row input component
  61863. */
  61864. get world2(): NodeMaterialConnectionPoint;
  61865. /**
  61866. * Gets the forth world row input component
  61867. */
  61868. get world3(): NodeMaterialConnectionPoint;
  61869. /**
  61870. * Gets the world input component
  61871. */
  61872. get world(): NodeMaterialConnectionPoint;
  61873. /**
  61874. * Gets the output component
  61875. */
  61876. get output(): NodeMaterialConnectionPoint;
  61877. /**
  61878. * Gets the isntanceID component
  61879. */
  61880. get instanceID(): NodeMaterialConnectionPoint;
  61881. autoConfigure(material: NodeMaterial): void;
  61882. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  61883. protected _buildBlock(state: NodeMaterialBuildState): this;
  61884. }
  61885. }
  61886. declare module BABYLON {
  61887. /**
  61888. * Block used to add morph targets support to vertex shader
  61889. */
  61890. export class MorphTargetsBlock extends NodeMaterialBlock {
  61891. private _repeatableContentAnchor;
  61892. /**
  61893. * Create a new MorphTargetsBlock
  61894. * @param name defines the block name
  61895. */
  61896. constructor(name: string);
  61897. /**
  61898. * Gets the current class name
  61899. * @returns the class name
  61900. */
  61901. getClassName(): string;
  61902. /**
  61903. * Gets the position input component
  61904. */
  61905. get position(): NodeMaterialConnectionPoint;
  61906. /**
  61907. * Gets the normal input component
  61908. */
  61909. get normal(): NodeMaterialConnectionPoint;
  61910. /**
  61911. * Gets the tangent input component
  61912. */
  61913. get tangent(): NodeMaterialConnectionPoint;
  61914. /**
  61915. * Gets the tangent input component
  61916. */
  61917. get uv(): NodeMaterialConnectionPoint;
  61918. /**
  61919. * Gets the position output component
  61920. */
  61921. get positionOutput(): NodeMaterialConnectionPoint;
  61922. /**
  61923. * Gets the normal output component
  61924. */
  61925. get normalOutput(): NodeMaterialConnectionPoint;
  61926. /**
  61927. * Gets the tangent output component
  61928. */
  61929. get tangentOutput(): NodeMaterialConnectionPoint;
  61930. /**
  61931. * Gets the tangent output component
  61932. */
  61933. get uvOutput(): NodeMaterialConnectionPoint;
  61934. initialize(state: NodeMaterialBuildState): void;
  61935. autoConfigure(material: NodeMaterial): void;
  61936. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61937. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61938. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61939. protected _buildBlock(state: NodeMaterialBuildState): this;
  61940. }
  61941. }
  61942. declare module BABYLON {
  61943. /**
  61944. * Block used to get data information from a light
  61945. */
  61946. export class LightInformationBlock extends NodeMaterialBlock {
  61947. private _lightDataUniformName;
  61948. private _lightColorUniformName;
  61949. private _lightTypeDefineName;
  61950. /**
  61951. * Gets or sets the light associated with this block
  61952. */
  61953. light: Nullable<Light>;
  61954. /**
  61955. * Creates a new LightInformationBlock
  61956. * @param name defines the block name
  61957. */
  61958. constructor(name: string);
  61959. /**
  61960. * Gets the current class name
  61961. * @returns the class name
  61962. */
  61963. getClassName(): string;
  61964. /**
  61965. * Gets the world position input component
  61966. */
  61967. get worldPosition(): NodeMaterialConnectionPoint;
  61968. /**
  61969. * Gets the direction output component
  61970. */
  61971. get direction(): NodeMaterialConnectionPoint;
  61972. /**
  61973. * Gets the direction output component
  61974. */
  61975. get color(): NodeMaterialConnectionPoint;
  61976. /**
  61977. * Gets the direction output component
  61978. */
  61979. get intensity(): NodeMaterialConnectionPoint;
  61980. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61981. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61982. protected _buildBlock(state: NodeMaterialBuildState): this;
  61983. serialize(): any;
  61984. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61985. }
  61986. }
  61987. declare module BABYLON {
  61988. /**
  61989. * Block used to add image processing support to fragment shader
  61990. */
  61991. export class ImageProcessingBlock extends NodeMaterialBlock {
  61992. /**
  61993. * Create a new ImageProcessingBlock
  61994. * @param name defines the block name
  61995. */
  61996. constructor(name: string);
  61997. /**
  61998. * Gets the current class name
  61999. * @returns the class name
  62000. */
  62001. getClassName(): string;
  62002. /**
  62003. * Gets the color input component
  62004. */
  62005. get color(): NodeMaterialConnectionPoint;
  62006. /**
  62007. * Gets the output component
  62008. */
  62009. get output(): NodeMaterialConnectionPoint;
  62010. /**
  62011. * Initialize the block and prepare the context for build
  62012. * @param state defines the state that will be used for the build
  62013. */
  62014. initialize(state: NodeMaterialBuildState): void;
  62015. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  62016. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62017. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62018. protected _buildBlock(state: NodeMaterialBuildState): this;
  62019. }
  62020. }
  62021. declare module BABYLON {
  62022. /**
  62023. * Block used to pertub normals based on a normal map
  62024. */
  62025. export class PerturbNormalBlock extends NodeMaterialBlock {
  62026. private _tangentSpaceParameterName;
  62027. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62028. invertX: boolean;
  62029. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  62030. invertY: boolean;
  62031. /**
  62032. * Create a new PerturbNormalBlock
  62033. * @param name defines the block name
  62034. */
  62035. constructor(name: string);
  62036. /**
  62037. * Gets the current class name
  62038. * @returns the class name
  62039. */
  62040. getClassName(): string;
  62041. /**
  62042. * Gets the world position input component
  62043. */
  62044. get worldPosition(): NodeMaterialConnectionPoint;
  62045. /**
  62046. * Gets the world normal input component
  62047. */
  62048. get worldNormal(): NodeMaterialConnectionPoint;
  62049. /**
  62050. * Gets the world tangent input component
  62051. */
  62052. get worldTangent(): NodeMaterialConnectionPoint;
  62053. /**
  62054. * Gets the uv input component
  62055. */
  62056. get uv(): NodeMaterialConnectionPoint;
  62057. /**
  62058. * Gets the normal map color input component
  62059. */
  62060. get normalMapColor(): NodeMaterialConnectionPoint;
  62061. /**
  62062. * Gets the strength input component
  62063. */
  62064. get strength(): NodeMaterialConnectionPoint;
  62065. /**
  62066. * Gets the output component
  62067. */
  62068. get output(): NodeMaterialConnectionPoint;
  62069. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62070. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62071. autoConfigure(material: NodeMaterial): void;
  62072. protected _buildBlock(state: NodeMaterialBuildState): this;
  62073. protected _dumpPropertiesCode(): string;
  62074. serialize(): any;
  62075. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62076. }
  62077. }
  62078. declare module BABYLON {
  62079. /**
  62080. * Block used to discard a pixel if a value is smaller than a cutoff
  62081. */
  62082. export class DiscardBlock extends NodeMaterialBlock {
  62083. /**
  62084. * Create a new DiscardBlock
  62085. * @param name defines the block name
  62086. */
  62087. constructor(name: string);
  62088. /**
  62089. * Gets the current class name
  62090. * @returns the class name
  62091. */
  62092. getClassName(): string;
  62093. /**
  62094. * Gets the color input component
  62095. */
  62096. get value(): NodeMaterialConnectionPoint;
  62097. /**
  62098. * Gets the cutoff input component
  62099. */
  62100. get cutoff(): NodeMaterialConnectionPoint;
  62101. protected _buildBlock(state: NodeMaterialBuildState): this;
  62102. }
  62103. }
  62104. declare module BABYLON {
  62105. /**
  62106. * Block used to test if the fragment shader is front facing
  62107. */
  62108. export class FrontFacingBlock extends NodeMaterialBlock {
  62109. /**
  62110. * Creates a new FrontFacingBlock
  62111. * @param name defines the block name
  62112. */
  62113. constructor(name: string);
  62114. /**
  62115. * Gets the current class name
  62116. * @returns the class name
  62117. */
  62118. getClassName(): string;
  62119. /**
  62120. * Gets the output component
  62121. */
  62122. get output(): NodeMaterialConnectionPoint;
  62123. protected _buildBlock(state: NodeMaterialBuildState): this;
  62124. }
  62125. }
  62126. declare module BABYLON {
  62127. /**
  62128. * Block used to get the derivative value on x and y of a given input
  62129. */
  62130. export class DerivativeBlock extends NodeMaterialBlock {
  62131. /**
  62132. * Create a new DerivativeBlock
  62133. * @param name defines the block name
  62134. */
  62135. constructor(name: string);
  62136. /**
  62137. * Gets the current class name
  62138. * @returns the class name
  62139. */
  62140. getClassName(): string;
  62141. /**
  62142. * Gets the input component
  62143. */
  62144. get input(): NodeMaterialConnectionPoint;
  62145. /**
  62146. * Gets the derivative output on x
  62147. */
  62148. get dx(): NodeMaterialConnectionPoint;
  62149. /**
  62150. * Gets the derivative output on y
  62151. */
  62152. get dy(): NodeMaterialConnectionPoint;
  62153. protected _buildBlock(state: NodeMaterialBuildState): this;
  62154. }
  62155. }
  62156. declare module BABYLON {
  62157. /**
  62158. * Block used to make gl_FragCoord available
  62159. */
  62160. export class FragCoordBlock extends NodeMaterialBlock {
  62161. /**
  62162. * Creates a new FragCoordBlock
  62163. * @param name defines the block name
  62164. */
  62165. constructor(name: string);
  62166. /**
  62167. * Gets the current class name
  62168. * @returns the class name
  62169. */
  62170. getClassName(): string;
  62171. /**
  62172. * Gets the xy component
  62173. */
  62174. get xy(): NodeMaterialConnectionPoint;
  62175. /**
  62176. * Gets the xyz component
  62177. */
  62178. get xyz(): NodeMaterialConnectionPoint;
  62179. /**
  62180. * Gets the xyzw component
  62181. */
  62182. get xyzw(): NodeMaterialConnectionPoint;
  62183. /**
  62184. * Gets the x component
  62185. */
  62186. get x(): NodeMaterialConnectionPoint;
  62187. /**
  62188. * Gets the y component
  62189. */
  62190. get y(): NodeMaterialConnectionPoint;
  62191. /**
  62192. * Gets the z component
  62193. */
  62194. get z(): NodeMaterialConnectionPoint;
  62195. /**
  62196. * Gets the w component
  62197. */
  62198. get output(): NodeMaterialConnectionPoint;
  62199. protected writeOutputs(state: NodeMaterialBuildState): string;
  62200. protected _buildBlock(state: NodeMaterialBuildState): this;
  62201. }
  62202. }
  62203. declare module BABYLON {
  62204. /**
  62205. * Block used to get the screen sizes
  62206. */
  62207. export class ScreenSizeBlock extends NodeMaterialBlock {
  62208. private _varName;
  62209. private _scene;
  62210. /**
  62211. * Creates a new ScreenSizeBlock
  62212. * @param name defines the block name
  62213. */
  62214. constructor(name: string);
  62215. /**
  62216. * Gets the current class name
  62217. * @returns the class name
  62218. */
  62219. getClassName(): string;
  62220. /**
  62221. * Gets the xy component
  62222. */
  62223. get xy(): NodeMaterialConnectionPoint;
  62224. /**
  62225. * Gets the x component
  62226. */
  62227. get x(): NodeMaterialConnectionPoint;
  62228. /**
  62229. * Gets the y component
  62230. */
  62231. get y(): NodeMaterialConnectionPoint;
  62232. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62233. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  62234. protected _buildBlock(state: NodeMaterialBuildState): this;
  62235. }
  62236. }
  62237. declare module BABYLON {
  62238. /**
  62239. * Block used to add support for scene fog
  62240. */
  62241. export class FogBlock extends NodeMaterialBlock {
  62242. private _fogDistanceName;
  62243. private _fogParameters;
  62244. /**
  62245. * Create a new FogBlock
  62246. * @param name defines the block name
  62247. */
  62248. constructor(name: string);
  62249. /**
  62250. * Gets the current class name
  62251. * @returns the class name
  62252. */
  62253. getClassName(): string;
  62254. /**
  62255. * Gets the world position input component
  62256. */
  62257. get worldPosition(): NodeMaterialConnectionPoint;
  62258. /**
  62259. * Gets the view input component
  62260. */
  62261. get view(): NodeMaterialConnectionPoint;
  62262. /**
  62263. * Gets the color input component
  62264. */
  62265. get input(): NodeMaterialConnectionPoint;
  62266. /**
  62267. * Gets the fog color input component
  62268. */
  62269. get fogColor(): NodeMaterialConnectionPoint;
  62270. /**
  62271. * Gets the output component
  62272. */
  62273. get output(): NodeMaterialConnectionPoint;
  62274. autoConfigure(material: NodeMaterial): void;
  62275. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62276. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62277. protected _buildBlock(state: NodeMaterialBuildState): this;
  62278. }
  62279. }
  62280. declare module BABYLON {
  62281. /**
  62282. * Block used to add light in the fragment shader
  62283. */
  62284. export class LightBlock extends NodeMaterialBlock {
  62285. private _lightId;
  62286. /**
  62287. * Gets or sets the light associated with this block
  62288. */
  62289. light: Nullable<Light>;
  62290. /**
  62291. * Create a new LightBlock
  62292. * @param name defines the block name
  62293. */
  62294. constructor(name: string);
  62295. /**
  62296. * Gets the current class name
  62297. * @returns the class name
  62298. */
  62299. getClassName(): string;
  62300. /**
  62301. * Gets the world position input component
  62302. */
  62303. get worldPosition(): NodeMaterialConnectionPoint;
  62304. /**
  62305. * Gets the world normal input component
  62306. */
  62307. get worldNormal(): NodeMaterialConnectionPoint;
  62308. /**
  62309. * Gets the camera (or eye) position component
  62310. */
  62311. get cameraPosition(): NodeMaterialConnectionPoint;
  62312. /**
  62313. * Gets the glossiness component
  62314. */
  62315. get glossiness(): NodeMaterialConnectionPoint;
  62316. /**
  62317. * Gets the glossinness power component
  62318. */
  62319. get glossPower(): NodeMaterialConnectionPoint;
  62320. /**
  62321. * Gets the diffuse color component
  62322. */
  62323. get diffuseColor(): NodeMaterialConnectionPoint;
  62324. /**
  62325. * Gets the specular color component
  62326. */
  62327. get specularColor(): NodeMaterialConnectionPoint;
  62328. /**
  62329. * Gets the diffuse output component
  62330. */
  62331. get diffuseOutput(): NodeMaterialConnectionPoint;
  62332. /**
  62333. * Gets the specular output component
  62334. */
  62335. get specularOutput(): NodeMaterialConnectionPoint;
  62336. /**
  62337. * Gets the shadow output component
  62338. */
  62339. get shadow(): NodeMaterialConnectionPoint;
  62340. autoConfigure(material: NodeMaterial): void;
  62341. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62342. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  62343. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62344. private _injectVertexCode;
  62345. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62346. serialize(): any;
  62347. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62348. }
  62349. }
  62350. declare module BABYLON {
  62351. /**
  62352. * Block used to read a reflection texture from a sampler
  62353. */
  62354. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  62355. /**
  62356. * Create a new ReflectionTextureBlock
  62357. * @param name defines the block name
  62358. */
  62359. constructor(name: string);
  62360. /**
  62361. * Gets the current class name
  62362. * @returns the class name
  62363. */
  62364. getClassName(): string;
  62365. /**
  62366. * Gets the world position input component
  62367. */
  62368. get position(): NodeMaterialConnectionPoint;
  62369. /**
  62370. * Gets the world position input component
  62371. */
  62372. get worldPosition(): NodeMaterialConnectionPoint;
  62373. /**
  62374. * Gets the world normal input component
  62375. */
  62376. get worldNormal(): NodeMaterialConnectionPoint;
  62377. /**
  62378. * Gets the world input component
  62379. */
  62380. get world(): NodeMaterialConnectionPoint;
  62381. /**
  62382. * Gets the camera (or eye) position component
  62383. */
  62384. get cameraPosition(): NodeMaterialConnectionPoint;
  62385. /**
  62386. * Gets the view input component
  62387. */
  62388. get view(): NodeMaterialConnectionPoint;
  62389. /**
  62390. * Gets the rgb output component
  62391. */
  62392. get rgb(): NodeMaterialConnectionPoint;
  62393. /**
  62394. * Gets the rgba output component
  62395. */
  62396. get rgba(): NodeMaterialConnectionPoint;
  62397. /**
  62398. * Gets the r output component
  62399. */
  62400. get r(): NodeMaterialConnectionPoint;
  62401. /**
  62402. * Gets the g output component
  62403. */
  62404. get g(): NodeMaterialConnectionPoint;
  62405. /**
  62406. * Gets the b output component
  62407. */
  62408. get b(): NodeMaterialConnectionPoint;
  62409. /**
  62410. * Gets the a output component
  62411. */
  62412. get a(): NodeMaterialConnectionPoint;
  62413. autoConfigure(material: NodeMaterial): void;
  62414. protected _buildBlock(state: NodeMaterialBuildState): this;
  62415. }
  62416. }
  62417. declare module BABYLON {
  62418. /**
  62419. * Block used to add 2 vectors
  62420. */
  62421. export class AddBlock extends NodeMaterialBlock {
  62422. /**
  62423. * Creates a new AddBlock
  62424. * @param name defines the block name
  62425. */
  62426. constructor(name: string);
  62427. /**
  62428. * Gets the current class name
  62429. * @returns the class name
  62430. */
  62431. getClassName(): string;
  62432. /**
  62433. * Gets the left operand input component
  62434. */
  62435. get left(): NodeMaterialConnectionPoint;
  62436. /**
  62437. * Gets the right operand input component
  62438. */
  62439. get right(): NodeMaterialConnectionPoint;
  62440. /**
  62441. * Gets the output component
  62442. */
  62443. get output(): NodeMaterialConnectionPoint;
  62444. protected _buildBlock(state: NodeMaterialBuildState): this;
  62445. }
  62446. }
  62447. declare module BABYLON {
  62448. /**
  62449. * Block used to scale a vector by a float
  62450. */
  62451. export class ScaleBlock extends NodeMaterialBlock {
  62452. /**
  62453. * Creates a new ScaleBlock
  62454. * @param name defines the block name
  62455. */
  62456. constructor(name: string);
  62457. /**
  62458. * Gets the current class name
  62459. * @returns the class name
  62460. */
  62461. getClassName(): string;
  62462. /**
  62463. * Gets the input component
  62464. */
  62465. get input(): NodeMaterialConnectionPoint;
  62466. /**
  62467. * Gets the factor input component
  62468. */
  62469. get factor(): NodeMaterialConnectionPoint;
  62470. /**
  62471. * Gets the output component
  62472. */
  62473. get output(): NodeMaterialConnectionPoint;
  62474. protected _buildBlock(state: NodeMaterialBuildState): this;
  62475. }
  62476. }
  62477. declare module BABYLON {
  62478. /**
  62479. * Block used to clamp a float
  62480. */
  62481. export class ClampBlock extends NodeMaterialBlock {
  62482. /** Gets or sets the minimum range */
  62483. minimum: number;
  62484. /** Gets or sets the maximum range */
  62485. maximum: number;
  62486. /**
  62487. * Creates a new ClampBlock
  62488. * @param name defines the block name
  62489. */
  62490. constructor(name: string);
  62491. /**
  62492. * Gets the current class name
  62493. * @returns the class name
  62494. */
  62495. getClassName(): string;
  62496. /**
  62497. * Gets the value input component
  62498. */
  62499. get value(): NodeMaterialConnectionPoint;
  62500. /**
  62501. * Gets the output component
  62502. */
  62503. get output(): NodeMaterialConnectionPoint;
  62504. protected _buildBlock(state: NodeMaterialBuildState): this;
  62505. protected _dumpPropertiesCode(): string;
  62506. serialize(): any;
  62507. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62508. }
  62509. }
  62510. declare module BABYLON {
  62511. /**
  62512. * Block used to apply a cross product between 2 vectors
  62513. */
  62514. export class CrossBlock extends NodeMaterialBlock {
  62515. /**
  62516. * Creates a new CrossBlock
  62517. * @param name defines the block name
  62518. */
  62519. constructor(name: string);
  62520. /**
  62521. * Gets the current class name
  62522. * @returns the class name
  62523. */
  62524. getClassName(): string;
  62525. /**
  62526. * Gets the left operand input component
  62527. */
  62528. get left(): NodeMaterialConnectionPoint;
  62529. /**
  62530. * Gets the right operand input component
  62531. */
  62532. get right(): NodeMaterialConnectionPoint;
  62533. /**
  62534. * Gets the output component
  62535. */
  62536. get output(): NodeMaterialConnectionPoint;
  62537. protected _buildBlock(state: NodeMaterialBuildState): this;
  62538. }
  62539. }
  62540. declare module BABYLON {
  62541. /**
  62542. * Block used to apply a dot product between 2 vectors
  62543. */
  62544. export class DotBlock extends NodeMaterialBlock {
  62545. /**
  62546. * Creates a new DotBlock
  62547. * @param name defines the block name
  62548. */
  62549. constructor(name: string);
  62550. /**
  62551. * Gets the current class name
  62552. * @returns the class name
  62553. */
  62554. getClassName(): string;
  62555. /**
  62556. * Gets the left operand input component
  62557. */
  62558. get left(): NodeMaterialConnectionPoint;
  62559. /**
  62560. * Gets the right operand input component
  62561. */
  62562. get right(): NodeMaterialConnectionPoint;
  62563. /**
  62564. * Gets the output component
  62565. */
  62566. get output(): NodeMaterialConnectionPoint;
  62567. protected _buildBlock(state: NodeMaterialBuildState): this;
  62568. }
  62569. }
  62570. declare module BABYLON {
  62571. /**
  62572. * Block used to normalize a vector
  62573. */
  62574. export class NormalizeBlock extends NodeMaterialBlock {
  62575. /**
  62576. * Creates a new NormalizeBlock
  62577. * @param name defines the block name
  62578. */
  62579. constructor(name: string);
  62580. /**
  62581. * Gets the current class name
  62582. * @returns the class name
  62583. */
  62584. getClassName(): string;
  62585. /**
  62586. * Gets the input component
  62587. */
  62588. get input(): NodeMaterialConnectionPoint;
  62589. /**
  62590. * Gets the output component
  62591. */
  62592. get output(): NodeMaterialConnectionPoint;
  62593. protected _buildBlock(state: NodeMaterialBuildState): this;
  62594. }
  62595. }
  62596. declare module BABYLON {
  62597. /**
  62598. * Operations supported by the Trigonometry block
  62599. */
  62600. export enum TrigonometryBlockOperations {
  62601. /** Cos */
  62602. Cos = 0,
  62603. /** Sin */
  62604. Sin = 1,
  62605. /** Abs */
  62606. Abs = 2,
  62607. /** Exp */
  62608. Exp = 3,
  62609. /** Exp2 */
  62610. Exp2 = 4,
  62611. /** Round */
  62612. Round = 5,
  62613. /** Floor */
  62614. Floor = 6,
  62615. /** Ceiling */
  62616. Ceiling = 7,
  62617. /** Square root */
  62618. Sqrt = 8,
  62619. /** Log */
  62620. Log = 9,
  62621. /** Tangent */
  62622. Tan = 10,
  62623. /** Arc tangent */
  62624. ArcTan = 11,
  62625. /** Arc cosinus */
  62626. ArcCos = 12,
  62627. /** Arc sinus */
  62628. ArcSin = 13,
  62629. /** Fraction */
  62630. Fract = 14,
  62631. /** Sign */
  62632. Sign = 15,
  62633. /** To radians (from degrees) */
  62634. Radians = 16,
  62635. /** To degrees (from radians) */
  62636. Degrees = 17
  62637. }
  62638. /**
  62639. * Block used to apply trigonometry operation to floats
  62640. */
  62641. export class TrigonometryBlock extends NodeMaterialBlock {
  62642. /**
  62643. * Gets or sets the operation applied by the block
  62644. */
  62645. operation: TrigonometryBlockOperations;
  62646. /**
  62647. * Creates a new TrigonometryBlock
  62648. * @param name defines the block name
  62649. */
  62650. constructor(name: string);
  62651. /**
  62652. * Gets the current class name
  62653. * @returns the class name
  62654. */
  62655. getClassName(): string;
  62656. /**
  62657. * Gets the input component
  62658. */
  62659. get input(): NodeMaterialConnectionPoint;
  62660. /**
  62661. * Gets the output component
  62662. */
  62663. get output(): NodeMaterialConnectionPoint;
  62664. protected _buildBlock(state: NodeMaterialBuildState): this;
  62665. serialize(): any;
  62666. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62667. protected _dumpPropertiesCode(): string;
  62668. }
  62669. }
  62670. declare module BABYLON {
  62671. /**
  62672. * Block used to create a Color3/4 out of individual inputs (one for each component)
  62673. */
  62674. export class ColorMergerBlock extends NodeMaterialBlock {
  62675. /**
  62676. * Create a new ColorMergerBlock
  62677. * @param name defines the block name
  62678. */
  62679. constructor(name: string);
  62680. /**
  62681. * Gets the current class name
  62682. * @returns the class name
  62683. */
  62684. getClassName(): string;
  62685. /**
  62686. * Gets the rgb component (input)
  62687. */
  62688. get rgbIn(): NodeMaterialConnectionPoint;
  62689. /**
  62690. * Gets the r component (input)
  62691. */
  62692. get r(): NodeMaterialConnectionPoint;
  62693. /**
  62694. * Gets the g component (input)
  62695. */
  62696. get g(): NodeMaterialConnectionPoint;
  62697. /**
  62698. * Gets the b component (input)
  62699. */
  62700. get b(): NodeMaterialConnectionPoint;
  62701. /**
  62702. * Gets the a component (input)
  62703. */
  62704. get a(): NodeMaterialConnectionPoint;
  62705. /**
  62706. * Gets the rgba component (output)
  62707. */
  62708. get rgba(): NodeMaterialConnectionPoint;
  62709. /**
  62710. * Gets the rgb component (output)
  62711. */
  62712. get rgbOut(): NodeMaterialConnectionPoint;
  62713. /**
  62714. * Gets the rgb component (output)
  62715. * @deprecated Please use rgbOut instead.
  62716. */
  62717. get rgb(): NodeMaterialConnectionPoint;
  62718. protected _buildBlock(state: NodeMaterialBuildState): this;
  62719. }
  62720. }
  62721. declare module BABYLON {
  62722. /**
  62723. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  62724. */
  62725. export class VectorSplitterBlock extends NodeMaterialBlock {
  62726. /**
  62727. * Create a new VectorSplitterBlock
  62728. * @param name defines the block name
  62729. */
  62730. constructor(name: string);
  62731. /**
  62732. * Gets the current class name
  62733. * @returns the class name
  62734. */
  62735. getClassName(): string;
  62736. /**
  62737. * Gets the xyzw component (input)
  62738. */
  62739. get xyzw(): NodeMaterialConnectionPoint;
  62740. /**
  62741. * Gets the xyz component (input)
  62742. */
  62743. get xyzIn(): NodeMaterialConnectionPoint;
  62744. /**
  62745. * Gets the xy component (input)
  62746. */
  62747. get xyIn(): NodeMaterialConnectionPoint;
  62748. /**
  62749. * Gets the xyz component (output)
  62750. */
  62751. get xyzOut(): NodeMaterialConnectionPoint;
  62752. /**
  62753. * Gets the xy component (output)
  62754. */
  62755. get xyOut(): NodeMaterialConnectionPoint;
  62756. /**
  62757. * Gets the x component (output)
  62758. */
  62759. get x(): NodeMaterialConnectionPoint;
  62760. /**
  62761. * Gets the y component (output)
  62762. */
  62763. get y(): NodeMaterialConnectionPoint;
  62764. /**
  62765. * Gets the z component (output)
  62766. */
  62767. get z(): NodeMaterialConnectionPoint;
  62768. /**
  62769. * Gets the w component (output)
  62770. */
  62771. get w(): NodeMaterialConnectionPoint;
  62772. protected _inputRename(name: string): string;
  62773. protected _outputRename(name: string): string;
  62774. protected _buildBlock(state: NodeMaterialBuildState): this;
  62775. }
  62776. }
  62777. declare module BABYLON {
  62778. /**
  62779. * Block used to lerp between 2 values
  62780. */
  62781. export class LerpBlock extends NodeMaterialBlock {
  62782. /**
  62783. * Creates a new LerpBlock
  62784. * @param name defines the block name
  62785. */
  62786. constructor(name: string);
  62787. /**
  62788. * Gets the current class name
  62789. * @returns the class name
  62790. */
  62791. getClassName(): string;
  62792. /**
  62793. * Gets the left operand input component
  62794. */
  62795. get left(): NodeMaterialConnectionPoint;
  62796. /**
  62797. * Gets the right operand input component
  62798. */
  62799. get right(): NodeMaterialConnectionPoint;
  62800. /**
  62801. * Gets the gradient operand input component
  62802. */
  62803. get gradient(): NodeMaterialConnectionPoint;
  62804. /**
  62805. * Gets the output component
  62806. */
  62807. get output(): NodeMaterialConnectionPoint;
  62808. protected _buildBlock(state: NodeMaterialBuildState): this;
  62809. }
  62810. }
  62811. declare module BABYLON {
  62812. /**
  62813. * Block used to divide 2 vectors
  62814. */
  62815. export class DivideBlock extends NodeMaterialBlock {
  62816. /**
  62817. * Creates a new DivideBlock
  62818. * @param name defines the block name
  62819. */
  62820. constructor(name: string);
  62821. /**
  62822. * Gets the current class name
  62823. * @returns the class name
  62824. */
  62825. getClassName(): string;
  62826. /**
  62827. * Gets the left operand input component
  62828. */
  62829. get left(): NodeMaterialConnectionPoint;
  62830. /**
  62831. * Gets the right operand input component
  62832. */
  62833. get right(): NodeMaterialConnectionPoint;
  62834. /**
  62835. * Gets the output component
  62836. */
  62837. get output(): NodeMaterialConnectionPoint;
  62838. protected _buildBlock(state: NodeMaterialBuildState): this;
  62839. }
  62840. }
  62841. declare module BABYLON {
  62842. /**
  62843. * Block used to subtract 2 vectors
  62844. */
  62845. export class SubtractBlock extends NodeMaterialBlock {
  62846. /**
  62847. * Creates a new SubtractBlock
  62848. * @param name defines the block name
  62849. */
  62850. constructor(name: string);
  62851. /**
  62852. * Gets the current class name
  62853. * @returns the class name
  62854. */
  62855. getClassName(): string;
  62856. /**
  62857. * Gets the left operand input component
  62858. */
  62859. get left(): NodeMaterialConnectionPoint;
  62860. /**
  62861. * Gets the right operand input component
  62862. */
  62863. get right(): NodeMaterialConnectionPoint;
  62864. /**
  62865. * Gets the output component
  62866. */
  62867. get output(): NodeMaterialConnectionPoint;
  62868. protected _buildBlock(state: NodeMaterialBuildState): this;
  62869. }
  62870. }
  62871. declare module BABYLON {
  62872. /**
  62873. * Block used to step a value
  62874. */
  62875. export class StepBlock extends NodeMaterialBlock {
  62876. /**
  62877. * Creates a new StepBlock
  62878. * @param name defines the block name
  62879. */
  62880. constructor(name: string);
  62881. /**
  62882. * Gets the current class name
  62883. * @returns the class name
  62884. */
  62885. getClassName(): string;
  62886. /**
  62887. * Gets the value operand input component
  62888. */
  62889. get value(): NodeMaterialConnectionPoint;
  62890. /**
  62891. * Gets the edge operand input component
  62892. */
  62893. get edge(): NodeMaterialConnectionPoint;
  62894. /**
  62895. * Gets the output component
  62896. */
  62897. get output(): NodeMaterialConnectionPoint;
  62898. protected _buildBlock(state: NodeMaterialBuildState): this;
  62899. }
  62900. }
  62901. declare module BABYLON {
  62902. /**
  62903. * Block used to get the opposite (1 - x) of a value
  62904. */
  62905. export class OneMinusBlock extends NodeMaterialBlock {
  62906. /**
  62907. * Creates a new OneMinusBlock
  62908. * @param name defines the block name
  62909. */
  62910. constructor(name: string);
  62911. /**
  62912. * Gets the current class name
  62913. * @returns the class name
  62914. */
  62915. getClassName(): string;
  62916. /**
  62917. * Gets the input component
  62918. */
  62919. get input(): NodeMaterialConnectionPoint;
  62920. /**
  62921. * Gets the output component
  62922. */
  62923. get output(): NodeMaterialConnectionPoint;
  62924. protected _buildBlock(state: NodeMaterialBuildState): this;
  62925. }
  62926. }
  62927. declare module BABYLON {
  62928. /**
  62929. * Block used to get the view direction
  62930. */
  62931. export class ViewDirectionBlock extends NodeMaterialBlock {
  62932. /**
  62933. * Creates a new ViewDirectionBlock
  62934. * @param name defines the block name
  62935. */
  62936. constructor(name: string);
  62937. /**
  62938. * Gets the current class name
  62939. * @returns the class name
  62940. */
  62941. getClassName(): string;
  62942. /**
  62943. * Gets the world position component
  62944. */
  62945. get worldPosition(): NodeMaterialConnectionPoint;
  62946. /**
  62947. * Gets the camera position component
  62948. */
  62949. get cameraPosition(): NodeMaterialConnectionPoint;
  62950. /**
  62951. * Gets the output component
  62952. */
  62953. get output(): NodeMaterialConnectionPoint;
  62954. autoConfigure(material: NodeMaterial): void;
  62955. protected _buildBlock(state: NodeMaterialBuildState): this;
  62956. }
  62957. }
  62958. declare module BABYLON {
  62959. /**
  62960. * Block used to compute fresnel value
  62961. */
  62962. export class FresnelBlock extends NodeMaterialBlock {
  62963. /**
  62964. * Create a new FresnelBlock
  62965. * @param name defines the block name
  62966. */
  62967. constructor(name: string);
  62968. /**
  62969. * Gets the current class name
  62970. * @returns the class name
  62971. */
  62972. getClassName(): string;
  62973. /**
  62974. * Gets the world normal input component
  62975. */
  62976. get worldNormal(): NodeMaterialConnectionPoint;
  62977. /**
  62978. * Gets the view direction input component
  62979. */
  62980. get viewDirection(): NodeMaterialConnectionPoint;
  62981. /**
  62982. * Gets the bias input component
  62983. */
  62984. get bias(): NodeMaterialConnectionPoint;
  62985. /**
  62986. * Gets the camera (or eye) position component
  62987. */
  62988. get power(): NodeMaterialConnectionPoint;
  62989. /**
  62990. * Gets the fresnel output component
  62991. */
  62992. get fresnel(): NodeMaterialConnectionPoint;
  62993. autoConfigure(material: NodeMaterial): void;
  62994. protected _buildBlock(state: NodeMaterialBuildState): this;
  62995. }
  62996. }
  62997. declare module BABYLON {
  62998. /**
  62999. * Block used to get the max of 2 values
  63000. */
  63001. export class MaxBlock extends NodeMaterialBlock {
  63002. /**
  63003. * Creates a new MaxBlock
  63004. * @param name defines the block name
  63005. */
  63006. constructor(name: string);
  63007. /**
  63008. * Gets the current class name
  63009. * @returns the class name
  63010. */
  63011. getClassName(): string;
  63012. /**
  63013. * Gets the left operand input component
  63014. */
  63015. get left(): NodeMaterialConnectionPoint;
  63016. /**
  63017. * Gets the right operand input component
  63018. */
  63019. get right(): NodeMaterialConnectionPoint;
  63020. /**
  63021. * Gets the output component
  63022. */
  63023. get output(): NodeMaterialConnectionPoint;
  63024. protected _buildBlock(state: NodeMaterialBuildState): this;
  63025. }
  63026. }
  63027. declare module BABYLON {
  63028. /**
  63029. * Block used to get the min of 2 values
  63030. */
  63031. export class MinBlock extends NodeMaterialBlock {
  63032. /**
  63033. * Creates a new MinBlock
  63034. * @param name defines the block name
  63035. */
  63036. constructor(name: string);
  63037. /**
  63038. * Gets the current class name
  63039. * @returns the class name
  63040. */
  63041. getClassName(): string;
  63042. /**
  63043. * Gets the left operand input component
  63044. */
  63045. get left(): NodeMaterialConnectionPoint;
  63046. /**
  63047. * Gets the right operand input component
  63048. */
  63049. get right(): NodeMaterialConnectionPoint;
  63050. /**
  63051. * Gets the output component
  63052. */
  63053. get output(): NodeMaterialConnectionPoint;
  63054. protected _buildBlock(state: NodeMaterialBuildState): this;
  63055. }
  63056. }
  63057. declare module BABYLON {
  63058. /**
  63059. * Block used to get the distance between 2 values
  63060. */
  63061. export class DistanceBlock extends NodeMaterialBlock {
  63062. /**
  63063. * Creates a new DistanceBlock
  63064. * @param name defines the block name
  63065. */
  63066. constructor(name: string);
  63067. /**
  63068. * Gets the current class name
  63069. * @returns the class name
  63070. */
  63071. getClassName(): string;
  63072. /**
  63073. * Gets the left operand input component
  63074. */
  63075. get left(): NodeMaterialConnectionPoint;
  63076. /**
  63077. * Gets the right operand input component
  63078. */
  63079. get right(): NodeMaterialConnectionPoint;
  63080. /**
  63081. * Gets the output component
  63082. */
  63083. get output(): NodeMaterialConnectionPoint;
  63084. protected _buildBlock(state: NodeMaterialBuildState): this;
  63085. }
  63086. }
  63087. declare module BABYLON {
  63088. /**
  63089. * Block used to get the length of a vector
  63090. */
  63091. export class LengthBlock extends NodeMaterialBlock {
  63092. /**
  63093. * Creates a new LengthBlock
  63094. * @param name defines the block name
  63095. */
  63096. constructor(name: string);
  63097. /**
  63098. * Gets the current class name
  63099. * @returns the class name
  63100. */
  63101. getClassName(): string;
  63102. /**
  63103. * Gets the value input component
  63104. */
  63105. get value(): NodeMaterialConnectionPoint;
  63106. /**
  63107. * Gets the output component
  63108. */
  63109. get output(): NodeMaterialConnectionPoint;
  63110. protected _buildBlock(state: NodeMaterialBuildState): this;
  63111. }
  63112. }
  63113. declare module BABYLON {
  63114. /**
  63115. * Block used to get negative version of a value (i.e. x * -1)
  63116. */
  63117. export class NegateBlock extends NodeMaterialBlock {
  63118. /**
  63119. * Creates a new NegateBlock
  63120. * @param name defines the block name
  63121. */
  63122. constructor(name: string);
  63123. /**
  63124. * Gets the current class name
  63125. * @returns the class name
  63126. */
  63127. getClassName(): string;
  63128. /**
  63129. * Gets the value input component
  63130. */
  63131. get value(): NodeMaterialConnectionPoint;
  63132. /**
  63133. * Gets the output component
  63134. */
  63135. get output(): NodeMaterialConnectionPoint;
  63136. protected _buildBlock(state: NodeMaterialBuildState): this;
  63137. }
  63138. }
  63139. declare module BABYLON {
  63140. /**
  63141. * Block used to get the value of the first parameter raised to the power of the second
  63142. */
  63143. export class PowBlock extends NodeMaterialBlock {
  63144. /**
  63145. * Creates a new PowBlock
  63146. * @param name defines the block name
  63147. */
  63148. constructor(name: string);
  63149. /**
  63150. * Gets the current class name
  63151. * @returns the class name
  63152. */
  63153. getClassName(): string;
  63154. /**
  63155. * Gets the value operand input component
  63156. */
  63157. get value(): NodeMaterialConnectionPoint;
  63158. /**
  63159. * Gets the power operand input component
  63160. */
  63161. get power(): NodeMaterialConnectionPoint;
  63162. /**
  63163. * Gets the output component
  63164. */
  63165. get output(): NodeMaterialConnectionPoint;
  63166. protected _buildBlock(state: NodeMaterialBuildState): this;
  63167. }
  63168. }
  63169. declare module BABYLON {
  63170. /**
  63171. * Block used to get a random number
  63172. */
  63173. export class RandomNumberBlock extends NodeMaterialBlock {
  63174. /**
  63175. * Creates a new RandomNumberBlock
  63176. * @param name defines the block name
  63177. */
  63178. constructor(name: string);
  63179. /**
  63180. * Gets the current class name
  63181. * @returns the class name
  63182. */
  63183. getClassName(): string;
  63184. /**
  63185. * Gets the seed input component
  63186. */
  63187. get seed(): NodeMaterialConnectionPoint;
  63188. /**
  63189. * Gets the output component
  63190. */
  63191. get output(): NodeMaterialConnectionPoint;
  63192. protected _buildBlock(state: NodeMaterialBuildState): this;
  63193. }
  63194. }
  63195. declare module BABYLON {
  63196. /**
  63197. * Block used to compute arc tangent of 2 values
  63198. */
  63199. export class ArcTan2Block extends NodeMaterialBlock {
  63200. /**
  63201. * Creates a new ArcTan2Block
  63202. * @param name defines the block name
  63203. */
  63204. constructor(name: string);
  63205. /**
  63206. * Gets the current class name
  63207. * @returns the class name
  63208. */
  63209. getClassName(): string;
  63210. /**
  63211. * Gets the x operand input component
  63212. */
  63213. get x(): NodeMaterialConnectionPoint;
  63214. /**
  63215. * Gets the y operand input component
  63216. */
  63217. get y(): NodeMaterialConnectionPoint;
  63218. /**
  63219. * Gets the output component
  63220. */
  63221. get output(): NodeMaterialConnectionPoint;
  63222. protected _buildBlock(state: NodeMaterialBuildState): this;
  63223. }
  63224. }
  63225. declare module BABYLON {
  63226. /**
  63227. * Block used to smooth step a value
  63228. */
  63229. export class SmoothStepBlock extends NodeMaterialBlock {
  63230. /**
  63231. * Creates a new SmoothStepBlock
  63232. * @param name defines the block name
  63233. */
  63234. constructor(name: string);
  63235. /**
  63236. * Gets the current class name
  63237. * @returns the class name
  63238. */
  63239. getClassName(): string;
  63240. /**
  63241. * Gets the value operand input component
  63242. */
  63243. get value(): NodeMaterialConnectionPoint;
  63244. /**
  63245. * Gets the first edge operand input component
  63246. */
  63247. get edge0(): NodeMaterialConnectionPoint;
  63248. /**
  63249. * Gets the second edge operand input component
  63250. */
  63251. get edge1(): NodeMaterialConnectionPoint;
  63252. /**
  63253. * Gets the output component
  63254. */
  63255. get output(): NodeMaterialConnectionPoint;
  63256. protected _buildBlock(state: NodeMaterialBuildState): this;
  63257. }
  63258. }
  63259. declare module BABYLON {
  63260. /**
  63261. * Block used to get the reciprocal (1 / x) of a value
  63262. */
  63263. export class ReciprocalBlock extends NodeMaterialBlock {
  63264. /**
  63265. * Creates a new ReciprocalBlock
  63266. * @param name defines the block name
  63267. */
  63268. constructor(name: string);
  63269. /**
  63270. * Gets the current class name
  63271. * @returns the class name
  63272. */
  63273. getClassName(): string;
  63274. /**
  63275. * Gets the input component
  63276. */
  63277. get input(): NodeMaterialConnectionPoint;
  63278. /**
  63279. * Gets the output component
  63280. */
  63281. get output(): NodeMaterialConnectionPoint;
  63282. protected _buildBlock(state: NodeMaterialBuildState): this;
  63283. }
  63284. }
  63285. declare module BABYLON {
  63286. /**
  63287. * Block used to replace a color by another one
  63288. */
  63289. export class ReplaceColorBlock extends NodeMaterialBlock {
  63290. /**
  63291. * Creates a new ReplaceColorBlock
  63292. * @param name defines the block name
  63293. */
  63294. constructor(name: string);
  63295. /**
  63296. * Gets the current class name
  63297. * @returns the class name
  63298. */
  63299. getClassName(): string;
  63300. /**
  63301. * Gets the value input component
  63302. */
  63303. get value(): NodeMaterialConnectionPoint;
  63304. /**
  63305. * Gets the reference input component
  63306. */
  63307. get reference(): NodeMaterialConnectionPoint;
  63308. /**
  63309. * Gets the distance input component
  63310. */
  63311. get distance(): NodeMaterialConnectionPoint;
  63312. /**
  63313. * Gets the replacement input component
  63314. */
  63315. get replacement(): NodeMaterialConnectionPoint;
  63316. /**
  63317. * Gets the output component
  63318. */
  63319. get output(): NodeMaterialConnectionPoint;
  63320. protected _buildBlock(state: NodeMaterialBuildState): this;
  63321. }
  63322. }
  63323. declare module BABYLON {
  63324. /**
  63325. * Block used to posterize a value
  63326. * @see https://en.wikipedia.org/wiki/Posterization
  63327. */
  63328. export class PosterizeBlock extends NodeMaterialBlock {
  63329. /**
  63330. * Creates a new PosterizeBlock
  63331. * @param name defines the block name
  63332. */
  63333. constructor(name: string);
  63334. /**
  63335. * Gets the current class name
  63336. * @returns the class name
  63337. */
  63338. getClassName(): string;
  63339. /**
  63340. * Gets the value input component
  63341. */
  63342. get value(): NodeMaterialConnectionPoint;
  63343. /**
  63344. * Gets the steps input component
  63345. */
  63346. get steps(): NodeMaterialConnectionPoint;
  63347. /**
  63348. * Gets the output component
  63349. */
  63350. get output(): NodeMaterialConnectionPoint;
  63351. protected _buildBlock(state: NodeMaterialBuildState): this;
  63352. }
  63353. }
  63354. declare module BABYLON {
  63355. /**
  63356. * Operations supported by the Wave block
  63357. */
  63358. export enum WaveBlockKind {
  63359. /** SawTooth */
  63360. SawTooth = 0,
  63361. /** Square */
  63362. Square = 1,
  63363. /** Triangle */
  63364. Triangle = 2
  63365. }
  63366. /**
  63367. * Block used to apply wave operation to floats
  63368. */
  63369. export class WaveBlock extends NodeMaterialBlock {
  63370. /**
  63371. * Gets or sets the kibnd of wave to be applied by the block
  63372. */
  63373. kind: WaveBlockKind;
  63374. /**
  63375. * Creates a new WaveBlock
  63376. * @param name defines the block name
  63377. */
  63378. constructor(name: string);
  63379. /**
  63380. * Gets the current class name
  63381. * @returns the class name
  63382. */
  63383. getClassName(): string;
  63384. /**
  63385. * Gets the input component
  63386. */
  63387. get input(): NodeMaterialConnectionPoint;
  63388. /**
  63389. * Gets the output component
  63390. */
  63391. get output(): NodeMaterialConnectionPoint;
  63392. protected _buildBlock(state: NodeMaterialBuildState): this;
  63393. serialize(): any;
  63394. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63395. }
  63396. }
  63397. declare module BABYLON {
  63398. /**
  63399. * Class used to store a color step for the GradientBlock
  63400. */
  63401. export class GradientBlockColorStep {
  63402. /**
  63403. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63404. */
  63405. step: number;
  63406. /**
  63407. * Gets or sets the color associated with this step
  63408. */
  63409. color: Color3;
  63410. /**
  63411. * Creates a new GradientBlockColorStep
  63412. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  63413. * @param color defines the color associated with this step
  63414. */
  63415. constructor(
  63416. /**
  63417. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63418. */
  63419. step: number,
  63420. /**
  63421. * Gets or sets the color associated with this step
  63422. */
  63423. color: Color3);
  63424. }
  63425. /**
  63426. * Block used to return a color from a gradient based on an input value between 0 and 1
  63427. */
  63428. export class GradientBlock extends NodeMaterialBlock {
  63429. /**
  63430. * Gets or sets the list of color steps
  63431. */
  63432. colorSteps: GradientBlockColorStep[];
  63433. /**
  63434. * Creates a new GradientBlock
  63435. * @param name defines the block name
  63436. */
  63437. constructor(name: string);
  63438. /**
  63439. * Gets the current class name
  63440. * @returns the class name
  63441. */
  63442. getClassName(): string;
  63443. /**
  63444. * Gets the gradient input component
  63445. */
  63446. get gradient(): NodeMaterialConnectionPoint;
  63447. /**
  63448. * Gets the output component
  63449. */
  63450. get output(): NodeMaterialConnectionPoint;
  63451. private _writeColorConstant;
  63452. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63453. serialize(): any;
  63454. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63455. protected _dumpPropertiesCode(): string;
  63456. }
  63457. }
  63458. declare module BABYLON {
  63459. /**
  63460. * Block used to normalize lerp between 2 values
  63461. */
  63462. export class NLerpBlock extends NodeMaterialBlock {
  63463. /**
  63464. * Creates a new NLerpBlock
  63465. * @param name defines the block name
  63466. */
  63467. constructor(name: string);
  63468. /**
  63469. * Gets the current class name
  63470. * @returns the class name
  63471. */
  63472. getClassName(): string;
  63473. /**
  63474. * Gets the left operand input component
  63475. */
  63476. get left(): NodeMaterialConnectionPoint;
  63477. /**
  63478. * Gets the right operand input component
  63479. */
  63480. get right(): NodeMaterialConnectionPoint;
  63481. /**
  63482. * Gets the gradient operand input component
  63483. */
  63484. get gradient(): NodeMaterialConnectionPoint;
  63485. /**
  63486. * Gets the output component
  63487. */
  63488. get output(): NodeMaterialConnectionPoint;
  63489. protected _buildBlock(state: NodeMaterialBuildState): this;
  63490. }
  63491. }
  63492. declare module BABYLON {
  63493. /**
  63494. * block used to Generate a Worley Noise 3D Noise Pattern
  63495. */
  63496. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  63497. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  63498. manhattanDistance: boolean;
  63499. /**
  63500. * Creates a new WorleyNoise3DBlock
  63501. * @param name defines the block name
  63502. */
  63503. constructor(name: string);
  63504. /**
  63505. * Gets the current class name
  63506. * @returns the class name
  63507. */
  63508. getClassName(): string;
  63509. /**
  63510. * Gets the seed input component
  63511. */
  63512. get seed(): NodeMaterialConnectionPoint;
  63513. /**
  63514. * Gets the jitter input component
  63515. */
  63516. get jitter(): NodeMaterialConnectionPoint;
  63517. /**
  63518. * Gets the output component
  63519. */
  63520. get output(): NodeMaterialConnectionPoint;
  63521. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63522. /**
  63523. * Exposes the properties to the UI?
  63524. */
  63525. protected _dumpPropertiesCode(): string;
  63526. /**
  63527. * Exposes the properties to the Seralize?
  63528. */
  63529. serialize(): any;
  63530. /**
  63531. * Exposes the properties to the deseralize?
  63532. */
  63533. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63534. }
  63535. }
  63536. declare module BABYLON {
  63537. /**
  63538. * block used to Generate a Simplex Perlin 3d Noise Pattern
  63539. */
  63540. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  63541. /**
  63542. * Creates a new SimplexPerlin3DBlock
  63543. * @param name defines the block name
  63544. */
  63545. constructor(name: string);
  63546. /**
  63547. * Gets the current class name
  63548. * @returns the class name
  63549. */
  63550. getClassName(): string;
  63551. /**
  63552. * Gets the seed operand input component
  63553. */
  63554. get seed(): NodeMaterialConnectionPoint;
  63555. /**
  63556. * Gets the output component
  63557. */
  63558. get output(): NodeMaterialConnectionPoint;
  63559. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63560. }
  63561. }
  63562. declare module BABYLON {
  63563. /**
  63564. * Block used to blend normals
  63565. */
  63566. export class NormalBlendBlock extends NodeMaterialBlock {
  63567. /**
  63568. * Creates a new NormalBlendBlock
  63569. * @param name defines the block name
  63570. */
  63571. constructor(name: string);
  63572. /**
  63573. * Gets the current class name
  63574. * @returns the class name
  63575. */
  63576. getClassName(): string;
  63577. /**
  63578. * Gets the first input component
  63579. */
  63580. get normalMap0(): NodeMaterialConnectionPoint;
  63581. /**
  63582. * Gets the second input component
  63583. */
  63584. get normalMap1(): NodeMaterialConnectionPoint;
  63585. /**
  63586. * Gets the output component
  63587. */
  63588. get output(): NodeMaterialConnectionPoint;
  63589. protected _buildBlock(state: NodeMaterialBuildState): this;
  63590. }
  63591. }
  63592. declare module BABYLON {
  63593. /**
  63594. * Block used to rotate a 2d vector by a given angle
  63595. */
  63596. export class Rotate2dBlock extends NodeMaterialBlock {
  63597. /**
  63598. * Creates a new Rotate2dBlock
  63599. * @param name defines the block name
  63600. */
  63601. constructor(name: string);
  63602. /**
  63603. * Gets the current class name
  63604. * @returns the class name
  63605. */
  63606. getClassName(): string;
  63607. /**
  63608. * Gets the input vector
  63609. */
  63610. get input(): NodeMaterialConnectionPoint;
  63611. /**
  63612. * Gets the input angle
  63613. */
  63614. get angle(): NodeMaterialConnectionPoint;
  63615. /**
  63616. * Gets the output component
  63617. */
  63618. get output(): NodeMaterialConnectionPoint;
  63619. autoConfigure(material: NodeMaterial): void;
  63620. protected _buildBlock(state: NodeMaterialBuildState): this;
  63621. }
  63622. }
  63623. declare module BABYLON {
  63624. /**
  63625. * Block used to get the reflected vector from a direction and a normal
  63626. */
  63627. export class ReflectBlock extends NodeMaterialBlock {
  63628. /**
  63629. * Creates a new ReflectBlock
  63630. * @param name defines the block name
  63631. */
  63632. constructor(name: string);
  63633. /**
  63634. * Gets the current class name
  63635. * @returns the class name
  63636. */
  63637. getClassName(): string;
  63638. /**
  63639. * Gets the incident component
  63640. */
  63641. get incident(): NodeMaterialConnectionPoint;
  63642. /**
  63643. * Gets the normal component
  63644. */
  63645. get normal(): NodeMaterialConnectionPoint;
  63646. /**
  63647. * Gets the output component
  63648. */
  63649. get output(): NodeMaterialConnectionPoint;
  63650. protected _buildBlock(state: NodeMaterialBuildState): this;
  63651. }
  63652. }
  63653. declare module BABYLON {
  63654. /**
  63655. * Block used to get the refracted vector from a direction and a normal
  63656. */
  63657. export class RefractBlock extends NodeMaterialBlock {
  63658. /**
  63659. * Creates a new RefractBlock
  63660. * @param name defines the block name
  63661. */
  63662. constructor(name: string);
  63663. /**
  63664. * Gets the current class name
  63665. * @returns the class name
  63666. */
  63667. getClassName(): string;
  63668. /**
  63669. * Gets the incident component
  63670. */
  63671. get incident(): NodeMaterialConnectionPoint;
  63672. /**
  63673. * Gets the normal component
  63674. */
  63675. get normal(): NodeMaterialConnectionPoint;
  63676. /**
  63677. * Gets the index of refraction component
  63678. */
  63679. get ior(): NodeMaterialConnectionPoint;
  63680. /**
  63681. * Gets the output component
  63682. */
  63683. get output(): NodeMaterialConnectionPoint;
  63684. protected _buildBlock(state: NodeMaterialBuildState): this;
  63685. }
  63686. }
  63687. declare module BABYLON {
  63688. /**
  63689. * Block used to desaturate a color
  63690. */
  63691. export class DesaturateBlock extends NodeMaterialBlock {
  63692. /**
  63693. * Creates a new DesaturateBlock
  63694. * @param name defines the block name
  63695. */
  63696. constructor(name: string);
  63697. /**
  63698. * Gets the current class name
  63699. * @returns the class name
  63700. */
  63701. getClassName(): string;
  63702. /**
  63703. * Gets the color operand input component
  63704. */
  63705. get color(): NodeMaterialConnectionPoint;
  63706. /**
  63707. * Gets the level operand input component
  63708. */
  63709. get level(): NodeMaterialConnectionPoint;
  63710. /**
  63711. * Gets the output component
  63712. */
  63713. get output(): NodeMaterialConnectionPoint;
  63714. protected _buildBlock(state: NodeMaterialBuildState): this;
  63715. }
  63716. }
  63717. declare module BABYLON {
  63718. /**
  63719. * Block used to implement the ambient occlusion module of the PBR material
  63720. */
  63721. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  63722. /**
  63723. * Create a new AmbientOcclusionBlock
  63724. * @param name defines the block name
  63725. */
  63726. constructor(name: string);
  63727. /**
  63728. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  63729. */
  63730. useAmbientInGrayScale: boolean;
  63731. /**
  63732. * Initialize the block and prepare the context for build
  63733. * @param state defines the state that will be used for the build
  63734. */
  63735. initialize(state: NodeMaterialBuildState): void;
  63736. /**
  63737. * Gets the current class name
  63738. * @returns the class name
  63739. */
  63740. getClassName(): string;
  63741. /**
  63742. * Gets the texture input component
  63743. */
  63744. get texture(): NodeMaterialConnectionPoint;
  63745. /**
  63746. * Gets the texture intensity component
  63747. */
  63748. get intensity(): NodeMaterialConnectionPoint;
  63749. /**
  63750. * Gets the direct light intensity input component
  63751. */
  63752. get directLightIntensity(): NodeMaterialConnectionPoint;
  63753. /**
  63754. * Gets the ambient occlusion object output component
  63755. */
  63756. get ambientOcclusion(): NodeMaterialConnectionPoint;
  63757. /**
  63758. * Gets the main code of the block (fragment side)
  63759. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  63760. * @returns the shader code
  63761. */
  63762. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  63763. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63764. protected _buildBlock(state: NodeMaterialBuildState): this;
  63765. protected _dumpPropertiesCode(): string;
  63766. serialize(): any;
  63767. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63768. }
  63769. }
  63770. declare module BABYLON {
  63771. /**
  63772. * Block used to implement the reflection module of the PBR material
  63773. */
  63774. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  63775. /** @hidden */
  63776. _defineLODReflectionAlpha: string;
  63777. /** @hidden */
  63778. _defineLinearSpecularReflection: string;
  63779. private _vEnvironmentIrradianceName;
  63780. /** @hidden */
  63781. _vReflectionMicrosurfaceInfosName: string;
  63782. /** @hidden */
  63783. _vReflectionInfosName: string;
  63784. /** @hidden */
  63785. _vReflectionFilteringInfoName: string;
  63786. private _scene;
  63787. /**
  63788. * The three properties below are set by the main PBR block prior to calling methods of this class.
  63789. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  63790. * It's less burden on the user side in the editor part.
  63791. */
  63792. /** @hidden */
  63793. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  63794. /** @hidden */
  63795. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  63796. /** @hidden */
  63797. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  63798. /**
  63799. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  63800. * diffuse part of the IBL.
  63801. */
  63802. useSphericalHarmonics: boolean;
  63803. /**
  63804. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  63805. */
  63806. forceIrradianceInFragment: boolean;
  63807. /**
  63808. * Create a new ReflectionBlock
  63809. * @param name defines the block name
  63810. */
  63811. constructor(name: string);
  63812. /**
  63813. * Gets the current class name
  63814. * @returns the class name
  63815. */
  63816. getClassName(): string;
  63817. /**
  63818. * Gets the position input component
  63819. */
  63820. get position(): NodeMaterialConnectionPoint;
  63821. /**
  63822. * Gets the world position input component
  63823. */
  63824. get worldPosition(): NodeMaterialConnectionPoint;
  63825. /**
  63826. * Gets the world normal input component
  63827. */
  63828. get worldNormal(): NodeMaterialConnectionPoint;
  63829. /**
  63830. * Gets the world input component
  63831. */
  63832. get world(): NodeMaterialConnectionPoint;
  63833. /**
  63834. * Gets the camera (or eye) position component
  63835. */
  63836. get cameraPosition(): NodeMaterialConnectionPoint;
  63837. /**
  63838. * Gets the view input component
  63839. */
  63840. get view(): NodeMaterialConnectionPoint;
  63841. /**
  63842. * Gets the color input component
  63843. */
  63844. get color(): NodeMaterialConnectionPoint;
  63845. /**
  63846. * Gets the reflection object output component
  63847. */
  63848. get reflection(): NodeMaterialConnectionPoint;
  63849. /**
  63850. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  63851. */
  63852. get hasTexture(): boolean;
  63853. /**
  63854. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  63855. */
  63856. get reflectionColor(): string;
  63857. protected _getTexture(): Nullable<BaseTexture>;
  63858. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63859. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  63860. /**
  63861. * Gets the code to inject in the vertex shader
  63862. * @param state current state of the node material building
  63863. * @returns the shader code
  63864. */
  63865. handleVertexSide(state: NodeMaterialBuildState): string;
  63866. /**
  63867. * Gets the main code of the block (fragment side)
  63868. * @param state current state of the node material building
  63869. * @param normalVarName name of the existing variable corresponding to the normal
  63870. * @returns the shader code
  63871. */
  63872. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  63873. protected _buildBlock(state: NodeMaterialBuildState): this;
  63874. protected _dumpPropertiesCode(): string;
  63875. serialize(): any;
  63876. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63877. }
  63878. }
  63879. declare module BABYLON {
  63880. /**
  63881. * Block used to implement the sheen module of the PBR material
  63882. */
  63883. export class SheenBlock extends NodeMaterialBlock {
  63884. /**
  63885. * Create a new SheenBlock
  63886. * @param name defines the block name
  63887. */
  63888. constructor(name: string);
  63889. /**
  63890. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  63891. * It allows the strength of the sheen effect to not depend on the base color of the material,
  63892. * making it easier to setup and tweak the effect
  63893. */
  63894. albedoScaling: boolean;
  63895. /**
  63896. * Defines if the sheen is linked to the sheen color.
  63897. */
  63898. linkSheenWithAlbedo: boolean;
  63899. /**
  63900. * Initialize the block and prepare the context for build
  63901. * @param state defines the state that will be used for the build
  63902. */
  63903. initialize(state: NodeMaterialBuildState): void;
  63904. /**
  63905. * Gets the current class name
  63906. * @returns the class name
  63907. */
  63908. getClassName(): string;
  63909. /**
  63910. * Gets the intensity input component
  63911. */
  63912. get intensity(): NodeMaterialConnectionPoint;
  63913. /**
  63914. * Gets the color input component
  63915. */
  63916. get color(): NodeMaterialConnectionPoint;
  63917. /**
  63918. * Gets the roughness input component
  63919. */
  63920. get roughness(): NodeMaterialConnectionPoint;
  63921. /**
  63922. * Gets the sheen object output component
  63923. */
  63924. get sheen(): NodeMaterialConnectionPoint;
  63925. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63926. /**
  63927. * Gets the main code of the block (fragment side)
  63928. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  63929. * @returns the shader code
  63930. */
  63931. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  63932. protected _buildBlock(state: NodeMaterialBuildState): this;
  63933. protected _dumpPropertiesCode(): string;
  63934. serialize(): any;
  63935. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63936. }
  63937. }
  63938. declare module BABYLON {
  63939. /**
  63940. * Block used to implement the reflectivity module of the PBR material
  63941. */
  63942. export class ReflectivityBlock extends NodeMaterialBlock {
  63943. private _metallicReflectanceColor;
  63944. private _metallicF0Factor;
  63945. /** @hidden */
  63946. _vMetallicReflectanceFactorsName: string;
  63947. /**
  63948. * The property below is set by the main PBR block prior to calling methods of this class.
  63949. */
  63950. /** @hidden */
  63951. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  63952. /**
  63953. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  63954. */
  63955. useAmbientOcclusionFromMetallicTextureRed: boolean;
  63956. /**
  63957. * Specifies if the metallic texture contains the metallness information in its blue channel.
  63958. */
  63959. useMetallnessFromMetallicTextureBlue: boolean;
  63960. /**
  63961. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  63962. */
  63963. useRoughnessFromMetallicTextureAlpha: boolean;
  63964. /**
  63965. * Specifies if the metallic texture contains the roughness information in its green channel.
  63966. */
  63967. useRoughnessFromMetallicTextureGreen: boolean;
  63968. /**
  63969. * Create a new ReflectivityBlock
  63970. * @param name defines the block name
  63971. */
  63972. constructor(name: string);
  63973. /**
  63974. * Initialize the block and prepare the context for build
  63975. * @param state defines the state that will be used for the build
  63976. */
  63977. initialize(state: NodeMaterialBuildState): void;
  63978. /**
  63979. * Gets the current class name
  63980. * @returns the class name
  63981. */
  63982. getClassName(): string;
  63983. /**
  63984. * Gets the metallic input component
  63985. */
  63986. get metallic(): NodeMaterialConnectionPoint;
  63987. /**
  63988. * Gets the roughness input component
  63989. */
  63990. get roughness(): NodeMaterialConnectionPoint;
  63991. /**
  63992. * Gets the texture input component
  63993. */
  63994. get texture(): NodeMaterialConnectionPoint;
  63995. /**
  63996. * Gets the reflectivity object output component
  63997. */
  63998. get reflectivity(): NodeMaterialConnectionPoint;
  63999. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64000. /**
  64001. * Gets the main code of the block (fragment side)
  64002. * @param state current state of the node material building
  64003. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  64004. * @returns the shader code
  64005. */
  64006. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  64007. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64008. protected _buildBlock(state: NodeMaterialBuildState): this;
  64009. protected _dumpPropertiesCode(): string;
  64010. serialize(): any;
  64011. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64012. }
  64013. }
  64014. declare module BABYLON {
  64015. /**
  64016. * Block used to implement the anisotropy module of the PBR material
  64017. */
  64018. export class AnisotropyBlock extends NodeMaterialBlock {
  64019. /**
  64020. * The two properties below are set by the main PBR block prior to calling methods of this class.
  64021. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64022. * It's less burden on the user side in the editor part.
  64023. */
  64024. /** @hidden */
  64025. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64026. /** @hidden */
  64027. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64028. /**
  64029. * Create a new AnisotropyBlock
  64030. * @param name defines the block name
  64031. */
  64032. constructor(name: string);
  64033. /**
  64034. * Initialize the block and prepare the context for build
  64035. * @param state defines the state that will be used for the build
  64036. */
  64037. initialize(state: NodeMaterialBuildState): void;
  64038. /**
  64039. * Gets the current class name
  64040. * @returns the class name
  64041. */
  64042. getClassName(): string;
  64043. /**
  64044. * Gets the intensity input component
  64045. */
  64046. get intensity(): NodeMaterialConnectionPoint;
  64047. /**
  64048. * Gets the direction input component
  64049. */
  64050. get direction(): NodeMaterialConnectionPoint;
  64051. /**
  64052. * Gets the texture input component
  64053. */
  64054. get texture(): NodeMaterialConnectionPoint;
  64055. /**
  64056. * Gets the uv input component
  64057. */
  64058. get uv(): NodeMaterialConnectionPoint;
  64059. /**
  64060. * Gets the worldTangent input component
  64061. */
  64062. get worldTangent(): NodeMaterialConnectionPoint;
  64063. /**
  64064. * Gets the anisotropy object output component
  64065. */
  64066. get anisotropy(): NodeMaterialConnectionPoint;
  64067. private _generateTBNSpace;
  64068. /**
  64069. * Gets the main code of the block (fragment side)
  64070. * @param state current state of the node material building
  64071. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64072. * @returns the shader code
  64073. */
  64074. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  64075. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64076. protected _buildBlock(state: NodeMaterialBuildState): this;
  64077. }
  64078. }
  64079. declare module BABYLON {
  64080. /**
  64081. * Block used to implement the clear coat module of the PBR material
  64082. */
  64083. export class ClearCoatBlock extends NodeMaterialBlock {
  64084. private _scene;
  64085. /**
  64086. * Create a new ClearCoatBlock
  64087. * @param name defines the block name
  64088. */
  64089. constructor(name: string);
  64090. /**
  64091. * Initialize the block and prepare the context for build
  64092. * @param state defines the state that will be used for the build
  64093. */
  64094. initialize(state: NodeMaterialBuildState): void;
  64095. /**
  64096. * Gets the current class name
  64097. * @returns the class name
  64098. */
  64099. getClassName(): string;
  64100. /**
  64101. * Gets the intensity input component
  64102. */
  64103. get intensity(): NodeMaterialConnectionPoint;
  64104. /**
  64105. * Gets the roughness input component
  64106. */
  64107. get roughness(): NodeMaterialConnectionPoint;
  64108. /**
  64109. * Gets the ior input component
  64110. */
  64111. get ior(): NodeMaterialConnectionPoint;
  64112. /**
  64113. * Gets the texture input component
  64114. */
  64115. get texture(): NodeMaterialConnectionPoint;
  64116. /**
  64117. * Gets the bump texture input component
  64118. */
  64119. get bumpTexture(): NodeMaterialConnectionPoint;
  64120. /**
  64121. * Gets the uv input component
  64122. */
  64123. get uv(): NodeMaterialConnectionPoint;
  64124. /**
  64125. * Gets the tint color input component
  64126. */
  64127. get tintColor(): NodeMaterialConnectionPoint;
  64128. /**
  64129. * Gets the tint "at distance" input component
  64130. */
  64131. get tintAtDistance(): NodeMaterialConnectionPoint;
  64132. /**
  64133. * Gets the tint thickness input component
  64134. */
  64135. get tintThickness(): NodeMaterialConnectionPoint;
  64136. /**
  64137. * Gets the world tangent input component
  64138. */
  64139. get worldTangent(): NodeMaterialConnectionPoint;
  64140. /**
  64141. * Gets the clear coat object output component
  64142. */
  64143. get clearcoat(): NodeMaterialConnectionPoint;
  64144. autoConfigure(material: NodeMaterial): void;
  64145. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64146. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64147. private _generateTBNSpace;
  64148. /**
  64149. * Gets the main code of the block (fragment side)
  64150. * @param state current state of the node material building
  64151. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  64152. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64153. * @param worldPosVarName name of the variable holding the world position
  64154. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64155. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  64156. * @param worldNormalVarName name of the variable holding the world normal
  64157. * @returns the shader code
  64158. */
  64159. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  64160. protected _buildBlock(state: NodeMaterialBuildState): this;
  64161. }
  64162. }
  64163. declare module BABYLON {
  64164. /**
  64165. * Block used to implement the sub surface module of the PBR material
  64166. */
  64167. export class SubSurfaceBlock extends NodeMaterialBlock {
  64168. /**
  64169. * Create a new SubSurfaceBlock
  64170. * @param name defines the block name
  64171. */
  64172. constructor(name: string);
  64173. /**
  64174. * Stores the intensity of the different subsurface effects in the thickness texture.
  64175. * * the green channel is the translucency intensity.
  64176. * * the blue channel is the scattering intensity.
  64177. * * the alpha channel is the refraction intensity.
  64178. */
  64179. useMaskFromThicknessTexture: boolean;
  64180. /**
  64181. * Initialize the block and prepare the context for build
  64182. * @param state defines the state that will be used for the build
  64183. */
  64184. initialize(state: NodeMaterialBuildState): void;
  64185. /**
  64186. * Gets the current class name
  64187. * @returns the class name
  64188. */
  64189. getClassName(): string;
  64190. /**
  64191. * Gets the min thickness input component
  64192. */
  64193. get minThickness(): NodeMaterialConnectionPoint;
  64194. /**
  64195. * Gets the max thickness input component
  64196. */
  64197. get maxThickness(): NodeMaterialConnectionPoint;
  64198. /**
  64199. * Gets the thickness texture component
  64200. */
  64201. get thicknessTexture(): NodeMaterialConnectionPoint;
  64202. /**
  64203. * Gets the tint color input component
  64204. */
  64205. get tintColor(): NodeMaterialConnectionPoint;
  64206. /**
  64207. * Gets the translucency intensity input component
  64208. */
  64209. get translucencyIntensity(): NodeMaterialConnectionPoint;
  64210. /**
  64211. * Gets the translucency diffusion distance input component
  64212. */
  64213. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  64214. /**
  64215. * Gets the refraction object parameters
  64216. */
  64217. get refraction(): NodeMaterialConnectionPoint;
  64218. /**
  64219. * Gets the sub surface object output component
  64220. */
  64221. get subsurface(): NodeMaterialConnectionPoint;
  64222. autoConfigure(material: NodeMaterial): void;
  64223. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64224. /**
  64225. * Gets the main code of the block (fragment side)
  64226. * @param state current state of the node material building
  64227. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  64228. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64229. * @param worldPosVarName name of the variable holding the world position
  64230. * @returns the shader code
  64231. */
  64232. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  64233. protected _buildBlock(state: NodeMaterialBuildState): this;
  64234. }
  64235. }
  64236. declare module BABYLON {
  64237. /**
  64238. * Block used to implement the PBR metallic/roughness model
  64239. */
  64240. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  64241. /**
  64242. * Gets or sets the light associated with this block
  64243. */
  64244. light: Nullable<Light>;
  64245. private _lightId;
  64246. private _scene;
  64247. private _environmentBRDFTexture;
  64248. private _environmentBrdfSamplerName;
  64249. private _vNormalWName;
  64250. private _invertNormalName;
  64251. /**
  64252. * Create a new ReflectionBlock
  64253. * @param name defines the block name
  64254. */
  64255. constructor(name: string);
  64256. /**
  64257. * Intensity of the direct lights e.g. the four lights available in your scene.
  64258. * This impacts both the direct diffuse and specular highlights.
  64259. */
  64260. directIntensity: number;
  64261. /**
  64262. * Intensity of the environment e.g. how much the environment will light the object
  64263. * either through harmonics for rough material or through the refelction for shiny ones.
  64264. */
  64265. environmentIntensity: number;
  64266. /**
  64267. * This is a special control allowing the reduction of the specular highlights coming from the
  64268. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  64269. */
  64270. specularIntensity: number;
  64271. /**
  64272. * Defines the falloff type used in this material.
  64273. * It by default is Physical.
  64274. */
  64275. lightFalloff: number;
  64276. /**
  64277. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  64278. */
  64279. useAlphaFromAlbedoTexture: boolean;
  64280. /**
  64281. * Specifies that alpha test should be used
  64282. */
  64283. useAlphaTest: boolean;
  64284. /**
  64285. * Defines the alpha limits in alpha test mode.
  64286. */
  64287. alphaTestCutoff: number;
  64288. /**
  64289. * Specifies that alpha blending should be used
  64290. */
  64291. useAlphaBlending: boolean;
  64292. /**
  64293. * Defines if the alpha value should be determined via the rgb values.
  64294. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  64295. */
  64296. opacityRGB: boolean;
  64297. /**
  64298. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  64299. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  64300. */
  64301. useRadianceOverAlpha: boolean;
  64302. /**
  64303. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  64304. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  64305. */
  64306. useSpecularOverAlpha: boolean;
  64307. /**
  64308. * Enables specular anti aliasing in the PBR shader.
  64309. * It will both interacts on the Geometry for analytical and IBL lighting.
  64310. * It also prefilter the roughness map based on the bump values.
  64311. */
  64312. enableSpecularAntiAliasing: boolean;
  64313. /**
  64314. * Enables realtime filtering on the texture.
  64315. */
  64316. realTimeFiltering: boolean;
  64317. /**
  64318. * Quality switch for realtime filtering
  64319. */
  64320. realTimeFilteringQuality: number;
  64321. /**
  64322. * Defines if the material uses energy conservation.
  64323. */
  64324. useEnergyConservation: boolean;
  64325. /**
  64326. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  64327. * too much the area relying on ambient texture to define their ambient occlusion.
  64328. */
  64329. useRadianceOcclusion: boolean;
  64330. /**
  64331. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  64332. * makes the reflect vector face the model (under horizon).
  64333. */
  64334. useHorizonOcclusion: boolean;
  64335. /**
  64336. * If set to true, no lighting calculations will be applied.
  64337. */
  64338. unlit: boolean;
  64339. /**
  64340. * Force normal to face away from face.
  64341. */
  64342. forceNormalForward: boolean;
  64343. /**
  64344. * Defines the material debug mode.
  64345. * It helps seeing only some components of the material while troubleshooting.
  64346. */
  64347. debugMode: number;
  64348. /**
  64349. * Specify from where on screen the debug mode should start.
  64350. * The value goes from -1 (full screen) to 1 (not visible)
  64351. * It helps with side by side comparison against the final render
  64352. * This defaults to 0
  64353. */
  64354. debugLimit: number;
  64355. /**
  64356. * As the default viewing range might not be enough (if the ambient is really small for instance)
  64357. * You can use the factor to better multiply the final value.
  64358. */
  64359. debugFactor: number;
  64360. /**
  64361. * Initialize the block and prepare the context for build
  64362. * @param state defines the state that will be used for the build
  64363. */
  64364. initialize(state: NodeMaterialBuildState): void;
  64365. /**
  64366. * Gets the current class name
  64367. * @returns the class name
  64368. */
  64369. getClassName(): string;
  64370. /**
  64371. * Gets the world position input component
  64372. */
  64373. get worldPosition(): NodeMaterialConnectionPoint;
  64374. /**
  64375. * Gets the world normal input component
  64376. */
  64377. get worldNormal(): NodeMaterialConnectionPoint;
  64378. /**
  64379. * Gets the perturbed normal input component
  64380. */
  64381. get perturbedNormal(): NodeMaterialConnectionPoint;
  64382. /**
  64383. * Gets the camera position input component
  64384. */
  64385. get cameraPosition(): NodeMaterialConnectionPoint;
  64386. /**
  64387. * Gets the base color input component
  64388. */
  64389. get baseColor(): NodeMaterialConnectionPoint;
  64390. /**
  64391. * Gets the opacity texture input component
  64392. */
  64393. get opacityTexture(): NodeMaterialConnectionPoint;
  64394. /**
  64395. * Gets the ambient color input component
  64396. */
  64397. get ambientColor(): NodeMaterialConnectionPoint;
  64398. /**
  64399. * Gets the reflectivity object parameters
  64400. */
  64401. get reflectivity(): NodeMaterialConnectionPoint;
  64402. /**
  64403. * Gets the ambient occlusion object parameters
  64404. */
  64405. get ambientOcclusion(): NodeMaterialConnectionPoint;
  64406. /**
  64407. * Gets the reflection object parameters
  64408. */
  64409. get reflection(): NodeMaterialConnectionPoint;
  64410. /**
  64411. * Gets the sheen object parameters
  64412. */
  64413. get sheen(): NodeMaterialConnectionPoint;
  64414. /**
  64415. * Gets the clear coat object parameters
  64416. */
  64417. get clearcoat(): NodeMaterialConnectionPoint;
  64418. /**
  64419. * Gets the sub surface object parameters
  64420. */
  64421. get subsurface(): NodeMaterialConnectionPoint;
  64422. /**
  64423. * Gets the anisotropy object parameters
  64424. */
  64425. get anisotropy(): NodeMaterialConnectionPoint;
  64426. /**
  64427. * Gets the ambient output component
  64428. */
  64429. get ambient(): NodeMaterialConnectionPoint;
  64430. /**
  64431. * Gets the diffuse output component
  64432. */
  64433. get diffuse(): NodeMaterialConnectionPoint;
  64434. /**
  64435. * Gets the specular output component
  64436. */
  64437. get specular(): NodeMaterialConnectionPoint;
  64438. /**
  64439. * Gets the sheen output component
  64440. */
  64441. get sheenDir(): NodeMaterialConnectionPoint;
  64442. /**
  64443. * Gets the clear coat output component
  64444. */
  64445. get clearcoatDir(): NodeMaterialConnectionPoint;
  64446. /**
  64447. * Gets the indirect diffuse output component
  64448. */
  64449. get diffuseIndirect(): NodeMaterialConnectionPoint;
  64450. /**
  64451. * Gets the indirect specular output component
  64452. */
  64453. get specularIndirect(): NodeMaterialConnectionPoint;
  64454. /**
  64455. * Gets the indirect sheen output component
  64456. */
  64457. get sheenIndirect(): NodeMaterialConnectionPoint;
  64458. /**
  64459. * Gets the indirect clear coat output component
  64460. */
  64461. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  64462. /**
  64463. * Gets the refraction output component
  64464. */
  64465. get refraction(): NodeMaterialConnectionPoint;
  64466. /**
  64467. * Gets the global lighting output component
  64468. */
  64469. get lighting(): NodeMaterialConnectionPoint;
  64470. /**
  64471. * Gets the shadow output component
  64472. */
  64473. get shadow(): NodeMaterialConnectionPoint;
  64474. /**
  64475. * Gets the alpha output component
  64476. */
  64477. get alpha(): NodeMaterialConnectionPoint;
  64478. autoConfigure(material: NodeMaterial): void;
  64479. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64480. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  64481. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64482. private _injectVertexCode;
  64483. /**
  64484. * Gets the code corresponding to the albedo/opacity module
  64485. * @returns the shader code
  64486. */
  64487. getAlbedoOpacityCode(): string;
  64488. protected _buildBlock(state: NodeMaterialBuildState): this;
  64489. protected _dumpPropertiesCode(): string;
  64490. serialize(): any;
  64491. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64492. }
  64493. }
  64494. declare module BABYLON {
  64495. /**
  64496. * Block used to compute value of one parameter modulo another
  64497. */
  64498. export class ModBlock extends NodeMaterialBlock {
  64499. /**
  64500. * Creates a new ModBlock
  64501. * @param name defines the block name
  64502. */
  64503. constructor(name: string);
  64504. /**
  64505. * Gets the current class name
  64506. * @returns the class name
  64507. */
  64508. getClassName(): string;
  64509. /**
  64510. * Gets the left operand input component
  64511. */
  64512. get left(): NodeMaterialConnectionPoint;
  64513. /**
  64514. * Gets the right operand input component
  64515. */
  64516. get right(): NodeMaterialConnectionPoint;
  64517. /**
  64518. * Gets the output component
  64519. */
  64520. get output(): NodeMaterialConnectionPoint;
  64521. protected _buildBlock(state: NodeMaterialBuildState): this;
  64522. }
  64523. }
  64524. declare module BABYLON {
  64525. /**
  64526. * Helper class to push actions to a pool of workers.
  64527. */
  64528. export class WorkerPool implements IDisposable {
  64529. private _workerInfos;
  64530. private _pendingActions;
  64531. /**
  64532. * Constructor
  64533. * @param workers Array of workers to use for actions
  64534. */
  64535. constructor(workers: Array<Worker>);
  64536. /**
  64537. * Terminates all workers and clears any pending actions.
  64538. */
  64539. dispose(): void;
  64540. /**
  64541. * Pushes an action to the worker pool. If all the workers are active, the action will be
  64542. * pended until a worker has completed its action.
  64543. * @param action The action to perform. Call onComplete when the action is complete.
  64544. */
  64545. push(action: (worker: Worker, onComplete: () => void) => void): void;
  64546. private _execute;
  64547. }
  64548. }
  64549. declare module BABYLON {
  64550. /**
  64551. * Configuration for Draco compression
  64552. */
  64553. export interface IDracoCompressionConfiguration {
  64554. /**
  64555. * Configuration for the decoder.
  64556. */
  64557. decoder: {
  64558. /**
  64559. * The url to the WebAssembly module.
  64560. */
  64561. wasmUrl?: string;
  64562. /**
  64563. * The url to the WebAssembly binary.
  64564. */
  64565. wasmBinaryUrl?: string;
  64566. /**
  64567. * The url to the fallback JavaScript module.
  64568. */
  64569. fallbackUrl?: string;
  64570. };
  64571. }
  64572. /**
  64573. * Draco compression (https://google.github.io/draco/)
  64574. *
  64575. * This class wraps the Draco module.
  64576. *
  64577. * **Encoder**
  64578. *
  64579. * The encoder is not currently implemented.
  64580. *
  64581. * **Decoder**
  64582. *
  64583. * 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.
  64584. *
  64585. * To update the configuration, use the following code:
  64586. * ```javascript
  64587. * DracoCompression.Configuration = {
  64588. * decoder: {
  64589. * wasmUrl: "<url to the WebAssembly library>",
  64590. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  64591. * fallbackUrl: "<url to the fallback JavaScript library>",
  64592. * }
  64593. * };
  64594. * ```
  64595. *
  64596. * 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.
  64597. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  64598. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  64599. *
  64600. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  64601. * ```javascript
  64602. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  64603. * ```
  64604. *
  64605. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  64606. */
  64607. export class DracoCompression implements IDisposable {
  64608. private _workerPoolPromise?;
  64609. private _decoderModulePromise?;
  64610. /**
  64611. * The configuration. Defaults to the following urls:
  64612. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  64613. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  64614. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  64615. */
  64616. static Configuration: IDracoCompressionConfiguration;
  64617. /**
  64618. * Returns true if the decoder configuration is available.
  64619. */
  64620. static get DecoderAvailable(): boolean;
  64621. /**
  64622. * Default number of workers to create when creating the draco compression object.
  64623. */
  64624. static DefaultNumWorkers: number;
  64625. private static GetDefaultNumWorkers;
  64626. private static _Default;
  64627. /**
  64628. * Default instance for the draco compression object.
  64629. */
  64630. static get Default(): DracoCompression;
  64631. /**
  64632. * Constructor
  64633. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  64634. */
  64635. constructor(numWorkers?: number);
  64636. /**
  64637. * Stop all async operations and release resources.
  64638. */
  64639. dispose(): void;
  64640. /**
  64641. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  64642. * @returns a promise that resolves when ready
  64643. */
  64644. whenReadyAsync(): Promise<void>;
  64645. /**
  64646. * Decode Draco compressed mesh data to vertex data.
  64647. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  64648. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  64649. * @returns A promise that resolves with the decoded vertex data
  64650. */
  64651. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  64652. [kind: string]: number;
  64653. }): Promise<VertexData>;
  64654. }
  64655. }
  64656. declare module BABYLON {
  64657. /**
  64658. * Class for building Constructive Solid Geometry
  64659. */
  64660. export class CSG {
  64661. private polygons;
  64662. /**
  64663. * The world matrix
  64664. */
  64665. matrix: Matrix;
  64666. /**
  64667. * Stores the position
  64668. */
  64669. position: Vector3;
  64670. /**
  64671. * Stores the rotation
  64672. */
  64673. rotation: Vector3;
  64674. /**
  64675. * Stores the rotation quaternion
  64676. */
  64677. rotationQuaternion: Nullable<Quaternion>;
  64678. /**
  64679. * Stores the scaling vector
  64680. */
  64681. scaling: Vector3;
  64682. /**
  64683. * Convert the Mesh to CSG
  64684. * @param mesh The Mesh to convert to CSG
  64685. * @returns A new CSG from the Mesh
  64686. */
  64687. static FromMesh(mesh: Mesh): CSG;
  64688. /**
  64689. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  64690. * @param polygons Polygons used to construct a CSG solid
  64691. */
  64692. private static FromPolygons;
  64693. /**
  64694. * Clones, or makes a deep copy, of the CSG
  64695. * @returns A new CSG
  64696. */
  64697. clone(): CSG;
  64698. /**
  64699. * Unions this CSG with another CSG
  64700. * @param csg The CSG to union against this CSG
  64701. * @returns The unioned CSG
  64702. */
  64703. union(csg: CSG): CSG;
  64704. /**
  64705. * Unions this CSG with another CSG in place
  64706. * @param csg The CSG to union against this CSG
  64707. */
  64708. unionInPlace(csg: CSG): void;
  64709. /**
  64710. * Subtracts this CSG with another CSG
  64711. * @param csg The CSG to subtract against this CSG
  64712. * @returns A new CSG
  64713. */
  64714. subtract(csg: CSG): CSG;
  64715. /**
  64716. * Subtracts this CSG with another CSG in place
  64717. * @param csg The CSG to subtact against this CSG
  64718. */
  64719. subtractInPlace(csg: CSG): void;
  64720. /**
  64721. * Intersect this CSG with another CSG
  64722. * @param csg The CSG to intersect against this CSG
  64723. * @returns A new CSG
  64724. */
  64725. intersect(csg: CSG): CSG;
  64726. /**
  64727. * Intersects this CSG with another CSG in place
  64728. * @param csg The CSG to intersect against this CSG
  64729. */
  64730. intersectInPlace(csg: CSG): void;
  64731. /**
  64732. * Return a new CSG solid with solid and empty space switched. This solid is
  64733. * not modified.
  64734. * @returns A new CSG solid with solid and empty space switched
  64735. */
  64736. inverse(): CSG;
  64737. /**
  64738. * Inverses the CSG in place
  64739. */
  64740. inverseInPlace(): void;
  64741. /**
  64742. * This is used to keep meshes transformations so they can be restored
  64743. * when we build back a Babylon Mesh
  64744. * NB : All CSG operations are performed in world coordinates
  64745. * @param csg The CSG to copy the transform attributes from
  64746. * @returns This CSG
  64747. */
  64748. copyTransformAttributes(csg: CSG): CSG;
  64749. /**
  64750. * Build Raw mesh from CSG
  64751. * Coordinates here are in world space
  64752. * @param name The name of the mesh geometry
  64753. * @param scene The Scene
  64754. * @param keepSubMeshes Specifies if the submeshes should be kept
  64755. * @returns A new Mesh
  64756. */
  64757. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64758. /**
  64759. * Build Mesh from CSG taking material and transforms into account
  64760. * @param name The name of the Mesh
  64761. * @param material The material of the Mesh
  64762. * @param scene The Scene
  64763. * @param keepSubMeshes Specifies if submeshes should be kept
  64764. * @returns The new Mesh
  64765. */
  64766. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64767. }
  64768. }
  64769. declare module BABYLON {
  64770. /**
  64771. * Class used to create a trail following a mesh
  64772. */
  64773. export class TrailMesh extends Mesh {
  64774. private _generator;
  64775. private _autoStart;
  64776. private _running;
  64777. private _diameter;
  64778. private _length;
  64779. private _sectionPolygonPointsCount;
  64780. private _sectionVectors;
  64781. private _sectionNormalVectors;
  64782. private _beforeRenderObserver;
  64783. /**
  64784. * @constructor
  64785. * @param name The value used by scene.getMeshByName() to do a lookup.
  64786. * @param generator The mesh or transform node to generate a trail.
  64787. * @param scene The scene to add this mesh to.
  64788. * @param diameter Diameter of trailing mesh. Default is 1.
  64789. * @param length Length of trailing mesh. Default is 60.
  64790. * @param autoStart Automatically start trailing mesh. Default true.
  64791. */
  64792. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  64793. /**
  64794. * "TrailMesh"
  64795. * @returns "TrailMesh"
  64796. */
  64797. getClassName(): string;
  64798. private _createMesh;
  64799. /**
  64800. * Start trailing mesh.
  64801. */
  64802. start(): void;
  64803. /**
  64804. * Stop trailing mesh.
  64805. */
  64806. stop(): void;
  64807. /**
  64808. * Update trailing mesh geometry.
  64809. */
  64810. update(): void;
  64811. /**
  64812. * Returns a new TrailMesh object.
  64813. * @param name is a string, the name given to the new mesh
  64814. * @param newGenerator use new generator object for cloned trail mesh
  64815. * @returns a new mesh
  64816. */
  64817. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  64818. /**
  64819. * Serializes this trail mesh
  64820. * @param serializationObject object to write serialization to
  64821. */
  64822. serialize(serializationObject: any): void;
  64823. /**
  64824. * Parses a serialized trail mesh
  64825. * @param parsedMesh the serialized mesh
  64826. * @param scene the scene to create the trail mesh in
  64827. * @returns the created trail mesh
  64828. */
  64829. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  64830. }
  64831. }
  64832. declare module BABYLON {
  64833. /**
  64834. * Class containing static functions to help procedurally build meshes
  64835. */
  64836. export class TiledBoxBuilder {
  64837. /**
  64838. * Creates a box mesh
  64839. * 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)
  64840. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64841. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64842. * * 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
  64843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64844. * @param name defines the name of the mesh
  64845. * @param options defines the options used to create the mesh
  64846. * @param scene defines the hosting scene
  64847. * @returns the box mesh
  64848. */
  64849. static CreateTiledBox(name: string, options: {
  64850. pattern?: number;
  64851. width?: number;
  64852. height?: number;
  64853. depth?: number;
  64854. tileSize?: number;
  64855. tileWidth?: number;
  64856. tileHeight?: number;
  64857. alignHorizontal?: number;
  64858. alignVertical?: number;
  64859. faceUV?: Vector4[];
  64860. faceColors?: Color4[];
  64861. sideOrientation?: number;
  64862. updatable?: boolean;
  64863. }, scene?: Nullable<Scene>): Mesh;
  64864. }
  64865. }
  64866. declare module BABYLON {
  64867. /**
  64868. * Class containing static functions to help procedurally build meshes
  64869. */
  64870. export class TorusKnotBuilder {
  64871. /**
  64872. * Creates a torus knot mesh
  64873. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64874. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64875. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64876. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64877. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64878. * * 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
  64879. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64880. * @param name defines the name of the mesh
  64881. * @param options defines the options used to create the mesh
  64882. * @param scene defines the hosting scene
  64883. * @returns the torus knot mesh
  64884. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64885. */
  64886. static CreateTorusKnot(name: string, options: {
  64887. radius?: number;
  64888. tube?: number;
  64889. radialSegments?: number;
  64890. tubularSegments?: number;
  64891. p?: number;
  64892. q?: number;
  64893. updatable?: boolean;
  64894. sideOrientation?: number;
  64895. frontUVs?: Vector4;
  64896. backUVs?: Vector4;
  64897. }, scene: any): Mesh;
  64898. }
  64899. }
  64900. declare module BABYLON {
  64901. /**
  64902. * Polygon
  64903. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  64904. */
  64905. export class Polygon {
  64906. /**
  64907. * Creates a rectangle
  64908. * @param xmin bottom X coord
  64909. * @param ymin bottom Y coord
  64910. * @param xmax top X coord
  64911. * @param ymax top Y coord
  64912. * @returns points that make the resulting rectation
  64913. */
  64914. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  64915. /**
  64916. * Creates a circle
  64917. * @param radius radius of circle
  64918. * @param cx scale in x
  64919. * @param cy scale in y
  64920. * @param numberOfSides number of sides that make up the circle
  64921. * @returns points that make the resulting circle
  64922. */
  64923. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  64924. /**
  64925. * Creates a polygon from input string
  64926. * @param input Input polygon data
  64927. * @returns the parsed points
  64928. */
  64929. static Parse(input: string): Vector2[];
  64930. /**
  64931. * Starts building a polygon from x and y coordinates
  64932. * @param x x coordinate
  64933. * @param y y coordinate
  64934. * @returns the started path2
  64935. */
  64936. static StartingAt(x: number, y: number): Path2;
  64937. }
  64938. /**
  64939. * Builds a polygon
  64940. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  64941. */
  64942. export class PolygonMeshBuilder {
  64943. private _points;
  64944. private _outlinepoints;
  64945. private _holes;
  64946. private _name;
  64947. private _scene;
  64948. private _epoints;
  64949. private _eholes;
  64950. private _addToepoint;
  64951. /**
  64952. * Babylon reference to the earcut plugin.
  64953. */
  64954. bjsEarcut: any;
  64955. /**
  64956. * Creates a PolygonMeshBuilder
  64957. * @param name name of the builder
  64958. * @param contours Path of the polygon
  64959. * @param scene scene to add to when creating the mesh
  64960. * @param earcutInjection can be used to inject your own earcut reference
  64961. */
  64962. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  64963. /**
  64964. * Adds a whole within the polygon
  64965. * @param hole Array of points defining the hole
  64966. * @returns this
  64967. */
  64968. addHole(hole: Vector2[]): PolygonMeshBuilder;
  64969. /**
  64970. * Creates the polygon
  64971. * @param updatable If the mesh should be updatable
  64972. * @param depth The depth of the mesh created
  64973. * @returns the created mesh
  64974. */
  64975. build(updatable?: boolean, depth?: number): Mesh;
  64976. /**
  64977. * Creates the polygon
  64978. * @param depth The depth of the mesh created
  64979. * @returns the created VertexData
  64980. */
  64981. buildVertexData(depth?: number): VertexData;
  64982. /**
  64983. * Adds a side to the polygon
  64984. * @param positions points that make the polygon
  64985. * @param normals normals of the polygon
  64986. * @param uvs uvs of the polygon
  64987. * @param indices indices of the polygon
  64988. * @param bounds bounds of the polygon
  64989. * @param points points of the polygon
  64990. * @param depth depth of the polygon
  64991. * @param flip flip of the polygon
  64992. */
  64993. private addSide;
  64994. }
  64995. }
  64996. declare module BABYLON {
  64997. /**
  64998. * Class containing static functions to help procedurally build meshes
  64999. */
  65000. export class PolygonBuilder {
  65001. /**
  65002. * Creates a polygon mesh
  65003. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65004. * * 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
  65005. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65006. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65007. * * 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)
  65008. * * Remember you can only change the shape positions, not their number when updating a polygon
  65009. * @param name defines the name of the mesh
  65010. * @param options defines the options used to create the mesh
  65011. * @param scene defines the hosting scene
  65012. * @param earcutInjection can be used to inject your own earcut reference
  65013. * @returns the polygon mesh
  65014. */
  65015. static CreatePolygon(name: string, options: {
  65016. shape: Vector3[];
  65017. holes?: Vector3[][];
  65018. depth?: number;
  65019. faceUV?: Vector4[];
  65020. faceColors?: Color4[];
  65021. updatable?: boolean;
  65022. sideOrientation?: number;
  65023. frontUVs?: Vector4;
  65024. backUVs?: Vector4;
  65025. wrap?: boolean;
  65026. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65027. /**
  65028. * Creates an extruded polygon mesh, with depth in the Y direction.
  65029. * * 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)
  65030. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65031. * @param name defines the name of the mesh
  65032. * @param options defines the options used to create the mesh
  65033. * @param scene defines the hosting scene
  65034. * @param earcutInjection can be used to inject your own earcut reference
  65035. * @returns the polygon mesh
  65036. */
  65037. static ExtrudePolygon(name: string, options: {
  65038. shape: Vector3[];
  65039. holes?: Vector3[][];
  65040. depth?: number;
  65041. faceUV?: Vector4[];
  65042. faceColors?: Color4[];
  65043. updatable?: boolean;
  65044. sideOrientation?: number;
  65045. frontUVs?: Vector4;
  65046. backUVs?: Vector4;
  65047. wrap?: boolean;
  65048. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65049. }
  65050. }
  65051. declare module BABYLON {
  65052. /**
  65053. * Class containing static functions to help procedurally build meshes
  65054. */
  65055. export class LatheBuilder {
  65056. /**
  65057. * Creates lathe mesh.
  65058. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  65059. * * 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
  65060. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  65061. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  65062. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  65063. * * 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
  65064. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  65065. * * 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
  65066. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65067. * * 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
  65068. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65069. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65070. * @param name defines the name of the mesh
  65071. * @param options defines the options used to create the mesh
  65072. * @param scene defines the hosting scene
  65073. * @returns the lathe mesh
  65074. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  65075. */
  65076. static CreateLathe(name: string, options: {
  65077. shape: Vector3[];
  65078. radius?: number;
  65079. tessellation?: number;
  65080. clip?: number;
  65081. arc?: number;
  65082. closed?: boolean;
  65083. updatable?: boolean;
  65084. sideOrientation?: number;
  65085. frontUVs?: Vector4;
  65086. backUVs?: Vector4;
  65087. cap?: number;
  65088. invertUV?: boolean;
  65089. }, scene?: Nullable<Scene>): Mesh;
  65090. }
  65091. }
  65092. declare module BABYLON {
  65093. /**
  65094. * Class containing static functions to help procedurally build meshes
  65095. */
  65096. export class TiledPlaneBuilder {
  65097. /**
  65098. * Creates a tiled plane mesh
  65099. * * The parameter `pattern` will, depending on value, do nothing or
  65100. * * * flip (reflect about central vertical) alternate tiles across and up
  65101. * * * flip every tile on alternate rows
  65102. * * * rotate (180 degs) alternate tiles across and up
  65103. * * * rotate every tile on alternate rows
  65104. * * * flip and rotate alternate tiles across and up
  65105. * * * flip and rotate every tile on alternate rows
  65106. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  65107. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  65108. * * 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
  65109. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65110. * * 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)
  65111. * * 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)
  65112. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65113. * @param name defines the name of the mesh
  65114. * @param options defines the options used to create the mesh
  65115. * @param scene defines the hosting scene
  65116. * @returns the box mesh
  65117. */
  65118. static CreateTiledPlane(name: string, options: {
  65119. pattern?: number;
  65120. tileSize?: number;
  65121. tileWidth?: number;
  65122. tileHeight?: number;
  65123. size?: number;
  65124. width?: number;
  65125. height?: number;
  65126. alignHorizontal?: number;
  65127. alignVertical?: number;
  65128. sideOrientation?: number;
  65129. frontUVs?: Vector4;
  65130. backUVs?: Vector4;
  65131. updatable?: boolean;
  65132. }, scene?: Nullable<Scene>): Mesh;
  65133. }
  65134. }
  65135. declare module BABYLON {
  65136. /**
  65137. * Class containing static functions to help procedurally build meshes
  65138. */
  65139. export class TubeBuilder {
  65140. /**
  65141. * Creates a tube mesh.
  65142. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65143. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65144. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65145. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65146. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65147. * * 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)
  65148. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65149. * * 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
  65150. * * 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
  65151. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65152. * * 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
  65153. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65154. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65155. * @param name defines the name of the mesh
  65156. * @param options defines the options used to create the mesh
  65157. * @param scene defines the hosting scene
  65158. * @returns the tube mesh
  65159. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65160. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65161. */
  65162. static CreateTube(name: string, options: {
  65163. path: Vector3[];
  65164. radius?: number;
  65165. tessellation?: number;
  65166. radiusFunction?: {
  65167. (i: number, distance: number): number;
  65168. };
  65169. cap?: number;
  65170. arc?: number;
  65171. updatable?: boolean;
  65172. sideOrientation?: number;
  65173. frontUVs?: Vector4;
  65174. backUVs?: Vector4;
  65175. instance?: Mesh;
  65176. invertUV?: boolean;
  65177. }, scene?: Nullable<Scene>): Mesh;
  65178. }
  65179. }
  65180. declare module BABYLON {
  65181. /**
  65182. * Class containing static functions to help procedurally build meshes
  65183. */
  65184. export class IcoSphereBuilder {
  65185. /**
  65186. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65187. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65188. * * 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`)
  65189. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65190. * * 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
  65191. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65192. * * 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
  65193. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65194. * @param name defines the name of the mesh
  65195. * @param options defines the options used to create the mesh
  65196. * @param scene defines the hosting scene
  65197. * @returns the icosahedron mesh
  65198. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65199. */
  65200. static CreateIcoSphere(name: string, options: {
  65201. radius?: number;
  65202. radiusX?: number;
  65203. radiusY?: number;
  65204. radiusZ?: number;
  65205. flat?: boolean;
  65206. subdivisions?: number;
  65207. sideOrientation?: number;
  65208. frontUVs?: Vector4;
  65209. backUVs?: Vector4;
  65210. updatable?: boolean;
  65211. }, scene?: Nullable<Scene>): Mesh;
  65212. }
  65213. }
  65214. declare module BABYLON {
  65215. /**
  65216. * Class containing static functions to help procedurally build meshes
  65217. */
  65218. export class DecalBuilder {
  65219. /**
  65220. * Creates a decal mesh.
  65221. * 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
  65222. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65223. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65224. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65225. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65226. * @param name defines the name of the mesh
  65227. * @param sourceMesh defines the mesh where the decal must be applied
  65228. * @param options defines the options used to create the mesh
  65229. * @param scene defines the hosting scene
  65230. * @returns the decal mesh
  65231. * @see https://doc.babylonjs.com/how_to/decals
  65232. */
  65233. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65234. position?: Vector3;
  65235. normal?: Vector3;
  65236. size?: Vector3;
  65237. angle?: number;
  65238. }): Mesh;
  65239. }
  65240. }
  65241. declare module BABYLON {
  65242. /**
  65243. * Class containing static functions to help procedurally build meshes
  65244. */
  65245. export class MeshBuilder {
  65246. /**
  65247. * Creates a box mesh
  65248. * * The parameter `size` sets the size (float) of each box side (default 1)
  65249. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  65250. * * 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)
  65251. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65252. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65253. * * 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
  65254. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65255. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65256. * @param name defines the name of the mesh
  65257. * @param options defines the options used to create the mesh
  65258. * @param scene defines the hosting scene
  65259. * @returns the box mesh
  65260. */
  65261. static CreateBox(name: string, options: {
  65262. size?: number;
  65263. width?: number;
  65264. height?: number;
  65265. depth?: number;
  65266. faceUV?: Vector4[];
  65267. faceColors?: Color4[];
  65268. sideOrientation?: number;
  65269. frontUVs?: Vector4;
  65270. backUVs?: Vector4;
  65271. wrap?: boolean;
  65272. topBaseAt?: number;
  65273. bottomBaseAt?: number;
  65274. updatable?: boolean;
  65275. }, scene?: Nullable<Scene>): Mesh;
  65276. /**
  65277. * Creates a tiled box mesh
  65278. * * faceTiles sets the pattern, tile size and number of tiles for a face
  65279. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65280. * @param name defines the name of the mesh
  65281. * @param options defines the options used to create the mesh
  65282. * @param scene defines the hosting scene
  65283. * @returns the tiled box mesh
  65284. */
  65285. static CreateTiledBox(name: string, options: {
  65286. pattern?: number;
  65287. size?: number;
  65288. width?: number;
  65289. height?: number;
  65290. depth: number;
  65291. tileSize?: number;
  65292. tileWidth?: number;
  65293. tileHeight?: number;
  65294. faceUV?: Vector4[];
  65295. faceColors?: Color4[];
  65296. alignHorizontal?: number;
  65297. alignVertical?: number;
  65298. sideOrientation?: number;
  65299. updatable?: boolean;
  65300. }, scene?: Nullable<Scene>): Mesh;
  65301. /**
  65302. * Creates a sphere mesh
  65303. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  65304. * * 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`)
  65305. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  65306. * * 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
  65307. * * 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)
  65308. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65309. * * 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
  65310. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65311. * @param name defines the name of the mesh
  65312. * @param options defines the options used to create the mesh
  65313. * @param scene defines the hosting scene
  65314. * @returns the sphere mesh
  65315. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  65316. */
  65317. static CreateSphere(name: string, options: {
  65318. segments?: number;
  65319. diameter?: number;
  65320. diameterX?: number;
  65321. diameterY?: number;
  65322. diameterZ?: number;
  65323. arc?: number;
  65324. slice?: number;
  65325. sideOrientation?: number;
  65326. frontUVs?: Vector4;
  65327. backUVs?: Vector4;
  65328. updatable?: boolean;
  65329. }, scene?: Nullable<Scene>): Mesh;
  65330. /**
  65331. * Creates a plane polygonal mesh. By default, this is a disc
  65332. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  65333. * * 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
  65334. * * 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
  65335. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65336. * * 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
  65337. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65338. * @param name defines the name of the mesh
  65339. * @param options defines the options used to create the mesh
  65340. * @param scene defines the hosting scene
  65341. * @returns the plane polygonal mesh
  65342. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  65343. */
  65344. static CreateDisc(name: string, options: {
  65345. radius?: number;
  65346. tessellation?: number;
  65347. arc?: number;
  65348. updatable?: boolean;
  65349. sideOrientation?: number;
  65350. frontUVs?: Vector4;
  65351. backUVs?: Vector4;
  65352. }, scene?: Nullable<Scene>): Mesh;
  65353. /**
  65354. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65355. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65356. * * 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`)
  65357. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65358. * * 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
  65359. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65360. * * 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
  65361. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65362. * @param name defines the name of the mesh
  65363. * @param options defines the options used to create the mesh
  65364. * @param scene defines the hosting scene
  65365. * @returns the icosahedron mesh
  65366. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65367. */
  65368. static CreateIcoSphere(name: string, options: {
  65369. radius?: number;
  65370. radiusX?: number;
  65371. radiusY?: number;
  65372. radiusZ?: number;
  65373. flat?: boolean;
  65374. subdivisions?: number;
  65375. sideOrientation?: number;
  65376. frontUVs?: Vector4;
  65377. backUVs?: Vector4;
  65378. updatable?: boolean;
  65379. }, scene?: Nullable<Scene>): Mesh;
  65380. /**
  65381. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65382. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  65383. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  65384. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  65385. * * 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
  65386. * * 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
  65387. * * 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
  65388. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65389. * * 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
  65390. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65391. * * 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
  65392. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  65393. * * 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
  65394. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  65395. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  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 ribbon mesh
  65400. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  65401. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65402. */
  65403. static CreateRibbon(name: string, options: {
  65404. pathArray: Vector3[][];
  65405. closeArray?: boolean;
  65406. closePath?: boolean;
  65407. offset?: number;
  65408. updatable?: boolean;
  65409. sideOrientation?: number;
  65410. frontUVs?: Vector4;
  65411. backUVs?: Vector4;
  65412. instance?: Mesh;
  65413. invertUV?: boolean;
  65414. uvs?: Vector2[];
  65415. colors?: Color4[];
  65416. }, scene?: Nullable<Scene>): Mesh;
  65417. /**
  65418. * Creates a cylinder or a cone mesh
  65419. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  65420. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  65421. * * 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.
  65422. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  65423. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  65424. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  65425. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  65426. * * 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).
  65427. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  65428. * * 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).
  65429. * * 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
  65430. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  65431. * * 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
  65432. * * 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.
  65433. * * If `enclose` is false, a ring surface is one element.
  65434. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  65435. * * 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
  65436. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65437. * * 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
  65438. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65439. * @param name defines the name of the mesh
  65440. * @param options defines the options used to create the mesh
  65441. * @param scene defines the hosting scene
  65442. * @returns the cylinder mesh
  65443. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  65444. */
  65445. static CreateCylinder(name: string, options: {
  65446. height?: number;
  65447. diameterTop?: number;
  65448. diameterBottom?: number;
  65449. diameter?: number;
  65450. tessellation?: number;
  65451. subdivisions?: number;
  65452. arc?: number;
  65453. faceColors?: Color4[];
  65454. faceUV?: Vector4[];
  65455. updatable?: boolean;
  65456. hasRings?: boolean;
  65457. enclose?: boolean;
  65458. cap?: number;
  65459. sideOrientation?: number;
  65460. frontUVs?: Vector4;
  65461. backUVs?: Vector4;
  65462. }, scene?: Nullable<Scene>): Mesh;
  65463. /**
  65464. * Creates a torus mesh
  65465. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  65466. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  65467. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  65468. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65469. * * 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
  65470. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65471. * @param name defines the name of the mesh
  65472. * @param options defines the options used to create the mesh
  65473. * @param scene defines the hosting scene
  65474. * @returns the torus mesh
  65475. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  65476. */
  65477. static CreateTorus(name: string, options: {
  65478. diameter?: number;
  65479. thickness?: number;
  65480. tessellation?: number;
  65481. updatable?: boolean;
  65482. sideOrientation?: number;
  65483. frontUVs?: Vector4;
  65484. backUVs?: Vector4;
  65485. }, scene?: Nullable<Scene>): Mesh;
  65486. /**
  65487. * Creates a torus knot mesh
  65488. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  65489. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  65490. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  65491. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  65492. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65493. * * 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
  65494. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65495. * @param name defines the name of the mesh
  65496. * @param options defines the options used to create the mesh
  65497. * @param scene defines the hosting scene
  65498. * @returns the torus knot mesh
  65499. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  65500. */
  65501. static CreateTorusKnot(name: string, options: {
  65502. radius?: number;
  65503. tube?: number;
  65504. radialSegments?: number;
  65505. tubularSegments?: number;
  65506. p?: number;
  65507. q?: number;
  65508. updatable?: boolean;
  65509. sideOrientation?: number;
  65510. frontUVs?: Vector4;
  65511. backUVs?: Vector4;
  65512. }, scene?: Nullable<Scene>): Mesh;
  65513. /**
  65514. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  65515. * * 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
  65516. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  65517. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  65518. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  65519. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  65520. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  65521. * * 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
  65522. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  65523. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65524. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  65525. * @param name defines the name of the new line system
  65526. * @param options defines the options used to create the line system
  65527. * @param scene defines the hosting scene
  65528. * @returns a new line system mesh
  65529. */
  65530. static CreateLineSystem(name: string, options: {
  65531. lines: Vector3[][];
  65532. updatable?: boolean;
  65533. instance?: Nullable<LinesMesh>;
  65534. colors?: Nullable<Color4[][]>;
  65535. useVertexAlpha?: boolean;
  65536. }, scene: Nullable<Scene>): LinesMesh;
  65537. /**
  65538. * Creates a line mesh
  65539. * 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
  65540. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  65541. * * The parameter `points` is an array successive Vector3
  65542. * * 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
  65543. * * The optional parameter `colors` is an array of successive Color4, one per line point
  65544. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  65545. * * When updating an instance, remember that only point positions can change, not the number of points
  65546. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65547. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  65548. * @param name defines the name of the new line system
  65549. * @param options defines the options used to create the line system
  65550. * @param scene defines the hosting scene
  65551. * @returns a new line mesh
  65552. */
  65553. static CreateLines(name: string, options: {
  65554. points: Vector3[];
  65555. updatable?: boolean;
  65556. instance?: Nullable<LinesMesh>;
  65557. colors?: Color4[];
  65558. useVertexAlpha?: boolean;
  65559. }, scene?: Nullable<Scene>): LinesMesh;
  65560. /**
  65561. * Creates a dashed line mesh
  65562. * * 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
  65563. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  65564. * * The parameter `points` is an array successive Vector3
  65565. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  65566. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  65567. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  65568. * * 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
  65569. * * When updating an instance, remember that only point positions can change, not the number of points
  65570. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65571. * @param name defines the name of the mesh
  65572. * @param options defines the options used to create the mesh
  65573. * @param scene defines the hosting scene
  65574. * @returns the dashed line mesh
  65575. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  65576. */
  65577. static CreateDashedLines(name: string, options: {
  65578. points: Vector3[];
  65579. dashSize?: number;
  65580. gapSize?: number;
  65581. dashNb?: number;
  65582. updatable?: boolean;
  65583. instance?: LinesMesh;
  65584. }, scene?: Nullable<Scene>): LinesMesh;
  65585. /**
  65586. * 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.
  65587. * * 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.
  65588. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65589. * * 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.
  65590. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  65591. * * 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
  65592. * * 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
  65593. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  65594. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65595. * * 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
  65596. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  65597. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65598. * @param name defines the name of the mesh
  65599. * @param options defines the options used to create the mesh
  65600. * @param scene defines the hosting scene
  65601. * @returns the extruded shape mesh
  65602. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65603. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65604. */
  65605. static ExtrudeShape(name: string, options: {
  65606. shape: Vector3[];
  65607. path: Vector3[];
  65608. scale?: number;
  65609. rotation?: number;
  65610. cap?: number;
  65611. updatable?: boolean;
  65612. sideOrientation?: number;
  65613. frontUVs?: Vector4;
  65614. backUVs?: Vector4;
  65615. instance?: Mesh;
  65616. invertUV?: boolean;
  65617. }, scene?: Nullable<Scene>): Mesh;
  65618. /**
  65619. * Creates an custom extruded shape mesh.
  65620. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  65621. * * 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.
  65622. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65623. * * 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
  65624. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  65625. * * 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
  65626. * * It must returns a float value that will be the scale value applied to the shape on each path point
  65627. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  65628. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  65629. * * 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
  65630. * * 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
  65631. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  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 optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65635. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65636. * @param name defines the name of the mesh
  65637. * @param options defines the options used to create the mesh
  65638. * @param scene defines the hosting scene
  65639. * @returns the custom extruded shape mesh
  65640. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  65641. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65642. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65643. */
  65644. static ExtrudeShapeCustom(name: string, options: {
  65645. shape: Vector3[];
  65646. path: Vector3[];
  65647. scaleFunction?: any;
  65648. rotationFunction?: any;
  65649. ribbonCloseArray?: boolean;
  65650. ribbonClosePath?: boolean;
  65651. cap?: number;
  65652. updatable?: boolean;
  65653. sideOrientation?: number;
  65654. frontUVs?: Vector4;
  65655. backUVs?: Vector4;
  65656. instance?: Mesh;
  65657. invertUV?: boolean;
  65658. }, scene?: Nullable<Scene>): Mesh;
  65659. /**
  65660. * Creates lathe mesh.
  65661. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  65662. * * 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
  65663. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  65664. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  65665. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  65666. * * 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
  65667. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  65668. * * 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
  65669. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65670. * * 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
  65671. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65673. * @param name defines the name of the mesh
  65674. * @param options defines the options used to create the mesh
  65675. * @param scene defines the hosting scene
  65676. * @returns the lathe mesh
  65677. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  65678. */
  65679. static CreateLathe(name: string, options: {
  65680. shape: Vector3[];
  65681. radius?: number;
  65682. tessellation?: number;
  65683. clip?: number;
  65684. arc?: number;
  65685. closed?: boolean;
  65686. updatable?: boolean;
  65687. sideOrientation?: number;
  65688. frontUVs?: Vector4;
  65689. backUVs?: Vector4;
  65690. cap?: number;
  65691. invertUV?: boolean;
  65692. }, scene?: Nullable<Scene>): Mesh;
  65693. /**
  65694. * Creates a tiled plane mesh
  65695. * * You can set a limited pattern arrangement with the tiles
  65696. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65697. * * 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
  65698. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65699. * @param name defines the name of the mesh
  65700. * @param options defines the options used to create the mesh
  65701. * @param scene defines the hosting scene
  65702. * @returns the plane mesh
  65703. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  65704. */
  65705. static CreateTiledPlane(name: string, options: {
  65706. pattern?: number;
  65707. tileSize?: number;
  65708. tileWidth?: number;
  65709. tileHeight?: number;
  65710. size?: number;
  65711. width?: number;
  65712. height?: number;
  65713. alignHorizontal?: number;
  65714. alignVertical?: number;
  65715. sideOrientation?: number;
  65716. frontUVs?: Vector4;
  65717. backUVs?: Vector4;
  65718. updatable?: boolean;
  65719. }, scene?: Nullable<Scene>): Mesh;
  65720. /**
  65721. * Creates a plane mesh
  65722. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  65723. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  65724. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  65725. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65726. * * 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
  65727. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65728. * @param name defines the name of the mesh
  65729. * @param options defines the options used to create the mesh
  65730. * @param scene defines the hosting scene
  65731. * @returns the plane mesh
  65732. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  65733. */
  65734. static CreatePlane(name: string, options: {
  65735. size?: number;
  65736. width?: number;
  65737. height?: number;
  65738. sideOrientation?: number;
  65739. frontUVs?: Vector4;
  65740. backUVs?: Vector4;
  65741. updatable?: boolean;
  65742. sourcePlane?: Plane;
  65743. }, scene?: Nullable<Scene>): Mesh;
  65744. /**
  65745. * Creates a ground mesh
  65746. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  65747. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  65748. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65749. * @param name defines the name of the mesh
  65750. * @param options defines the options used to create the mesh
  65751. * @param scene defines the hosting scene
  65752. * @returns the ground mesh
  65753. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  65754. */
  65755. static CreateGround(name: string, options: {
  65756. width?: number;
  65757. height?: number;
  65758. subdivisions?: number;
  65759. subdivisionsX?: number;
  65760. subdivisionsY?: number;
  65761. updatable?: boolean;
  65762. }, scene?: Nullable<Scene>): Mesh;
  65763. /**
  65764. * Creates a tiled ground mesh
  65765. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  65766. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  65767. * * 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
  65768. * * 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
  65769. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65770. * @param name defines the name of the mesh
  65771. * @param options defines the options used to create the mesh
  65772. * @param scene defines the hosting scene
  65773. * @returns the tiled ground mesh
  65774. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  65775. */
  65776. static CreateTiledGround(name: string, options: {
  65777. xmin: number;
  65778. zmin: number;
  65779. xmax: number;
  65780. zmax: number;
  65781. subdivisions?: {
  65782. w: number;
  65783. h: number;
  65784. };
  65785. precision?: {
  65786. w: number;
  65787. h: number;
  65788. };
  65789. updatable?: boolean;
  65790. }, scene?: Nullable<Scene>): Mesh;
  65791. /**
  65792. * Creates a ground mesh from a height map
  65793. * * The parameter `url` sets the URL of the height map image resource.
  65794. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  65795. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  65796. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  65797. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  65798. * * 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.
  65799. * * 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).
  65800. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  65801. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65802. * @param name defines the name of the mesh
  65803. * @param url defines the url to the height map
  65804. * @param options defines the options used to create the mesh
  65805. * @param scene defines the hosting scene
  65806. * @returns the ground mesh
  65807. * @see https://doc.babylonjs.com/babylon101/height_map
  65808. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  65809. */
  65810. static CreateGroundFromHeightMap(name: string, url: string, options: {
  65811. width?: number;
  65812. height?: number;
  65813. subdivisions?: number;
  65814. minHeight?: number;
  65815. maxHeight?: number;
  65816. colorFilter?: Color3;
  65817. alphaFilter?: number;
  65818. updatable?: boolean;
  65819. onReady?: (mesh: GroundMesh) => void;
  65820. }, scene?: Nullable<Scene>): GroundMesh;
  65821. /**
  65822. * Creates a polygon mesh
  65823. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65824. * * 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
  65825. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65826. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65827. * * 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)
  65828. * * Remember you can only change the shape positions, not their number when updating a polygon
  65829. * @param name defines the name of the mesh
  65830. * @param options defines the options used to create the mesh
  65831. * @param scene defines the hosting scene
  65832. * @param earcutInjection can be used to inject your own earcut reference
  65833. * @returns the polygon mesh
  65834. */
  65835. static CreatePolygon(name: string, options: {
  65836. shape: Vector3[];
  65837. holes?: Vector3[][];
  65838. depth?: number;
  65839. faceUV?: Vector4[];
  65840. faceColors?: Color4[];
  65841. updatable?: boolean;
  65842. sideOrientation?: number;
  65843. frontUVs?: Vector4;
  65844. backUVs?: Vector4;
  65845. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65846. /**
  65847. * Creates an extruded polygon mesh, with depth in the Y direction.
  65848. * * 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)
  65849. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65850. * @param name defines the name of the mesh
  65851. * @param options defines the options used to create the mesh
  65852. * @param scene defines the hosting scene
  65853. * @param earcutInjection can be used to inject your own earcut reference
  65854. * @returns the polygon mesh
  65855. */
  65856. static ExtrudePolygon(name: string, options: {
  65857. shape: Vector3[];
  65858. holes?: Vector3[][];
  65859. depth?: number;
  65860. faceUV?: Vector4[];
  65861. faceColors?: Color4[];
  65862. updatable?: boolean;
  65863. sideOrientation?: number;
  65864. frontUVs?: Vector4;
  65865. backUVs?: Vector4;
  65866. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65867. /**
  65868. * Creates a tube mesh.
  65869. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65870. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65871. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65872. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65873. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65874. * * 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)
  65875. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65876. * * 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
  65877. * * 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
  65878. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65879. * * 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
  65880. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65881. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65882. * @param name defines the name of the mesh
  65883. * @param options defines the options used to create the mesh
  65884. * @param scene defines the hosting scene
  65885. * @returns the tube mesh
  65886. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65887. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65888. */
  65889. static CreateTube(name: string, options: {
  65890. path: Vector3[];
  65891. radius?: number;
  65892. tessellation?: number;
  65893. radiusFunction?: {
  65894. (i: number, distance: number): number;
  65895. };
  65896. cap?: number;
  65897. arc?: number;
  65898. updatable?: boolean;
  65899. sideOrientation?: number;
  65900. frontUVs?: Vector4;
  65901. backUVs?: Vector4;
  65902. instance?: Mesh;
  65903. invertUV?: boolean;
  65904. }, scene?: Nullable<Scene>): Mesh;
  65905. /**
  65906. * Creates a polyhedron mesh
  65907. * * 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
  65908. * * The parameter `size` (positive float, default 1) sets the polygon size
  65909. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  65910. * * 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`
  65911. * * 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
  65912. * * 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)`)
  65913. * * 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
  65914. * * 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
  65915. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65916. * * 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
  65917. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65918. * @param name defines the name of the mesh
  65919. * @param options defines the options used to create the mesh
  65920. * @param scene defines the hosting scene
  65921. * @returns the polyhedron mesh
  65922. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  65923. */
  65924. static CreatePolyhedron(name: string, options: {
  65925. type?: number;
  65926. size?: number;
  65927. sizeX?: number;
  65928. sizeY?: number;
  65929. sizeZ?: number;
  65930. custom?: any;
  65931. faceUV?: Vector4[];
  65932. faceColors?: Color4[];
  65933. flat?: boolean;
  65934. updatable?: boolean;
  65935. sideOrientation?: number;
  65936. frontUVs?: Vector4;
  65937. backUVs?: Vector4;
  65938. }, scene?: Nullable<Scene>): Mesh;
  65939. /**
  65940. * Creates a decal mesh.
  65941. * 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
  65942. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65943. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65944. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65945. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65946. * @param name defines the name of the mesh
  65947. * @param sourceMesh defines the mesh where the decal must be applied
  65948. * @param options defines the options used to create the mesh
  65949. * @param scene defines the hosting scene
  65950. * @returns the decal mesh
  65951. * @see https://doc.babylonjs.com/how_to/decals
  65952. */
  65953. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65954. position?: Vector3;
  65955. normal?: Vector3;
  65956. size?: Vector3;
  65957. angle?: number;
  65958. }): Mesh;
  65959. }
  65960. }
  65961. declare module BABYLON {
  65962. /**
  65963. * A simplifier interface for future simplification implementations
  65964. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65965. */
  65966. export interface ISimplifier {
  65967. /**
  65968. * Simplification of a given mesh according to the given settings.
  65969. * Since this requires computation, it is assumed that the function runs async.
  65970. * @param settings The settings of the simplification, including quality and distance
  65971. * @param successCallback A callback that will be called after the mesh was simplified.
  65972. * @param errorCallback in case of an error, this callback will be called. optional.
  65973. */
  65974. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  65975. }
  65976. /**
  65977. * Expected simplification settings.
  65978. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  65979. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65980. */
  65981. export interface ISimplificationSettings {
  65982. /**
  65983. * Gets or sets the expected quality
  65984. */
  65985. quality: number;
  65986. /**
  65987. * Gets or sets the distance when this optimized version should be used
  65988. */
  65989. distance: number;
  65990. /**
  65991. * Gets an already optimized mesh
  65992. */
  65993. optimizeMesh?: boolean;
  65994. }
  65995. /**
  65996. * Class used to specify simplification options
  65997. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65998. */
  65999. export class SimplificationSettings implements ISimplificationSettings {
  66000. /** expected quality */
  66001. quality: number;
  66002. /** distance when this optimized version should be used */
  66003. distance: number;
  66004. /** already optimized mesh */
  66005. optimizeMesh?: boolean | undefined;
  66006. /**
  66007. * Creates a SimplificationSettings
  66008. * @param quality expected quality
  66009. * @param distance distance when this optimized version should be used
  66010. * @param optimizeMesh already optimized mesh
  66011. */
  66012. constructor(
  66013. /** expected quality */
  66014. quality: number,
  66015. /** distance when this optimized version should be used */
  66016. distance: number,
  66017. /** already optimized mesh */
  66018. optimizeMesh?: boolean | undefined);
  66019. }
  66020. /**
  66021. * Interface used to define a simplification task
  66022. */
  66023. export interface ISimplificationTask {
  66024. /**
  66025. * Array of settings
  66026. */
  66027. settings: Array<ISimplificationSettings>;
  66028. /**
  66029. * Simplification type
  66030. */
  66031. simplificationType: SimplificationType;
  66032. /**
  66033. * Mesh to simplify
  66034. */
  66035. mesh: Mesh;
  66036. /**
  66037. * Callback called on success
  66038. */
  66039. successCallback?: () => void;
  66040. /**
  66041. * Defines if parallel processing can be used
  66042. */
  66043. parallelProcessing: boolean;
  66044. }
  66045. /**
  66046. * Queue used to order the simplification tasks
  66047. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66048. */
  66049. export class SimplificationQueue {
  66050. private _simplificationArray;
  66051. /**
  66052. * Gets a boolean indicating that the process is still running
  66053. */
  66054. running: boolean;
  66055. /**
  66056. * Creates a new queue
  66057. */
  66058. constructor();
  66059. /**
  66060. * Adds a new simplification task
  66061. * @param task defines a task to add
  66062. */
  66063. addTask(task: ISimplificationTask): void;
  66064. /**
  66065. * Execute next task
  66066. */
  66067. executeNext(): void;
  66068. /**
  66069. * Execute a simplification task
  66070. * @param task defines the task to run
  66071. */
  66072. runSimplification(task: ISimplificationTask): void;
  66073. private getSimplifier;
  66074. }
  66075. /**
  66076. * The implemented types of simplification
  66077. * At the moment only Quadratic Error Decimation is implemented
  66078. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66079. */
  66080. export enum SimplificationType {
  66081. /** Quadratic error decimation */
  66082. QUADRATIC = 0
  66083. }
  66084. /**
  66085. * An implementation of the Quadratic Error simplification algorithm.
  66086. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  66087. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  66088. * @author RaananW
  66089. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66090. */
  66091. export class QuadraticErrorSimplification implements ISimplifier {
  66092. private _mesh;
  66093. private triangles;
  66094. private vertices;
  66095. private references;
  66096. private _reconstructedMesh;
  66097. /** Gets or sets the number pf sync interations */
  66098. syncIterations: number;
  66099. /** Gets or sets the aggressiveness of the simplifier */
  66100. aggressiveness: number;
  66101. /** Gets or sets the number of allowed iterations for decimation */
  66102. decimationIterations: number;
  66103. /** Gets or sets the espilon to use for bounding box computation */
  66104. boundingBoxEpsilon: number;
  66105. /**
  66106. * Creates a new QuadraticErrorSimplification
  66107. * @param _mesh defines the target mesh
  66108. */
  66109. constructor(_mesh: Mesh);
  66110. /**
  66111. * Simplification of a given mesh according to the given settings.
  66112. * Since this requires computation, it is assumed that the function runs async.
  66113. * @param settings The settings of the simplification, including quality and distance
  66114. * @param successCallback A callback that will be called after the mesh was simplified.
  66115. */
  66116. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  66117. private runDecimation;
  66118. private initWithMesh;
  66119. private init;
  66120. private reconstructMesh;
  66121. private initDecimatedMesh;
  66122. private isFlipped;
  66123. private updateTriangles;
  66124. private identifyBorder;
  66125. private updateMesh;
  66126. private vertexError;
  66127. private calculateError;
  66128. }
  66129. }
  66130. declare module BABYLON {
  66131. interface Scene {
  66132. /** @hidden (Backing field) */
  66133. _simplificationQueue: SimplificationQueue;
  66134. /**
  66135. * Gets or sets the simplification queue attached to the scene
  66136. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66137. */
  66138. simplificationQueue: SimplificationQueue;
  66139. }
  66140. interface Mesh {
  66141. /**
  66142. * Simplify the mesh according to the given array of settings.
  66143. * Function will return immediately and will simplify async
  66144. * @param settings a collection of simplification settings
  66145. * @param parallelProcessing should all levels calculate parallel or one after the other
  66146. * @param simplificationType the type of simplification to run
  66147. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  66148. * @returns the current mesh
  66149. */
  66150. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  66151. }
  66152. /**
  66153. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  66154. * created in a scene
  66155. */
  66156. export class SimplicationQueueSceneComponent implements ISceneComponent {
  66157. /**
  66158. * The component name helpfull to identify the component in the list of scene components.
  66159. */
  66160. readonly name: string;
  66161. /**
  66162. * The scene the component belongs to.
  66163. */
  66164. scene: Scene;
  66165. /**
  66166. * Creates a new instance of the component for the given scene
  66167. * @param scene Defines the scene to register the component in
  66168. */
  66169. constructor(scene: Scene);
  66170. /**
  66171. * Registers the component in a given scene
  66172. */
  66173. register(): void;
  66174. /**
  66175. * Rebuilds the elements related to this component in case of
  66176. * context lost for instance.
  66177. */
  66178. rebuild(): void;
  66179. /**
  66180. * Disposes the component and the associated ressources
  66181. */
  66182. dispose(): void;
  66183. private _beforeCameraUpdate;
  66184. }
  66185. }
  66186. declare module BABYLON {
  66187. interface Mesh {
  66188. /**
  66189. * Creates a new thin instance
  66190. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  66191. * @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
  66192. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  66193. */
  66194. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  66195. /**
  66196. * Adds the transformation (matrix) of the current mesh as a thin instance
  66197. * @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
  66198. * @returns the thin instance index number
  66199. */
  66200. thinInstanceAddSelf(refresh: boolean): number;
  66201. /**
  66202. * Registers a custom attribute to be used with thin instances
  66203. * @param kind name of the attribute
  66204. * @param stride size in floats of the attribute
  66205. */
  66206. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  66207. /**
  66208. * Sets the matrix of a thin instance
  66209. * @param index index of the thin instance
  66210. * @param matrix matrix to set
  66211. * @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
  66212. */
  66213. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  66214. /**
  66215. * Sets the value of a custom attribute for a thin instance
  66216. * @param kind name of the attribute
  66217. * @param index index of the thin instance
  66218. * @param value value to set
  66219. * @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
  66220. */
  66221. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  66222. /**
  66223. * 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.
  66224. */
  66225. thinInstanceCount: number;
  66226. /**
  66227. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  66228. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  66229. * @param buffer buffer to set
  66230. * @param stride size in floats of each value of the buffer
  66231. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  66232. */
  66233. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  66234. /**
  66235. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  66236. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  66237. */
  66238. thinInstanceBufferUpdated(kind: string): void;
  66239. /**
  66240. * Refreshes the bounding info, taking into account all the thin instances defined
  66241. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  66242. */
  66243. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  66244. /** @hidden */
  66245. _thinInstanceInitializeUserStorage(): void;
  66246. /** @hidden */
  66247. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  66248. /** @hidden */
  66249. _userThinInstanceBuffersStorage: {
  66250. data: {
  66251. [key: string]: Float32Array;
  66252. };
  66253. sizes: {
  66254. [key: string]: number;
  66255. };
  66256. vertexBuffers: {
  66257. [key: string]: Nullable<VertexBuffer>;
  66258. };
  66259. strides: {
  66260. [key: string]: number;
  66261. };
  66262. };
  66263. }
  66264. }
  66265. declare module BABYLON {
  66266. /**
  66267. * Navigation plugin interface to add navigation constrained by a navigation mesh
  66268. */
  66269. export interface INavigationEnginePlugin {
  66270. /**
  66271. * plugin name
  66272. */
  66273. name: string;
  66274. /**
  66275. * Creates a navigation mesh
  66276. * @param meshes array of all the geometry used to compute the navigatio mesh
  66277. * @param parameters bunch of parameters used to filter geometry
  66278. */
  66279. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  66280. /**
  66281. * Create a navigation mesh debug mesh
  66282. * @param scene is where the mesh will be added
  66283. * @returns debug display mesh
  66284. */
  66285. createDebugNavMesh(scene: Scene): Mesh;
  66286. /**
  66287. * Get a navigation mesh constrained position, closest to the parameter position
  66288. * @param position world position
  66289. * @returns the closest point to position constrained by the navigation mesh
  66290. */
  66291. getClosestPoint(position: Vector3): Vector3;
  66292. /**
  66293. * Get a navigation mesh constrained position, closest to the parameter position
  66294. * @param position world position
  66295. * @param result output the closest point to position constrained by the navigation mesh
  66296. */
  66297. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66298. /**
  66299. * Get a navigation mesh constrained position, within a particular radius
  66300. * @param position world position
  66301. * @param maxRadius the maximum distance to the constrained world position
  66302. * @returns the closest point to position constrained by the navigation mesh
  66303. */
  66304. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66305. /**
  66306. * Get a navigation mesh constrained position, within a particular radius
  66307. * @param position world position
  66308. * @param maxRadius the maximum distance to the constrained world position
  66309. * @param result output the closest point to position constrained by the navigation mesh
  66310. */
  66311. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  66312. /**
  66313. * Compute the final position from a segment made of destination-position
  66314. * @param position world position
  66315. * @param destination world position
  66316. * @returns the resulting point along the navmesh
  66317. */
  66318. moveAlong(position: Vector3, destination: Vector3): Vector3;
  66319. /**
  66320. * Compute the final position from a segment made of destination-position
  66321. * @param position world position
  66322. * @param destination world position
  66323. * @param result output the resulting point along the navmesh
  66324. */
  66325. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  66326. /**
  66327. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  66328. * @param start world position
  66329. * @param end world position
  66330. * @returns array containing world position composing the path
  66331. */
  66332. computePath(start: Vector3, end: Vector3): Vector3[];
  66333. /**
  66334. * If this plugin is supported
  66335. * @returns true if plugin is supported
  66336. */
  66337. isSupported(): boolean;
  66338. /**
  66339. * Create a new Crowd so you can add agents
  66340. * @param maxAgents the maximum agent count in the crowd
  66341. * @param maxAgentRadius the maximum radius an agent can have
  66342. * @param scene to attach the crowd to
  66343. * @returns the crowd you can add agents to
  66344. */
  66345. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  66346. /**
  66347. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66348. * The queries will try to find a solution within those bounds
  66349. * default is (1,1,1)
  66350. * @param extent x,y,z value that define the extent around the queries point of reference
  66351. */
  66352. setDefaultQueryExtent(extent: Vector3): void;
  66353. /**
  66354. * Get the Bounding box extent specified by setDefaultQueryExtent
  66355. * @returns the box extent values
  66356. */
  66357. getDefaultQueryExtent(): Vector3;
  66358. /**
  66359. * build the navmesh from a previously saved state using getNavmeshData
  66360. * @param data the Uint8Array returned by getNavmeshData
  66361. */
  66362. buildFromNavmeshData(data: Uint8Array): void;
  66363. /**
  66364. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  66365. * @returns data the Uint8Array that can be saved and reused
  66366. */
  66367. getNavmeshData(): Uint8Array;
  66368. /**
  66369. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66370. * @param result output the box extent values
  66371. */
  66372. getDefaultQueryExtentToRef(result: Vector3): void;
  66373. /**
  66374. * Release all resources
  66375. */
  66376. dispose(): void;
  66377. }
  66378. /**
  66379. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  66380. */
  66381. export interface ICrowd {
  66382. /**
  66383. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  66384. * You can attach anything to that node. The node position is updated in the scene update tick.
  66385. * @param pos world position that will be constrained by the navigation mesh
  66386. * @param parameters agent parameters
  66387. * @param transform hooked to the agent that will be update by the scene
  66388. * @returns agent index
  66389. */
  66390. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  66391. /**
  66392. * Returns the agent position in world space
  66393. * @param index agent index returned by addAgent
  66394. * @returns world space position
  66395. */
  66396. getAgentPosition(index: number): Vector3;
  66397. /**
  66398. * Gets the agent position result in world space
  66399. * @param index agent index returned by addAgent
  66400. * @param result output world space position
  66401. */
  66402. getAgentPositionToRef(index: number, result: Vector3): void;
  66403. /**
  66404. * Gets the agent velocity in world space
  66405. * @param index agent index returned by addAgent
  66406. * @returns world space velocity
  66407. */
  66408. getAgentVelocity(index: number): Vector3;
  66409. /**
  66410. * Gets the agent velocity result in world space
  66411. * @param index agent index returned by addAgent
  66412. * @param result output world space velocity
  66413. */
  66414. getAgentVelocityToRef(index: number, result: Vector3): void;
  66415. /**
  66416. * remove a particular agent previously created
  66417. * @param index agent index returned by addAgent
  66418. */
  66419. removeAgent(index: number): void;
  66420. /**
  66421. * get the list of all agents attached to this crowd
  66422. * @returns list of agent indices
  66423. */
  66424. getAgents(): number[];
  66425. /**
  66426. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  66427. * @param deltaTime in seconds
  66428. */
  66429. update(deltaTime: number): void;
  66430. /**
  66431. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  66432. * @param index agent index returned by addAgent
  66433. * @param destination targeted world position
  66434. */
  66435. agentGoto(index: number, destination: Vector3): void;
  66436. /**
  66437. * Teleport the agent to a new position
  66438. * @param index agent index returned by addAgent
  66439. * @param destination targeted world position
  66440. */
  66441. agentTeleport(index: number, destination: Vector3): void;
  66442. /**
  66443. * Update agent parameters
  66444. * @param index agent index returned by addAgent
  66445. * @param parameters agent parameters
  66446. */
  66447. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  66448. /**
  66449. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66450. * The queries will try to find a solution within those bounds
  66451. * default is (1,1,1)
  66452. * @param extent x,y,z value that define the extent around the queries point of reference
  66453. */
  66454. setDefaultQueryExtent(extent: Vector3): void;
  66455. /**
  66456. * Get the Bounding box extent specified by setDefaultQueryExtent
  66457. * @returns the box extent values
  66458. */
  66459. getDefaultQueryExtent(): Vector3;
  66460. /**
  66461. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66462. * @param result output the box extent values
  66463. */
  66464. getDefaultQueryExtentToRef(result: Vector3): void;
  66465. /**
  66466. * Release all resources
  66467. */
  66468. dispose(): void;
  66469. }
  66470. /**
  66471. * Configures an agent
  66472. */
  66473. export interface IAgentParameters {
  66474. /**
  66475. * Agent radius. [Limit: >= 0]
  66476. */
  66477. radius: number;
  66478. /**
  66479. * Agent height. [Limit: > 0]
  66480. */
  66481. height: number;
  66482. /**
  66483. * Maximum allowed acceleration. [Limit: >= 0]
  66484. */
  66485. maxAcceleration: number;
  66486. /**
  66487. * Maximum allowed speed. [Limit: >= 0]
  66488. */
  66489. maxSpeed: number;
  66490. /**
  66491. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  66492. */
  66493. collisionQueryRange: number;
  66494. /**
  66495. * The path visibility optimization range. [Limit: > 0]
  66496. */
  66497. pathOptimizationRange: number;
  66498. /**
  66499. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  66500. */
  66501. separationWeight: number;
  66502. }
  66503. /**
  66504. * Configures the navigation mesh creation
  66505. */
  66506. export interface INavMeshParameters {
  66507. /**
  66508. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  66509. */
  66510. cs: number;
  66511. /**
  66512. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  66513. */
  66514. ch: number;
  66515. /**
  66516. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  66517. */
  66518. walkableSlopeAngle: number;
  66519. /**
  66520. * Minimum floor to 'ceiling' height that will still allow the floor area to
  66521. * be considered walkable. [Limit: >= 3] [Units: vx]
  66522. */
  66523. walkableHeight: number;
  66524. /**
  66525. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  66526. */
  66527. walkableClimb: number;
  66528. /**
  66529. * The distance to erode/shrink the walkable area of the heightfield away from
  66530. * obstructions. [Limit: >=0] [Units: vx]
  66531. */
  66532. walkableRadius: number;
  66533. /**
  66534. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  66535. */
  66536. maxEdgeLen: number;
  66537. /**
  66538. * The maximum distance a simplfied contour's border edges should deviate
  66539. * the original raw contour. [Limit: >=0] [Units: vx]
  66540. */
  66541. maxSimplificationError: number;
  66542. /**
  66543. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  66544. */
  66545. minRegionArea: number;
  66546. /**
  66547. * Any regions with a span count smaller than this value will, if possible,
  66548. * be merged with larger regions. [Limit: >=0] [Units: vx]
  66549. */
  66550. mergeRegionArea: number;
  66551. /**
  66552. * The maximum number of vertices allowed for polygons generated during the
  66553. * contour to polygon conversion process. [Limit: >= 3]
  66554. */
  66555. maxVertsPerPoly: number;
  66556. /**
  66557. * Sets the sampling distance to use when generating the detail mesh.
  66558. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  66559. */
  66560. detailSampleDist: number;
  66561. /**
  66562. * The maximum distance the detail mesh surface should deviate from heightfield
  66563. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  66564. */
  66565. detailSampleMaxError: number;
  66566. }
  66567. }
  66568. declare module BABYLON {
  66569. /**
  66570. * RecastJS navigation plugin
  66571. */
  66572. export class RecastJSPlugin implements INavigationEnginePlugin {
  66573. /**
  66574. * Reference to the Recast library
  66575. */
  66576. bjsRECAST: any;
  66577. /**
  66578. * plugin name
  66579. */
  66580. name: string;
  66581. /**
  66582. * the first navmesh created. We might extend this to support multiple navmeshes
  66583. */
  66584. navMesh: any;
  66585. /**
  66586. * Initializes the recastJS plugin
  66587. * @param recastInjection can be used to inject your own recast reference
  66588. */
  66589. constructor(recastInjection?: any);
  66590. /**
  66591. * Creates a navigation mesh
  66592. * @param meshes array of all the geometry used to compute the navigatio mesh
  66593. * @param parameters bunch of parameters used to filter geometry
  66594. */
  66595. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  66596. /**
  66597. * Create a navigation mesh debug mesh
  66598. * @param scene is where the mesh will be added
  66599. * @returns debug display mesh
  66600. */
  66601. createDebugNavMesh(scene: Scene): Mesh;
  66602. /**
  66603. * Get a navigation mesh constrained position, closest to the parameter position
  66604. * @param position world position
  66605. * @returns the closest point to position constrained by the navigation mesh
  66606. */
  66607. getClosestPoint(position: Vector3): Vector3;
  66608. /**
  66609. * Get a navigation mesh constrained position, closest to the parameter position
  66610. * @param position world position
  66611. * @param result output the closest point to position constrained by the navigation mesh
  66612. */
  66613. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66614. /**
  66615. * Get a navigation mesh constrained position, within a particular radius
  66616. * @param position world position
  66617. * @param maxRadius the maximum distance to the constrained world position
  66618. * @returns the closest point to position constrained by the navigation mesh
  66619. */
  66620. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66621. /**
  66622. * Get a navigation mesh constrained position, within a particular radius
  66623. * @param position world position
  66624. * @param maxRadius the maximum distance to the constrained world position
  66625. * @param result output the closest point to position constrained by the navigation mesh
  66626. */
  66627. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  66628. /**
  66629. * Compute the final position from a segment made of destination-position
  66630. * @param position world position
  66631. * @param destination world position
  66632. * @returns the resulting point along the navmesh
  66633. */
  66634. moveAlong(position: Vector3, destination: Vector3): Vector3;
  66635. /**
  66636. * Compute the final position from a segment made of destination-position
  66637. * @param position world position
  66638. * @param destination world position
  66639. * @param result output the resulting point along the navmesh
  66640. */
  66641. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  66642. /**
  66643. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  66644. * @param start world position
  66645. * @param end world position
  66646. * @returns array containing world position composing the path
  66647. */
  66648. computePath(start: Vector3, end: Vector3): Vector3[];
  66649. /**
  66650. * Create a new Crowd so you can add agents
  66651. * @param maxAgents the maximum agent count in the crowd
  66652. * @param maxAgentRadius the maximum radius an agent can have
  66653. * @param scene to attach the crowd to
  66654. * @returns the crowd you can add agents to
  66655. */
  66656. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  66657. /**
  66658. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66659. * The queries will try to find a solution within those bounds
  66660. * default is (1,1,1)
  66661. * @param extent x,y,z value that define the extent around the queries point of reference
  66662. */
  66663. setDefaultQueryExtent(extent: Vector3): void;
  66664. /**
  66665. * Get the Bounding box extent specified by setDefaultQueryExtent
  66666. * @returns the box extent values
  66667. */
  66668. getDefaultQueryExtent(): Vector3;
  66669. /**
  66670. * build the navmesh from a previously saved state using getNavmeshData
  66671. * @param data the Uint8Array returned by getNavmeshData
  66672. */
  66673. buildFromNavmeshData(data: Uint8Array): void;
  66674. /**
  66675. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  66676. * @returns data the Uint8Array that can be saved and reused
  66677. */
  66678. getNavmeshData(): Uint8Array;
  66679. /**
  66680. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66681. * @param result output the box extent values
  66682. */
  66683. getDefaultQueryExtentToRef(result: Vector3): void;
  66684. /**
  66685. * Disposes
  66686. */
  66687. dispose(): void;
  66688. /**
  66689. * If this plugin is supported
  66690. * @returns true if plugin is supported
  66691. */
  66692. isSupported(): boolean;
  66693. }
  66694. /**
  66695. * Recast detour crowd implementation
  66696. */
  66697. export class RecastJSCrowd implements ICrowd {
  66698. /**
  66699. * Recast/detour plugin
  66700. */
  66701. bjsRECASTPlugin: RecastJSPlugin;
  66702. /**
  66703. * Link to the detour crowd
  66704. */
  66705. recastCrowd: any;
  66706. /**
  66707. * One transform per agent
  66708. */
  66709. transforms: TransformNode[];
  66710. /**
  66711. * All agents created
  66712. */
  66713. agents: number[];
  66714. /**
  66715. * Link to the scene is kept to unregister the crowd from the scene
  66716. */
  66717. private _scene;
  66718. /**
  66719. * Observer for crowd updates
  66720. */
  66721. private _onBeforeAnimationsObserver;
  66722. /**
  66723. * Constructor
  66724. * @param plugin recastJS plugin
  66725. * @param maxAgents the maximum agent count in the crowd
  66726. * @param maxAgentRadius the maximum radius an agent can have
  66727. * @param scene to attach the crowd to
  66728. * @returns the crowd you can add agents to
  66729. */
  66730. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  66731. /**
  66732. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  66733. * You can attach anything to that node. The node position is updated in the scene update tick.
  66734. * @param pos world position that will be constrained by the navigation mesh
  66735. * @param parameters agent parameters
  66736. * @param transform hooked to the agent that will be update by the scene
  66737. * @returns agent index
  66738. */
  66739. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  66740. /**
  66741. * Returns the agent position in world space
  66742. * @param index agent index returned by addAgent
  66743. * @returns world space position
  66744. */
  66745. getAgentPosition(index: number): Vector3;
  66746. /**
  66747. * Returns the agent position result in world space
  66748. * @param index agent index returned by addAgent
  66749. * @param result output world space position
  66750. */
  66751. getAgentPositionToRef(index: number, result: Vector3): void;
  66752. /**
  66753. * Returns the agent velocity in world space
  66754. * @param index agent index returned by addAgent
  66755. * @returns world space velocity
  66756. */
  66757. getAgentVelocity(index: number): Vector3;
  66758. /**
  66759. * Returns the agent velocity result in world space
  66760. * @param index agent index returned by addAgent
  66761. * @param result output world space velocity
  66762. */
  66763. getAgentVelocityToRef(index: number, result: Vector3): void;
  66764. /**
  66765. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  66766. * @param index agent index returned by addAgent
  66767. * @param destination targeted world position
  66768. */
  66769. agentGoto(index: number, destination: Vector3): void;
  66770. /**
  66771. * Teleport the agent to a new position
  66772. * @param index agent index returned by addAgent
  66773. * @param destination targeted world position
  66774. */
  66775. agentTeleport(index: number, destination: Vector3): void;
  66776. /**
  66777. * Update agent parameters
  66778. * @param index agent index returned by addAgent
  66779. * @param parameters agent parameters
  66780. */
  66781. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  66782. /**
  66783. * remove a particular agent previously created
  66784. * @param index agent index returned by addAgent
  66785. */
  66786. removeAgent(index: number): void;
  66787. /**
  66788. * get the list of all agents attached to this crowd
  66789. * @returns list of agent indices
  66790. */
  66791. getAgents(): number[];
  66792. /**
  66793. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  66794. * @param deltaTime in seconds
  66795. */
  66796. update(deltaTime: number): void;
  66797. /**
  66798. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66799. * The queries will try to find a solution within those bounds
  66800. * default is (1,1,1)
  66801. * @param extent x,y,z value that define the extent around the queries point of reference
  66802. */
  66803. setDefaultQueryExtent(extent: Vector3): void;
  66804. /**
  66805. * Get the Bounding box extent specified by setDefaultQueryExtent
  66806. * @returns the box extent values
  66807. */
  66808. getDefaultQueryExtent(): Vector3;
  66809. /**
  66810. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66811. * @param result output the box extent values
  66812. */
  66813. getDefaultQueryExtentToRef(result: Vector3): void;
  66814. /**
  66815. * Release all resources
  66816. */
  66817. dispose(): void;
  66818. }
  66819. }
  66820. declare module BABYLON {
  66821. /**
  66822. * Class used to enable access to IndexedDB
  66823. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  66824. */
  66825. export class Database implements IOfflineProvider {
  66826. private _callbackManifestChecked;
  66827. private _currentSceneUrl;
  66828. private _db;
  66829. private _enableSceneOffline;
  66830. private _enableTexturesOffline;
  66831. private _manifestVersionFound;
  66832. private _mustUpdateRessources;
  66833. private _hasReachedQuota;
  66834. private _isSupported;
  66835. private _idbFactory;
  66836. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  66837. private static IsUASupportingBlobStorage;
  66838. /**
  66839. * Gets a boolean indicating if Database storate is enabled (off by default)
  66840. */
  66841. static IDBStorageEnabled: boolean;
  66842. /**
  66843. * Gets a boolean indicating if scene must be saved in the database
  66844. */
  66845. get enableSceneOffline(): boolean;
  66846. /**
  66847. * Gets a boolean indicating if textures must be saved in the database
  66848. */
  66849. get enableTexturesOffline(): boolean;
  66850. /**
  66851. * Creates a new Database
  66852. * @param urlToScene defines the url to load the scene
  66853. * @param callbackManifestChecked defines the callback to use when manifest is checked
  66854. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  66855. */
  66856. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  66857. private static _ParseURL;
  66858. private static _ReturnFullUrlLocation;
  66859. private _checkManifestFile;
  66860. /**
  66861. * Open the database and make it available
  66862. * @param successCallback defines the callback to call on success
  66863. * @param errorCallback defines the callback to call on error
  66864. */
  66865. open(successCallback: () => void, errorCallback: () => void): void;
  66866. /**
  66867. * Loads an image from the database
  66868. * @param url defines the url to load from
  66869. * @param image defines the target DOM image
  66870. */
  66871. loadImage(url: string, image: HTMLImageElement): void;
  66872. private _loadImageFromDBAsync;
  66873. private _saveImageIntoDBAsync;
  66874. private _checkVersionFromDB;
  66875. private _loadVersionFromDBAsync;
  66876. private _saveVersionIntoDBAsync;
  66877. /**
  66878. * Loads a file from database
  66879. * @param url defines the URL to load from
  66880. * @param sceneLoaded defines a callback to call on success
  66881. * @param progressCallBack defines a callback to call when progress changed
  66882. * @param errorCallback defines a callback to call on error
  66883. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  66884. */
  66885. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  66886. private _loadFileAsync;
  66887. private _saveFileAsync;
  66888. /**
  66889. * Validates if xhr data is correct
  66890. * @param xhr defines the request to validate
  66891. * @param dataType defines the expected data type
  66892. * @returns true if data is correct
  66893. */
  66894. private static _ValidateXHRData;
  66895. }
  66896. }
  66897. declare module BABYLON {
  66898. /** @hidden */
  66899. export var gpuUpdateParticlesPixelShader: {
  66900. name: string;
  66901. shader: string;
  66902. };
  66903. }
  66904. declare module BABYLON {
  66905. /** @hidden */
  66906. export var gpuUpdateParticlesVertexShader: {
  66907. name: string;
  66908. shader: string;
  66909. };
  66910. }
  66911. declare module BABYLON {
  66912. /** @hidden */
  66913. export var clipPlaneFragmentDeclaration2: {
  66914. name: string;
  66915. shader: string;
  66916. };
  66917. }
  66918. declare module BABYLON {
  66919. /** @hidden */
  66920. export var gpuRenderParticlesPixelShader: {
  66921. name: string;
  66922. shader: string;
  66923. };
  66924. }
  66925. declare module BABYLON {
  66926. /** @hidden */
  66927. export var clipPlaneVertexDeclaration2: {
  66928. name: string;
  66929. shader: string;
  66930. };
  66931. }
  66932. declare module BABYLON {
  66933. /** @hidden */
  66934. export var gpuRenderParticlesVertexShader: {
  66935. name: string;
  66936. shader: string;
  66937. };
  66938. }
  66939. declare module BABYLON {
  66940. /**
  66941. * This represents a GPU particle system in Babylon
  66942. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  66943. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  66944. */
  66945. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  66946. /**
  66947. * The layer mask we are rendering the particles through.
  66948. */
  66949. layerMask: number;
  66950. private _capacity;
  66951. private _activeCount;
  66952. private _currentActiveCount;
  66953. private _accumulatedCount;
  66954. private _renderEffect;
  66955. private _updateEffect;
  66956. private _buffer0;
  66957. private _buffer1;
  66958. private _spriteBuffer;
  66959. private _updateVAO;
  66960. private _renderVAO;
  66961. private _targetIndex;
  66962. private _sourceBuffer;
  66963. private _targetBuffer;
  66964. private _engine;
  66965. private _currentRenderId;
  66966. private _started;
  66967. private _stopped;
  66968. private _timeDelta;
  66969. private _randomTexture;
  66970. private _randomTexture2;
  66971. private _attributesStrideSize;
  66972. private _updateEffectOptions;
  66973. private _randomTextureSize;
  66974. private _actualFrame;
  66975. private _customEffect;
  66976. private readonly _rawTextureWidth;
  66977. /**
  66978. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  66979. */
  66980. static get IsSupported(): boolean;
  66981. /**
  66982. * An event triggered when the system is disposed.
  66983. */
  66984. onDisposeObservable: Observable<IParticleSystem>;
  66985. /**
  66986. * Gets the maximum number of particles active at the same time.
  66987. * @returns The max number of active particles.
  66988. */
  66989. getCapacity(): number;
  66990. /**
  66991. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  66992. * to override the particles.
  66993. */
  66994. forceDepthWrite: boolean;
  66995. /**
  66996. * Gets or set the number of active particles
  66997. */
  66998. get activeParticleCount(): number;
  66999. set activeParticleCount(value: number);
  67000. private _preWarmDone;
  67001. /**
  67002. * Specifies if the particles are updated in emitter local space or world space.
  67003. */
  67004. isLocal: boolean;
  67005. /**
  67006. * Is this system ready to be used/rendered
  67007. * @return true if the system is ready
  67008. */
  67009. isReady(): boolean;
  67010. /**
  67011. * Gets if the system has been started. (Note: this will still be true after stop is called)
  67012. * @returns True if it has been started, otherwise false.
  67013. */
  67014. isStarted(): boolean;
  67015. /**
  67016. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  67017. * @returns True if it has been stopped, otherwise false.
  67018. */
  67019. isStopped(): boolean;
  67020. /**
  67021. * Gets a boolean indicating that the system is stopping
  67022. * @returns true if the system is currently stopping
  67023. */
  67024. isStopping(): boolean;
  67025. /**
  67026. * Gets the number of particles active at the same time.
  67027. * @returns The number of active particles.
  67028. */
  67029. getActiveCount(): number;
  67030. /**
  67031. * Starts the particle system and begins to emit
  67032. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  67033. */
  67034. start(delay?: number): void;
  67035. /**
  67036. * Stops the particle system.
  67037. */
  67038. stop(): void;
  67039. /**
  67040. * Remove all active particles
  67041. */
  67042. reset(): void;
  67043. /**
  67044. * Returns the string "GPUParticleSystem"
  67045. * @returns a string containing the class name
  67046. */
  67047. getClassName(): string;
  67048. /**
  67049. * Gets the custom effect used to render the particles
  67050. * @param blendMode Blend mode for which the effect should be retrieved
  67051. * @returns The effect
  67052. */
  67053. getCustomEffect(blendMode?: number): Nullable<Effect>;
  67054. /**
  67055. * Sets the custom effect used to render the particles
  67056. * @param effect The effect to set
  67057. * @param blendMode Blend mode for which the effect should be set
  67058. */
  67059. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  67060. /** @hidden */
  67061. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  67062. /**
  67063. * Observable that will be called just before the particles are drawn
  67064. */
  67065. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  67066. /**
  67067. * Gets the name of the particle vertex shader
  67068. */
  67069. get vertexShaderName(): string;
  67070. private _colorGradientsTexture;
  67071. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  67072. /**
  67073. * Adds a new color gradient
  67074. * @param gradient defines the gradient to use (between 0 and 1)
  67075. * @param color1 defines the color to affect to the specified gradient
  67076. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  67077. * @returns the current particle system
  67078. */
  67079. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  67080. private _refreshColorGradient;
  67081. /** Force the system to rebuild all gradients that need to be resync */
  67082. forceRefreshGradients(): void;
  67083. /**
  67084. * Remove a specific color gradient
  67085. * @param gradient defines the gradient to remove
  67086. * @returns the current particle system
  67087. */
  67088. removeColorGradient(gradient: number): GPUParticleSystem;
  67089. private _angularSpeedGradientsTexture;
  67090. private _sizeGradientsTexture;
  67091. private _velocityGradientsTexture;
  67092. private _limitVelocityGradientsTexture;
  67093. private _dragGradientsTexture;
  67094. private _addFactorGradient;
  67095. /**
  67096. * Adds a new size gradient
  67097. * @param gradient defines the gradient to use (between 0 and 1)
  67098. * @param factor defines the size factor to affect to the specified gradient
  67099. * @returns the current particle system
  67100. */
  67101. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  67102. /**
  67103. * Remove a specific size gradient
  67104. * @param gradient defines the gradient to remove
  67105. * @returns the current particle system
  67106. */
  67107. removeSizeGradient(gradient: number): GPUParticleSystem;
  67108. private _refreshFactorGradient;
  67109. /**
  67110. * Adds a new angular speed gradient
  67111. * @param gradient defines the gradient to use (between 0 and 1)
  67112. * @param factor defines the angular speed to affect to the specified gradient
  67113. * @returns the current particle system
  67114. */
  67115. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  67116. /**
  67117. * Remove a specific angular speed gradient
  67118. * @param gradient defines the gradient to remove
  67119. * @returns the current particle system
  67120. */
  67121. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  67122. /**
  67123. * Adds a new velocity gradient
  67124. * @param gradient defines the gradient to use (between 0 and 1)
  67125. * @param factor defines the velocity to affect to the specified gradient
  67126. * @returns the current particle system
  67127. */
  67128. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67129. /**
  67130. * Remove a specific velocity gradient
  67131. * @param gradient defines the gradient to remove
  67132. * @returns the current particle system
  67133. */
  67134. removeVelocityGradient(gradient: number): GPUParticleSystem;
  67135. /**
  67136. * Adds a new limit velocity gradient
  67137. * @param gradient defines the gradient to use (between 0 and 1)
  67138. * @param factor defines the limit velocity value to affect to the specified gradient
  67139. * @returns the current particle system
  67140. */
  67141. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67142. /**
  67143. * Remove a specific limit velocity gradient
  67144. * @param gradient defines the gradient to remove
  67145. * @returns the current particle system
  67146. */
  67147. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  67148. /**
  67149. * Adds a new drag gradient
  67150. * @param gradient defines the gradient to use (between 0 and 1)
  67151. * @param factor defines the drag value to affect to the specified gradient
  67152. * @returns the current particle system
  67153. */
  67154. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  67155. /**
  67156. * Remove a specific drag gradient
  67157. * @param gradient defines the gradient to remove
  67158. * @returns the current particle system
  67159. */
  67160. removeDragGradient(gradient: number): GPUParticleSystem;
  67161. /**
  67162. * Not supported by GPUParticleSystem
  67163. * @param gradient defines the gradient to use (between 0 and 1)
  67164. * @param factor defines the emit rate value to affect to the specified gradient
  67165. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67166. * @returns the current particle system
  67167. */
  67168. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67169. /**
  67170. * Not supported by GPUParticleSystem
  67171. * @param gradient defines the gradient to remove
  67172. * @returns the current particle system
  67173. */
  67174. removeEmitRateGradient(gradient: number): IParticleSystem;
  67175. /**
  67176. * Not supported by GPUParticleSystem
  67177. * @param gradient defines the gradient to use (between 0 and 1)
  67178. * @param factor defines the start size value to affect to the specified gradient
  67179. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67180. * @returns the current particle system
  67181. */
  67182. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67183. /**
  67184. * Not supported by GPUParticleSystem
  67185. * @param gradient defines the gradient to remove
  67186. * @returns the current particle system
  67187. */
  67188. removeStartSizeGradient(gradient: number): IParticleSystem;
  67189. /**
  67190. * Not supported by GPUParticleSystem
  67191. * @param gradient defines the gradient to use (between 0 and 1)
  67192. * @param min defines the color remap minimal range
  67193. * @param max defines the color remap maximal range
  67194. * @returns the current particle system
  67195. */
  67196. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67197. /**
  67198. * Not supported by GPUParticleSystem
  67199. * @param gradient defines the gradient to remove
  67200. * @returns the current particle system
  67201. */
  67202. removeColorRemapGradient(): IParticleSystem;
  67203. /**
  67204. * Not supported by GPUParticleSystem
  67205. * @param gradient defines the gradient to use (between 0 and 1)
  67206. * @param min defines the alpha remap minimal range
  67207. * @param max defines the alpha remap maximal range
  67208. * @returns the current particle system
  67209. */
  67210. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  67211. /**
  67212. * Not supported by GPUParticleSystem
  67213. * @param gradient defines the gradient to remove
  67214. * @returns the current particle system
  67215. */
  67216. removeAlphaRemapGradient(): IParticleSystem;
  67217. /**
  67218. * Not supported by GPUParticleSystem
  67219. * @param gradient defines the gradient to use (between 0 and 1)
  67220. * @param color defines the color to affect to the specified gradient
  67221. * @returns the current particle system
  67222. */
  67223. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  67224. /**
  67225. * Not supported by GPUParticleSystem
  67226. * @param gradient defines the gradient to remove
  67227. * @returns the current particle system
  67228. */
  67229. removeRampGradient(): IParticleSystem;
  67230. /**
  67231. * Not supported by GPUParticleSystem
  67232. * @returns the list of ramp gradients
  67233. */
  67234. getRampGradients(): Nullable<Array<Color3Gradient>>;
  67235. /**
  67236. * Not supported by GPUParticleSystem
  67237. * Gets or sets a boolean indicating that ramp gradients must be used
  67238. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  67239. */
  67240. get useRampGradients(): boolean;
  67241. set useRampGradients(value: boolean);
  67242. /**
  67243. * Not supported by GPUParticleSystem
  67244. * @param gradient defines the gradient to use (between 0 and 1)
  67245. * @param factor defines the life time factor to affect to the specified gradient
  67246. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67247. * @returns the current particle system
  67248. */
  67249. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67250. /**
  67251. * Not supported by GPUParticleSystem
  67252. * @param gradient defines the gradient to remove
  67253. * @returns the current particle system
  67254. */
  67255. removeLifeTimeGradient(gradient: number): IParticleSystem;
  67256. /**
  67257. * Instantiates a GPU particle system.
  67258. * 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.
  67259. * @param name The name of the particle system
  67260. * @param options The options used to create the system
  67261. * @param scene The scene the particle system belongs to
  67262. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  67263. * @param customEffect a custom effect used to change the way particles are rendered by default
  67264. */
  67265. constructor(name: string, options: Partial<{
  67266. capacity: number;
  67267. randomTextureSize: number;
  67268. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  67269. protected _reset(): void;
  67270. private _createUpdateVAO;
  67271. private _createRenderVAO;
  67272. private _initialize;
  67273. /** @hidden */
  67274. _recreateUpdateEffect(): void;
  67275. private _getEffect;
  67276. /**
  67277. * Fill the defines array according to the current settings of the particle system
  67278. * @param defines Array to be updated
  67279. * @param blendMode blend mode to take into account when updating the array
  67280. */
  67281. fillDefines(defines: Array<string>, blendMode?: number): void;
  67282. /**
  67283. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  67284. * @param uniforms Uniforms array to fill
  67285. * @param attributes Attributes array to fill
  67286. * @param samplers Samplers array to fill
  67287. */
  67288. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  67289. /** @hidden */
  67290. _recreateRenderEffect(): Effect;
  67291. /**
  67292. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  67293. * @param preWarm defines if we are in the pre-warmimg phase
  67294. */
  67295. animate(preWarm?: boolean): void;
  67296. private _createFactorGradientTexture;
  67297. private _createSizeGradientTexture;
  67298. private _createAngularSpeedGradientTexture;
  67299. private _createVelocityGradientTexture;
  67300. private _createLimitVelocityGradientTexture;
  67301. private _createDragGradientTexture;
  67302. private _createColorGradientTexture;
  67303. /**
  67304. * Renders the particle system in its current state
  67305. * @param preWarm defines if the system should only update the particles but not render them
  67306. * @returns the current number of particles
  67307. */
  67308. render(preWarm?: boolean): number;
  67309. /**
  67310. * Rebuilds the particle system
  67311. */
  67312. rebuild(): void;
  67313. private _releaseBuffers;
  67314. private _releaseVAOs;
  67315. /**
  67316. * Disposes the particle system and free the associated resources
  67317. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  67318. */
  67319. dispose(disposeTexture?: boolean): void;
  67320. /**
  67321. * Clones the particle system.
  67322. * @param name The name of the cloned object
  67323. * @param newEmitter The new emitter to use
  67324. * @returns the cloned particle system
  67325. */
  67326. clone(name: string, newEmitter: any): GPUParticleSystem;
  67327. /**
  67328. * Serializes the particle system to a JSON object
  67329. * @param serializeTexture defines if the texture must be serialized as well
  67330. * @returns the JSON object
  67331. */
  67332. serialize(serializeTexture?: boolean): any;
  67333. /**
  67334. * Parses a JSON object to create a GPU particle system.
  67335. * @param parsedParticleSystem The JSON object to parse
  67336. * @param scene The scene to create the particle system in
  67337. * @param rootUrl The root url to use to load external dependencies like texture
  67338. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  67339. * @returns the parsed GPU particle system
  67340. */
  67341. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  67342. }
  67343. }
  67344. declare module BABYLON {
  67345. /**
  67346. * Represents a set of particle systems working together to create a specific effect
  67347. */
  67348. export class ParticleSystemSet implements IDisposable {
  67349. /**
  67350. * Gets or sets base Assets URL
  67351. */
  67352. static BaseAssetsUrl: string;
  67353. private _emitterCreationOptions;
  67354. private _emitterNode;
  67355. /**
  67356. * Gets the particle system list
  67357. */
  67358. systems: IParticleSystem[];
  67359. /**
  67360. * Gets the emitter node used with this set
  67361. */
  67362. get emitterNode(): Nullable<TransformNode>;
  67363. /**
  67364. * Creates a new emitter mesh as a sphere
  67365. * @param options defines the options used to create the sphere
  67366. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  67367. * @param scene defines the hosting scene
  67368. */
  67369. setEmitterAsSphere(options: {
  67370. diameter: number;
  67371. segments: number;
  67372. color: Color3;
  67373. }, renderingGroupId: number, scene: Scene): void;
  67374. /**
  67375. * Starts all particle systems of the set
  67376. * @param emitter defines an optional mesh to use as emitter for the particle systems
  67377. */
  67378. start(emitter?: AbstractMesh): void;
  67379. /**
  67380. * Release all associated resources
  67381. */
  67382. dispose(): void;
  67383. /**
  67384. * Serialize the set into a JSON compatible object
  67385. * @param serializeTexture defines if the texture must be serialized as well
  67386. * @returns a JSON compatible representation of the set
  67387. */
  67388. serialize(serializeTexture?: boolean): any;
  67389. /**
  67390. * Parse a new ParticleSystemSet from a serialized source
  67391. * @param data defines a JSON compatible representation of the set
  67392. * @param scene defines the hosting scene
  67393. * @param gpu defines if we want GPU particles or CPU particles
  67394. * @returns a new ParticleSystemSet
  67395. */
  67396. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  67397. }
  67398. }
  67399. declare module BABYLON {
  67400. /**
  67401. * This class is made for on one-liner static method to help creating particle system set.
  67402. */
  67403. export class ParticleHelper {
  67404. /**
  67405. * Gets or sets base Assets URL
  67406. */
  67407. static BaseAssetsUrl: string;
  67408. /** Define the Url to load snippets */
  67409. static SnippetUrl: string;
  67410. /**
  67411. * Create a default particle system that you can tweak
  67412. * @param emitter defines the emitter to use
  67413. * @param capacity defines the system capacity (default is 500 particles)
  67414. * @param scene defines the hosting scene
  67415. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  67416. * @returns the new Particle system
  67417. */
  67418. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  67419. /**
  67420. * This is the main static method (one-liner) of this helper to create different particle systems
  67421. * @param type This string represents the type to the particle system to create
  67422. * @param scene The scene where the particle system should live
  67423. * @param gpu If the system will use gpu
  67424. * @returns the ParticleSystemSet created
  67425. */
  67426. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  67427. /**
  67428. * Static function used to export a particle system to a ParticleSystemSet variable.
  67429. * Please note that the emitter shape is not exported
  67430. * @param systems defines the particle systems to export
  67431. * @returns the created particle system set
  67432. */
  67433. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  67434. /**
  67435. * Creates a particle system from a snippet saved in a remote file
  67436. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  67437. * @param url defines the url to load from
  67438. * @param scene defines the hosting scene
  67439. * @param gpu If the system will use gpu
  67440. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67441. * @returns a promise that will resolve to the new particle system
  67442. */
  67443. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  67444. /**
  67445. * Creates a particle system from a snippet saved by the particle system editor
  67446. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  67447. * @param scene defines the hosting scene
  67448. * @param gpu If the system will use gpu
  67449. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67450. * @returns a promise that will resolve to the new particle system
  67451. */
  67452. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  67453. }
  67454. }
  67455. declare module BABYLON {
  67456. interface Engine {
  67457. /**
  67458. * Create an effect to use with particle systems.
  67459. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  67460. * the particle system for which you want to create a custom effect in the last parameter
  67461. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  67462. * @param uniformsNames defines a list of attribute names
  67463. * @param samplers defines an array of string used to represent textures
  67464. * @param defines defines the string containing the defines to use to compile the shaders
  67465. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  67466. * @param onCompiled defines a function to call when the effect creation is successful
  67467. * @param onError defines a function to call when the effect creation has failed
  67468. * @param particleSystem the particle system you want to create the effect for
  67469. * @returns the new Effect
  67470. */
  67471. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  67472. }
  67473. interface Mesh {
  67474. /**
  67475. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  67476. * @returns an array of IParticleSystem
  67477. */
  67478. getEmittedParticleSystems(): IParticleSystem[];
  67479. /**
  67480. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  67481. * @returns an array of IParticleSystem
  67482. */
  67483. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  67484. }
  67485. }
  67486. declare module BABYLON {
  67487. /** Defines the 4 color options */
  67488. export enum PointColor {
  67489. /** color value */
  67490. Color = 2,
  67491. /** uv value */
  67492. UV = 1,
  67493. /** random value */
  67494. Random = 0,
  67495. /** stated value */
  67496. Stated = 3
  67497. }
  67498. /**
  67499. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  67500. * 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.
  67501. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  67502. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  67503. *
  67504. * Full documentation here : TO BE ENTERED
  67505. */
  67506. export class PointsCloudSystem implements IDisposable {
  67507. /**
  67508. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  67509. * Example : var p = SPS.particles[i];
  67510. */
  67511. particles: CloudPoint[];
  67512. /**
  67513. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  67514. */
  67515. nbParticles: number;
  67516. /**
  67517. * This a counter for your own usage. It's not set by any SPS functions.
  67518. */
  67519. counter: number;
  67520. /**
  67521. * The PCS name. This name is also given to the underlying mesh.
  67522. */
  67523. name: string;
  67524. /**
  67525. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  67526. */
  67527. mesh: Mesh;
  67528. /**
  67529. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  67530. * Please read :
  67531. */
  67532. vars: any;
  67533. /**
  67534. * @hidden
  67535. */
  67536. _size: number;
  67537. private _scene;
  67538. private _promises;
  67539. private _positions;
  67540. private _indices;
  67541. private _normals;
  67542. private _colors;
  67543. private _uvs;
  67544. private _indices32;
  67545. private _positions32;
  67546. private _colors32;
  67547. private _uvs32;
  67548. private _updatable;
  67549. private _isVisibilityBoxLocked;
  67550. private _alwaysVisible;
  67551. private _groups;
  67552. private _groupCounter;
  67553. private _computeParticleColor;
  67554. private _computeParticleTexture;
  67555. private _computeParticleRotation;
  67556. private _computeBoundingBox;
  67557. private _isReady;
  67558. /**
  67559. * Creates a PCS (Points Cloud System) object
  67560. * @param name (String) is the PCS name, this will be the underlying mesh name
  67561. * @param pointSize (number) is the size for each point
  67562. * @param scene (Scene) is the scene in which the PCS is added
  67563. * @param options defines the options of the PCS e.g.
  67564. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  67565. */
  67566. constructor(name: string, pointSize: number, scene: Scene, options?: {
  67567. updatable?: boolean;
  67568. });
  67569. /**
  67570. * Builds the PCS underlying mesh. Returns a standard Mesh.
  67571. * If no points were added to the PCS, the returned mesh is just a single point.
  67572. * @returns a promise for the created mesh
  67573. */
  67574. buildMeshAsync(): Promise<Mesh>;
  67575. /**
  67576. * @hidden
  67577. */
  67578. private _buildMesh;
  67579. private _addParticle;
  67580. private _randomUnitVector;
  67581. private _getColorIndicesForCoord;
  67582. private _setPointsColorOrUV;
  67583. private _colorFromTexture;
  67584. private _calculateDensity;
  67585. /**
  67586. * Adds points to the PCS in random positions within a unit sphere
  67587. * @param nb (positive integer) the number of particles to be created from this model
  67588. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  67589. * @returns the number of groups in the system
  67590. */
  67591. addPoints(nb: number, pointFunction?: any): number;
  67592. /**
  67593. * Adds points to the PCS from the surface of the model shape
  67594. * @param mesh is any Mesh object that will be used as a surface model for the points
  67595. * @param nb (positive integer) the number of particles to be created from this model
  67596. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67597. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67598. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67599. * @returns the number of groups in the system
  67600. */
  67601. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67602. /**
  67603. * Adds points to the PCS inside the model shape
  67604. * @param mesh is any Mesh object that will be used as a surface model for the points
  67605. * @param nb (positive integer) the number of particles to be created from this model
  67606. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67607. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67608. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67609. * @returns the number of groups in the system
  67610. */
  67611. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67612. /**
  67613. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  67614. * This method calls `updateParticle()` for each particle of the SPS.
  67615. * For an animated SPS, it is usually called within the render loop.
  67616. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  67617. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  67618. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  67619. * @returns the PCS.
  67620. */
  67621. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  67622. /**
  67623. * Disposes the PCS.
  67624. */
  67625. dispose(): void;
  67626. /**
  67627. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  67628. * doc :
  67629. * @returns the PCS.
  67630. */
  67631. refreshVisibleSize(): PointsCloudSystem;
  67632. /**
  67633. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  67634. * @param size the size (float) of the visibility box
  67635. * note : this doesn't lock the PCS mesh bounding box.
  67636. * doc :
  67637. */
  67638. setVisibilityBox(size: number): void;
  67639. /**
  67640. * Gets whether the PCS is always visible or not
  67641. * doc :
  67642. */
  67643. get isAlwaysVisible(): boolean;
  67644. /**
  67645. * Sets the PCS as always visible or not
  67646. * doc :
  67647. */
  67648. set isAlwaysVisible(val: boolean);
  67649. /**
  67650. * Tells to `setParticles()` to compute the particle rotations or not
  67651. * Default value : false. The PCS is faster when it's set to false
  67652. * Note : particle rotations are only applied to parent particles
  67653. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  67654. */
  67655. set computeParticleRotation(val: boolean);
  67656. /**
  67657. * Tells to `setParticles()` to compute the particle colors or not.
  67658. * Default value : true. The PCS is faster when it's set to false.
  67659. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  67660. */
  67661. set computeParticleColor(val: boolean);
  67662. set computeParticleTexture(val: boolean);
  67663. /**
  67664. * Gets if `setParticles()` computes the particle colors or not.
  67665. * Default value : false. The PCS is faster when it's set to false.
  67666. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  67667. */
  67668. get computeParticleColor(): boolean;
  67669. /**
  67670. * Gets if `setParticles()` computes the particle textures or not.
  67671. * Default value : false. The PCS is faster when it's set to false.
  67672. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  67673. */
  67674. get computeParticleTexture(): boolean;
  67675. /**
  67676. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  67677. */
  67678. set computeBoundingBox(val: boolean);
  67679. /**
  67680. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  67681. */
  67682. get computeBoundingBox(): boolean;
  67683. /**
  67684. * This function does nothing. It may be overwritten to set all the particle first values.
  67685. * The PCS doesn't call this function, you may have to call it by your own.
  67686. * doc :
  67687. */
  67688. initParticles(): void;
  67689. /**
  67690. * This function does nothing. It may be overwritten to recycle a particle
  67691. * The PCS doesn't call this function, you can to call it
  67692. * doc :
  67693. * @param particle The particle to recycle
  67694. * @returns the recycled particle
  67695. */
  67696. recycleParticle(particle: CloudPoint): CloudPoint;
  67697. /**
  67698. * Updates a particle : this function should be overwritten by the user.
  67699. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  67700. * doc :
  67701. * @example : just set a particle position or velocity and recycle conditions
  67702. * @param particle The particle to update
  67703. * @returns the updated particle
  67704. */
  67705. updateParticle(particle: CloudPoint): CloudPoint;
  67706. /**
  67707. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  67708. * This does nothing and may be overwritten by the user.
  67709. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  67710. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  67711. * @param update the boolean update value actually passed to setParticles()
  67712. */
  67713. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  67714. /**
  67715. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  67716. * This will be passed three parameters.
  67717. * This does nothing and may be overwritten by the user.
  67718. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  67719. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  67720. * @param update the boolean update value actually passed to setParticles()
  67721. */
  67722. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  67723. }
  67724. }
  67725. declare module BABYLON {
  67726. /**
  67727. * Represents one particle of a points cloud system.
  67728. */
  67729. export class CloudPoint {
  67730. /**
  67731. * particle global index
  67732. */
  67733. idx: number;
  67734. /**
  67735. * The color of the particle
  67736. */
  67737. color: Nullable<Color4>;
  67738. /**
  67739. * The world space position of the particle.
  67740. */
  67741. position: Vector3;
  67742. /**
  67743. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  67744. */
  67745. rotation: Vector3;
  67746. /**
  67747. * The world space rotation quaternion of the particle.
  67748. */
  67749. rotationQuaternion: Nullable<Quaternion>;
  67750. /**
  67751. * The uv of the particle.
  67752. */
  67753. uv: Nullable<Vector2>;
  67754. /**
  67755. * The current speed of the particle.
  67756. */
  67757. velocity: Vector3;
  67758. /**
  67759. * The pivot point in the particle local space.
  67760. */
  67761. pivot: Vector3;
  67762. /**
  67763. * Must the particle be translated from its pivot point in its local space ?
  67764. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  67765. * Default : false
  67766. */
  67767. translateFromPivot: boolean;
  67768. /**
  67769. * Index of this particle in the global "positions" array (Internal use)
  67770. * @hidden
  67771. */
  67772. _pos: number;
  67773. /**
  67774. * @hidden Index of this particle in the global "indices" array (Internal use)
  67775. */
  67776. _ind: number;
  67777. /**
  67778. * Group this particle belongs to
  67779. */
  67780. _group: PointsGroup;
  67781. /**
  67782. * Group id of this particle
  67783. */
  67784. groupId: number;
  67785. /**
  67786. * Index of the particle in its group id (Internal use)
  67787. */
  67788. idxInGroup: number;
  67789. /**
  67790. * @hidden Particle BoundingInfo object (Internal use)
  67791. */
  67792. _boundingInfo: BoundingInfo;
  67793. /**
  67794. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  67795. */
  67796. _pcs: PointsCloudSystem;
  67797. /**
  67798. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  67799. */
  67800. _stillInvisible: boolean;
  67801. /**
  67802. * @hidden Last computed particle rotation matrix
  67803. */
  67804. _rotationMatrix: number[];
  67805. /**
  67806. * Parent particle Id, if any.
  67807. * Default null.
  67808. */
  67809. parentId: Nullable<number>;
  67810. /**
  67811. * @hidden Internal global position in the PCS.
  67812. */
  67813. _globalPosition: Vector3;
  67814. /**
  67815. * Creates a Point Cloud object.
  67816. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  67817. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  67818. * @param group (PointsGroup) is the group the particle belongs to
  67819. * @param groupId (integer) is the group identifier in the PCS.
  67820. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  67821. * @param pcs defines the PCS it is associated to
  67822. */
  67823. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  67824. /**
  67825. * get point size
  67826. */
  67827. get size(): Vector3;
  67828. /**
  67829. * Set point size
  67830. */
  67831. set size(scale: Vector3);
  67832. /**
  67833. * Legacy support, changed quaternion to rotationQuaternion
  67834. */
  67835. get quaternion(): Nullable<Quaternion>;
  67836. /**
  67837. * Legacy support, changed quaternion to rotationQuaternion
  67838. */
  67839. set quaternion(q: Nullable<Quaternion>);
  67840. /**
  67841. * Returns a boolean. True if the particle intersects a mesh, else false
  67842. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  67843. * @param target is the object (point or mesh) what the intersection is computed against
  67844. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  67845. * @returns true if it intersects
  67846. */
  67847. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  67848. /**
  67849. * get the rotation matrix of the particle
  67850. * @hidden
  67851. */
  67852. getRotationMatrix(m: Matrix): void;
  67853. }
  67854. /**
  67855. * Represents a group of points in a points cloud system
  67856. * * PCS internal tool, don't use it manually.
  67857. */
  67858. export class PointsGroup {
  67859. /**
  67860. * The group id
  67861. * @hidden
  67862. */
  67863. groupID: number;
  67864. /**
  67865. * image data for group (internal use)
  67866. * @hidden
  67867. */
  67868. _groupImageData: Nullable<ArrayBufferView>;
  67869. /**
  67870. * Image Width (internal use)
  67871. * @hidden
  67872. */
  67873. _groupImgWidth: number;
  67874. /**
  67875. * Image Height (internal use)
  67876. * @hidden
  67877. */
  67878. _groupImgHeight: number;
  67879. /**
  67880. * Custom position function (internal use)
  67881. * @hidden
  67882. */
  67883. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  67884. /**
  67885. * density per facet for surface points
  67886. * @hidden
  67887. */
  67888. _groupDensity: number[];
  67889. /**
  67890. * Only when points are colored by texture carries pointer to texture list array
  67891. * @hidden
  67892. */
  67893. _textureNb: number;
  67894. /**
  67895. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  67896. * PCS internal tool, don't use it manually.
  67897. * @hidden
  67898. */
  67899. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  67900. }
  67901. }
  67902. declare module BABYLON {
  67903. interface Scene {
  67904. /** @hidden (Backing field) */
  67905. _physicsEngine: Nullable<IPhysicsEngine>;
  67906. /** @hidden */
  67907. _physicsTimeAccumulator: number;
  67908. /**
  67909. * Gets the current physics engine
  67910. * @returns a IPhysicsEngine or null if none attached
  67911. */
  67912. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  67913. /**
  67914. * Enables physics to the current scene
  67915. * @param gravity defines the scene's gravity for the physics engine
  67916. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  67917. * @return a boolean indicating if the physics engine was initialized
  67918. */
  67919. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  67920. /**
  67921. * Disables and disposes the physics engine associated with the scene
  67922. */
  67923. disablePhysicsEngine(): void;
  67924. /**
  67925. * Gets a boolean indicating if there is an active physics engine
  67926. * @returns a boolean indicating if there is an active physics engine
  67927. */
  67928. isPhysicsEnabled(): boolean;
  67929. /**
  67930. * Deletes a physics compound impostor
  67931. * @param compound defines the compound to delete
  67932. */
  67933. deleteCompoundImpostor(compound: any): void;
  67934. /**
  67935. * An event triggered when physic simulation is about to be run
  67936. */
  67937. onBeforePhysicsObservable: Observable<Scene>;
  67938. /**
  67939. * An event triggered when physic simulation has been done
  67940. */
  67941. onAfterPhysicsObservable: Observable<Scene>;
  67942. }
  67943. interface AbstractMesh {
  67944. /** @hidden */
  67945. _physicsImpostor: Nullable<PhysicsImpostor>;
  67946. /**
  67947. * Gets or sets impostor used for physic simulation
  67948. * @see https://doc.babylonjs.com/features/physics_engine
  67949. */
  67950. physicsImpostor: Nullable<PhysicsImpostor>;
  67951. /**
  67952. * Gets the current physics impostor
  67953. * @see https://doc.babylonjs.com/features/physics_engine
  67954. * @returns a physics impostor or null
  67955. */
  67956. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  67957. /** Apply a physic impulse to the mesh
  67958. * @param force defines the force to apply
  67959. * @param contactPoint defines where to apply the force
  67960. * @returns the current mesh
  67961. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  67962. */
  67963. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  67964. /**
  67965. * Creates a physic joint between two meshes
  67966. * @param otherMesh defines the other mesh to use
  67967. * @param pivot1 defines the pivot to use on this mesh
  67968. * @param pivot2 defines the pivot to use on the other mesh
  67969. * @param options defines additional options (can be plugin dependent)
  67970. * @returns the current mesh
  67971. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  67972. */
  67973. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  67974. /** @hidden */
  67975. _disposePhysicsObserver: Nullable<Observer<Node>>;
  67976. }
  67977. /**
  67978. * Defines the physics engine scene component responsible to manage a physics engine
  67979. */
  67980. export class PhysicsEngineSceneComponent implements ISceneComponent {
  67981. /**
  67982. * The component name helpful to identify the component in the list of scene components.
  67983. */
  67984. readonly name: string;
  67985. /**
  67986. * The scene the component belongs to.
  67987. */
  67988. scene: Scene;
  67989. /**
  67990. * Creates a new instance of the component for the given scene
  67991. * @param scene Defines the scene to register the component in
  67992. */
  67993. constructor(scene: Scene);
  67994. /**
  67995. * Registers the component in a given scene
  67996. */
  67997. register(): void;
  67998. /**
  67999. * Rebuilds the elements related to this component in case of
  68000. * context lost for instance.
  68001. */
  68002. rebuild(): void;
  68003. /**
  68004. * Disposes the component and the associated ressources
  68005. */
  68006. dispose(): void;
  68007. }
  68008. }
  68009. declare module BABYLON {
  68010. /**
  68011. * A helper for physics simulations
  68012. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68013. */
  68014. export class PhysicsHelper {
  68015. private _scene;
  68016. private _physicsEngine;
  68017. /**
  68018. * Initializes the Physics helper
  68019. * @param scene Babylon.js scene
  68020. */
  68021. constructor(scene: Scene);
  68022. /**
  68023. * Applies a radial explosion impulse
  68024. * @param origin the origin of the explosion
  68025. * @param radiusOrEventOptions the radius or the options of radial explosion
  68026. * @param strength the explosion strength
  68027. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68028. * @returns A physics radial explosion event, or null
  68029. */
  68030. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68031. /**
  68032. * Applies a radial explosion force
  68033. * @param origin the origin of the explosion
  68034. * @param radiusOrEventOptions the radius or the options of radial explosion
  68035. * @param strength the explosion strength
  68036. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68037. * @returns A physics radial explosion event, or null
  68038. */
  68039. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68040. /**
  68041. * Creates a gravitational field
  68042. * @param origin the origin of the explosion
  68043. * @param radiusOrEventOptions the radius or the options of radial explosion
  68044. * @param strength the explosion strength
  68045. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68046. * @returns A physics gravitational field event, or null
  68047. */
  68048. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  68049. /**
  68050. * Creates a physics updraft event
  68051. * @param origin the origin of the updraft
  68052. * @param radiusOrEventOptions the radius or the options of the updraft
  68053. * @param strength the strength of the updraft
  68054. * @param height the height of the updraft
  68055. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  68056. * @returns A physics updraft event, or null
  68057. */
  68058. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  68059. /**
  68060. * Creates a physics vortex event
  68061. * @param origin the of the vortex
  68062. * @param radiusOrEventOptions the radius or the options of the vortex
  68063. * @param strength the strength of the vortex
  68064. * @param height the height of the vortex
  68065. * @returns a Physics vortex event, or null
  68066. * A physics vortex event or null
  68067. */
  68068. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  68069. }
  68070. /**
  68071. * Represents a physics radial explosion event
  68072. */
  68073. class PhysicsRadialExplosionEvent {
  68074. private _scene;
  68075. private _options;
  68076. private _sphere;
  68077. private _dataFetched;
  68078. /**
  68079. * Initializes a radial explosioin event
  68080. * @param _scene BabylonJS scene
  68081. * @param _options The options for the vortex event
  68082. */
  68083. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  68084. /**
  68085. * Returns the data related to the radial explosion event (sphere).
  68086. * @returns The radial explosion event data
  68087. */
  68088. getData(): PhysicsRadialExplosionEventData;
  68089. /**
  68090. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  68091. * @param impostor A physics imposter
  68092. * @param origin the origin of the explosion
  68093. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  68094. */
  68095. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  68096. /**
  68097. * Triggers affecterd impostors callbacks
  68098. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  68099. */
  68100. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  68101. /**
  68102. * Disposes the sphere.
  68103. * @param force Specifies if the sphere should be disposed by force
  68104. */
  68105. dispose(force?: boolean): void;
  68106. /*** Helpers ***/
  68107. private _prepareSphere;
  68108. private _intersectsWithSphere;
  68109. }
  68110. /**
  68111. * Represents a gravitational field event
  68112. */
  68113. class PhysicsGravitationalFieldEvent {
  68114. private _physicsHelper;
  68115. private _scene;
  68116. private _origin;
  68117. private _options;
  68118. private _tickCallback;
  68119. private _sphere;
  68120. private _dataFetched;
  68121. /**
  68122. * Initializes the physics gravitational field event
  68123. * @param _physicsHelper A physics helper
  68124. * @param _scene BabylonJS scene
  68125. * @param _origin The origin position of the gravitational field event
  68126. * @param _options The options for the vortex event
  68127. */
  68128. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  68129. /**
  68130. * Returns the data related to the gravitational field event (sphere).
  68131. * @returns A gravitational field event
  68132. */
  68133. getData(): PhysicsGravitationalFieldEventData;
  68134. /**
  68135. * Enables the gravitational field.
  68136. */
  68137. enable(): void;
  68138. /**
  68139. * Disables the gravitational field.
  68140. */
  68141. disable(): void;
  68142. /**
  68143. * Disposes the sphere.
  68144. * @param force The force to dispose from the gravitational field event
  68145. */
  68146. dispose(force?: boolean): void;
  68147. private _tick;
  68148. }
  68149. /**
  68150. * Represents a physics updraft event
  68151. */
  68152. class PhysicsUpdraftEvent {
  68153. private _scene;
  68154. private _origin;
  68155. private _options;
  68156. private _physicsEngine;
  68157. private _originTop;
  68158. private _originDirection;
  68159. private _tickCallback;
  68160. private _cylinder;
  68161. private _cylinderPosition;
  68162. private _dataFetched;
  68163. /**
  68164. * Initializes the physics updraft event
  68165. * @param _scene BabylonJS scene
  68166. * @param _origin The origin position of the updraft
  68167. * @param _options The options for the updraft event
  68168. */
  68169. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  68170. /**
  68171. * Returns the data related to the updraft event (cylinder).
  68172. * @returns A physics updraft event
  68173. */
  68174. getData(): PhysicsUpdraftEventData;
  68175. /**
  68176. * Enables the updraft.
  68177. */
  68178. enable(): void;
  68179. /**
  68180. * Disables the updraft.
  68181. */
  68182. disable(): void;
  68183. /**
  68184. * Disposes the cylinder.
  68185. * @param force Specifies if the updraft should be disposed by force
  68186. */
  68187. dispose(force?: boolean): void;
  68188. private getImpostorHitData;
  68189. private _tick;
  68190. /*** Helpers ***/
  68191. private _prepareCylinder;
  68192. private _intersectsWithCylinder;
  68193. }
  68194. /**
  68195. * Represents a physics vortex event
  68196. */
  68197. class PhysicsVortexEvent {
  68198. private _scene;
  68199. private _origin;
  68200. private _options;
  68201. private _physicsEngine;
  68202. private _originTop;
  68203. private _tickCallback;
  68204. private _cylinder;
  68205. private _cylinderPosition;
  68206. private _dataFetched;
  68207. /**
  68208. * Initializes the physics vortex event
  68209. * @param _scene The BabylonJS scene
  68210. * @param _origin The origin position of the vortex
  68211. * @param _options The options for the vortex event
  68212. */
  68213. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  68214. /**
  68215. * Returns the data related to the vortex event (cylinder).
  68216. * @returns The physics vortex event data
  68217. */
  68218. getData(): PhysicsVortexEventData;
  68219. /**
  68220. * Enables the vortex.
  68221. */
  68222. enable(): void;
  68223. /**
  68224. * Disables the cortex.
  68225. */
  68226. disable(): void;
  68227. /**
  68228. * Disposes the sphere.
  68229. * @param force
  68230. */
  68231. dispose(force?: boolean): void;
  68232. private getImpostorHitData;
  68233. private _tick;
  68234. /*** Helpers ***/
  68235. private _prepareCylinder;
  68236. private _intersectsWithCylinder;
  68237. }
  68238. /**
  68239. * Options fot the radial explosion event
  68240. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68241. */
  68242. export class PhysicsRadialExplosionEventOptions {
  68243. /**
  68244. * The radius of the sphere for the radial explosion.
  68245. */
  68246. radius: number;
  68247. /**
  68248. * The strenth of the explosion.
  68249. */
  68250. strength: number;
  68251. /**
  68252. * The strenght of the force in correspondence to the distance of the affected object
  68253. */
  68254. falloff: PhysicsRadialImpulseFalloff;
  68255. /**
  68256. * Sphere options for the radial explosion.
  68257. */
  68258. sphere: {
  68259. segments: number;
  68260. diameter: number;
  68261. };
  68262. /**
  68263. * Sphere options for the radial explosion.
  68264. */
  68265. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  68266. }
  68267. /**
  68268. * Options fot the updraft event
  68269. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68270. */
  68271. export class PhysicsUpdraftEventOptions {
  68272. /**
  68273. * The radius of the cylinder for the vortex
  68274. */
  68275. radius: number;
  68276. /**
  68277. * The strenth of the updraft.
  68278. */
  68279. strength: number;
  68280. /**
  68281. * The height of the cylinder for the updraft.
  68282. */
  68283. height: number;
  68284. /**
  68285. * The mode for the the updraft.
  68286. */
  68287. updraftMode: PhysicsUpdraftMode;
  68288. }
  68289. /**
  68290. * Options fot the vortex event
  68291. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68292. */
  68293. export class PhysicsVortexEventOptions {
  68294. /**
  68295. * The radius of the cylinder for the vortex
  68296. */
  68297. radius: number;
  68298. /**
  68299. * The strenth of the vortex.
  68300. */
  68301. strength: number;
  68302. /**
  68303. * The height of the cylinder for the vortex.
  68304. */
  68305. height: number;
  68306. /**
  68307. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  68308. */
  68309. centripetalForceThreshold: number;
  68310. /**
  68311. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  68312. */
  68313. centripetalForceMultiplier: number;
  68314. /**
  68315. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  68316. */
  68317. centrifugalForceMultiplier: number;
  68318. /**
  68319. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  68320. */
  68321. updraftForceMultiplier: number;
  68322. }
  68323. /**
  68324. * The strenght of the force in correspondence to the distance of the affected object
  68325. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68326. */
  68327. export enum PhysicsRadialImpulseFalloff {
  68328. /** Defines that impulse is constant in strength across it's whole radius */
  68329. Constant = 0,
  68330. /** Defines that impulse gets weaker if it's further from the origin */
  68331. Linear = 1
  68332. }
  68333. /**
  68334. * The strength of the force in correspondence to the distance of the affected object
  68335. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68336. */
  68337. export enum PhysicsUpdraftMode {
  68338. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  68339. Center = 0,
  68340. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  68341. Perpendicular = 1
  68342. }
  68343. /**
  68344. * Interface for a physics hit data
  68345. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68346. */
  68347. export interface PhysicsHitData {
  68348. /**
  68349. * The force applied at the contact point
  68350. */
  68351. force: Vector3;
  68352. /**
  68353. * The contact point
  68354. */
  68355. contactPoint: Vector3;
  68356. /**
  68357. * The distance from the origin to the contact point
  68358. */
  68359. distanceFromOrigin: number;
  68360. }
  68361. /**
  68362. * Interface for radial explosion event data
  68363. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68364. */
  68365. export interface PhysicsRadialExplosionEventData {
  68366. /**
  68367. * A sphere used for the radial explosion event
  68368. */
  68369. sphere: Mesh;
  68370. }
  68371. /**
  68372. * Interface for gravitational field event data
  68373. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68374. */
  68375. export interface PhysicsGravitationalFieldEventData {
  68376. /**
  68377. * A sphere mesh used for the gravitational field event
  68378. */
  68379. sphere: Mesh;
  68380. }
  68381. /**
  68382. * Interface for updraft event data
  68383. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68384. */
  68385. export interface PhysicsUpdraftEventData {
  68386. /**
  68387. * A cylinder used for the updraft event
  68388. */
  68389. cylinder: Mesh;
  68390. }
  68391. /**
  68392. * Interface for vortex event data
  68393. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68394. */
  68395. export interface PhysicsVortexEventData {
  68396. /**
  68397. * A cylinder used for the vortex event
  68398. */
  68399. cylinder: Mesh;
  68400. }
  68401. /**
  68402. * Interface for an affected physics impostor
  68403. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68404. */
  68405. export interface PhysicsAffectedImpostorWithData {
  68406. /**
  68407. * The impostor affected by the effect
  68408. */
  68409. impostor: PhysicsImpostor;
  68410. /**
  68411. * The data about the hit/horce from the explosion
  68412. */
  68413. hitData: PhysicsHitData;
  68414. }
  68415. }
  68416. declare module BABYLON {
  68417. /** @hidden */
  68418. export var blackAndWhitePixelShader: {
  68419. name: string;
  68420. shader: string;
  68421. };
  68422. }
  68423. declare module BABYLON {
  68424. /**
  68425. * Post process used to render in black and white
  68426. */
  68427. export class BlackAndWhitePostProcess extends PostProcess {
  68428. /**
  68429. * Linear about to convert he result to black and white (default: 1)
  68430. */
  68431. degree: number;
  68432. /**
  68433. * Creates a black and white post process
  68434. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  68435. * @param name The name of the effect.
  68436. * @param options The required width/height ratio to downsize to before computing the render pass.
  68437. * @param camera The camera to apply the render pass to.
  68438. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68439. * @param engine The engine which the post process will be applied. (default: current engine)
  68440. * @param reusable If the post process can be reused on the same frame. (default: false)
  68441. */
  68442. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68443. }
  68444. }
  68445. declare module BABYLON {
  68446. /**
  68447. * This represents a set of one or more post processes in Babylon.
  68448. * A post process can be used to apply a shader to a texture after it is rendered.
  68449. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68450. */
  68451. export class PostProcessRenderEffect {
  68452. private _postProcesses;
  68453. private _getPostProcesses;
  68454. private _singleInstance;
  68455. private _cameras;
  68456. private _indicesForCamera;
  68457. /**
  68458. * Name of the effect
  68459. * @hidden
  68460. */
  68461. _name: string;
  68462. /**
  68463. * Instantiates a post process render effect.
  68464. * A post process can be used to apply a shader to a texture after it is rendered.
  68465. * @param engine The engine the effect is tied to
  68466. * @param name The name of the effect
  68467. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  68468. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  68469. */
  68470. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  68471. /**
  68472. * Checks if all the post processes in the effect are supported.
  68473. */
  68474. get isSupported(): boolean;
  68475. /**
  68476. * Updates the current state of the effect
  68477. * @hidden
  68478. */
  68479. _update(): void;
  68480. /**
  68481. * Attaches the effect on cameras
  68482. * @param cameras The camera to attach to.
  68483. * @hidden
  68484. */
  68485. _attachCameras(cameras: Camera): void;
  68486. /**
  68487. * Attaches the effect on cameras
  68488. * @param cameras The camera to attach to.
  68489. * @hidden
  68490. */
  68491. _attachCameras(cameras: Camera[]): void;
  68492. /**
  68493. * Detaches the effect on cameras
  68494. * @param cameras The camera to detatch from.
  68495. * @hidden
  68496. */
  68497. _detachCameras(cameras: Camera): void;
  68498. /**
  68499. * Detatches the effect on cameras
  68500. * @param cameras The camera to detatch from.
  68501. * @hidden
  68502. */
  68503. _detachCameras(cameras: Camera[]): void;
  68504. /**
  68505. * Enables the effect on given cameras
  68506. * @param cameras The camera to enable.
  68507. * @hidden
  68508. */
  68509. _enable(cameras: Camera): void;
  68510. /**
  68511. * Enables the effect on given cameras
  68512. * @param cameras The camera to enable.
  68513. * @hidden
  68514. */
  68515. _enable(cameras: Nullable<Camera[]>): void;
  68516. /**
  68517. * Disables the effect on the given cameras
  68518. * @param cameras The camera to disable.
  68519. * @hidden
  68520. */
  68521. _disable(cameras: Camera): void;
  68522. /**
  68523. * Disables the effect on the given cameras
  68524. * @param cameras The camera to disable.
  68525. * @hidden
  68526. */
  68527. _disable(cameras: Nullable<Camera[]>): void;
  68528. /**
  68529. * Gets a list of the post processes contained in the effect.
  68530. * @param camera The camera to get the post processes on.
  68531. * @returns The list of the post processes in the effect.
  68532. */
  68533. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  68534. }
  68535. }
  68536. declare module BABYLON {
  68537. /** @hidden */
  68538. export var extractHighlightsPixelShader: {
  68539. name: string;
  68540. shader: string;
  68541. };
  68542. }
  68543. declare module BABYLON {
  68544. /**
  68545. * 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.
  68546. */
  68547. export class ExtractHighlightsPostProcess extends PostProcess {
  68548. /**
  68549. * The luminance threshold, pixels below this value will be set to black.
  68550. */
  68551. threshold: number;
  68552. /** @hidden */
  68553. _exposure: number;
  68554. /**
  68555. * Post process which has the input texture to be used when performing highlight extraction
  68556. * @hidden
  68557. */
  68558. _inputPostProcess: Nullable<PostProcess>;
  68559. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68560. }
  68561. }
  68562. declare module BABYLON {
  68563. /** @hidden */
  68564. export var bloomMergePixelShader: {
  68565. name: string;
  68566. shader: string;
  68567. };
  68568. }
  68569. declare module BABYLON {
  68570. /**
  68571. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68572. */
  68573. export class BloomMergePostProcess extends PostProcess {
  68574. /** Weight of the bloom to be added to the original input. */
  68575. weight: number;
  68576. /**
  68577. * Creates a new instance of @see BloomMergePostProcess
  68578. * @param name The name of the effect.
  68579. * @param originalFromInput Post process which's input will be used for the merge.
  68580. * @param blurred Blurred highlights post process which's output will be used.
  68581. * @param weight Weight of the bloom to be added to the original input.
  68582. * @param options The required width/height ratio to downsize to before computing the render pass.
  68583. * @param camera The camera to apply the render pass to.
  68584. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68585. * @param engine The engine which the post process will be applied. (default: current engine)
  68586. * @param reusable If the post process can be reused on the same frame. (default: false)
  68587. * @param textureType Type of textures used when performing the post process. (default: 0)
  68588. * @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)
  68589. */
  68590. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  68591. /** Weight of the bloom to be added to the original input. */
  68592. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68593. }
  68594. }
  68595. declare module BABYLON {
  68596. /**
  68597. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  68598. */
  68599. export class BloomEffect extends PostProcessRenderEffect {
  68600. private bloomScale;
  68601. /**
  68602. * @hidden Internal
  68603. */
  68604. _effects: Array<PostProcess>;
  68605. /**
  68606. * @hidden Internal
  68607. */
  68608. _downscale: ExtractHighlightsPostProcess;
  68609. private _blurX;
  68610. private _blurY;
  68611. private _merge;
  68612. /**
  68613. * The luminance threshold to find bright areas of the image to bloom.
  68614. */
  68615. get threshold(): number;
  68616. set threshold(value: number);
  68617. /**
  68618. * The strength of the bloom.
  68619. */
  68620. get weight(): number;
  68621. set weight(value: number);
  68622. /**
  68623. * Specifies the size of the bloom blur kernel, relative to the final output size
  68624. */
  68625. get kernel(): number;
  68626. set kernel(value: number);
  68627. /**
  68628. * Creates a new instance of @see BloomEffect
  68629. * @param scene The scene the effect belongs to.
  68630. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  68631. * @param bloomKernel The size of the kernel to be used when applying the blur.
  68632. * @param bloomWeight The the strength of bloom.
  68633. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68634. * @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)
  68635. */
  68636. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  68637. /**
  68638. * Disposes each of the internal effects for a given camera.
  68639. * @param camera The camera to dispose the effect on.
  68640. */
  68641. disposeEffects(camera: Camera): void;
  68642. /**
  68643. * @hidden Internal
  68644. */
  68645. _updateEffects(): void;
  68646. /**
  68647. * Internal
  68648. * @returns if all the contained post processes are ready.
  68649. * @hidden
  68650. */
  68651. _isReady(): boolean;
  68652. }
  68653. }
  68654. declare module BABYLON {
  68655. /** @hidden */
  68656. export var chromaticAberrationPixelShader: {
  68657. name: string;
  68658. shader: string;
  68659. };
  68660. }
  68661. declare module BABYLON {
  68662. /**
  68663. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  68664. */
  68665. export class ChromaticAberrationPostProcess extends PostProcess {
  68666. /**
  68667. * The amount of seperation of rgb channels (default: 30)
  68668. */
  68669. aberrationAmount: number;
  68670. /**
  68671. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  68672. */
  68673. radialIntensity: number;
  68674. /**
  68675. * 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))
  68676. */
  68677. direction: Vector2;
  68678. /**
  68679. * 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))
  68680. */
  68681. centerPosition: Vector2;
  68682. /**
  68683. * Creates a new instance ChromaticAberrationPostProcess
  68684. * @param name The name of the effect.
  68685. * @param screenWidth The width of the screen to apply the effect on.
  68686. * @param screenHeight The height of the screen to apply the effect on.
  68687. * @param options The required width/height ratio to downsize to before computing the render pass.
  68688. * @param camera The camera to apply the render pass to.
  68689. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68690. * @param engine The engine which the post process will be applied. (default: current engine)
  68691. * @param reusable If the post process can be reused on the same frame. (default: false)
  68692. * @param textureType Type of textures used when performing the post process. (default: 0)
  68693. * @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)
  68694. */
  68695. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68696. }
  68697. }
  68698. declare module BABYLON {
  68699. /** @hidden */
  68700. export var circleOfConfusionPixelShader: {
  68701. name: string;
  68702. shader: string;
  68703. };
  68704. }
  68705. declare module BABYLON {
  68706. /**
  68707. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  68708. */
  68709. export class CircleOfConfusionPostProcess extends PostProcess {
  68710. /**
  68711. * 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.
  68712. */
  68713. lensSize: number;
  68714. /**
  68715. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68716. */
  68717. fStop: number;
  68718. /**
  68719. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68720. */
  68721. focusDistance: number;
  68722. /**
  68723. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  68724. */
  68725. focalLength: number;
  68726. private _depthTexture;
  68727. /**
  68728. * Creates a new instance CircleOfConfusionPostProcess
  68729. * @param name The name of the effect.
  68730. * @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.
  68731. * @param options The required width/height ratio to downsize to before computing the render pass.
  68732. * @param camera The camera to apply the render pass to.
  68733. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68734. * @param engine The engine which the post process will be applied. (default: current engine)
  68735. * @param reusable If the post process can be reused on the same frame. (default: false)
  68736. * @param textureType Type of textures used when performing the post process. (default: 0)
  68737. * @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)
  68738. */
  68739. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68740. /**
  68741. * 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.
  68742. */
  68743. set depthTexture(value: RenderTargetTexture);
  68744. }
  68745. }
  68746. declare module BABYLON {
  68747. /** @hidden */
  68748. export var colorCorrectionPixelShader: {
  68749. name: string;
  68750. shader: string;
  68751. };
  68752. }
  68753. declare module BABYLON {
  68754. /**
  68755. *
  68756. * This post-process allows the modification of rendered colors by using
  68757. * a 'look-up table' (LUT). This effect is also called Color Grading.
  68758. *
  68759. * The object needs to be provided an url to a texture containing the color
  68760. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  68761. * Use an image editing software to tweak the LUT to match your needs.
  68762. *
  68763. * For an example of a color LUT, see here:
  68764. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  68765. * For explanations on color grading, see here:
  68766. * @see http://udn.epicgames.com/Three/ColorGrading.html
  68767. *
  68768. */
  68769. export class ColorCorrectionPostProcess extends PostProcess {
  68770. private _colorTableTexture;
  68771. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68772. }
  68773. }
  68774. declare module BABYLON {
  68775. /** @hidden */
  68776. export var convolutionPixelShader: {
  68777. name: string;
  68778. shader: string;
  68779. };
  68780. }
  68781. declare module BABYLON {
  68782. /**
  68783. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  68784. * input texture to perform effects such as edge detection or sharpening
  68785. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68786. */
  68787. export class ConvolutionPostProcess extends PostProcess {
  68788. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68789. kernel: number[];
  68790. /**
  68791. * Creates a new instance ConvolutionPostProcess
  68792. * @param name The name of the effect.
  68793. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  68794. * @param options The required width/height ratio to downsize to before computing the render pass.
  68795. * @param camera The camera to apply the render pass to.
  68796. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68797. * @param engine The engine which the post process will be applied. (default: current engine)
  68798. * @param reusable If the post process can be reused on the same frame. (default: false)
  68799. * @param textureType Type of textures used when performing the post process. (default: 0)
  68800. */
  68801. constructor(name: string,
  68802. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68803. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68804. /**
  68805. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68806. */
  68807. static EdgeDetect0Kernel: number[];
  68808. /**
  68809. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68810. */
  68811. static EdgeDetect1Kernel: number[];
  68812. /**
  68813. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68814. */
  68815. static EdgeDetect2Kernel: number[];
  68816. /**
  68817. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68818. */
  68819. static SharpenKernel: number[];
  68820. /**
  68821. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68822. */
  68823. static EmbossKernel: number[];
  68824. /**
  68825. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68826. */
  68827. static GaussianKernel: number[];
  68828. }
  68829. }
  68830. declare module BABYLON {
  68831. /**
  68832. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  68833. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  68834. * based on samples that have a large difference in distance than the center pixel.
  68835. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  68836. */
  68837. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  68838. direction: Vector2;
  68839. /**
  68840. * Creates a new instance CircleOfConfusionPostProcess
  68841. * @param name The name of the effect.
  68842. * @param scene The scene the effect belongs to.
  68843. * @param direction The direction the blur should be applied.
  68844. * @param kernel The size of the kernel used to blur.
  68845. * @param options The required width/height ratio to downsize to before computing the render pass.
  68846. * @param camera The camera to apply the render pass to.
  68847. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  68848. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  68849. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68850. * @param engine The engine which the post process will be applied. (default: current engine)
  68851. * @param reusable If the post process can be reused on the same frame. (default: false)
  68852. * @param textureType Type of textures used when performing the post process. (default: 0)
  68853. * @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)
  68854. */
  68855. 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);
  68856. }
  68857. }
  68858. declare module BABYLON {
  68859. /** @hidden */
  68860. export var depthOfFieldMergePixelShader: {
  68861. name: string;
  68862. shader: string;
  68863. };
  68864. }
  68865. declare module BABYLON {
  68866. /**
  68867. * Options to be set when merging outputs from the default pipeline.
  68868. */
  68869. export class DepthOfFieldMergePostProcessOptions {
  68870. /**
  68871. * The original image to merge on top of
  68872. */
  68873. originalFromInput: PostProcess;
  68874. /**
  68875. * Parameters to perform the merge of the depth of field effect
  68876. */
  68877. depthOfField?: {
  68878. circleOfConfusion: PostProcess;
  68879. blurSteps: Array<PostProcess>;
  68880. };
  68881. /**
  68882. * Parameters to perform the merge of bloom effect
  68883. */
  68884. bloom?: {
  68885. blurred: PostProcess;
  68886. weight: number;
  68887. };
  68888. }
  68889. /**
  68890. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68891. */
  68892. export class DepthOfFieldMergePostProcess extends PostProcess {
  68893. private blurSteps;
  68894. /**
  68895. * Creates a new instance of DepthOfFieldMergePostProcess
  68896. * @param name The name of the effect.
  68897. * @param originalFromInput Post process which's input will be used for the merge.
  68898. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  68899. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  68900. * @param options The required width/height ratio to downsize to before computing the render pass.
  68901. * @param camera The camera to apply the render pass to.
  68902. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68903. * @param engine The engine which the post process will be applied. (default: current engine)
  68904. * @param reusable If the post process can be reused on the same frame. (default: false)
  68905. * @param textureType Type of textures used when performing the post process. (default: 0)
  68906. * @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)
  68907. */
  68908. 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);
  68909. /**
  68910. * Updates the effect with the current post process compile time values and recompiles the shader.
  68911. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  68912. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  68913. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  68914. * @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
  68915. * @param onCompiled Called when the shader has been compiled.
  68916. * @param onError Called if there is an error when compiling a shader.
  68917. */
  68918. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68919. }
  68920. }
  68921. declare module BABYLON {
  68922. /**
  68923. * Specifies the level of max blur that should be applied when using the depth of field effect
  68924. */
  68925. export enum DepthOfFieldEffectBlurLevel {
  68926. /**
  68927. * Subtle blur
  68928. */
  68929. Low = 0,
  68930. /**
  68931. * Medium blur
  68932. */
  68933. Medium = 1,
  68934. /**
  68935. * Large blur
  68936. */
  68937. High = 2
  68938. }
  68939. /**
  68940. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  68941. */
  68942. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  68943. private _circleOfConfusion;
  68944. /**
  68945. * @hidden Internal, blurs from high to low
  68946. */
  68947. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  68948. private _depthOfFieldBlurY;
  68949. private _dofMerge;
  68950. /**
  68951. * @hidden Internal post processes in depth of field effect
  68952. */
  68953. _effects: Array<PostProcess>;
  68954. /**
  68955. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  68956. */
  68957. set focalLength(value: number);
  68958. get focalLength(): number;
  68959. /**
  68960. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68961. */
  68962. set fStop(value: number);
  68963. get fStop(): number;
  68964. /**
  68965. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68966. */
  68967. set focusDistance(value: number);
  68968. get focusDistance(): number;
  68969. /**
  68970. * 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.
  68971. */
  68972. set lensSize(value: number);
  68973. get lensSize(): number;
  68974. /**
  68975. * Creates a new instance DepthOfFieldEffect
  68976. * @param scene The scene the effect belongs to.
  68977. * @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.
  68978. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68979. * @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)
  68980. */
  68981. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  68982. /**
  68983. * Get the current class name of the current effet
  68984. * @returns "DepthOfFieldEffect"
  68985. */
  68986. getClassName(): string;
  68987. /**
  68988. * 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.
  68989. */
  68990. set depthTexture(value: RenderTargetTexture);
  68991. /**
  68992. * Disposes each of the internal effects for a given camera.
  68993. * @param camera The camera to dispose the effect on.
  68994. */
  68995. disposeEffects(camera: Camera): void;
  68996. /**
  68997. * @hidden Internal
  68998. */
  68999. _updateEffects(): void;
  69000. /**
  69001. * Internal
  69002. * @returns if all the contained post processes are ready.
  69003. * @hidden
  69004. */
  69005. _isReady(): boolean;
  69006. }
  69007. }
  69008. declare module BABYLON {
  69009. /** @hidden */
  69010. export var displayPassPixelShader: {
  69011. name: string;
  69012. shader: string;
  69013. };
  69014. }
  69015. declare module BABYLON {
  69016. /**
  69017. * DisplayPassPostProcess which produces an output the same as it's input
  69018. */
  69019. export class DisplayPassPostProcess extends PostProcess {
  69020. /**
  69021. * Creates the DisplayPassPostProcess
  69022. * @param name The name of the effect.
  69023. * @param options The required width/height ratio to downsize to before computing the render pass.
  69024. * @param camera The camera to apply the render pass to.
  69025. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69026. * @param engine The engine which the post process will be applied. (default: current engine)
  69027. * @param reusable If the post process can be reused on the same frame. (default: false)
  69028. */
  69029. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69030. }
  69031. }
  69032. declare module BABYLON {
  69033. /** @hidden */
  69034. export var filterPixelShader: {
  69035. name: string;
  69036. shader: string;
  69037. };
  69038. }
  69039. declare module BABYLON {
  69040. /**
  69041. * Applies a kernel filter to the image
  69042. */
  69043. export class FilterPostProcess extends PostProcess {
  69044. /** The matrix to be applied to the image */
  69045. kernelMatrix: Matrix;
  69046. /**
  69047. *
  69048. * @param name The name of the effect.
  69049. * @param kernelMatrix The matrix to be applied to the 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. */
  69056. constructor(name: string,
  69057. /** The matrix to be applied to the image */
  69058. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69059. }
  69060. }
  69061. declare module BABYLON {
  69062. /** @hidden */
  69063. export var fxaaPixelShader: {
  69064. name: string;
  69065. shader: string;
  69066. };
  69067. }
  69068. declare module BABYLON {
  69069. /** @hidden */
  69070. export var fxaaVertexShader: {
  69071. name: string;
  69072. shader: string;
  69073. };
  69074. }
  69075. declare module BABYLON {
  69076. /**
  69077. * Fxaa post process
  69078. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  69079. */
  69080. export class FxaaPostProcess extends PostProcess {
  69081. /** @hidden */
  69082. texelWidth: number;
  69083. /** @hidden */
  69084. texelHeight: number;
  69085. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69086. private _getDefines;
  69087. }
  69088. }
  69089. declare module BABYLON {
  69090. /** @hidden */
  69091. export var grainPixelShader: {
  69092. name: string;
  69093. shader: string;
  69094. };
  69095. }
  69096. declare module BABYLON {
  69097. /**
  69098. * The GrainPostProcess adds noise to the image at mid luminance levels
  69099. */
  69100. export class GrainPostProcess extends PostProcess {
  69101. /**
  69102. * The intensity of the grain added (default: 30)
  69103. */
  69104. intensity: number;
  69105. /**
  69106. * If the grain should be randomized on every frame
  69107. */
  69108. animated: boolean;
  69109. /**
  69110. * Creates a new instance of @see GrainPostProcess
  69111. * @param name The name of the effect.
  69112. * @param options The required width/height ratio to downsize to before computing the render pass.
  69113. * @param camera The camera to apply the render pass to.
  69114. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69115. * @param engine The engine which the post process will be applied. (default: current engine)
  69116. * @param reusable If the post process can be reused on the same frame. (default: false)
  69117. * @param textureType Type of textures used when performing the post process. (default: 0)
  69118. * @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)
  69119. */
  69120. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69121. }
  69122. }
  69123. declare module BABYLON {
  69124. /** @hidden */
  69125. export var highlightsPixelShader: {
  69126. name: string;
  69127. shader: string;
  69128. };
  69129. }
  69130. declare module BABYLON {
  69131. /**
  69132. * Extracts highlights from the image
  69133. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69134. */
  69135. export class HighlightsPostProcess extends PostProcess {
  69136. /**
  69137. * Extracts highlights from the image
  69138. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  69139. * @param name The name of the effect.
  69140. * @param options The required width/height ratio to downsize to before computing the render pass.
  69141. * @param camera The camera to apply the render pass to.
  69142. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69143. * @param engine The engine which the post process will be applied. (default: current engine)
  69144. * @param reusable If the post process can be reused on the same frame. (default: false)
  69145. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  69146. */
  69147. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69148. }
  69149. }
  69150. declare module BABYLON {
  69151. /** @hidden */
  69152. export var mrtFragmentDeclaration: {
  69153. name: string;
  69154. shader: string;
  69155. };
  69156. }
  69157. declare module BABYLON {
  69158. /** @hidden */
  69159. export var geometryPixelShader: {
  69160. name: string;
  69161. shader: string;
  69162. };
  69163. }
  69164. declare module BABYLON {
  69165. /** @hidden */
  69166. export var geometryVertexShader: {
  69167. name: string;
  69168. shader: string;
  69169. };
  69170. }
  69171. declare module BABYLON {
  69172. /** @hidden */
  69173. interface ISavedTransformationMatrix {
  69174. world: Matrix;
  69175. viewProjection: Matrix;
  69176. }
  69177. /**
  69178. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  69179. */
  69180. export class GeometryBufferRenderer {
  69181. /**
  69182. * Constant used to retrieve the position texture index in the G-Buffer textures array
  69183. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  69184. */
  69185. static readonly POSITION_TEXTURE_TYPE: number;
  69186. /**
  69187. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  69188. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  69189. */
  69190. static readonly VELOCITY_TEXTURE_TYPE: number;
  69191. /**
  69192. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  69193. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  69194. */
  69195. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  69196. /**
  69197. * Dictionary used to store the previous transformation matrices of each rendered mesh
  69198. * in order to compute objects velocities when enableVelocity is set to "true"
  69199. * @hidden
  69200. */
  69201. _previousTransformationMatrices: {
  69202. [index: number]: ISavedTransformationMatrix;
  69203. };
  69204. /**
  69205. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  69206. * in order to compute objects velocities when enableVelocity is set to "true"
  69207. * @hidden
  69208. */
  69209. _previousBonesTransformationMatrices: {
  69210. [index: number]: Float32Array;
  69211. };
  69212. /**
  69213. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  69214. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  69215. */
  69216. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  69217. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  69218. renderTransparentMeshes: boolean;
  69219. private _scene;
  69220. private _resizeObserver;
  69221. private _multiRenderTarget;
  69222. private _ratio;
  69223. private _enablePosition;
  69224. private _enableVelocity;
  69225. private _enableReflectivity;
  69226. private _positionIndex;
  69227. private _velocityIndex;
  69228. private _reflectivityIndex;
  69229. protected _effect: Effect;
  69230. protected _cachedDefines: string;
  69231. /**
  69232. * Set the render list (meshes to be rendered) used in the G buffer.
  69233. */
  69234. set renderList(meshes: Mesh[]);
  69235. /**
  69236. * Gets wether or not G buffer are supported by the running hardware.
  69237. * This requires draw buffer supports
  69238. */
  69239. get isSupported(): boolean;
  69240. /**
  69241. * Returns the index of the given texture type in the G-Buffer textures array
  69242. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  69243. * @returns the index of the given texture type in the G-Buffer textures array
  69244. */
  69245. getTextureIndex(textureType: number): number;
  69246. /**
  69247. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  69248. */
  69249. get enablePosition(): boolean;
  69250. /**
  69251. * Sets whether or not objects positions are enabled for the G buffer.
  69252. */
  69253. set enablePosition(enable: boolean);
  69254. /**
  69255. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  69256. */
  69257. get enableVelocity(): boolean;
  69258. /**
  69259. * Sets wether or not objects velocities are enabled for the G buffer.
  69260. */
  69261. set enableVelocity(enable: boolean);
  69262. /**
  69263. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  69264. */
  69265. get enableReflectivity(): boolean;
  69266. /**
  69267. * Sets wether or not objects roughness are enabled for the G buffer.
  69268. */
  69269. set enableReflectivity(enable: boolean);
  69270. /**
  69271. * Gets the scene associated with the buffer.
  69272. */
  69273. get scene(): Scene;
  69274. /**
  69275. * Gets the ratio used by the buffer during its creation.
  69276. * How big is the buffer related to the main canvas.
  69277. */
  69278. get ratio(): number;
  69279. /** @hidden */
  69280. static _SceneComponentInitialization: (scene: Scene) => void;
  69281. /**
  69282. * Creates a new G Buffer for the scene
  69283. * @param scene The scene the buffer belongs to
  69284. * @param ratio How big is the buffer related to the main canvas.
  69285. */
  69286. constructor(scene: Scene, ratio?: number);
  69287. /**
  69288. * Checks wether everything is ready to render a submesh to the G buffer.
  69289. * @param subMesh the submesh to check readiness for
  69290. * @param useInstances is the mesh drawn using instance or not
  69291. * @returns true if ready otherwise false
  69292. */
  69293. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69294. /**
  69295. * Gets the current underlying G Buffer.
  69296. * @returns the buffer
  69297. */
  69298. getGBuffer(): MultiRenderTarget;
  69299. /**
  69300. * Gets the number of samples used to render the buffer (anti aliasing).
  69301. */
  69302. get samples(): number;
  69303. /**
  69304. * Sets the number of samples used to render the buffer (anti aliasing).
  69305. */
  69306. set samples(value: number);
  69307. /**
  69308. * Disposes the renderer and frees up associated resources.
  69309. */
  69310. dispose(): void;
  69311. protected _createRenderTargets(): void;
  69312. private _copyBonesTransformationMatrices;
  69313. }
  69314. }
  69315. declare module BABYLON {
  69316. interface Scene {
  69317. /** @hidden (Backing field) */
  69318. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  69319. /**
  69320. * Gets or Sets the current geometry buffer associated to the scene.
  69321. */
  69322. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  69323. /**
  69324. * Enables a GeometryBufferRender and associates it with the scene
  69325. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  69326. * @returns the GeometryBufferRenderer
  69327. */
  69328. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  69329. /**
  69330. * Disables the GeometryBufferRender associated with the scene
  69331. */
  69332. disableGeometryBufferRenderer(): void;
  69333. }
  69334. /**
  69335. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  69336. * in several rendering techniques.
  69337. */
  69338. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  69339. /**
  69340. * The component name helpful to identify the component in the list of scene components.
  69341. */
  69342. readonly name: string;
  69343. /**
  69344. * The scene the component belongs to.
  69345. */
  69346. scene: Scene;
  69347. /**
  69348. * Creates a new instance of the component for the given scene
  69349. * @param scene Defines the scene to register the component in
  69350. */
  69351. constructor(scene: Scene);
  69352. /**
  69353. * Registers the component in a given scene
  69354. */
  69355. register(): void;
  69356. /**
  69357. * Rebuilds the elements related to this component in case of
  69358. * context lost for instance.
  69359. */
  69360. rebuild(): void;
  69361. /**
  69362. * Disposes the component and the associated ressources
  69363. */
  69364. dispose(): void;
  69365. private _gatherRenderTargets;
  69366. }
  69367. }
  69368. declare module BABYLON {
  69369. /** @hidden */
  69370. export var motionBlurPixelShader: {
  69371. name: string;
  69372. shader: string;
  69373. };
  69374. }
  69375. declare module BABYLON {
  69376. /**
  69377. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  69378. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  69379. * As an example, all you have to do is to create the post-process:
  69380. * var mb = new BABYLON.MotionBlurPostProcess(
  69381. * 'mb', // The name of the effect.
  69382. * scene, // The scene containing the objects to blur according to their velocity.
  69383. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  69384. * camera // The camera to apply the render pass to.
  69385. * );
  69386. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  69387. */
  69388. export class MotionBlurPostProcess extends PostProcess {
  69389. /**
  69390. * Defines how much the image is blurred by the movement. Default value is equal to 1
  69391. */
  69392. motionStrength: number;
  69393. /**
  69394. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  69395. */
  69396. get motionBlurSamples(): number;
  69397. /**
  69398. * Sets the number of iterations to be used for motion blur quality
  69399. */
  69400. set motionBlurSamples(samples: number);
  69401. private _motionBlurSamples;
  69402. private _geometryBufferRenderer;
  69403. /**
  69404. * Creates a new instance MotionBlurPostProcess
  69405. * @param name The name of the effect.
  69406. * @param scene The scene containing the objects to blur according to their velocity.
  69407. * @param options The required width/height ratio to downsize to before computing the render pass.
  69408. * @param camera The camera to apply the render pass to.
  69409. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69410. * @param engine The engine which the post process will be applied. (default: current engine)
  69411. * @param reusable If the post process can be reused on the same frame. (default: false)
  69412. * @param textureType Type of textures used when performing the post process. (default: 0)
  69413. * @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)
  69414. */
  69415. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69416. /**
  69417. * Excludes the given skinned mesh from computing bones velocities.
  69418. * 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.
  69419. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  69420. */
  69421. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  69422. /**
  69423. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  69424. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  69425. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  69426. */
  69427. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  69428. /**
  69429. * Disposes the post process.
  69430. * @param camera The camera to dispose the post process on.
  69431. */
  69432. dispose(camera?: Camera): void;
  69433. }
  69434. }
  69435. declare module BABYLON {
  69436. /** @hidden */
  69437. export var refractionPixelShader: {
  69438. name: string;
  69439. shader: string;
  69440. };
  69441. }
  69442. declare module BABYLON {
  69443. /**
  69444. * Post process which applies a refractin texture
  69445. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  69446. */
  69447. export class RefractionPostProcess extends PostProcess {
  69448. /** the base color of the refraction (used to taint the rendering) */
  69449. color: Color3;
  69450. /** simulated refraction depth */
  69451. depth: number;
  69452. /** the coefficient of the base color (0 to remove base color tainting) */
  69453. colorLevel: number;
  69454. private _refTexture;
  69455. private _ownRefractionTexture;
  69456. /**
  69457. * Gets or sets the refraction texture
  69458. * Please note that you are responsible for disposing the texture if you set it manually
  69459. */
  69460. get refractionTexture(): Texture;
  69461. set refractionTexture(value: Texture);
  69462. /**
  69463. * Initializes the RefractionPostProcess
  69464. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  69465. * @param name The name of the effect.
  69466. * @param refractionTextureUrl Url of the refraction texture to use
  69467. * @param color the base color of the refraction (used to taint the rendering)
  69468. * @param depth simulated refraction depth
  69469. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  69470. * @param camera The camera to apply the render pass to.
  69471. * @param options The required width/height ratio to downsize to before computing the render pass.
  69472. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69473. * @param engine The engine which the post process will be applied. (default: current engine)
  69474. * @param reusable If the post process can be reused on the same frame. (default: false)
  69475. */
  69476. constructor(name: string, refractionTextureUrl: string,
  69477. /** the base color of the refraction (used to taint the rendering) */
  69478. color: Color3,
  69479. /** simulated refraction depth */
  69480. depth: number,
  69481. /** the coefficient of the base color (0 to remove base color tainting) */
  69482. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69483. /**
  69484. * Disposes of the post process
  69485. * @param camera Camera to dispose post process on
  69486. */
  69487. dispose(camera: Camera): void;
  69488. }
  69489. }
  69490. declare module BABYLON {
  69491. /** @hidden */
  69492. export var sharpenPixelShader: {
  69493. name: string;
  69494. shader: string;
  69495. };
  69496. }
  69497. declare module BABYLON {
  69498. /**
  69499. * The SharpenPostProcess applies a sharpen kernel to every pixel
  69500. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  69501. */
  69502. export class SharpenPostProcess extends PostProcess {
  69503. /**
  69504. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  69505. */
  69506. colorAmount: number;
  69507. /**
  69508. * How much sharpness should be applied (default: 0.3)
  69509. */
  69510. edgeAmount: number;
  69511. /**
  69512. * Creates a new instance ConvolutionPostProcess
  69513. * @param name The name of the effect.
  69514. * @param options The required width/height ratio to downsize to before computing the render pass.
  69515. * @param camera The camera to apply the render pass to.
  69516. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69517. * @param engine The engine which the post process will be applied. (default: current engine)
  69518. * @param reusable If the post process can be reused on the same frame. (default: false)
  69519. * @param textureType Type of textures used when performing the post process. (default: 0)
  69520. * @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)
  69521. */
  69522. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69523. }
  69524. }
  69525. declare module BABYLON {
  69526. /**
  69527. * PostProcessRenderPipeline
  69528. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69529. */
  69530. export class PostProcessRenderPipeline {
  69531. private engine;
  69532. private _renderEffects;
  69533. private _renderEffectsForIsolatedPass;
  69534. /**
  69535. * List of inspectable custom properties (used by the Inspector)
  69536. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  69537. */
  69538. inspectableCustomProperties: IInspectable[];
  69539. /**
  69540. * @hidden
  69541. */
  69542. protected _cameras: Camera[];
  69543. /** @hidden */
  69544. _name: string;
  69545. /**
  69546. * Gets pipeline name
  69547. */
  69548. get name(): string;
  69549. /** Gets the list of attached cameras */
  69550. get cameras(): Camera[];
  69551. /**
  69552. * Initializes a PostProcessRenderPipeline
  69553. * @param engine engine to add the pipeline to
  69554. * @param name name of the pipeline
  69555. */
  69556. constructor(engine: Engine, name: string);
  69557. /**
  69558. * Gets the class name
  69559. * @returns "PostProcessRenderPipeline"
  69560. */
  69561. getClassName(): string;
  69562. /**
  69563. * If all the render effects in the pipeline are supported
  69564. */
  69565. get isSupported(): boolean;
  69566. /**
  69567. * Adds an effect to the pipeline
  69568. * @param renderEffect the effect to add
  69569. */
  69570. addEffect(renderEffect: PostProcessRenderEffect): void;
  69571. /** @hidden */
  69572. _rebuild(): void;
  69573. /** @hidden */
  69574. _enableEffect(renderEffectName: string, cameras: Camera): void;
  69575. /** @hidden */
  69576. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  69577. /** @hidden */
  69578. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  69579. /** @hidden */
  69580. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  69581. /** @hidden */
  69582. _attachCameras(cameras: Camera, unique: boolean): void;
  69583. /** @hidden */
  69584. _attachCameras(cameras: Camera[], unique: boolean): void;
  69585. /** @hidden */
  69586. _detachCameras(cameras: Camera): void;
  69587. /** @hidden */
  69588. _detachCameras(cameras: Nullable<Camera[]>): void;
  69589. /** @hidden */
  69590. _update(): void;
  69591. /** @hidden */
  69592. _reset(): void;
  69593. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  69594. /**
  69595. * Sets the required values to the prepass renderer.
  69596. * @param prePassRenderer defines the prepass renderer to setup.
  69597. * @returns true if the pre pass is needed.
  69598. */
  69599. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  69600. /**
  69601. * Disposes of the pipeline
  69602. */
  69603. dispose(): void;
  69604. }
  69605. }
  69606. declare module BABYLON {
  69607. /**
  69608. * PostProcessRenderPipelineManager class
  69609. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69610. */
  69611. export class PostProcessRenderPipelineManager {
  69612. private _renderPipelines;
  69613. /**
  69614. * Initializes a PostProcessRenderPipelineManager
  69615. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69616. */
  69617. constructor();
  69618. /**
  69619. * Gets the list of supported render pipelines
  69620. */
  69621. get supportedPipelines(): PostProcessRenderPipeline[];
  69622. /**
  69623. * Adds a pipeline to the manager
  69624. * @param renderPipeline The pipeline to add
  69625. */
  69626. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  69627. /**
  69628. * Attaches a camera to the pipeline
  69629. * @param renderPipelineName The name of the pipeline to attach to
  69630. * @param cameras the camera to attach
  69631. * @param unique if the camera can be attached multiple times to the pipeline
  69632. */
  69633. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  69634. /**
  69635. * Detaches a camera from the pipeline
  69636. * @param renderPipelineName The name of the pipeline to detach from
  69637. * @param cameras the camera to detach
  69638. */
  69639. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  69640. /**
  69641. * Enables an effect by name on a pipeline
  69642. * @param renderPipelineName the name of the pipeline to enable the effect in
  69643. * @param renderEffectName the name of the effect to enable
  69644. * @param cameras the cameras that the effect should be enabled on
  69645. */
  69646. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  69647. /**
  69648. * Disables an effect by name on a pipeline
  69649. * @param renderPipelineName the name of the pipeline to disable the effect in
  69650. * @param renderEffectName the name of the effect to disable
  69651. * @param cameras the cameras that the effect should be disabled on
  69652. */
  69653. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  69654. /**
  69655. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  69656. */
  69657. update(): void;
  69658. /** @hidden */
  69659. _rebuild(): void;
  69660. /**
  69661. * Disposes of the manager and pipelines
  69662. */
  69663. dispose(): void;
  69664. }
  69665. }
  69666. declare module BABYLON {
  69667. interface Scene {
  69668. /** @hidden (Backing field) */
  69669. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  69670. /**
  69671. * Gets the postprocess render pipeline manager
  69672. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69673. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  69674. */
  69675. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  69676. }
  69677. /**
  69678. * Defines the Render Pipeline scene component responsible to rendering pipelines
  69679. */
  69680. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  69681. /**
  69682. * The component name helpfull to identify the component in the list of scene components.
  69683. */
  69684. readonly name: string;
  69685. /**
  69686. * The scene the component belongs to.
  69687. */
  69688. scene: Scene;
  69689. /**
  69690. * Creates a new instance of the component for the given scene
  69691. * @param scene Defines the scene to register the component in
  69692. */
  69693. constructor(scene: Scene);
  69694. /**
  69695. * Registers the component in a given scene
  69696. */
  69697. register(): void;
  69698. /**
  69699. * Rebuilds the elements related to this component in case of
  69700. * context lost for instance.
  69701. */
  69702. rebuild(): void;
  69703. /**
  69704. * Disposes the component and the associated ressources
  69705. */
  69706. dispose(): void;
  69707. private _gatherRenderTargets;
  69708. }
  69709. }
  69710. declare module BABYLON {
  69711. /**
  69712. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  69713. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  69714. */
  69715. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69716. private _scene;
  69717. private _camerasToBeAttached;
  69718. /**
  69719. * ID of the sharpen post process,
  69720. */
  69721. private readonly SharpenPostProcessId;
  69722. /**
  69723. * @ignore
  69724. * ID of the image processing post process;
  69725. */
  69726. readonly ImageProcessingPostProcessId: string;
  69727. /**
  69728. * @ignore
  69729. * ID of the Fast Approximate Anti-Aliasing post process;
  69730. */
  69731. readonly FxaaPostProcessId: string;
  69732. /**
  69733. * ID of the chromatic aberration post process,
  69734. */
  69735. private readonly ChromaticAberrationPostProcessId;
  69736. /**
  69737. * ID of the grain post process
  69738. */
  69739. private readonly GrainPostProcessId;
  69740. /**
  69741. * Sharpen post process which will apply a sharpen convolution to enhance edges
  69742. */
  69743. sharpen: SharpenPostProcess;
  69744. private _sharpenEffect;
  69745. private bloom;
  69746. /**
  69747. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  69748. */
  69749. depthOfField: DepthOfFieldEffect;
  69750. /**
  69751. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69752. */
  69753. fxaa: FxaaPostProcess;
  69754. /**
  69755. * Image post processing pass used to perform operations such as tone mapping or color grading.
  69756. */
  69757. imageProcessing: ImageProcessingPostProcess;
  69758. /**
  69759. * Chromatic aberration post process which will shift rgb colors in the image
  69760. */
  69761. chromaticAberration: ChromaticAberrationPostProcess;
  69762. private _chromaticAberrationEffect;
  69763. /**
  69764. * Grain post process which add noise to the image
  69765. */
  69766. grain: GrainPostProcess;
  69767. private _grainEffect;
  69768. /**
  69769. * Glow post process which adds a glow to emissive areas of the image
  69770. */
  69771. private _glowLayer;
  69772. /**
  69773. * Animations which can be used to tweak settings over a period of time
  69774. */
  69775. animations: Animation[];
  69776. private _imageProcessingConfigurationObserver;
  69777. private _sharpenEnabled;
  69778. private _bloomEnabled;
  69779. private _depthOfFieldEnabled;
  69780. private _depthOfFieldBlurLevel;
  69781. private _fxaaEnabled;
  69782. private _imageProcessingEnabled;
  69783. private _defaultPipelineTextureType;
  69784. private _bloomScale;
  69785. private _chromaticAberrationEnabled;
  69786. private _grainEnabled;
  69787. private _buildAllowed;
  69788. /**
  69789. * Gets active scene
  69790. */
  69791. get scene(): Scene;
  69792. /**
  69793. * Enable or disable the sharpen process from the pipeline
  69794. */
  69795. set sharpenEnabled(enabled: boolean);
  69796. get sharpenEnabled(): boolean;
  69797. private _resizeObserver;
  69798. private _hardwareScaleLevel;
  69799. private _bloomKernel;
  69800. /**
  69801. * Specifies the size of the bloom blur kernel, relative to the final output size
  69802. */
  69803. get bloomKernel(): number;
  69804. set bloomKernel(value: number);
  69805. /**
  69806. * Specifies the weight of the bloom in the final rendering
  69807. */
  69808. private _bloomWeight;
  69809. /**
  69810. * Specifies the luma threshold for the area that will be blurred by the bloom
  69811. */
  69812. private _bloomThreshold;
  69813. private _hdr;
  69814. /**
  69815. * The strength of the bloom.
  69816. */
  69817. set bloomWeight(value: number);
  69818. get bloomWeight(): number;
  69819. /**
  69820. * The strength of the bloom.
  69821. */
  69822. set bloomThreshold(value: number);
  69823. get bloomThreshold(): number;
  69824. /**
  69825. * The scale of the bloom, lower value will provide better performance.
  69826. */
  69827. set bloomScale(value: number);
  69828. get bloomScale(): number;
  69829. /**
  69830. * Enable or disable the bloom from the pipeline
  69831. */
  69832. set bloomEnabled(enabled: boolean);
  69833. get bloomEnabled(): boolean;
  69834. private _rebuildBloom;
  69835. /**
  69836. * If the depth of field is enabled.
  69837. */
  69838. get depthOfFieldEnabled(): boolean;
  69839. set depthOfFieldEnabled(enabled: boolean);
  69840. /**
  69841. * Blur level of the depth of field effect. (Higher blur will effect performance)
  69842. */
  69843. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  69844. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  69845. /**
  69846. * If the anti aliasing is enabled.
  69847. */
  69848. set fxaaEnabled(enabled: boolean);
  69849. get fxaaEnabled(): boolean;
  69850. private _samples;
  69851. /**
  69852. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69853. */
  69854. set samples(sampleCount: number);
  69855. get samples(): number;
  69856. /**
  69857. * If image processing is enabled.
  69858. */
  69859. set imageProcessingEnabled(enabled: boolean);
  69860. get imageProcessingEnabled(): boolean;
  69861. /**
  69862. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  69863. */
  69864. set glowLayerEnabled(enabled: boolean);
  69865. get glowLayerEnabled(): boolean;
  69866. /**
  69867. * Gets the glow layer (or null if not defined)
  69868. */
  69869. get glowLayer(): Nullable<GlowLayer>;
  69870. /**
  69871. * Enable or disable the chromaticAberration process from the pipeline
  69872. */
  69873. set chromaticAberrationEnabled(enabled: boolean);
  69874. get chromaticAberrationEnabled(): boolean;
  69875. /**
  69876. * Enable or disable the grain process from the pipeline
  69877. */
  69878. set grainEnabled(enabled: boolean);
  69879. get grainEnabled(): boolean;
  69880. /**
  69881. * @constructor
  69882. * @param name - The rendering pipeline name (default: "")
  69883. * @param hdr - If high dynamic range textures should be used (default: true)
  69884. * @param scene - The scene linked to this pipeline (default: the last created scene)
  69885. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  69886. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  69887. */
  69888. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  69889. /**
  69890. * Get the class name
  69891. * @returns "DefaultRenderingPipeline"
  69892. */
  69893. getClassName(): string;
  69894. /**
  69895. * Force the compilation of the entire pipeline.
  69896. */
  69897. prepare(): void;
  69898. private _hasCleared;
  69899. private _prevPostProcess;
  69900. private _prevPrevPostProcess;
  69901. private _setAutoClearAndTextureSharing;
  69902. private _depthOfFieldSceneObserver;
  69903. private _buildPipeline;
  69904. private _disposePostProcesses;
  69905. /**
  69906. * Adds a camera to the pipeline
  69907. * @param camera the camera to be added
  69908. */
  69909. addCamera(camera: Camera): void;
  69910. /**
  69911. * Removes a camera from the pipeline
  69912. * @param camera the camera to remove
  69913. */
  69914. removeCamera(camera: Camera): void;
  69915. /**
  69916. * Dispose of the pipeline and stop all post processes
  69917. */
  69918. dispose(): void;
  69919. /**
  69920. * Serialize the rendering pipeline (Used when exporting)
  69921. * @returns the serialized object
  69922. */
  69923. serialize(): any;
  69924. /**
  69925. * Parse the serialized pipeline
  69926. * @param source Source pipeline.
  69927. * @param scene The scene to load the pipeline to.
  69928. * @param rootUrl The URL of the serialized pipeline.
  69929. * @returns An instantiated pipeline from the serialized object.
  69930. */
  69931. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  69932. }
  69933. }
  69934. declare module BABYLON {
  69935. /** @hidden */
  69936. export var lensHighlightsPixelShader: {
  69937. name: string;
  69938. shader: string;
  69939. };
  69940. }
  69941. declare module BABYLON {
  69942. /** @hidden */
  69943. export var depthOfFieldPixelShader: {
  69944. name: string;
  69945. shader: string;
  69946. };
  69947. }
  69948. declare module BABYLON {
  69949. /**
  69950. * BABYLON.JS Chromatic Aberration GLSL Shader
  69951. * Author: Olivier Guyot
  69952. * Separates very slightly R, G and B colors on the edges of the screen
  69953. * Inspired by Francois Tarlier & Martins Upitis
  69954. */
  69955. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  69956. /**
  69957. * @ignore
  69958. * The chromatic aberration PostProcess id in the pipeline
  69959. */
  69960. LensChromaticAberrationEffect: string;
  69961. /**
  69962. * @ignore
  69963. * The highlights enhancing PostProcess id in the pipeline
  69964. */
  69965. HighlightsEnhancingEffect: string;
  69966. /**
  69967. * @ignore
  69968. * The depth-of-field PostProcess id in the pipeline
  69969. */
  69970. LensDepthOfFieldEffect: string;
  69971. private _scene;
  69972. private _depthTexture;
  69973. private _grainTexture;
  69974. private _chromaticAberrationPostProcess;
  69975. private _highlightsPostProcess;
  69976. private _depthOfFieldPostProcess;
  69977. private _edgeBlur;
  69978. private _grainAmount;
  69979. private _chromaticAberration;
  69980. private _distortion;
  69981. private _highlightsGain;
  69982. private _highlightsThreshold;
  69983. private _dofDistance;
  69984. private _dofAperture;
  69985. private _dofDarken;
  69986. private _dofPentagon;
  69987. private _blurNoise;
  69988. /**
  69989. * @constructor
  69990. *
  69991. * Effect parameters are as follow:
  69992. * {
  69993. * chromatic_aberration: number; // from 0 to x (1 for realism)
  69994. * edge_blur: number; // from 0 to x (1 for realism)
  69995. * distortion: number; // from 0 to x (1 for realism)
  69996. * grain_amount: number; // from 0 to 1
  69997. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  69998. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  69999. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  70000. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  70001. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  70002. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  70003. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  70004. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  70005. * }
  70006. * Note: if an effect parameter is unset, effect is disabled
  70007. *
  70008. * @param name The rendering pipeline name
  70009. * @param parameters - An object containing all parameters (see above)
  70010. * @param scene The scene linked to this pipeline
  70011. * @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)
  70012. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70013. */
  70014. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  70015. /**
  70016. * Get the class name
  70017. * @returns "LensRenderingPipeline"
  70018. */
  70019. getClassName(): string;
  70020. /**
  70021. * Gets associated scene
  70022. */
  70023. get scene(): Scene;
  70024. /**
  70025. * Gets or sets the edge blur
  70026. */
  70027. get edgeBlur(): number;
  70028. set edgeBlur(value: number);
  70029. /**
  70030. * Gets or sets the grain amount
  70031. */
  70032. get grainAmount(): number;
  70033. set grainAmount(value: number);
  70034. /**
  70035. * Gets or sets the chromatic aberration amount
  70036. */
  70037. get chromaticAberration(): number;
  70038. set chromaticAberration(value: number);
  70039. /**
  70040. * Gets or sets the depth of field aperture
  70041. */
  70042. get dofAperture(): number;
  70043. set dofAperture(value: number);
  70044. /**
  70045. * Gets or sets the edge distortion
  70046. */
  70047. get edgeDistortion(): number;
  70048. set edgeDistortion(value: number);
  70049. /**
  70050. * Gets or sets the depth of field distortion
  70051. */
  70052. get dofDistortion(): number;
  70053. set dofDistortion(value: number);
  70054. /**
  70055. * Gets or sets the darken out of focus amount
  70056. */
  70057. get darkenOutOfFocus(): number;
  70058. set darkenOutOfFocus(value: number);
  70059. /**
  70060. * Gets or sets a boolean indicating if blur noise is enabled
  70061. */
  70062. get blurNoise(): boolean;
  70063. set blurNoise(value: boolean);
  70064. /**
  70065. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  70066. */
  70067. get pentagonBokeh(): boolean;
  70068. set pentagonBokeh(value: boolean);
  70069. /**
  70070. * Gets or sets the highlight grain amount
  70071. */
  70072. get highlightsGain(): number;
  70073. set highlightsGain(value: number);
  70074. /**
  70075. * Gets or sets the highlight threshold
  70076. */
  70077. get highlightsThreshold(): number;
  70078. set highlightsThreshold(value: number);
  70079. /**
  70080. * Sets the amount of blur at the edges
  70081. * @param amount blur amount
  70082. */
  70083. setEdgeBlur(amount: number): void;
  70084. /**
  70085. * Sets edge blur to 0
  70086. */
  70087. disableEdgeBlur(): void;
  70088. /**
  70089. * Sets the amout of grain
  70090. * @param amount Amount of grain
  70091. */
  70092. setGrainAmount(amount: number): void;
  70093. /**
  70094. * Set grain amount to 0
  70095. */
  70096. disableGrain(): void;
  70097. /**
  70098. * Sets the chromatic aberration amount
  70099. * @param amount amount of chromatic aberration
  70100. */
  70101. setChromaticAberration(amount: number): void;
  70102. /**
  70103. * Sets chromatic aberration amount to 0
  70104. */
  70105. disableChromaticAberration(): void;
  70106. /**
  70107. * Sets the EdgeDistortion amount
  70108. * @param amount amount of EdgeDistortion
  70109. */
  70110. setEdgeDistortion(amount: number): void;
  70111. /**
  70112. * Sets edge distortion to 0
  70113. */
  70114. disableEdgeDistortion(): void;
  70115. /**
  70116. * Sets the FocusDistance amount
  70117. * @param amount amount of FocusDistance
  70118. */
  70119. setFocusDistance(amount: number): void;
  70120. /**
  70121. * Disables depth of field
  70122. */
  70123. disableDepthOfField(): void;
  70124. /**
  70125. * Sets the Aperture amount
  70126. * @param amount amount of Aperture
  70127. */
  70128. setAperture(amount: number): void;
  70129. /**
  70130. * Sets the DarkenOutOfFocus amount
  70131. * @param amount amount of DarkenOutOfFocus
  70132. */
  70133. setDarkenOutOfFocus(amount: number): void;
  70134. private _pentagonBokehIsEnabled;
  70135. /**
  70136. * Creates a pentagon bokeh effect
  70137. */
  70138. enablePentagonBokeh(): void;
  70139. /**
  70140. * Disables the pentagon bokeh effect
  70141. */
  70142. disablePentagonBokeh(): void;
  70143. /**
  70144. * Enables noise blur
  70145. */
  70146. enableNoiseBlur(): void;
  70147. /**
  70148. * Disables noise blur
  70149. */
  70150. disableNoiseBlur(): void;
  70151. /**
  70152. * Sets the HighlightsGain amount
  70153. * @param amount amount of HighlightsGain
  70154. */
  70155. setHighlightsGain(amount: number): void;
  70156. /**
  70157. * Sets the HighlightsThreshold amount
  70158. * @param amount amount of HighlightsThreshold
  70159. */
  70160. setHighlightsThreshold(amount: number): void;
  70161. /**
  70162. * Disables highlights
  70163. */
  70164. disableHighlights(): void;
  70165. /**
  70166. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  70167. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  70168. */
  70169. dispose(disableDepthRender?: boolean): void;
  70170. private _createChromaticAberrationPostProcess;
  70171. private _createHighlightsPostProcess;
  70172. private _createDepthOfFieldPostProcess;
  70173. private _createGrainTexture;
  70174. }
  70175. }
  70176. declare module BABYLON {
  70177. /** @hidden */
  70178. export var ssao2PixelShader: {
  70179. name: string;
  70180. shader: string;
  70181. };
  70182. }
  70183. declare module BABYLON {
  70184. /** @hidden */
  70185. export var ssaoCombinePixelShader: {
  70186. name: string;
  70187. shader: string;
  70188. };
  70189. }
  70190. declare module BABYLON {
  70191. /**
  70192. * Render pipeline to produce ssao effect
  70193. */
  70194. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  70195. /**
  70196. * @ignore
  70197. * The PassPostProcess id in the pipeline that contains the original scene color
  70198. */
  70199. SSAOOriginalSceneColorEffect: string;
  70200. /**
  70201. * @ignore
  70202. * The SSAO PostProcess id in the pipeline
  70203. */
  70204. SSAORenderEffect: string;
  70205. /**
  70206. * @ignore
  70207. * The horizontal blur PostProcess id in the pipeline
  70208. */
  70209. SSAOBlurHRenderEffect: string;
  70210. /**
  70211. * @ignore
  70212. * The vertical blur PostProcess id in the pipeline
  70213. */
  70214. SSAOBlurVRenderEffect: string;
  70215. /**
  70216. * @ignore
  70217. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  70218. */
  70219. SSAOCombineRenderEffect: string;
  70220. /**
  70221. * The output strength of the SSAO post-process. Default value is 1.0.
  70222. */
  70223. totalStrength: number;
  70224. /**
  70225. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  70226. */
  70227. maxZ: number;
  70228. /**
  70229. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  70230. */
  70231. minZAspect: number;
  70232. private _samples;
  70233. /**
  70234. * Number of samples used for the SSAO calculations. Default value is 8
  70235. */
  70236. set samples(n: number);
  70237. get samples(): number;
  70238. private _textureSamples;
  70239. /**
  70240. * Number of samples to use for antialiasing
  70241. */
  70242. set textureSamples(n: number);
  70243. get textureSamples(): number;
  70244. /**
  70245. * Force rendering the geometry through geometry buffer
  70246. */
  70247. private _forceGeometryBuffer;
  70248. /**
  70249. * Ratio object used for SSAO ratio and blur ratio
  70250. */
  70251. private _ratio;
  70252. /**
  70253. * Dynamically generated sphere sampler.
  70254. */
  70255. private _sampleSphere;
  70256. /**
  70257. * Blur filter offsets
  70258. */
  70259. private _samplerOffsets;
  70260. private _expensiveBlur;
  70261. /**
  70262. * If bilateral blur should be used
  70263. */
  70264. set expensiveBlur(b: boolean);
  70265. get expensiveBlur(): boolean;
  70266. /**
  70267. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  70268. */
  70269. radius: number;
  70270. /**
  70271. * The base color of the SSAO post-process
  70272. * The final result is "base + ssao" between [0, 1]
  70273. */
  70274. base: number;
  70275. /**
  70276. * Support test.
  70277. */
  70278. static get IsSupported(): boolean;
  70279. private _scene;
  70280. private _randomTexture;
  70281. private _originalColorPostProcess;
  70282. private _ssaoPostProcess;
  70283. private _blurHPostProcess;
  70284. private _blurVPostProcess;
  70285. private _ssaoCombinePostProcess;
  70286. private _prePassRenderer;
  70287. /**
  70288. * Gets active scene
  70289. */
  70290. get scene(): Scene;
  70291. /**
  70292. * @constructor
  70293. * @param name The rendering pipeline name
  70294. * @param scene The scene linked to this pipeline
  70295. * @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 }
  70296. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70297. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  70298. */
  70299. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  70300. /**
  70301. * Get the class name
  70302. * @returns "SSAO2RenderingPipeline"
  70303. */
  70304. getClassName(): string;
  70305. /**
  70306. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  70307. */
  70308. dispose(disableGeometryBufferRenderer?: boolean): void;
  70309. private _createBlurPostProcess;
  70310. /** @hidden */
  70311. _rebuild(): void;
  70312. private _bits;
  70313. private _radicalInverse_VdC;
  70314. private _hammersley;
  70315. private _hemisphereSample_uniform;
  70316. private _generateHemisphere;
  70317. private _getDefinesForSSAO;
  70318. private _createSSAOPostProcess;
  70319. private _createSSAOCombinePostProcess;
  70320. private _createRandomTexture;
  70321. /**
  70322. * Serialize the rendering pipeline (Used when exporting)
  70323. * @returns the serialized object
  70324. */
  70325. serialize(): any;
  70326. /**
  70327. * Parse the serialized pipeline
  70328. * @param source Source pipeline.
  70329. * @param scene The scene to load the pipeline to.
  70330. * @param rootUrl The URL of the serialized pipeline.
  70331. * @returns An instantiated pipeline from the serialized object.
  70332. */
  70333. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  70334. /**
  70335. * Sets the required values to the prepass renderer.
  70336. * @param prePassRenderer defines the prepass renderer to setup
  70337. * @returns true if the pre pass is needed.
  70338. */
  70339. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  70340. }
  70341. }
  70342. declare module BABYLON {
  70343. /** @hidden */
  70344. export var ssaoPixelShader: {
  70345. name: string;
  70346. shader: string;
  70347. };
  70348. }
  70349. declare module BABYLON {
  70350. /**
  70351. * Render pipeline to produce ssao effect
  70352. */
  70353. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  70354. /**
  70355. * @ignore
  70356. * The PassPostProcess id in the pipeline that contains the original scene color
  70357. */
  70358. SSAOOriginalSceneColorEffect: string;
  70359. /**
  70360. * @ignore
  70361. * The SSAO PostProcess id in the pipeline
  70362. */
  70363. SSAORenderEffect: string;
  70364. /**
  70365. * @ignore
  70366. * The horizontal blur PostProcess id in the pipeline
  70367. */
  70368. SSAOBlurHRenderEffect: string;
  70369. /**
  70370. * @ignore
  70371. * The vertical blur PostProcess id in the pipeline
  70372. */
  70373. SSAOBlurVRenderEffect: string;
  70374. /**
  70375. * @ignore
  70376. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  70377. */
  70378. SSAOCombineRenderEffect: string;
  70379. /**
  70380. * The output strength of the SSAO post-process. Default value is 1.0.
  70381. */
  70382. totalStrength: number;
  70383. /**
  70384. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  70385. */
  70386. radius: number;
  70387. /**
  70388. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  70389. * Must not be equal to fallOff and superior to fallOff.
  70390. * Default value is 0.0075
  70391. */
  70392. area: number;
  70393. /**
  70394. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  70395. * Must not be equal to area and inferior to area.
  70396. * Default value is 0.000001
  70397. */
  70398. fallOff: number;
  70399. /**
  70400. * The base color of the SSAO post-process
  70401. * The final result is "base + ssao" between [0, 1]
  70402. */
  70403. base: number;
  70404. private _scene;
  70405. private _depthTexture;
  70406. private _randomTexture;
  70407. private _originalColorPostProcess;
  70408. private _ssaoPostProcess;
  70409. private _blurHPostProcess;
  70410. private _blurVPostProcess;
  70411. private _ssaoCombinePostProcess;
  70412. private _firstUpdate;
  70413. /**
  70414. * Gets active scene
  70415. */
  70416. get scene(): Scene;
  70417. /**
  70418. * @constructor
  70419. * @param name - The rendering pipeline name
  70420. * @param scene - The scene linked to this pipeline
  70421. * @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 }
  70422. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  70423. */
  70424. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  70425. /**
  70426. * Get the class name
  70427. * @returns "SSAORenderingPipeline"
  70428. */
  70429. getClassName(): string;
  70430. /**
  70431. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  70432. */
  70433. dispose(disableDepthRender?: boolean): void;
  70434. private _createBlurPostProcess;
  70435. /** @hidden */
  70436. _rebuild(): void;
  70437. private _createSSAOPostProcess;
  70438. private _createSSAOCombinePostProcess;
  70439. private _createRandomTexture;
  70440. }
  70441. }
  70442. declare module BABYLON {
  70443. /** @hidden */
  70444. export var screenSpaceReflectionPixelShader: {
  70445. name: string;
  70446. shader: string;
  70447. };
  70448. }
  70449. declare module BABYLON {
  70450. /**
  70451. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  70452. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  70453. */
  70454. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  70455. /**
  70456. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  70457. */
  70458. threshold: number;
  70459. /**
  70460. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  70461. */
  70462. strength: number;
  70463. /**
  70464. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  70465. */
  70466. reflectionSpecularFalloffExponent: number;
  70467. /**
  70468. * 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]
  70469. */
  70470. step: number;
  70471. /**
  70472. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  70473. */
  70474. roughnessFactor: number;
  70475. private _geometryBufferRenderer;
  70476. private _enableSmoothReflections;
  70477. private _reflectionSamples;
  70478. private _smoothSteps;
  70479. /**
  70480. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  70481. * @param name The name of the effect.
  70482. * @param scene The scene containing the objects to calculate reflections.
  70483. * @param options The required width/height ratio to downsize to before computing the render pass.
  70484. * @param camera The camera to apply the render pass to.
  70485. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70486. * @param engine The engine which the post process will be applied. (default: current engine)
  70487. * @param reusable If the post process can be reused on the same frame. (default: false)
  70488. * @param textureType Type of textures used when performing the post process. (default: 0)
  70489. * @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)
  70490. */
  70491. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70492. /**
  70493. * Gets wether or not smoothing reflections is enabled.
  70494. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  70495. */
  70496. get enableSmoothReflections(): boolean;
  70497. /**
  70498. * Sets wether or not smoothing reflections is enabled.
  70499. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  70500. */
  70501. set enableSmoothReflections(enabled: boolean);
  70502. /**
  70503. * Gets the number of samples taken while computing reflections. More samples count is high,
  70504. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  70505. */
  70506. get reflectionSamples(): number;
  70507. /**
  70508. * Sets the number of samples taken while computing reflections. More samples count is high,
  70509. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  70510. */
  70511. set reflectionSamples(samples: number);
  70512. /**
  70513. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  70514. * more the post-process will require GPU power and can generate a drop in FPS.
  70515. * Default value (5.0) work pretty well in all cases but can be adjusted.
  70516. */
  70517. get smoothSteps(): number;
  70518. set smoothSteps(steps: number);
  70519. private _updateEffectDefines;
  70520. }
  70521. }
  70522. declare module BABYLON {
  70523. /** @hidden */
  70524. export var standardPixelShader: {
  70525. name: string;
  70526. shader: string;
  70527. };
  70528. }
  70529. declare module BABYLON {
  70530. /**
  70531. * Standard rendering pipeline
  70532. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  70533. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  70534. */
  70535. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  70536. /**
  70537. * Public members
  70538. */
  70539. /**
  70540. * Post-process which contains the original scene color before the pipeline applies all the effects
  70541. */
  70542. originalPostProcess: Nullable<PostProcess>;
  70543. /**
  70544. * Post-process used to down scale an image x4
  70545. */
  70546. downSampleX4PostProcess: Nullable<PostProcess>;
  70547. /**
  70548. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  70549. */
  70550. brightPassPostProcess: Nullable<PostProcess>;
  70551. /**
  70552. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  70553. */
  70554. blurHPostProcesses: PostProcess[];
  70555. /**
  70556. * Post-process array storing all the vertical blur post-processes used by the pipeline
  70557. */
  70558. blurVPostProcesses: PostProcess[];
  70559. /**
  70560. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  70561. */
  70562. textureAdderPostProcess: Nullable<PostProcess>;
  70563. /**
  70564. * Post-process used to create volumetric lighting effect
  70565. */
  70566. volumetricLightPostProcess: Nullable<PostProcess>;
  70567. /**
  70568. * Post-process used to smooth the previous volumetric light post-process on the X axis
  70569. */
  70570. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  70571. /**
  70572. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  70573. */
  70574. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  70575. /**
  70576. * Post-process used to merge the volumetric light effect and the real scene color
  70577. */
  70578. volumetricLightMergePostProces: Nullable<PostProcess>;
  70579. /**
  70580. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  70581. */
  70582. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  70583. /**
  70584. * Base post-process used to calculate the average luminance of the final image for HDR
  70585. */
  70586. luminancePostProcess: Nullable<PostProcess>;
  70587. /**
  70588. * Post-processes used to create down sample post-processes in order to get
  70589. * the average luminance of the final image for HDR
  70590. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  70591. */
  70592. luminanceDownSamplePostProcesses: PostProcess[];
  70593. /**
  70594. * Post-process used to create a HDR effect (light adaptation)
  70595. */
  70596. hdrPostProcess: Nullable<PostProcess>;
  70597. /**
  70598. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  70599. */
  70600. textureAdderFinalPostProcess: Nullable<PostProcess>;
  70601. /**
  70602. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  70603. */
  70604. lensFlareFinalPostProcess: Nullable<PostProcess>;
  70605. /**
  70606. * Post-process used to merge the final HDR post-process and the real scene color
  70607. */
  70608. hdrFinalPostProcess: Nullable<PostProcess>;
  70609. /**
  70610. * Post-process used to create a lens flare effect
  70611. */
  70612. lensFlarePostProcess: Nullable<PostProcess>;
  70613. /**
  70614. * Post-process that merges the result of the lens flare post-process and the real scene color
  70615. */
  70616. lensFlareComposePostProcess: Nullable<PostProcess>;
  70617. /**
  70618. * Post-process used to create a motion blur effect
  70619. */
  70620. motionBlurPostProcess: Nullable<PostProcess>;
  70621. /**
  70622. * Post-process used to create a depth of field effect
  70623. */
  70624. depthOfFieldPostProcess: Nullable<PostProcess>;
  70625. /**
  70626. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  70627. */
  70628. fxaaPostProcess: Nullable<FxaaPostProcess>;
  70629. /**
  70630. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  70631. */
  70632. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  70633. /**
  70634. * Represents the brightness threshold in order to configure the illuminated surfaces
  70635. */
  70636. brightThreshold: number;
  70637. /**
  70638. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  70639. */
  70640. blurWidth: number;
  70641. /**
  70642. * Sets if the blur for highlighted surfaces must be only horizontal
  70643. */
  70644. horizontalBlur: boolean;
  70645. /**
  70646. * Gets the overall exposure used by the pipeline
  70647. */
  70648. get exposure(): number;
  70649. /**
  70650. * Sets the overall exposure used by the pipeline
  70651. */
  70652. set exposure(value: number);
  70653. /**
  70654. * Texture used typically to simulate "dirty" on camera lens
  70655. */
  70656. lensTexture: Nullable<Texture>;
  70657. /**
  70658. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  70659. */
  70660. volumetricLightCoefficient: number;
  70661. /**
  70662. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  70663. */
  70664. volumetricLightPower: number;
  70665. /**
  70666. * Used the set the blur intensity to smooth the volumetric lights
  70667. */
  70668. volumetricLightBlurScale: number;
  70669. /**
  70670. * Light (spot or directional) used to generate the volumetric lights rays
  70671. * The source light must have a shadow generate so the pipeline can get its
  70672. * depth map
  70673. */
  70674. sourceLight: Nullable<SpotLight | DirectionalLight>;
  70675. /**
  70676. * For eye adaptation, represents the minimum luminance the eye can see
  70677. */
  70678. hdrMinimumLuminance: number;
  70679. /**
  70680. * For eye adaptation, represents the decrease luminance speed
  70681. */
  70682. hdrDecreaseRate: number;
  70683. /**
  70684. * For eye adaptation, represents the increase luminance speed
  70685. */
  70686. hdrIncreaseRate: number;
  70687. /**
  70688. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  70689. */
  70690. get hdrAutoExposure(): boolean;
  70691. /**
  70692. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  70693. */
  70694. set hdrAutoExposure(value: boolean);
  70695. /**
  70696. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  70697. */
  70698. lensColorTexture: Nullable<Texture>;
  70699. /**
  70700. * The overall strengh for the lens flare effect
  70701. */
  70702. lensFlareStrength: number;
  70703. /**
  70704. * Dispersion coefficient for lens flare ghosts
  70705. */
  70706. lensFlareGhostDispersal: number;
  70707. /**
  70708. * Main lens flare halo width
  70709. */
  70710. lensFlareHaloWidth: number;
  70711. /**
  70712. * Based on the lens distortion effect, defines how much the lens flare result
  70713. * is distorted
  70714. */
  70715. lensFlareDistortionStrength: number;
  70716. /**
  70717. * Configures the blur intensity used for for lens flare (halo)
  70718. */
  70719. lensFlareBlurWidth: number;
  70720. /**
  70721. * Lens star texture must be used to simulate rays on the flares and is available
  70722. * in the documentation
  70723. */
  70724. lensStarTexture: Nullable<Texture>;
  70725. /**
  70726. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  70727. * flare effect by taking account of the dirt texture
  70728. */
  70729. lensFlareDirtTexture: Nullable<Texture>;
  70730. /**
  70731. * Represents the focal length for the depth of field effect
  70732. */
  70733. depthOfFieldDistance: number;
  70734. /**
  70735. * Represents the blur intensity for the blurred part of the depth of field effect
  70736. */
  70737. depthOfFieldBlurWidth: number;
  70738. /**
  70739. * Gets how much the image is blurred by the movement while using the motion blur post-process
  70740. */
  70741. get motionStrength(): number;
  70742. /**
  70743. * Sets how much the image is blurred by the movement while using the motion blur post-process
  70744. */
  70745. set motionStrength(strength: number);
  70746. /**
  70747. * Gets wether or not the motion blur post-process is object based or screen based.
  70748. */
  70749. get objectBasedMotionBlur(): boolean;
  70750. /**
  70751. * Sets wether or not the motion blur post-process should be object based or screen based
  70752. */
  70753. set objectBasedMotionBlur(value: boolean);
  70754. /**
  70755. * List of animations for the pipeline (IAnimatable implementation)
  70756. */
  70757. animations: Animation[];
  70758. /**
  70759. * Private members
  70760. */
  70761. private _scene;
  70762. private _currentDepthOfFieldSource;
  70763. private _basePostProcess;
  70764. private _fixedExposure;
  70765. private _currentExposure;
  70766. private _hdrAutoExposure;
  70767. private _hdrCurrentLuminance;
  70768. private _motionStrength;
  70769. private _isObjectBasedMotionBlur;
  70770. private _floatTextureType;
  70771. private _camerasToBeAttached;
  70772. private _ratio;
  70773. private _bloomEnabled;
  70774. private _depthOfFieldEnabled;
  70775. private _vlsEnabled;
  70776. private _lensFlareEnabled;
  70777. private _hdrEnabled;
  70778. private _motionBlurEnabled;
  70779. private _fxaaEnabled;
  70780. private _screenSpaceReflectionsEnabled;
  70781. private _motionBlurSamples;
  70782. private _volumetricLightStepsCount;
  70783. private _samples;
  70784. /**
  70785. * @ignore
  70786. * Specifies if the bloom pipeline is enabled
  70787. */
  70788. get BloomEnabled(): boolean;
  70789. set BloomEnabled(enabled: boolean);
  70790. /**
  70791. * @ignore
  70792. * Specifies if the depth of field pipeline is enabed
  70793. */
  70794. get DepthOfFieldEnabled(): boolean;
  70795. set DepthOfFieldEnabled(enabled: boolean);
  70796. /**
  70797. * @ignore
  70798. * Specifies if the lens flare pipeline is enabed
  70799. */
  70800. get LensFlareEnabled(): boolean;
  70801. set LensFlareEnabled(enabled: boolean);
  70802. /**
  70803. * @ignore
  70804. * Specifies if the HDR pipeline is enabled
  70805. */
  70806. get HDREnabled(): boolean;
  70807. set HDREnabled(enabled: boolean);
  70808. /**
  70809. * @ignore
  70810. * Specifies if the volumetric lights scattering effect is enabled
  70811. */
  70812. get VLSEnabled(): boolean;
  70813. set VLSEnabled(enabled: boolean);
  70814. /**
  70815. * @ignore
  70816. * Specifies if the motion blur effect is enabled
  70817. */
  70818. get MotionBlurEnabled(): boolean;
  70819. set MotionBlurEnabled(enabled: boolean);
  70820. /**
  70821. * Specifies if anti-aliasing is enabled
  70822. */
  70823. get fxaaEnabled(): boolean;
  70824. set fxaaEnabled(enabled: boolean);
  70825. /**
  70826. * Specifies if screen space reflections are enabled.
  70827. */
  70828. get screenSpaceReflectionsEnabled(): boolean;
  70829. set screenSpaceReflectionsEnabled(enabled: boolean);
  70830. /**
  70831. * Specifies the number of steps used to calculate the volumetric lights
  70832. * Typically in interval [50, 200]
  70833. */
  70834. get volumetricLightStepsCount(): number;
  70835. set volumetricLightStepsCount(count: number);
  70836. /**
  70837. * Specifies the number of samples used for the motion blur effect
  70838. * Typically in interval [16, 64]
  70839. */
  70840. get motionBlurSamples(): number;
  70841. set motionBlurSamples(samples: number);
  70842. /**
  70843. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70844. */
  70845. get samples(): number;
  70846. set samples(sampleCount: number);
  70847. /**
  70848. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  70849. * @constructor
  70850. * @param name The rendering pipeline name
  70851. * @param scene The scene linked to this pipeline
  70852. * @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)
  70853. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  70854. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70855. */
  70856. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  70857. private _buildPipeline;
  70858. private _createDownSampleX4PostProcess;
  70859. private _createBrightPassPostProcess;
  70860. private _createBlurPostProcesses;
  70861. private _createTextureAdderPostProcess;
  70862. private _createVolumetricLightPostProcess;
  70863. private _createLuminancePostProcesses;
  70864. private _createHdrPostProcess;
  70865. private _createLensFlarePostProcess;
  70866. private _createDepthOfFieldPostProcess;
  70867. private _createMotionBlurPostProcess;
  70868. private _getDepthTexture;
  70869. private _disposePostProcesses;
  70870. /**
  70871. * Dispose of the pipeline and stop all post processes
  70872. */
  70873. dispose(): void;
  70874. /**
  70875. * Serialize the rendering pipeline (Used when exporting)
  70876. * @returns the serialized object
  70877. */
  70878. serialize(): any;
  70879. /**
  70880. * Parse the serialized pipeline
  70881. * @param source Source pipeline.
  70882. * @param scene The scene to load the pipeline to.
  70883. * @param rootUrl The URL of the serialized pipeline.
  70884. * @returns An instantiated pipeline from the serialized object.
  70885. */
  70886. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  70887. /**
  70888. * Luminance steps
  70889. */
  70890. static LuminanceSteps: number;
  70891. }
  70892. }
  70893. declare module BABYLON {
  70894. /** @hidden */
  70895. export var stereoscopicInterlacePixelShader: {
  70896. name: string;
  70897. shader: string;
  70898. };
  70899. }
  70900. declare module BABYLON {
  70901. /**
  70902. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  70903. */
  70904. export class StereoscopicInterlacePostProcessI extends PostProcess {
  70905. private _stepSize;
  70906. private _passedProcess;
  70907. /**
  70908. * Initializes a StereoscopicInterlacePostProcessI
  70909. * @param name The name of the effect.
  70910. * @param rigCameras The rig cameras to be appled to the post process
  70911. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  70912. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  70913. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70914. * @param engine The engine which the post process will be applied. (default: current engine)
  70915. * @param reusable If the post process can be reused on the same frame. (default: false)
  70916. */
  70917. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70918. }
  70919. /**
  70920. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  70921. */
  70922. export class StereoscopicInterlacePostProcess extends PostProcess {
  70923. private _stepSize;
  70924. private _passedProcess;
  70925. /**
  70926. * Initializes a StereoscopicInterlacePostProcess
  70927. * @param name The name of the effect.
  70928. * @param rigCameras The rig cameras to be appled to the post process
  70929. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  70930. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70931. * @param engine The engine which the post process will be applied. (default: current engine)
  70932. * @param reusable If the post process can be reused on the same frame. (default: false)
  70933. */
  70934. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70935. }
  70936. }
  70937. declare module BABYLON {
  70938. /** @hidden */
  70939. export var tonemapPixelShader: {
  70940. name: string;
  70941. shader: string;
  70942. };
  70943. }
  70944. declare module BABYLON {
  70945. /** Defines operator used for tonemapping */
  70946. export enum TonemappingOperator {
  70947. /** Hable */
  70948. Hable = 0,
  70949. /** Reinhard */
  70950. Reinhard = 1,
  70951. /** HejiDawson */
  70952. HejiDawson = 2,
  70953. /** Photographic */
  70954. Photographic = 3
  70955. }
  70956. /**
  70957. * Defines a post process to apply tone mapping
  70958. */
  70959. export class TonemapPostProcess extends PostProcess {
  70960. private _operator;
  70961. /** Defines the required exposure adjustement */
  70962. exposureAdjustment: number;
  70963. /**
  70964. * Creates a new TonemapPostProcess
  70965. * @param name defines the name of the postprocess
  70966. * @param _operator defines the operator to use
  70967. * @param exposureAdjustment defines the required exposure adjustement
  70968. * @param camera defines the camera to use (can be null)
  70969. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  70970. * @param engine defines the hosting engine (can be ignore if camera is set)
  70971. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  70972. */
  70973. constructor(name: string, _operator: TonemappingOperator,
  70974. /** Defines the required exposure adjustement */
  70975. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  70976. }
  70977. }
  70978. declare module BABYLON {
  70979. /** @hidden */
  70980. export var volumetricLightScatteringPixelShader: {
  70981. name: string;
  70982. shader: string;
  70983. };
  70984. }
  70985. declare module BABYLON {
  70986. /** @hidden */
  70987. export var volumetricLightScatteringPassVertexShader: {
  70988. name: string;
  70989. shader: string;
  70990. };
  70991. }
  70992. declare module BABYLON {
  70993. /** @hidden */
  70994. export var volumetricLightScatteringPassPixelShader: {
  70995. name: string;
  70996. shader: string;
  70997. };
  70998. }
  70999. declare module BABYLON {
  71000. /**
  71001. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  71002. */
  71003. export class VolumetricLightScatteringPostProcess extends PostProcess {
  71004. private _volumetricLightScatteringPass;
  71005. private _volumetricLightScatteringRTT;
  71006. private _viewPort;
  71007. private _screenCoordinates;
  71008. private _cachedDefines;
  71009. /**
  71010. * If not undefined, the mesh position is computed from the attached node position
  71011. */
  71012. attachedNode: {
  71013. position: Vector3;
  71014. };
  71015. /**
  71016. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  71017. */
  71018. customMeshPosition: Vector3;
  71019. /**
  71020. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  71021. */
  71022. useCustomMeshPosition: boolean;
  71023. /**
  71024. * If the post-process should inverse the light scattering direction
  71025. */
  71026. invert: boolean;
  71027. /**
  71028. * The internal mesh used by the post-process
  71029. */
  71030. mesh: Mesh;
  71031. /**
  71032. * @hidden
  71033. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  71034. */
  71035. get useDiffuseColor(): boolean;
  71036. set useDiffuseColor(useDiffuseColor: boolean);
  71037. /**
  71038. * Array containing the excluded meshes not rendered in the internal pass
  71039. */
  71040. excludedMeshes: AbstractMesh[];
  71041. /**
  71042. * Controls the overall intensity of the post-process
  71043. */
  71044. exposure: number;
  71045. /**
  71046. * Dissipates each sample's contribution in range [0, 1]
  71047. */
  71048. decay: number;
  71049. /**
  71050. * Controls the overall intensity of each sample
  71051. */
  71052. weight: number;
  71053. /**
  71054. * Controls the density of each sample
  71055. */
  71056. density: number;
  71057. /**
  71058. * @constructor
  71059. * @param name The post-process name
  71060. * @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)
  71061. * @param camera The camera that the post-process will be attached to
  71062. * @param mesh The mesh used to create the light scattering
  71063. * @param samples The post-process quality, default 100
  71064. * @param samplingModeThe post-process filtering mode
  71065. * @param engine The babylon engine
  71066. * @param reusable If the post-process is reusable
  71067. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  71068. */
  71069. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  71070. /**
  71071. * Returns the string "VolumetricLightScatteringPostProcess"
  71072. * @returns "VolumetricLightScatteringPostProcess"
  71073. */
  71074. getClassName(): string;
  71075. private _isReady;
  71076. /**
  71077. * Sets the new light position for light scattering effect
  71078. * @param position The new custom light position
  71079. */
  71080. setCustomMeshPosition(position: Vector3): void;
  71081. /**
  71082. * Returns the light position for light scattering effect
  71083. * @return Vector3 The custom light position
  71084. */
  71085. getCustomMeshPosition(): Vector3;
  71086. /**
  71087. * Disposes the internal assets and detaches the post-process from the camera
  71088. */
  71089. dispose(camera: Camera): void;
  71090. /**
  71091. * Returns the render target texture used by the post-process
  71092. * @return the render target texture used by the post-process
  71093. */
  71094. getPass(): RenderTargetTexture;
  71095. private _meshExcluded;
  71096. private _createPass;
  71097. private _updateMeshScreenCoordinates;
  71098. /**
  71099. * Creates a default mesh for the Volumeric Light Scattering post-process
  71100. * @param name The mesh name
  71101. * @param scene The scene where to create the mesh
  71102. * @return the default mesh
  71103. */
  71104. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  71105. }
  71106. }
  71107. declare module BABYLON {
  71108. /** @hidden */
  71109. export var screenSpaceCurvaturePixelShader: {
  71110. name: string;
  71111. shader: string;
  71112. };
  71113. }
  71114. declare module BABYLON {
  71115. /**
  71116. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  71117. */
  71118. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  71119. /**
  71120. * Defines how much ridge the curvature effect displays.
  71121. */
  71122. ridge: number;
  71123. /**
  71124. * Defines how much valley the curvature effect displays.
  71125. */
  71126. valley: number;
  71127. private _geometryBufferRenderer;
  71128. /**
  71129. * Creates a new instance ScreenSpaceCurvaturePostProcess
  71130. * @param name The name of the effect.
  71131. * @param scene The scene containing the objects to blur according to their velocity.
  71132. * @param options The required width/height ratio to downsize to before computing the render pass.
  71133. * @param camera The camera to apply the render pass to.
  71134. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71135. * @param engine The engine which the post process will be applied. (default: current engine)
  71136. * @param reusable If the post process can be reused on the same frame. (default: false)
  71137. * @param textureType Type of textures used when performing the post process. (default: 0)
  71138. * @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)
  71139. */
  71140. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71141. /**
  71142. * Support test.
  71143. */
  71144. static get IsSupported(): boolean;
  71145. }
  71146. }
  71147. declare module BABYLON {
  71148. interface Scene {
  71149. /** @hidden (Backing field) */
  71150. _boundingBoxRenderer: BoundingBoxRenderer;
  71151. /** @hidden (Backing field) */
  71152. _forceShowBoundingBoxes: boolean;
  71153. /**
  71154. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  71155. */
  71156. forceShowBoundingBoxes: boolean;
  71157. /**
  71158. * Gets the bounding box renderer associated with the scene
  71159. * @returns a BoundingBoxRenderer
  71160. */
  71161. getBoundingBoxRenderer(): BoundingBoxRenderer;
  71162. }
  71163. interface AbstractMesh {
  71164. /** @hidden (Backing field) */
  71165. _showBoundingBox: boolean;
  71166. /**
  71167. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  71168. */
  71169. showBoundingBox: boolean;
  71170. }
  71171. /**
  71172. * Component responsible of rendering the bounding box of the meshes in a scene.
  71173. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  71174. */
  71175. export class BoundingBoxRenderer implements ISceneComponent {
  71176. /**
  71177. * The component name helpfull to identify the component in the list of scene components.
  71178. */
  71179. readonly name: string;
  71180. /**
  71181. * The scene the component belongs to.
  71182. */
  71183. scene: Scene;
  71184. /**
  71185. * Color of the bounding box lines placed in front of an object
  71186. */
  71187. frontColor: Color3;
  71188. /**
  71189. * Color of the bounding box lines placed behind an object
  71190. */
  71191. backColor: Color3;
  71192. /**
  71193. * Defines if the renderer should show the back lines or not
  71194. */
  71195. showBackLines: boolean;
  71196. /**
  71197. * Observable raised before rendering a bounding box
  71198. */
  71199. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  71200. /**
  71201. * Observable raised after rendering a bounding box
  71202. */
  71203. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  71204. /**
  71205. * @hidden
  71206. */
  71207. renderList: SmartArray<BoundingBox>;
  71208. private _colorShader;
  71209. private _vertexBuffers;
  71210. private _indexBuffer;
  71211. private _fillIndexBuffer;
  71212. private _fillIndexData;
  71213. /**
  71214. * Instantiates a new bounding box renderer in a scene.
  71215. * @param scene the scene the renderer renders in
  71216. */
  71217. constructor(scene: Scene);
  71218. /**
  71219. * Registers the component in a given scene
  71220. */
  71221. register(): void;
  71222. private _evaluateSubMesh;
  71223. private _activeMesh;
  71224. private _prepareRessources;
  71225. private _createIndexBuffer;
  71226. /**
  71227. * Rebuilds the elements related to this component in case of
  71228. * context lost for instance.
  71229. */
  71230. rebuild(): void;
  71231. /**
  71232. * @hidden
  71233. */
  71234. reset(): void;
  71235. /**
  71236. * Render the bounding boxes of a specific rendering group
  71237. * @param renderingGroupId defines the rendering group to render
  71238. */
  71239. render(renderingGroupId: number): void;
  71240. /**
  71241. * In case of occlusion queries, we can render the occlusion bounding box through this method
  71242. * @param mesh Define the mesh to render the occlusion bounding box for
  71243. */
  71244. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  71245. /**
  71246. * Dispose and release the resources attached to this renderer.
  71247. */
  71248. dispose(): void;
  71249. }
  71250. }
  71251. declare module BABYLON {
  71252. interface Scene {
  71253. /** @hidden (Backing field) */
  71254. _depthRenderer: {
  71255. [id: string]: DepthRenderer;
  71256. };
  71257. /**
  71258. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  71259. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  71260. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  71261. * @returns the created depth renderer
  71262. */
  71263. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  71264. /**
  71265. * Disables a depth renderer for a given camera
  71266. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  71267. */
  71268. disableDepthRenderer(camera?: Nullable<Camera>): void;
  71269. }
  71270. /**
  71271. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  71272. * in several rendering techniques.
  71273. */
  71274. export class DepthRendererSceneComponent implements ISceneComponent {
  71275. /**
  71276. * The component name helpfull to identify the component in the list of scene components.
  71277. */
  71278. readonly name: string;
  71279. /**
  71280. * The scene the component belongs to.
  71281. */
  71282. scene: Scene;
  71283. /**
  71284. * Creates a new instance of the component for the given scene
  71285. * @param scene Defines the scene to register the component in
  71286. */
  71287. constructor(scene: Scene);
  71288. /**
  71289. * Registers the component in a given scene
  71290. */
  71291. register(): void;
  71292. /**
  71293. * Rebuilds the elements related to this component in case of
  71294. * context lost for instance.
  71295. */
  71296. rebuild(): void;
  71297. /**
  71298. * Disposes the component and the associated ressources
  71299. */
  71300. dispose(): void;
  71301. private _gatherRenderTargets;
  71302. private _gatherActiveCameraRenderTargets;
  71303. }
  71304. }
  71305. declare module BABYLON {
  71306. interface AbstractScene {
  71307. /** @hidden (Backing field) */
  71308. _prePassRenderer: Nullable<PrePassRenderer>;
  71309. /**
  71310. * Gets or Sets the current prepass renderer associated to the scene.
  71311. */
  71312. prePassRenderer: Nullable<PrePassRenderer>;
  71313. /**
  71314. * Enables the prepass and associates it with the scene
  71315. * @returns the PrePassRenderer
  71316. */
  71317. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  71318. /**
  71319. * Disables the prepass associated with the scene
  71320. */
  71321. disablePrePassRenderer(): void;
  71322. }
  71323. /**
  71324. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  71325. * in several rendering techniques.
  71326. */
  71327. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  71328. /**
  71329. * The component name helpful to identify the component in the list of scene components.
  71330. */
  71331. readonly name: string;
  71332. /**
  71333. * The scene the component belongs to.
  71334. */
  71335. scene: Scene;
  71336. /**
  71337. * Creates a new instance of the component for the given scene
  71338. * @param scene Defines the scene to register the component in
  71339. */
  71340. constructor(scene: Scene);
  71341. /**
  71342. * Registers the component in a given scene
  71343. */
  71344. register(): void;
  71345. private _beforeCameraDraw;
  71346. private _afterCameraDraw;
  71347. private _beforeClearStage;
  71348. /**
  71349. * Serializes the component data to the specified json object
  71350. * @param serializationObject The object to serialize to
  71351. */
  71352. serialize(serializationObject: any): void;
  71353. /**
  71354. * Adds all the elements from the container to the scene
  71355. * @param container the container holding the elements
  71356. */
  71357. addFromContainer(container: AbstractScene): void;
  71358. /**
  71359. * Removes all the elements in the container from the scene
  71360. * @param container contains the elements to remove
  71361. * @param dispose if the removed element should be disposed (default: false)
  71362. */
  71363. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  71364. /**
  71365. * Rebuilds the elements related to this component in case of
  71366. * context lost for instance.
  71367. */
  71368. rebuild(): void;
  71369. /**
  71370. * Disposes the component and the associated ressources
  71371. */
  71372. dispose(): void;
  71373. }
  71374. }
  71375. declare module BABYLON {
  71376. /** @hidden */
  71377. export var outlinePixelShader: {
  71378. name: string;
  71379. shader: string;
  71380. };
  71381. }
  71382. declare module BABYLON {
  71383. /** @hidden */
  71384. export var outlineVertexShader: {
  71385. name: string;
  71386. shader: string;
  71387. };
  71388. }
  71389. declare module BABYLON {
  71390. interface Scene {
  71391. /** @hidden */
  71392. _outlineRenderer: OutlineRenderer;
  71393. /**
  71394. * Gets the outline renderer associated with the scene
  71395. * @returns a OutlineRenderer
  71396. */
  71397. getOutlineRenderer(): OutlineRenderer;
  71398. }
  71399. interface AbstractMesh {
  71400. /** @hidden (Backing field) */
  71401. _renderOutline: boolean;
  71402. /**
  71403. * Gets or sets a boolean indicating if the outline must be rendered as well
  71404. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  71405. */
  71406. renderOutline: boolean;
  71407. /** @hidden (Backing field) */
  71408. _renderOverlay: boolean;
  71409. /**
  71410. * Gets or sets a boolean indicating if the overlay must be rendered as well
  71411. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  71412. */
  71413. renderOverlay: boolean;
  71414. }
  71415. /**
  71416. * This class is responsible to draw bothe outline/overlay of meshes.
  71417. * It should not be used directly but through the available method on mesh.
  71418. */
  71419. export class OutlineRenderer implements ISceneComponent {
  71420. /**
  71421. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  71422. */
  71423. private static _StencilReference;
  71424. /**
  71425. * The name of the component. Each component must have a unique name.
  71426. */
  71427. name: string;
  71428. /**
  71429. * The scene the component belongs to.
  71430. */
  71431. scene: Scene;
  71432. /**
  71433. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  71434. */
  71435. zOffset: number;
  71436. private _engine;
  71437. private _effect;
  71438. private _cachedDefines;
  71439. private _savedDepthWrite;
  71440. /**
  71441. * Instantiates a new outline renderer. (There could be only one per scene).
  71442. * @param scene Defines the scene it belongs to
  71443. */
  71444. constructor(scene: Scene);
  71445. /**
  71446. * Register the component to one instance of a scene.
  71447. */
  71448. register(): void;
  71449. /**
  71450. * Rebuilds the elements related to this component in case of
  71451. * context lost for instance.
  71452. */
  71453. rebuild(): void;
  71454. /**
  71455. * Disposes the component and the associated ressources.
  71456. */
  71457. dispose(): void;
  71458. /**
  71459. * Renders the outline in the canvas.
  71460. * @param subMesh Defines the sumesh to render
  71461. * @param batch Defines the batch of meshes in case of instances
  71462. * @param useOverlay Defines if the rendering is for the overlay or the outline
  71463. */
  71464. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  71465. /**
  71466. * Returns whether or not the outline renderer is ready for a given submesh.
  71467. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  71468. * @param subMesh Defines the submesh to check readyness for
  71469. * @param useInstances Defines wheter wee are trying to render instances or not
  71470. * @returns true if ready otherwise false
  71471. */
  71472. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  71473. private _beforeRenderingMesh;
  71474. private _afterRenderingMesh;
  71475. }
  71476. }
  71477. declare module BABYLON {
  71478. /**
  71479. * Defines the basic options interface of a Sprite Frame Source Size.
  71480. */
  71481. export interface ISpriteJSONSpriteSourceSize {
  71482. /**
  71483. * number of the original width of the Frame
  71484. */
  71485. w: number;
  71486. /**
  71487. * number of the original height of the Frame
  71488. */
  71489. h: number;
  71490. }
  71491. /**
  71492. * Defines the basic options interface of a Sprite Frame Data.
  71493. */
  71494. export interface ISpriteJSONSpriteFrameData {
  71495. /**
  71496. * number of the x offset of the Frame
  71497. */
  71498. x: number;
  71499. /**
  71500. * number of the y offset of the Frame
  71501. */
  71502. y: number;
  71503. /**
  71504. * number of the width of the Frame
  71505. */
  71506. w: number;
  71507. /**
  71508. * number of the height of the Frame
  71509. */
  71510. h: number;
  71511. }
  71512. /**
  71513. * Defines the basic options interface of a JSON Sprite.
  71514. */
  71515. export interface ISpriteJSONSprite {
  71516. /**
  71517. * string name of the Frame
  71518. */
  71519. filename: string;
  71520. /**
  71521. * ISpriteJSONSpriteFrame basic object of the frame data
  71522. */
  71523. frame: ISpriteJSONSpriteFrameData;
  71524. /**
  71525. * boolean to flag is the frame was rotated.
  71526. */
  71527. rotated: boolean;
  71528. /**
  71529. * boolean to flag is the frame was trimmed.
  71530. */
  71531. trimmed: boolean;
  71532. /**
  71533. * ISpriteJSONSpriteFrame basic object of the source data
  71534. */
  71535. spriteSourceSize: ISpriteJSONSpriteFrameData;
  71536. /**
  71537. * ISpriteJSONSpriteFrame basic object of the source data
  71538. */
  71539. sourceSize: ISpriteJSONSpriteSourceSize;
  71540. }
  71541. /**
  71542. * Defines the basic options interface of a JSON atlas.
  71543. */
  71544. export interface ISpriteJSONAtlas {
  71545. /**
  71546. * Array of objects that contain the frame data.
  71547. */
  71548. frames: Array<ISpriteJSONSprite>;
  71549. /**
  71550. * object basic object containing the sprite meta data.
  71551. */
  71552. meta?: object;
  71553. }
  71554. }
  71555. declare module BABYLON {
  71556. /** @hidden */
  71557. export var spriteMapPixelShader: {
  71558. name: string;
  71559. shader: string;
  71560. };
  71561. }
  71562. declare module BABYLON {
  71563. /** @hidden */
  71564. export var spriteMapVertexShader: {
  71565. name: string;
  71566. shader: string;
  71567. };
  71568. }
  71569. declare module BABYLON {
  71570. /**
  71571. * Defines the basic options interface of a SpriteMap
  71572. */
  71573. export interface ISpriteMapOptions {
  71574. /**
  71575. * Vector2 of the number of cells in the grid.
  71576. */
  71577. stageSize?: Vector2;
  71578. /**
  71579. * Vector2 of the size of the output plane in World Units.
  71580. */
  71581. outputSize?: Vector2;
  71582. /**
  71583. * Vector3 of the position of the output plane in World Units.
  71584. */
  71585. outputPosition?: Vector3;
  71586. /**
  71587. * Vector3 of the rotation of the output plane.
  71588. */
  71589. outputRotation?: Vector3;
  71590. /**
  71591. * number of layers that the system will reserve in resources.
  71592. */
  71593. layerCount?: number;
  71594. /**
  71595. * number of max animation frames a single cell will reserve in resources.
  71596. */
  71597. maxAnimationFrames?: number;
  71598. /**
  71599. * number cell index of the base tile when the system compiles.
  71600. */
  71601. baseTile?: number;
  71602. /**
  71603. * boolean flip the sprite after its been repositioned by the framing data.
  71604. */
  71605. flipU?: boolean;
  71606. /**
  71607. * Vector3 scalar of the global RGB values of the SpriteMap.
  71608. */
  71609. colorMultiply?: Vector3;
  71610. }
  71611. /**
  71612. * Defines the IDisposable interface in order to be cleanable from resources.
  71613. */
  71614. export interface ISpriteMap extends IDisposable {
  71615. /**
  71616. * String name of the SpriteMap.
  71617. */
  71618. name: string;
  71619. /**
  71620. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  71621. */
  71622. atlasJSON: ISpriteJSONAtlas;
  71623. /**
  71624. * Texture of the SpriteMap.
  71625. */
  71626. spriteSheet: Texture;
  71627. /**
  71628. * The parameters to initialize the SpriteMap with.
  71629. */
  71630. options: ISpriteMapOptions;
  71631. }
  71632. /**
  71633. * Class used to manage a grid restricted sprite deployment on an Output plane.
  71634. */
  71635. export class SpriteMap implements ISpriteMap {
  71636. /** The Name of the spriteMap */
  71637. name: string;
  71638. /** The JSON file with the frame and meta data */
  71639. atlasJSON: ISpriteJSONAtlas;
  71640. /** The systems Sprite Sheet Texture */
  71641. spriteSheet: Texture;
  71642. /** Arguments passed with the Constructor */
  71643. options: ISpriteMapOptions;
  71644. /** Public Sprite Storage array, parsed from atlasJSON */
  71645. sprites: Array<ISpriteJSONSprite>;
  71646. /** Returns the Number of Sprites in the System */
  71647. get spriteCount(): number;
  71648. /** Returns the Position of Output Plane*/
  71649. get position(): Vector3;
  71650. /** Returns the Position of Output Plane*/
  71651. set position(v: Vector3);
  71652. /** Returns the Rotation of Output Plane*/
  71653. get rotation(): Vector3;
  71654. /** Returns the Rotation of Output Plane*/
  71655. set rotation(v: Vector3);
  71656. /** Sets the AnimationMap*/
  71657. get animationMap(): RawTexture;
  71658. /** Sets the AnimationMap*/
  71659. set animationMap(v: RawTexture);
  71660. /** Scene that the SpriteMap was created in */
  71661. private _scene;
  71662. /** Texture Buffer of Float32 that holds tile frame data*/
  71663. private _frameMap;
  71664. /** Texture Buffers of Float32 that holds tileMap data*/
  71665. private _tileMaps;
  71666. /** Texture Buffer of Float32 that holds Animation Data*/
  71667. private _animationMap;
  71668. /** Custom ShaderMaterial Central to the System*/
  71669. private _material;
  71670. /** Custom ShaderMaterial Central to the System*/
  71671. private _output;
  71672. /** Systems Time Ticker*/
  71673. private _time;
  71674. /**
  71675. * Creates a new SpriteMap
  71676. * @param name defines the SpriteMaps Name
  71677. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  71678. * @param spriteSheet is the Texture that the Sprites are on.
  71679. * @param options a basic deployment configuration
  71680. * @param scene The Scene that the map is deployed on
  71681. */
  71682. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  71683. /**
  71684. * Returns tileID location
  71685. * @returns Vector2 the cell position ID
  71686. */
  71687. getTileID(): Vector2;
  71688. /**
  71689. * Gets the UV location of the mouse over the SpriteMap.
  71690. * @returns Vector2 the UV position of the mouse interaction
  71691. */
  71692. getMousePosition(): Vector2;
  71693. /**
  71694. * Creates the "frame" texture Buffer
  71695. * -------------------------------------
  71696. * Structure of frames
  71697. * "filename": "Falling-Water-2.png",
  71698. * "frame": {"x":69,"y":103,"w":24,"h":32},
  71699. * "rotated": true,
  71700. * "trimmed": true,
  71701. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  71702. * "sourceSize": {"w":32,"h":32}
  71703. * @returns RawTexture of the frameMap
  71704. */
  71705. private _createFrameBuffer;
  71706. /**
  71707. * Creates the tileMap texture Buffer
  71708. * @param buffer normally and array of numbers, or a false to generate from scratch
  71709. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  71710. * @returns RawTexture of the tileMap
  71711. */
  71712. private _createTileBuffer;
  71713. /**
  71714. * Modifies the data of the tileMaps
  71715. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  71716. * @param pos is the iVector2 Coordinates of the Tile
  71717. * @param tile The SpriteIndex of the new Tile
  71718. */
  71719. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  71720. /**
  71721. * Creates the animationMap texture Buffer
  71722. * @param buffer normally and array of numbers, or a false to generate from scratch
  71723. * @returns RawTexture of the animationMap
  71724. */
  71725. private _createTileAnimationBuffer;
  71726. /**
  71727. * Modifies the data of the animationMap
  71728. * @param cellID is the Index of the Sprite
  71729. * @param _frame is the target Animation frame
  71730. * @param toCell is the Target Index of the next frame of the animation
  71731. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  71732. * @param speed is a global scalar of the time variable on the map.
  71733. */
  71734. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  71735. /**
  71736. * Exports the .tilemaps file
  71737. */
  71738. saveTileMaps(): void;
  71739. /**
  71740. * Imports the .tilemaps file
  71741. * @param url of the .tilemaps file
  71742. */
  71743. loadTileMaps(url: string): void;
  71744. /**
  71745. * Release associated resources
  71746. */
  71747. dispose(): void;
  71748. }
  71749. }
  71750. declare module BABYLON {
  71751. /**
  71752. * Class used to manage multiple sprites of different sizes on the same spritesheet
  71753. * @see https://doc.babylonjs.com/babylon101/sprites
  71754. */
  71755. export class SpritePackedManager extends SpriteManager {
  71756. /** defines the packed manager's name */
  71757. name: string;
  71758. /**
  71759. * Creates a new sprite manager from a packed sprite sheet
  71760. * @param name defines the manager's name
  71761. * @param imgUrl defines the sprite sheet url
  71762. * @param capacity defines the maximum allowed number of sprites
  71763. * @param scene defines the hosting scene
  71764. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  71765. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  71766. * @param samplingMode defines the smapling mode to use with spritesheet
  71767. * @param fromPacked set to true; do not alter
  71768. */
  71769. constructor(
  71770. /** defines the packed manager's name */
  71771. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  71772. }
  71773. }
  71774. declare module BABYLON {
  71775. /**
  71776. * Defines the list of states available for a task inside a AssetsManager
  71777. */
  71778. export enum AssetTaskState {
  71779. /**
  71780. * Initialization
  71781. */
  71782. INIT = 0,
  71783. /**
  71784. * Running
  71785. */
  71786. RUNNING = 1,
  71787. /**
  71788. * Done
  71789. */
  71790. DONE = 2,
  71791. /**
  71792. * Error
  71793. */
  71794. ERROR = 3
  71795. }
  71796. /**
  71797. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  71798. */
  71799. export abstract class AbstractAssetTask {
  71800. /**
  71801. * Task name
  71802. */ name: string;
  71803. /**
  71804. * Callback called when the task is successful
  71805. */
  71806. onSuccess: (task: any) => void;
  71807. /**
  71808. * Callback called when the task is not successful
  71809. */
  71810. onError: (task: any, message?: string, exception?: any) => void;
  71811. /**
  71812. * Creates a new AssetsManager
  71813. * @param name defines the name of the task
  71814. */
  71815. constructor(
  71816. /**
  71817. * Task name
  71818. */ name: string);
  71819. private _isCompleted;
  71820. private _taskState;
  71821. private _errorObject;
  71822. /**
  71823. * Get if the task is completed
  71824. */
  71825. get isCompleted(): boolean;
  71826. /**
  71827. * Gets the current state of the task
  71828. */
  71829. get taskState(): AssetTaskState;
  71830. /**
  71831. * Gets the current error object (if task is in error)
  71832. */
  71833. get errorObject(): {
  71834. message?: string;
  71835. exception?: any;
  71836. };
  71837. /**
  71838. * Internal only
  71839. * @hidden
  71840. */
  71841. _setErrorObject(message?: string, exception?: any): void;
  71842. /**
  71843. * Execute the current task
  71844. * @param scene defines the scene where you want your assets to be loaded
  71845. * @param onSuccess is a callback called when the task is successfully executed
  71846. * @param onError is a callback called if an error occurs
  71847. */
  71848. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71849. /**
  71850. * Execute the current task
  71851. * @param scene defines the scene where you want your assets to be loaded
  71852. * @param onSuccess is a callback called when the task is successfully executed
  71853. * @param onError is a callback called if an error occurs
  71854. */
  71855. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71856. /**
  71857. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  71858. * This can be used with failed tasks that have the reason for failure fixed.
  71859. */
  71860. reset(): void;
  71861. private onErrorCallback;
  71862. private onDoneCallback;
  71863. }
  71864. /**
  71865. * Define the interface used by progress events raised during assets loading
  71866. */
  71867. export interface IAssetsProgressEvent {
  71868. /**
  71869. * Defines the number of remaining tasks to process
  71870. */
  71871. remainingCount: number;
  71872. /**
  71873. * Defines the total number of tasks
  71874. */
  71875. totalCount: number;
  71876. /**
  71877. * Defines the task that was just processed
  71878. */
  71879. task: AbstractAssetTask;
  71880. }
  71881. /**
  71882. * Class used to share progress information about assets loading
  71883. */
  71884. export class AssetsProgressEvent implements IAssetsProgressEvent {
  71885. /**
  71886. * Defines the number of remaining tasks to process
  71887. */
  71888. remainingCount: number;
  71889. /**
  71890. * Defines the total number of tasks
  71891. */
  71892. totalCount: number;
  71893. /**
  71894. * Defines the task that was just processed
  71895. */
  71896. task: AbstractAssetTask;
  71897. /**
  71898. * Creates a AssetsProgressEvent
  71899. * @param remainingCount defines the number of remaining tasks to process
  71900. * @param totalCount defines the total number of tasks
  71901. * @param task defines the task that was just processed
  71902. */
  71903. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  71904. }
  71905. /**
  71906. * Define a task used by AssetsManager to load meshes
  71907. */
  71908. export class MeshAssetTask extends AbstractAssetTask {
  71909. /**
  71910. * Defines the name of the task
  71911. */
  71912. name: string;
  71913. /**
  71914. * Defines the list of mesh's names you want to load
  71915. */
  71916. meshesNames: any;
  71917. /**
  71918. * Defines the root url to use as a base to load your meshes and associated resources
  71919. */
  71920. rootUrl: string;
  71921. /**
  71922. * Defines the filename or File of the scene to load from
  71923. */
  71924. sceneFilename: string | File;
  71925. /**
  71926. * Gets the list of loaded meshes
  71927. */
  71928. loadedMeshes: Array<AbstractMesh>;
  71929. /**
  71930. * Gets the list of loaded particle systems
  71931. */
  71932. loadedParticleSystems: Array<IParticleSystem>;
  71933. /**
  71934. * Gets the list of loaded skeletons
  71935. */
  71936. loadedSkeletons: Array<Skeleton>;
  71937. /**
  71938. * Gets the list of loaded animation groups
  71939. */
  71940. loadedAnimationGroups: Array<AnimationGroup>;
  71941. /**
  71942. * Callback called when the task is successful
  71943. */
  71944. onSuccess: (task: MeshAssetTask) => void;
  71945. /**
  71946. * Callback called when the task is successful
  71947. */
  71948. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  71949. /**
  71950. * Creates a new MeshAssetTask
  71951. * @param name defines the name of the task
  71952. * @param meshesNames defines the list of mesh's names you want to load
  71953. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  71954. * @param sceneFilename defines the filename or File of the scene to load from
  71955. */
  71956. constructor(
  71957. /**
  71958. * Defines the name of the task
  71959. */
  71960. name: string,
  71961. /**
  71962. * Defines the list of mesh's names you want to load
  71963. */
  71964. meshesNames: any,
  71965. /**
  71966. * Defines the root url to use as a base to load your meshes and associated resources
  71967. */
  71968. rootUrl: string,
  71969. /**
  71970. * Defines the filename or File of the scene to load from
  71971. */
  71972. sceneFilename: string | File);
  71973. /**
  71974. * Execute the current task
  71975. * @param scene defines the scene where you want your assets to be loaded
  71976. * @param onSuccess is a callback called when the task is successfully executed
  71977. * @param onError is a callback called if an error occurs
  71978. */
  71979. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71980. }
  71981. /**
  71982. * Define a task used by AssetsManager to load text content
  71983. */
  71984. export class TextFileAssetTask extends AbstractAssetTask {
  71985. /**
  71986. * Defines the name of the task
  71987. */
  71988. name: string;
  71989. /**
  71990. * Defines the location of the file to load
  71991. */
  71992. url: string;
  71993. /**
  71994. * Gets the loaded text string
  71995. */
  71996. text: string;
  71997. /**
  71998. * Callback called when the task is successful
  71999. */
  72000. onSuccess: (task: TextFileAssetTask) => void;
  72001. /**
  72002. * Callback called when the task is successful
  72003. */
  72004. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  72005. /**
  72006. * Creates a new TextFileAssetTask object
  72007. * @param name defines the name of the task
  72008. * @param url defines the location of the file to load
  72009. */
  72010. constructor(
  72011. /**
  72012. * Defines the name of the task
  72013. */
  72014. name: string,
  72015. /**
  72016. * Defines the location of the file to load
  72017. */
  72018. url: string);
  72019. /**
  72020. * Execute the current task
  72021. * @param scene defines the scene where you want your assets to be loaded
  72022. * @param onSuccess is a callback called when the task is successfully executed
  72023. * @param onError is a callback called if an error occurs
  72024. */
  72025. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72026. }
  72027. /**
  72028. * Define a task used by AssetsManager to load binary data
  72029. */
  72030. export class BinaryFileAssetTask extends AbstractAssetTask {
  72031. /**
  72032. * Defines the name of the task
  72033. */
  72034. name: string;
  72035. /**
  72036. * Defines the location of the file to load
  72037. */
  72038. url: string;
  72039. /**
  72040. * Gets the lodaded data (as an array buffer)
  72041. */
  72042. data: ArrayBuffer;
  72043. /**
  72044. * Callback called when the task is successful
  72045. */
  72046. onSuccess: (task: BinaryFileAssetTask) => void;
  72047. /**
  72048. * Callback called when the task is successful
  72049. */
  72050. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  72051. /**
  72052. * Creates a new BinaryFileAssetTask object
  72053. * @param name defines the name of the new task
  72054. * @param url defines the location of the file to load
  72055. */
  72056. constructor(
  72057. /**
  72058. * Defines the name of the task
  72059. */
  72060. name: string,
  72061. /**
  72062. * Defines the location of the file to load
  72063. */
  72064. url: string);
  72065. /**
  72066. * Execute the current task
  72067. * @param scene defines the scene where you want your assets to be loaded
  72068. * @param onSuccess is a callback called when the task is successfully executed
  72069. * @param onError is a callback called if an error occurs
  72070. */
  72071. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72072. }
  72073. /**
  72074. * Define a task used by AssetsManager to load images
  72075. */
  72076. export class ImageAssetTask extends AbstractAssetTask {
  72077. /**
  72078. * Defines the name of the task
  72079. */
  72080. name: string;
  72081. /**
  72082. * Defines the location of the image to load
  72083. */
  72084. url: string;
  72085. /**
  72086. * Gets the loaded images
  72087. */
  72088. image: HTMLImageElement;
  72089. /**
  72090. * Callback called when the task is successful
  72091. */
  72092. onSuccess: (task: ImageAssetTask) => void;
  72093. /**
  72094. * Callback called when the task is successful
  72095. */
  72096. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  72097. /**
  72098. * Creates a new ImageAssetTask
  72099. * @param name defines the name of the task
  72100. * @param url defines the location of the image to load
  72101. */
  72102. constructor(
  72103. /**
  72104. * Defines the name of the task
  72105. */
  72106. name: string,
  72107. /**
  72108. * Defines the location of the image to load
  72109. */
  72110. url: string);
  72111. /**
  72112. * Execute the current task
  72113. * @param scene defines the scene where you want your assets to be loaded
  72114. * @param onSuccess is a callback called when the task is successfully executed
  72115. * @param onError is a callback called if an error occurs
  72116. */
  72117. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72118. }
  72119. /**
  72120. * Defines the interface used by texture loading tasks
  72121. */
  72122. export interface ITextureAssetTask<TEX extends BaseTexture> {
  72123. /**
  72124. * Gets the loaded texture
  72125. */
  72126. texture: TEX;
  72127. }
  72128. /**
  72129. * Define a task used by AssetsManager to load 2D textures
  72130. */
  72131. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  72132. /**
  72133. * Defines the name of the task
  72134. */
  72135. name: string;
  72136. /**
  72137. * Defines the location of the file to load
  72138. */
  72139. url: string;
  72140. /**
  72141. * Defines if mipmap should not be generated (default is false)
  72142. */
  72143. noMipmap?: boolean | undefined;
  72144. /**
  72145. * Defines if texture must be inverted on Y axis (default is true)
  72146. */
  72147. invertY: boolean;
  72148. /**
  72149. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72150. */
  72151. samplingMode: number;
  72152. /**
  72153. * Gets the loaded texture
  72154. */
  72155. texture: Texture;
  72156. /**
  72157. * Callback called when the task is successful
  72158. */
  72159. onSuccess: (task: TextureAssetTask) => void;
  72160. /**
  72161. * Callback called when the task is successful
  72162. */
  72163. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  72164. /**
  72165. * Creates a new TextureAssetTask object
  72166. * @param name defines the name of the task
  72167. * @param url defines the location of the file to load
  72168. * @param noMipmap defines if mipmap should not be generated (default is false)
  72169. * @param invertY defines if texture must be inverted on Y axis (default is true)
  72170. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72171. */
  72172. constructor(
  72173. /**
  72174. * Defines the name of the task
  72175. */
  72176. name: string,
  72177. /**
  72178. * Defines the location of the file to load
  72179. */
  72180. url: string,
  72181. /**
  72182. * Defines if mipmap should not be generated (default is false)
  72183. */
  72184. noMipmap?: boolean | undefined,
  72185. /**
  72186. * Defines if texture must be inverted on Y axis (default is true)
  72187. */
  72188. invertY?: boolean,
  72189. /**
  72190. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  72191. */
  72192. samplingMode?: number);
  72193. /**
  72194. * Execute the current task
  72195. * @param scene defines the scene where you want your assets to be loaded
  72196. * @param onSuccess is a callback called when the task is successfully executed
  72197. * @param onError is a callback called if an error occurs
  72198. */
  72199. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72200. }
  72201. /**
  72202. * Define a task used by AssetsManager to load cube textures
  72203. */
  72204. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  72205. /**
  72206. * Defines the name of the task
  72207. */
  72208. name: string;
  72209. /**
  72210. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72211. */
  72212. url: string;
  72213. /**
  72214. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72215. */
  72216. extensions?: string[] | undefined;
  72217. /**
  72218. * Defines if mipmaps should not be generated (default is false)
  72219. */
  72220. noMipmap?: boolean | undefined;
  72221. /**
  72222. * Defines the explicit list of files (undefined by default)
  72223. */
  72224. files?: string[] | undefined;
  72225. /**
  72226. * Gets the loaded texture
  72227. */
  72228. texture: CubeTexture;
  72229. /**
  72230. * Callback called when the task is successful
  72231. */
  72232. onSuccess: (task: CubeTextureAssetTask) => void;
  72233. /**
  72234. * Callback called when the task is successful
  72235. */
  72236. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  72237. /**
  72238. * Creates a new CubeTextureAssetTask
  72239. * @param name defines the name of the task
  72240. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72241. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72242. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72243. * @param files defines the explicit list of files (undefined by default)
  72244. */
  72245. constructor(
  72246. /**
  72247. * Defines the name of the task
  72248. */
  72249. name: string,
  72250. /**
  72251. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  72252. */
  72253. url: string,
  72254. /**
  72255. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  72256. */
  72257. extensions?: string[] | undefined,
  72258. /**
  72259. * Defines if mipmaps should not be generated (default is false)
  72260. */
  72261. noMipmap?: boolean | undefined,
  72262. /**
  72263. * Defines the explicit list of files (undefined by default)
  72264. */
  72265. files?: string[] | undefined);
  72266. /**
  72267. * Execute the current task
  72268. * @param scene defines the scene where you want your assets to be loaded
  72269. * @param onSuccess is a callback called when the task is successfully executed
  72270. * @param onError is a callback called if an error occurs
  72271. */
  72272. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72273. }
  72274. /**
  72275. * Define a task used by AssetsManager to load HDR cube textures
  72276. */
  72277. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  72278. /**
  72279. * Defines the name of the task
  72280. */
  72281. name: string;
  72282. /**
  72283. * Defines the location of the file to load
  72284. */
  72285. url: string;
  72286. /**
  72287. * Defines the desired size (the more it increases the longer the generation will be)
  72288. */
  72289. size: number;
  72290. /**
  72291. * Defines if mipmaps should not be generated (default is false)
  72292. */
  72293. noMipmap: boolean;
  72294. /**
  72295. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72296. */
  72297. generateHarmonics: boolean;
  72298. /**
  72299. * 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)
  72300. */
  72301. gammaSpace: boolean;
  72302. /**
  72303. * Internal Use Only
  72304. */
  72305. reserved: boolean;
  72306. /**
  72307. * Gets the loaded texture
  72308. */
  72309. texture: HDRCubeTexture;
  72310. /**
  72311. * Callback called when the task is successful
  72312. */
  72313. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  72314. /**
  72315. * Callback called when the task is successful
  72316. */
  72317. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  72318. /**
  72319. * Creates a new HDRCubeTextureAssetTask object
  72320. * @param name defines the name of the task
  72321. * @param url defines the location of the file to load
  72322. * @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.
  72323. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72324. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72325. * @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)
  72326. * @param reserved Internal use only
  72327. */
  72328. constructor(
  72329. /**
  72330. * Defines the name of the task
  72331. */
  72332. name: string,
  72333. /**
  72334. * Defines the location of the file to load
  72335. */
  72336. url: string,
  72337. /**
  72338. * Defines the desired size (the more it increases the longer the generation will be)
  72339. */
  72340. size: number,
  72341. /**
  72342. * Defines if mipmaps should not be generated (default is false)
  72343. */
  72344. noMipmap?: boolean,
  72345. /**
  72346. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72347. */
  72348. generateHarmonics?: boolean,
  72349. /**
  72350. * 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)
  72351. */
  72352. gammaSpace?: boolean,
  72353. /**
  72354. * Internal Use Only
  72355. */
  72356. reserved?: boolean);
  72357. /**
  72358. * Execute the current task
  72359. * @param scene defines the scene where you want your assets to be loaded
  72360. * @param onSuccess is a callback called when the task is successfully executed
  72361. * @param onError is a callback called if an error occurs
  72362. */
  72363. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72364. }
  72365. /**
  72366. * Define a task used by AssetsManager to load Equirectangular cube textures
  72367. */
  72368. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  72369. /**
  72370. * Defines the name of the task
  72371. */
  72372. name: string;
  72373. /**
  72374. * Defines the location of the file to load
  72375. */
  72376. url: string;
  72377. /**
  72378. * Defines the desired size (the more it increases the longer the generation will be)
  72379. */
  72380. size: number;
  72381. /**
  72382. * Defines if mipmaps should not be generated (default is false)
  72383. */
  72384. noMipmap: boolean;
  72385. /**
  72386. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  72387. * but the standard material would require them in Gamma space) (default is true)
  72388. */
  72389. gammaSpace: boolean;
  72390. /**
  72391. * Gets the loaded texture
  72392. */
  72393. texture: EquiRectangularCubeTexture;
  72394. /**
  72395. * Callback called when the task is successful
  72396. */
  72397. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  72398. /**
  72399. * Callback called when the task is successful
  72400. */
  72401. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  72402. /**
  72403. * Creates a new EquiRectangularCubeTextureAssetTask object
  72404. * @param name defines the name of the task
  72405. * @param url defines the location of the file to load
  72406. * @param size defines the desired size (the more it increases the longer the generation will be)
  72407. * If the size is omitted this implies you are using a preprocessed cubemap.
  72408. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72409. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  72410. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  72411. * (default is true)
  72412. */
  72413. constructor(
  72414. /**
  72415. * Defines the name of the task
  72416. */
  72417. name: string,
  72418. /**
  72419. * Defines the location of the file to load
  72420. */
  72421. url: string,
  72422. /**
  72423. * Defines the desired size (the more it increases the longer the generation will be)
  72424. */
  72425. size: number,
  72426. /**
  72427. * Defines if mipmaps should not be generated (default is false)
  72428. */
  72429. noMipmap?: boolean,
  72430. /**
  72431. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  72432. * but the standard material would require them in Gamma space) (default is true)
  72433. */
  72434. gammaSpace?: boolean);
  72435. /**
  72436. * Execute the current task
  72437. * @param scene defines the scene where you want your assets to be loaded
  72438. * @param onSuccess is a callback called when the task is successfully executed
  72439. * @param onError is a callback called if an error occurs
  72440. */
  72441. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72442. }
  72443. /**
  72444. * This class can be used to easily import assets into a scene
  72445. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  72446. */
  72447. export class AssetsManager {
  72448. private _scene;
  72449. private _isLoading;
  72450. protected _tasks: AbstractAssetTask[];
  72451. protected _waitingTasksCount: number;
  72452. protected _totalTasksCount: number;
  72453. /**
  72454. * Callback called when all tasks are processed
  72455. */
  72456. onFinish: (tasks: AbstractAssetTask[]) => void;
  72457. /**
  72458. * Callback called when a task is successful
  72459. */
  72460. onTaskSuccess: (task: AbstractAssetTask) => void;
  72461. /**
  72462. * Callback called when a task had an error
  72463. */
  72464. onTaskError: (task: AbstractAssetTask) => void;
  72465. /**
  72466. * Callback called when a task is done (whatever the result is)
  72467. */
  72468. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  72469. /**
  72470. * Observable called when all tasks are processed
  72471. */
  72472. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  72473. /**
  72474. * Observable called when a task had an error
  72475. */
  72476. onTaskErrorObservable: Observable<AbstractAssetTask>;
  72477. /**
  72478. * Observable called when all tasks were executed
  72479. */
  72480. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  72481. /**
  72482. * Observable called when a task is done (whatever the result is)
  72483. */
  72484. onProgressObservable: Observable<IAssetsProgressEvent>;
  72485. /**
  72486. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  72487. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  72488. */
  72489. useDefaultLoadingScreen: boolean;
  72490. /**
  72491. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  72492. * when all assets have been downloaded.
  72493. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  72494. */
  72495. autoHideLoadingUI: boolean;
  72496. /**
  72497. * Creates a new AssetsManager
  72498. * @param scene defines the scene to work on
  72499. */
  72500. constructor(scene: Scene);
  72501. /**
  72502. * Add a MeshAssetTask to the list of active tasks
  72503. * @param taskName defines the name of the new task
  72504. * @param meshesNames defines the name of meshes to load
  72505. * @param rootUrl defines the root url to use to locate files
  72506. * @param sceneFilename defines the filename of the scene file
  72507. * @returns a new MeshAssetTask object
  72508. */
  72509. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  72510. /**
  72511. * Add a TextFileAssetTask to the list of active tasks
  72512. * @param taskName defines the name of the new task
  72513. * @param url defines the url of the file to load
  72514. * @returns a new TextFileAssetTask object
  72515. */
  72516. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  72517. /**
  72518. * Add a BinaryFileAssetTask to the list of active tasks
  72519. * @param taskName defines the name of the new task
  72520. * @param url defines the url of the file to load
  72521. * @returns a new BinaryFileAssetTask object
  72522. */
  72523. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  72524. /**
  72525. * Add a ImageAssetTask to the list of active tasks
  72526. * @param taskName defines the name of the new task
  72527. * @param url defines the url of the file to load
  72528. * @returns a new ImageAssetTask object
  72529. */
  72530. addImageTask(taskName: string, url: string): ImageAssetTask;
  72531. /**
  72532. * Add a TextureAssetTask to the list of active tasks
  72533. * @param taskName defines the name of the new task
  72534. * @param url defines the url of the file to load
  72535. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72536. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  72537. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  72538. * @returns a new TextureAssetTask object
  72539. */
  72540. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  72541. /**
  72542. * Add a CubeTextureAssetTask to the list of active tasks
  72543. * @param taskName defines the name of the new task
  72544. * @param url defines the url of the file to load
  72545. * @param extensions defines the extension to use to load the cube map (can be null)
  72546. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72547. * @param files defines the list of files to load (can be null)
  72548. * @returns a new CubeTextureAssetTask object
  72549. */
  72550. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  72551. /**
  72552. *
  72553. * Add a HDRCubeTextureAssetTask to the list of active tasks
  72554. * @param taskName defines the name of the new task
  72555. * @param url defines the url of the file to load
  72556. * @param size defines the size you want for the cubemap (can be null)
  72557. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72558. * @param generateHarmonics defines if you want to automatically generate (true by default)
  72559. * @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)
  72560. * @param reserved Internal use only
  72561. * @returns a new HDRCubeTextureAssetTask object
  72562. */
  72563. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  72564. /**
  72565. *
  72566. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  72567. * @param taskName defines the name of the new task
  72568. * @param url defines the url of the file to load
  72569. * @param size defines the size you want for the cubemap (can be null)
  72570. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72571. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  72572. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  72573. * @returns a new EquiRectangularCubeTextureAssetTask object
  72574. */
  72575. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  72576. /**
  72577. * Remove a task from the assets manager.
  72578. * @param task the task to remove
  72579. */
  72580. removeTask(task: AbstractAssetTask): void;
  72581. private _decreaseWaitingTasksCount;
  72582. private _runTask;
  72583. /**
  72584. * Reset the AssetsManager and remove all tasks
  72585. * @return the current instance of the AssetsManager
  72586. */
  72587. reset(): AssetsManager;
  72588. /**
  72589. * Start the loading process
  72590. * @return the current instance of the AssetsManager
  72591. */
  72592. load(): AssetsManager;
  72593. /**
  72594. * Start the loading process as an async operation
  72595. * @return a promise returning the list of failed tasks
  72596. */
  72597. loadAsync(): Promise<void>;
  72598. }
  72599. }
  72600. declare module BABYLON {
  72601. /**
  72602. * Wrapper class for promise with external resolve and reject.
  72603. */
  72604. export class Deferred<T> {
  72605. /**
  72606. * The promise associated with this deferred object.
  72607. */
  72608. readonly promise: Promise<T>;
  72609. private _resolve;
  72610. private _reject;
  72611. /**
  72612. * The resolve method of the promise associated with this deferred object.
  72613. */
  72614. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  72615. /**
  72616. * The reject method of the promise associated with this deferred object.
  72617. */
  72618. get reject(): (reason?: any) => void;
  72619. /**
  72620. * Constructor for this deferred object.
  72621. */
  72622. constructor();
  72623. }
  72624. }
  72625. declare module BABYLON {
  72626. /**
  72627. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  72628. */
  72629. export class MeshExploder {
  72630. private _centerMesh;
  72631. private _meshes;
  72632. private _meshesOrigins;
  72633. private _toCenterVectors;
  72634. private _scaledDirection;
  72635. private _newPosition;
  72636. private _centerPosition;
  72637. /**
  72638. * Explodes meshes from a center mesh.
  72639. * @param meshes The meshes to explode.
  72640. * @param centerMesh The mesh to be center of explosion.
  72641. */
  72642. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  72643. private _setCenterMesh;
  72644. /**
  72645. * Get class name
  72646. * @returns "MeshExploder"
  72647. */
  72648. getClassName(): string;
  72649. /**
  72650. * "Exploded meshes"
  72651. * @returns Array of meshes with the centerMesh at index 0.
  72652. */
  72653. getMeshes(): Array<Mesh>;
  72654. /**
  72655. * Explodes meshes giving a specific direction
  72656. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  72657. */
  72658. explode(direction?: number): void;
  72659. }
  72660. }
  72661. declare module BABYLON {
  72662. /**
  72663. * Class used to help managing file picking and drag'n'drop
  72664. */
  72665. export class FilesInput {
  72666. /**
  72667. * List of files ready to be loaded
  72668. */
  72669. static get FilesToLoad(): {
  72670. [key: string]: File;
  72671. };
  72672. /**
  72673. * Callback called when a file is processed
  72674. */
  72675. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  72676. private _engine;
  72677. private _currentScene;
  72678. private _sceneLoadedCallback;
  72679. private _progressCallback;
  72680. private _additionalRenderLoopLogicCallback;
  72681. private _textureLoadingCallback;
  72682. private _startingProcessingFilesCallback;
  72683. private _onReloadCallback;
  72684. private _errorCallback;
  72685. private _elementToMonitor;
  72686. private _sceneFileToLoad;
  72687. private _filesToLoad;
  72688. /**
  72689. * Creates a new FilesInput
  72690. * @param engine defines the rendering engine
  72691. * @param scene defines the hosting scene
  72692. * @param sceneLoadedCallback callback called when scene is loaded
  72693. * @param progressCallback callback called to track progress
  72694. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  72695. * @param textureLoadingCallback callback called when a texture is loading
  72696. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  72697. * @param onReloadCallback callback called when a reload is requested
  72698. * @param errorCallback callback call if an error occurs
  72699. */
  72700. 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>);
  72701. private _dragEnterHandler;
  72702. private _dragOverHandler;
  72703. private _dropHandler;
  72704. /**
  72705. * Calls this function to listen to drag'n'drop events on a specific DOM element
  72706. * @param elementToMonitor defines the DOM element to track
  72707. */
  72708. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  72709. /** Gets the current list of files to load */
  72710. get filesToLoad(): File[];
  72711. /**
  72712. * Release all associated resources
  72713. */
  72714. dispose(): void;
  72715. private renderFunction;
  72716. private drag;
  72717. private drop;
  72718. private _traverseFolder;
  72719. private _processFiles;
  72720. /**
  72721. * Load files from a drop event
  72722. * @param event defines the drop event to use as source
  72723. */
  72724. loadFiles(event: any): void;
  72725. private _processReload;
  72726. /**
  72727. * Reload the current scene from the loaded files
  72728. */
  72729. reload(): void;
  72730. }
  72731. }
  72732. declare module BABYLON {
  72733. /**
  72734. * Defines the root class used to create scene optimization to use with SceneOptimizer
  72735. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72736. */
  72737. export class SceneOptimization {
  72738. /**
  72739. * Defines the priority of this optimization (0 by default which means first in the list)
  72740. */
  72741. priority: number;
  72742. /**
  72743. * Gets a string describing the action executed by the current optimization
  72744. * @returns description string
  72745. */
  72746. getDescription(): string;
  72747. /**
  72748. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72749. * @param scene defines the current scene where to apply this optimization
  72750. * @param optimizer defines the current optimizer
  72751. * @returns true if everything that can be done was applied
  72752. */
  72753. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72754. /**
  72755. * Creates the SceneOptimization object
  72756. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72757. * @param desc defines the description associated with the optimization
  72758. */
  72759. constructor(
  72760. /**
  72761. * Defines the priority of this optimization (0 by default which means first in the list)
  72762. */
  72763. priority?: number);
  72764. }
  72765. /**
  72766. * Defines an optimization used to reduce the size of render target textures
  72767. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72768. */
  72769. export class TextureOptimization extends SceneOptimization {
  72770. /**
  72771. * Defines the priority of this optimization (0 by default which means first in the list)
  72772. */
  72773. priority: number;
  72774. /**
  72775. * 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
  72776. */
  72777. maximumSize: number;
  72778. /**
  72779. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72780. */
  72781. step: number;
  72782. /**
  72783. * Gets a string describing the action executed by the current optimization
  72784. * @returns description string
  72785. */
  72786. getDescription(): string;
  72787. /**
  72788. * Creates the TextureOptimization object
  72789. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72790. * @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
  72791. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72792. */
  72793. constructor(
  72794. /**
  72795. * Defines the priority of this optimization (0 by default which means first in the list)
  72796. */
  72797. priority?: number,
  72798. /**
  72799. * 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
  72800. */
  72801. maximumSize?: number,
  72802. /**
  72803. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72804. */
  72805. step?: number);
  72806. /**
  72807. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72808. * @param scene defines the current scene where to apply this optimization
  72809. * @param optimizer defines the current optimizer
  72810. * @returns true if everything that can be done was applied
  72811. */
  72812. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72813. }
  72814. /**
  72815. * Defines an optimization used to increase or decrease the rendering resolution
  72816. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72817. */
  72818. export class HardwareScalingOptimization extends SceneOptimization {
  72819. /**
  72820. * Defines the priority of this optimization (0 by default which means first in the list)
  72821. */
  72822. priority: number;
  72823. /**
  72824. * Defines the maximum scale to use (2 by default)
  72825. */
  72826. maximumScale: number;
  72827. /**
  72828. * Defines the step to use between two passes (0.5 by default)
  72829. */
  72830. step: number;
  72831. private _currentScale;
  72832. private _directionOffset;
  72833. /**
  72834. * Gets a string describing the action executed by the current optimization
  72835. * @return description string
  72836. */
  72837. getDescription(): string;
  72838. /**
  72839. * Creates the HardwareScalingOptimization object
  72840. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72841. * @param maximumScale defines the maximum scale to use (2 by default)
  72842. * @param step defines the step to use between two passes (0.5 by default)
  72843. */
  72844. constructor(
  72845. /**
  72846. * Defines the priority of this optimization (0 by default which means first in the list)
  72847. */
  72848. priority?: number,
  72849. /**
  72850. * Defines the maximum scale to use (2 by default)
  72851. */
  72852. maximumScale?: number,
  72853. /**
  72854. * Defines the step to use between two passes (0.5 by default)
  72855. */
  72856. step?: number);
  72857. /**
  72858. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72859. * @param scene defines the current scene where to apply this optimization
  72860. * @param optimizer defines the current optimizer
  72861. * @returns true if everything that can be done was applied
  72862. */
  72863. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72864. }
  72865. /**
  72866. * Defines an optimization used to remove shadows
  72867. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72868. */
  72869. export class ShadowsOptimization extends SceneOptimization {
  72870. /**
  72871. * Gets a string describing the action executed by the current optimization
  72872. * @return description string
  72873. */
  72874. getDescription(): string;
  72875. /**
  72876. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72877. * @param scene defines the current scene where to apply this optimization
  72878. * @param optimizer defines the current optimizer
  72879. * @returns true if everything that can be done was applied
  72880. */
  72881. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72882. }
  72883. /**
  72884. * Defines an optimization used to turn post-processes off
  72885. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72886. */
  72887. export class PostProcessesOptimization extends SceneOptimization {
  72888. /**
  72889. * Gets a string describing the action executed by the current optimization
  72890. * @return description string
  72891. */
  72892. getDescription(): string;
  72893. /**
  72894. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72895. * @param scene defines the current scene where to apply this optimization
  72896. * @param optimizer defines the current optimizer
  72897. * @returns true if everything that can be done was applied
  72898. */
  72899. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72900. }
  72901. /**
  72902. * Defines an optimization used to turn lens flares off
  72903. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72904. */
  72905. export class LensFlaresOptimization extends SceneOptimization {
  72906. /**
  72907. * Gets a string describing the action executed by the current optimization
  72908. * @return description string
  72909. */
  72910. getDescription(): string;
  72911. /**
  72912. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72913. * @param scene defines the current scene where to apply this optimization
  72914. * @param optimizer defines the current optimizer
  72915. * @returns true if everything that can be done was applied
  72916. */
  72917. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72918. }
  72919. /**
  72920. * Defines an optimization based on user defined callback.
  72921. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72922. */
  72923. export class CustomOptimization extends SceneOptimization {
  72924. /**
  72925. * Callback called to apply the custom optimization.
  72926. */
  72927. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  72928. /**
  72929. * Callback called to get custom description
  72930. */
  72931. onGetDescription: () => string;
  72932. /**
  72933. * Gets a string describing the action executed by the current optimization
  72934. * @returns description string
  72935. */
  72936. getDescription(): string;
  72937. /**
  72938. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72939. * @param scene defines the current scene where to apply this optimization
  72940. * @param optimizer defines the current optimizer
  72941. * @returns true if everything that can be done was applied
  72942. */
  72943. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72944. }
  72945. /**
  72946. * Defines an optimization used to turn particles off
  72947. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72948. */
  72949. export class ParticlesOptimization extends SceneOptimization {
  72950. /**
  72951. * Gets a string describing the action executed by the current optimization
  72952. * @return description string
  72953. */
  72954. getDescription(): string;
  72955. /**
  72956. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72957. * @param scene defines the current scene where to apply this optimization
  72958. * @param optimizer defines the current optimizer
  72959. * @returns true if everything that can be done was applied
  72960. */
  72961. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72962. }
  72963. /**
  72964. * Defines an optimization used to turn render targets off
  72965. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72966. */
  72967. export class RenderTargetsOptimization extends SceneOptimization {
  72968. /**
  72969. * Gets a string describing the action executed by the current optimization
  72970. * @return description string
  72971. */
  72972. getDescription(): string;
  72973. /**
  72974. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72975. * @param scene defines the current scene where to apply this optimization
  72976. * @param optimizer defines the current optimizer
  72977. * @returns true if everything that can be done was applied
  72978. */
  72979. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72980. }
  72981. /**
  72982. * Defines an optimization used to merge meshes with compatible materials
  72983. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72984. */
  72985. export class MergeMeshesOptimization extends SceneOptimization {
  72986. private static _UpdateSelectionTree;
  72987. /**
  72988. * Gets or sets a boolean which defines if optimization octree has to be updated
  72989. */
  72990. static get UpdateSelectionTree(): boolean;
  72991. /**
  72992. * Gets or sets a boolean which defines if optimization octree has to be updated
  72993. */
  72994. static set UpdateSelectionTree(value: boolean);
  72995. /**
  72996. * Gets a string describing the action executed by the current optimization
  72997. * @return description string
  72998. */
  72999. getDescription(): string;
  73000. private _canBeMerged;
  73001. /**
  73002. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  73003. * @param scene defines the current scene where to apply this optimization
  73004. * @param optimizer defines the current optimizer
  73005. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  73006. * @returns true if everything that can be done was applied
  73007. */
  73008. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  73009. }
  73010. /**
  73011. * Defines a list of options used by SceneOptimizer
  73012. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73013. */
  73014. export class SceneOptimizerOptions {
  73015. /**
  73016. * Defines the target frame rate to reach (60 by default)
  73017. */
  73018. targetFrameRate: number;
  73019. /**
  73020. * Defines the interval between two checkes (2000ms by default)
  73021. */
  73022. trackerDuration: number;
  73023. /**
  73024. * Gets the list of optimizations to apply
  73025. */
  73026. optimizations: SceneOptimization[];
  73027. /**
  73028. * Creates a new list of options used by SceneOptimizer
  73029. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  73030. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  73031. */
  73032. constructor(
  73033. /**
  73034. * Defines the target frame rate to reach (60 by default)
  73035. */
  73036. targetFrameRate?: number,
  73037. /**
  73038. * Defines the interval between two checkes (2000ms by default)
  73039. */
  73040. trackerDuration?: number);
  73041. /**
  73042. * Add a new optimization
  73043. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  73044. * @returns the current SceneOptimizerOptions
  73045. */
  73046. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  73047. /**
  73048. * Add a new custom optimization
  73049. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  73050. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  73051. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  73052. * @returns the current SceneOptimizerOptions
  73053. */
  73054. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  73055. /**
  73056. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  73057. * @param targetFrameRate defines the target frame rate (60 by default)
  73058. * @returns a SceneOptimizerOptions object
  73059. */
  73060. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73061. /**
  73062. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  73063. * @param targetFrameRate defines the target frame rate (60 by default)
  73064. * @returns a SceneOptimizerOptions object
  73065. */
  73066. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73067. /**
  73068. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  73069. * @param targetFrameRate defines the target frame rate (60 by default)
  73070. * @returns a SceneOptimizerOptions object
  73071. */
  73072. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  73073. }
  73074. /**
  73075. * Class used to run optimizations in order to reach a target frame rate
  73076. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  73077. */
  73078. export class SceneOptimizer implements IDisposable {
  73079. private _isRunning;
  73080. private _options;
  73081. private _scene;
  73082. private _currentPriorityLevel;
  73083. private _targetFrameRate;
  73084. private _trackerDuration;
  73085. private _currentFrameRate;
  73086. private _sceneDisposeObserver;
  73087. private _improvementMode;
  73088. /**
  73089. * Defines an observable called when the optimizer reaches the target frame rate
  73090. */
  73091. onSuccessObservable: Observable<SceneOptimizer>;
  73092. /**
  73093. * Defines an observable called when the optimizer enables an optimization
  73094. */
  73095. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  73096. /**
  73097. * Defines an observable called when the optimizer is not able to reach the target frame rate
  73098. */
  73099. onFailureObservable: Observable<SceneOptimizer>;
  73100. /**
  73101. * Gets a boolean indicating if the optimizer is in improvement mode
  73102. */
  73103. get isInImprovementMode(): boolean;
  73104. /**
  73105. * Gets the current priority level (0 at start)
  73106. */
  73107. get currentPriorityLevel(): number;
  73108. /**
  73109. * Gets the current frame rate checked by the SceneOptimizer
  73110. */
  73111. get currentFrameRate(): number;
  73112. /**
  73113. * Gets or sets the current target frame rate (60 by default)
  73114. */
  73115. get targetFrameRate(): number;
  73116. /**
  73117. * Gets or sets the current target frame rate (60 by default)
  73118. */
  73119. set targetFrameRate(value: number);
  73120. /**
  73121. * Gets or sets the current interval between two checks (every 2000ms by default)
  73122. */
  73123. get trackerDuration(): number;
  73124. /**
  73125. * Gets or sets the current interval between two checks (every 2000ms by default)
  73126. */
  73127. set trackerDuration(value: number);
  73128. /**
  73129. * Gets the list of active optimizations
  73130. */
  73131. get optimizations(): SceneOptimization[];
  73132. /**
  73133. * Creates a new SceneOptimizer
  73134. * @param scene defines the scene to work on
  73135. * @param options defines the options to use with the SceneOptimizer
  73136. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  73137. * @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)
  73138. */
  73139. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  73140. /**
  73141. * Stops the current optimizer
  73142. */
  73143. stop(): void;
  73144. /**
  73145. * Reset the optimizer to initial step (current priority level = 0)
  73146. */
  73147. reset(): void;
  73148. /**
  73149. * Start the optimizer. By default it will try to reach a specific framerate
  73150. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  73151. */
  73152. start(): void;
  73153. private _checkCurrentState;
  73154. /**
  73155. * Release all resources
  73156. */
  73157. dispose(): void;
  73158. /**
  73159. * Helper function to create a SceneOptimizer with one single line of code
  73160. * @param scene defines the scene to work on
  73161. * @param options defines the options to use with the SceneOptimizer
  73162. * @param onSuccess defines a callback to call on success
  73163. * @param onFailure defines a callback to call on failure
  73164. * @returns the new SceneOptimizer object
  73165. */
  73166. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  73167. }
  73168. }
  73169. declare module BABYLON {
  73170. /**
  73171. * Class used to serialize a scene into a string
  73172. */
  73173. export class SceneSerializer {
  73174. /**
  73175. * Clear cache used by a previous serialization
  73176. */
  73177. static ClearCache(): void;
  73178. /**
  73179. * Serialize a scene into a JSON compatible object
  73180. * @param scene defines the scene to serialize
  73181. * @returns a JSON compatible object
  73182. */
  73183. static Serialize(scene: Scene): any;
  73184. /**
  73185. * Serialize a mesh into a JSON compatible object
  73186. * @param toSerialize defines the mesh to serialize
  73187. * @param withParents defines if parents must be serialized as well
  73188. * @param withChildren defines if children must be serialized as well
  73189. * @returns a JSON compatible object
  73190. */
  73191. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  73192. }
  73193. }
  73194. declare module BABYLON {
  73195. /**
  73196. * Class used to host texture specific utilities
  73197. */
  73198. export class TextureTools {
  73199. /**
  73200. * Uses the GPU to create a copy texture rescaled at a given size
  73201. * @param texture Texture to copy from
  73202. * @param width defines the desired width
  73203. * @param height defines the desired height
  73204. * @param useBilinearMode defines if bilinear mode has to be used
  73205. * @return the generated texture
  73206. */
  73207. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  73208. }
  73209. }
  73210. declare module BABYLON {
  73211. /**
  73212. * This represents the different options available for the video capture.
  73213. */
  73214. export interface VideoRecorderOptions {
  73215. /** Defines the mime type of the video. */
  73216. mimeType: string;
  73217. /** Defines the FPS the video should be recorded at. */
  73218. fps: number;
  73219. /** Defines the chunk size for the recording data. */
  73220. recordChunckSize: number;
  73221. /** The audio tracks to attach to the recording. */
  73222. audioTracks?: MediaStreamTrack[];
  73223. }
  73224. /**
  73225. * This can help with recording videos from BabylonJS.
  73226. * This is based on the available WebRTC functionalities of the browser.
  73227. *
  73228. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  73229. */
  73230. export class VideoRecorder {
  73231. private static readonly _defaultOptions;
  73232. /**
  73233. * Returns whether or not the VideoRecorder is available in your browser.
  73234. * @param engine Defines the Babylon Engine.
  73235. * @returns true if supported otherwise false.
  73236. */
  73237. static IsSupported(engine: Engine): boolean;
  73238. private readonly _options;
  73239. private _canvas;
  73240. private _mediaRecorder;
  73241. private _recordedChunks;
  73242. private _fileName;
  73243. private _resolve;
  73244. private _reject;
  73245. /**
  73246. * True when a recording is already in progress.
  73247. */
  73248. get isRecording(): boolean;
  73249. /**
  73250. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  73251. * @param engine Defines the BabylonJS Engine you wish to record.
  73252. * @param options Defines options that can be used to customize the capture.
  73253. */
  73254. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  73255. /**
  73256. * Stops the current recording before the default capture timeout passed in the startRecording function.
  73257. */
  73258. stopRecording(): void;
  73259. /**
  73260. * Starts recording the canvas for a max duration specified in parameters.
  73261. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  73262. * If null no automatic download will start and you can rely on the promise to get the data back.
  73263. * @param maxDuration Defines the maximum recording time in seconds.
  73264. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  73265. * @return A promise callback at the end of the recording with the video data in Blob.
  73266. */
  73267. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  73268. /**
  73269. * Releases internal resources used during the recording.
  73270. */
  73271. dispose(): void;
  73272. private _handleDataAvailable;
  73273. private _handleError;
  73274. private _handleStop;
  73275. }
  73276. }
  73277. declare module BABYLON {
  73278. /**
  73279. * Class containing a set of static utilities functions for screenshots
  73280. */
  73281. export class ScreenshotTools {
  73282. /**
  73283. * Captures a screenshot of the current rendering
  73284. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73285. * @param engine defines the rendering engine
  73286. * @param camera defines the source camera
  73287. * @param size This parameter can be set to a single number or to an object with the
  73288. * following (optional) properties: precision, width, height. If a single number is passed,
  73289. * it will be used for both width and height. If an object is passed, the screenshot size
  73290. * will be derived from the parameters. The precision property is a multiplier allowing
  73291. * rendering at a higher or lower resolution
  73292. * @param successCallback defines the callback receives a single parameter which contains the
  73293. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  73294. * src parameter of an <img> to display it
  73295. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  73296. * Check your browser for supported MIME types
  73297. */
  73298. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  73299. /**
  73300. * Captures a screenshot of the current rendering
  73301. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73302. * @param engine defines the rendering engine
  73303. * @param camera defines the source camera
  73304. * @param size This parameter can be set to a single number or to an object with the
  73305. * following (optional) properties: precision, width, height. If a single number is passed,
  73306. * it will be used for both width and height. If an object is passed, the screenshot size
  73307. * will be derived from the parameters. The precision property is a multiplier allowing
  73308. * rendering at a higher or lower resolution
  73309. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  73310. * Check your browser for supported MIME types
  73311. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  73312. * to the src parameter of an <img> to display it
  73313. */
  73314. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  73315. /**
  73316. * Generates an image screenshot from the specified camera.
  73317. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73318. * @param engine The engine to use for rendering
  73319. * @param camera The camera to use for rendering
  73320. * @param size This parameter can be set to a single number or to an object with the
  73321. * following (optional) properties: precision, width, height. If a single number is passed,
  73322. * it will be used for both width and height. If an object is passed, the screenshot size
  73323. * will be derived from the parameters. The precision property is a multiplier allowing
  73324. * rendering at a higher or lower resolution
  73325. * @param successCallback The callback receives a single parameter which contains the
  73326. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  73327. * src parameter of an <img> to display it
  73328. * @param mimeType The MIME type of the screenshot image (default: image/png).
  73329. * Check your browser for supported MIME types
  73330. * @param samples Texture samples (default: 1)
  73331. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  73332. * @param fileName A name for for the downloaded file.
  73333. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  73334. */
  73335. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  73336. /**
  73337. * Generates an image screenshot from the specified camera.
  73338. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  73339. * @param engine The engine to use for rendering
  73340. * @param camera The camera to use for rendering
  73341. * @param size This parameter can be set to a single number or to an object with the
  73342. * following (optional) properties: precision, width, height. If a single number is passed,
  73343. * it will be used for both width and height. If an object is passed, the screenshot size
  73344. * will be derived from the parameters. The precision property is a multiplier allowing
  73345. * rendering at a higher or lower resolution
  73346. * @param mimeType The MIME type of the screenshot image (default: image/png).
  73347. * Check your browser for supported MIME types
  73348. * @param samples Texture samples (default: 1)
  73349. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  73350. * @param fileName A name for for the downloaded file.
  73351. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  73352. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  73353. * to the src parameter of an <img> to display it
  73354. */
  73355. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  73356. /**
  73357. * Gets height and width for screenshot size
  73358. * @private
  73359. */
  73360. private static _getScreenshotSize;
  73361. }
  73362. }
  73363. declare module BABYLON {
  73364. /**
  73365. * Interface for a data buffer
  73366. */
  73367. export interface IDataBuffer {
  73368. /**
  73369. * Reads bytes from the data buffer.
  73370. * @param byteOffset The byte offset to read
  73371. * @param byteLength The byte length to read
  73372. * @returns A promise that resolves when the bytes are read
  73373. */
  73374. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  73375. /**
  73376. * The byte length of the buffer.
  73377. */
  73378. readonly byteLength: number;
  73379. }
  73380. /**
  73381. * Utility class for reading from a data buffer
  73382. */
  73383. export class DataReader {
  73384. /**
  73385. * The data buffer associated with this data reader.
  73386. */
  73387. readonly buffer: IDataBuffer;
  73388. /**
  73389. * The current byte offset from the beginning of the data buffer.
  73390. */
  73391. byteOffset: number;
  73392. private _dataView;
  73393. private _dataByteOffset;
  73394. /**
  73395. * Constructor
  73396. * @param buffer The buffer to read
  73397. */
  73398. constructor(buffer: IDataBuffer);
  73399. /**
  73400. * Loads the given byte length.
  73401. * @param byteLength The byte length to load
  73402. * @returns A promise that resolves when the load is complete
  73403. */
  73404. loadAsync(byteLength: number): Promise<void>;
  73405. /**
  73406. * Read a unsigned 32-bit integer from the currently loaded data range.
  73407. * @returns The 32-bit integer read
  73408. */
  73409. readUint32(): number;
  73410. /**
  73411. * Read a byte array from the currently loaded data range.
  73412. * @param byteLength The byte length to read
  73413. * @returns The byte array read
  73414. */
  73415. readUint8Array(byteLength: number): Uint8Array;
  73416. /**
  73417. * Read a string from the currently loaded data range.
  73418. * @param byteLength The byte length to read
  73419. * @returns The string read
  73420. */
  73421. readString(byteLength: number): string;
  73422. /**
  73423. * Skips the given byte length the currently loaded data range.
  73424. * @param byteLength The byte length to skip
  73425. */
  73426. skipBytes(byteLength: number): void;
  73427. }
  73428. }
  73429. declare module BABYLON {
  73430. /**
  73431. * Class for storing data to local storage if available or in-memory storage otherwise
  73432. */
  73433. export class DataStorage {
  73434. private static _Storage;
  73435. private static _GetStorage;
  73436. /**
  73437. * Reads a string from the data storage
  73438. * @param key The key to read
  73439. * @param defaultValue The value if the key doesn't exist
  73440. * @returns The string value
  73441. */
  73442. static ReadString(key: string, defaultValue: string): string;
  73443. /**
  73444. * Writes a string to the data storage
  73445. * @param key The key to write
  73446. * @param value The value to write
  73447. */
  73448. static WriteString(key: string, value: string): void;
  73449. /**
  73450. * Reads a boolean from the data storage
  73451. * @param key The key to read
  73452. * @param defaultValue The value if the key doesn't exist
  73453. * @returns The boolean value
  73454. */
  73455. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  73456. /**
  73457. * Writes a boolean to the data storage
  73458. * @param key The key to write
  73459. * @param value The value to write
  73460. */
  73461. static WriteBoolean(key: string, value: boolean): void;
  73462. /**
  73463. * Reads a number from the data storage
  73464. * @param key The key to read
  73465. * @param defaultValue The value if the key doesn't exist
  73466. * @returns The number value
  73467. */
  73468. static ReadNumber(key: string, defaultValue: number): number;
  73469. /**
  73470. * Writes a number to the data storage
  73471. * @param key The key to write
  73472. * @param value The value to write
  73473. */
  73474. static WriteNumber(key: string, value: number): void;
  73475. }
  73476. }
  73477. declare module BABYLON {
  73478. /**
  73479. * Class used to record delta files between 2 scene states
  73480. */
  73481. export class SceneRecorder {
  73482. private _trackedScene;
  73483. private _savedJSON;
  73484. /**
  73485. * Track a given scene. This means the current scene state will be considered the original state
  73486. * @param scene defines the scene to track
  73487. */
  73488. track(scene: Scene): void;
  73489. /**
  73490. * Get the delta between current state and original state
  73491. * @returns a string containing the delta
  73492. */
  73493. getDelta(): any;
  73494. private _compareArray;
  73495. private _compareObjects;
  73496. private _compareCollections;
  73497. /**
  73498. * Apply a given delta to a given scene
  73499. * @param deltaJSON defines the JSON containing the delta
  73500. * @param scene defines the scene to apply the delta to
  73501. */
  73502. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  73503. private static _ApplyPropertiesToEntity;
  73504. private static _ApplyDeltaForEntity;
  73505. }
  73506. }
  73507. declare module BABYLON {
  73508. /**
  73509. * An interface for all Hit test features
  73510. */
  73511. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  73512. /**
  73513. * Triggered when new babylon (transformed) hit test results are available
  73514. */
  73515. onHitTestResultObservable: Observable<T[]>;
  73516. }
  73517. /**
  73518. * Options used for hit testing
  73519. */
  73520. export interface IWebXRLegacyHitTestOptions {
  73521. /**
  73522. * Only test when user interacted with the scene. Default - hit test every frame
  73523. */
  73524. testOnPointerDownOnly?: boolean;
  73525. /**
  73526. * The node to use to transform the local results to world coordinates
  73527. */
  73528. worldParentNode?: TransformNode;
  73529. }
  73530. /**
  73531. * Interface defining the babylon result of raycasting/hit-test
  73532. */
  73533. export interface IWebXRLegacyHitResult {
  73534. /**
  73535. * Transformation matrix that can be applied to a node that will put it in the hit point location
  73536. */
  73537. transformationMatrix: Matrix;
  73538. /**
  73539. * The native hit test result
  73540. */
  73541. xrHitResult: XRHitResult | XRHitTestResult;
  73542. }
  73543. /**
  73544. * The currently-working hit-test module.
  73545. * Hit test (or Ray-casting) is used to interact with the real world.
  73546. * For further information read here - https://github.com/immersive-web/hit-test
  73547. */
  73548. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  73549. /**
  73550. * options to use when constructing this feature
  73551. */
  73552. readonly options: IWebXRLegacyHitTestOptions;
  73553. private _direction;
  73554. private _mat;
  73555. private _onSelectEnabled;
  73556. private _origin;
  73557. /**
  73558. * The module's name
  73559. */
  73560. static readonly Name: string;
  73561. /**
  73562. * The (Babylon) version of this module.
  73563. * This is an integer representing the implementation version.
  73564. * This number does not correspond to the WebXR specs version
  73565. */
  73566. static readonly Version: number;
  73567. /**
  73568. * Populated with the last native XR Hit Results
  73569. */
  73570. lastNativeXRHitResults: XRHitResult[];
  73571. /**
  73572. * Triggered when new babylon (transformed) hit test results are available
  73573. */
  73574. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  73575. /**
  73576. * Creates a new instance of the (legacy version) hit test feature
  73577. * @param _xrSessionManager an instance of WebXRSessionManager
  73578. * @param options options to use when constructing this feature
  73579. */
  73580. constructor(_xrSessionManager: WebXRSessionManager,
  73581. /**
  73582. * options to use when constructing this feature
  73583. */
  73584. options?: IWebXRLegacyHitTestOptions);
  73585. /**
  73586. * execute a hit test with an XR Ray
  73587. *
  73588. * @param xrSession a native xrSession that will execute this hit test
  73589. * @param xrRay the ray (position and direction) to use for ray-casting
  73590. * @param referenceSpace native XR reference space to use for the hit-test
  73591. * @param filter filter function that will filter the results
  73592. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  73593. */
  73594. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  73595. /**
  73596. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  73597. * @param event the (select) event to use to select with
  73598. * @param referenceSpace the reference space to use for this hit test
  73599. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  73600. */
  73601. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  73602. /**
  73603. * attach this feature
  73604. * Will usually be called by the features manager
  73605. *
  73606. * @returns true if successful.
  73607. */
  73608. attach(): boolean;
  73609. /**
  73610. * detach this feature.
  73611. * Will usually be called by the features manager
  73612. *
  73613. * @returns true if successful.
  73614. */
  73615. detach(): boolean;
  73616. /**
  73617. * Dispose this feature and all of the resources attached
  73618. */
  73619. dispose(): void;
  73620. protected _onXRFrame(frame: XRFrame): void;
  73621. private _onHitTestResults;
  73622. private _onSelect;
  73623. }
  73624. }
  73625. declare module BABYLON {
  73626. /**
  73627. * Options used for hit testing (version 2)
  73628. */
  73629. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  73630. /**
  73631. * Do not create a permanent hit test. Will usually be used when only
  73632. * transient inputs are needed.
  73633. */
  73634. disablePermanentHitTest?: boolean;
  73635. /**
  73636. * Enable transient (for example touch-based) hit test inspections
  73637. */
  73638. enableTransientHitTest?: boolean;
  73639. /**
  73640. * Offset ray for the permanent hit test
  73641. */
  73642. offsetRay?: Vector3;
  73643. /**
  73644. * Offset ray for the transient hit test
  73645. */
  73646. transientOffsetRay?: Vector3;
  73647. /**
  73648. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  73649. */
  73650. useReferenceSpace?: boolean;
  73651. }
  73652. /**
  73653. * Interface defining the babylon result of hit-test
  73654. */
  73655. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  73656. /**
  73657. * The input source that generated this hit test (if transient)
  73658. */
  73659. inputSource?: XRInputSource;
  73660. /**
  73661. * Is this a transient hit test
  73662. */
  73663. isTransient?: boolean;
  73664. /**
  73665. * Position of the hit test result
  73666. */
  73667. position: Vector3;
  73668. /**
  73669. * Rotation of the hit test result
  73670. */
  73671. rotationQuaternion: Quaternion;
  73672. /**
  73673. * The native hit test result
  73674. */
  73675. xrHitResult: XRHitTestResult;
  73676. }
  73677. /**
  73678. * The currently-working hit-test module.
  73679. * Hit test (or Ray-casting) is used to interact with the real world.
  73680. * For further information read here - https://github.com/immersive-web/hit-test
  73681. *
  73682. * Tested on chrome (mobile) 80.
  73683. */
  73684. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  73685. /**
  73686. * options to use when constructing this feature
  73687. */
  73688. readonly options: IWebXRHitTestOptions;
  73689. private _tmpMat;
  73690. private _tmpPos;
  73691. private _tmpQuat;
  73692. private _transientXrHitTestSource;
  73693. private _xrHitTestSource;
  73694. private initHitTestSource;
  73695. /**
  73696. * The module's name
  73697. */
  73698. static readonly Name: string;
  73699. /**
  73700. * The (Babylon) version of this module.
  73701. * This is an integer representing the implementation version.
  73702. * This number does not correspond to the WebXR specs version
  73703. */
  73704. static readonly Version: number;
  73705. /**
  73706. * When set to true, each hit test will have its own position/rotation objects
  73707. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  73708. * the developers will clone them or copy them as they see fit.
  73709. */
  73710. autoCloneTransformation: boolean;
  73711. /**
  73712. * Triggered when new babylon (transformed) hit test results are available
  73713. */
  73714. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  73715. /**
  73716. * Use this to temporarily pause hit test checks.
  73717. */
  73718. paused: boolean;
  73719. /**
  73720. * Creates a new instance of the hit test feature
  73721. * @param _xrSessionManager an instance of WebXRSessionManager
  73722. * @param options options to use when constructing this feature
  73723. */
  73724. constructor(_xrSessionManager: WebXRSessionManager,
  73725. /**
  73726. * options to use when constructing this feature
  73727. */
  73728. options?: IWebXRHitTestOptions);
  73729. /**
  73730. * attach this feature
  73731. * Will usually be called by the features manager
  73732. *
  73733. * @returns true if successful.
  73734. */
  73735. attach(): boolean;
  73736. /**
  73737. * detach this feature.
  73738. * Will usually be called by the features manager
  73739. *
  73740. * @returns true if successful.
  73741. */
  73742. detach(): boolean;
  73743. /**
  73744. * Dispose this feature and all of the resources attached
  73745. */
  73746. dispose(): void;
  73747. protected _onXRFrame(frame: XRFrame): void;
  73748. private _processWebXRHitTestResult;
  73749. }
  73750. }
  73751. declare module BABYLON {
  73752. /**
  73753. * Configuration options of the anchor system
  73754. */
  73755. export interface IWebXRAnchorSystemOptions {
  73756. /**
  73757. * a node that will be used to convert local to world coordinates
  73758. */
  73759. worldParentNode?: TransformNode;
  73760. /**
  73761. * If set to true a reference of the created anchors will be kept until the next session starts
  73762. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  73763. */
  73764. doNotRemoveAnchorsOnSessionEnded?: boolean;
  73765. }
  73766. /**
  73767. * A babylon container for an XR Anchor
  73768. */
  73769. export interface IWebXRAnchor {
  73770. /**
  73771. * A babylon-assigned ID for this anchor
  73772. */
  73773. id: number;
  73774. /**
  73775. * Transformation matrix to apply to an object attached to this anchor
  73776. */
  73777. transformationMatrix: Matrix;
  73778. /**
  73779. * The native anchor object
  73780. */
  73781. xrAnchor: XRAnchor;
  73782. /**
  73783. * if defined, this object will be constantly updated by the anchor's position and rotation
  73784. */
  73785. attachedNode?: TransformNode;
  73786. }
  73787. /**
  73788. * An implementation of the anchor system for WebXR.
  73789. * For further information see https://github.com/immersive-web/anchors/
  73790. */
  73791. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  73792. private _options;
  73793. private _lastFrameDetected;
  73794. private _trackedAnchors;
  73795. private _referenceSpaceForFrameAnchors;
  73796. private _futureAnchors;
  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. * Observers registered here will be executed when a new anchor was added to the session
  73809. */
  73810. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  73811. /**
  73812. * Observers registered here will be executed when an anchor was removed from the session
  73813. */
  73814. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  73815. /**
  73816. * Observers registered here will be executed when an existing anchor updates
  73817. * This can execute N times every frame
  73818. */
  73819. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  73820. /**
  73821. * Set the reference space to use for anchor creation, when not using a hit test.
  73822. * Will default to the session's reference space if not defined
  73823. */
  73824. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  73825. /**
  73826. * constructs a new anchor system
  73827. * @param _xrSessionManager an instance of WebXRSessionManager
  73828. * @param _options configuration object for this feature
  73829. */
  73830. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  73831. private _tmpVector;
  73832. private _tmpQuaternion;
  73833. private _populateTmpTransformation;
  73834. /**
  73835. * Create a new anchor point using a hit test result at a specific point in the scene
  73836. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  73837. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  73838. *
  73839. * @param hitTestResult The hit test result to use for this anchor creation
  73840. * @param position an optional position offset for this anchor
  73841. * @param rotationQuaternion an optional rotation offset for this anchor
  73842. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  73843. */
  73844. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  73845. /**
  73846. * Add a new anchor at a specific position and rotation
  73847. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  73848. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  73849. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  73850. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  73851. *
  73852. * @param position the position in which to add an anchor
  73853. * @param rotationQuaternion an optional rotation for the anchor transformation
  73854. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  73855. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  73856. */
  73857. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  73858. /**
  73859. * detach this feature.
  73860. * Will usually be called by the features manager
  73861. *
  73862. * @returns true if successful.
  73863. */
  73864. detach(): boolean;
  73865. /**
  73866. * Dispose this feature and all of the resources attached
  73867. */
  73868. dispose(): void;
  73869. protected _onXRFrame(frame: XRFrame): void;
  73870. /**
  73871. * avoiding using Array.find for global support.
  73872. * @param xrAnchor the plane to find in the array
  73873. */
  73874. private _findIndexInAnchorArray;
  73875. private _updateAnchorWithXRFrame;
  73876. private _createAnchorAtTransformation;
  73877. }
  73878. }
  73879. declare module BABYLON {
  73880. /**
  73881. * Options used in the plane detector module
  73882. */
  73883. export interface IWebXRPlaneDetectorOptions {
  73884. /**
  73885. * The node to use to transform the local results to world coordinates
  73886. */
  73887. worldParentNode?: TransformNode;
  73888. /**
  73889. * If set to true a reference of the created planes will be kept until the next session starts
  73890. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  73891. */
  73892. doNotRemovePlanesOnSessionEnded?: boolean;
  73893. }
  73894. /**
  73895. * A babylon interface for a WebXR plane.
  73896. * A Plane is actually a polygon, built from N points in space
  73897. *
  73898. * Supported in chrome 79, not supported in canary 81 ATM
  73899. */
  73900. export interface IWebXRPlane {
  73901. /**
  73902. * a babylon-assigned ID for this polygon
  73903. */
  73904. id: number;
  73905. /**
  73906. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  73907. */
  73908. polygonDefinition: Array<Vector3>;
  73909. /**
  73910. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  73911. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  73912. */
  73913. transformationMatrix: Matrix;
  73914. /**
  73915. * the native xr-plane object
  73916. */
  73917. xrPlane: XRPlane;
  73918. }
  73919. /**
  73920. * The plane detector is used to detect planes in the real world when in AR
  73921. * For more information see https://github.com/immersive-web/real-world-geometry/
  73922. */
  73923. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  73924. private _options;
  73925. private _detectedPlanes;
  73926. private _enabled;
  73927. private _lastFrameDetected;
  73928. /**
  73929. * The module's name
  73930. */
  73931. static readonly Name: string;
  73932. /**
  73933. * The (Babylon) version of this module.
  73934. * This is an integer representing the implementation version.
  73935. * This number does not correspond to the WebXR specs version
  73936. */
  73937. static readonly Version: number;
  73938. /**
  73939. * Observers registered here will be executed when a new plane was added to the session
  73940. */
  73941. onPlaneAddedObservable: Observable<IWebXRPlane>;
  73942. /**
  73943. * Observers registered here will be executed when a plane is no longer detected in the session
  73944. */
  73945. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  73946. /**
  73947. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  73948. * This can execute N times every frame
  73949. */
  73950. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  73951. /**
  73952. * construct a new Plane Detector
  73953. * @param _xrSessionManager an instance of xr Session manager
  73954. * @param _options configuration to use when constructing this feature
  73955. */
  73956. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  73957. /**
  73958. * detach this feature.
  73959. * Will usually be called by the features manager
  73960. *
  73961. * @returns true if successful.
  73962. */
  73963. detach(): boolean;
  73964. /**
  73965. * Dispose this feature and all of the resources attached
  73966. */
  73967. dispose(): void;
  73968. protected _onXRFrame(frame: XRFrame): void;
  73969. private _init;
  73970. private _updatePlaneWithXRPlane;
  73971. /**
  73972. * avoiding using Array.find for global support.
  73973. * @param xrPlane the plane to find in the array
  73974. */
  73975. private findIndexInPlaneArray;
  73976. }
  73977. }
  73978. declare module BABYLON {
  73979. /**
  73980. * Options interface for the background remover plugin
  73981. */
  73982. export interface IWebXRBackgroundRemoverOptions {
  73983. /**
  73984. * Further background meshes to disable when entering AR
  73985. */
  73986. backgroundMeshes?: AbstractMesh[];
  73987. /**
  73988. * flags to configure the removal of the environment helper.
  73989. * If not set, the entire background will be removed. If set, flags should be set as well.
  73990. */
  73991. environmentHelperRemovalFlags?: {
  73992. /**
  73993. * Should the skybox be removed (default false)
  73994. */
  73995. skyBox?: boolean;
  73996. /**
  73997. * Should the ground be removed (default false)
  73998. */
  73999. ground?: boolean;
  74000. };
  74001. /**
  74002. * don't disable the environment helper
  74003. */
  74004. ignoreEnvironmentHelper?: boolean;
  74005. }
  74006. /**
  74007. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  74008. */
  74009. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  74010. /**
  74011. * read-only options to be used in this module
  74012. */
  74013. readonly options: IWebXRBackgroundRemoverOptions;
  74014. /**
  74015. * The module's name
  74016. */
  74017. static readonly Name: string;
  74018. /**
  74019. * The (Babylon) version of this module.
  74020. * This is an integer representing the implementation version.
  74021. * This number does not correspond to the WebXR specs version
  74022. */
  74023. static readonly Version: number;
  74024. /**
  74025. * registered observers will be triggered when the background state changes
  74026. */
  74027. onBackgroundStateChangedObservable: Observable<boolean>;
  74028. /**
  74029. * constructs a new background remover module
  74030. * @param _xrSessionManager the session manager for this module
  74031. * @param options read-only options to be used in this module
  74032. */
  74033. constructor(_xrSessionManager: WebXRSessionManager,
  74034. /**
  74035. * read-only options to be used in this module
  74036. */
  74037. options?: IWebXRBackgroundRemoverOptions);
  74038. /**
  74039. * attach this feature
  74040. * Will usually be called by the features manager
  74041. *
  74042. * @returns true if successful.
  74043. */
  74044. attach(): boolean;
  74045. /**
  74046. * detach this feature.
  74047. * Will usually be called by the features manager
  74048. *
  74049. * @returns true if successful.
  74050. */
  74051. detach(): boolean;
  74052. /**
  74053. * Dispose this feature and all of the resources attached
  74054. */
  74055. dispose(): void;
  74056. protected _onXRFrame(_xrFrame: XRFrame): void;
  74057. private _setBackgroundState;
  74058. }
  74059. }
  74060. declare module BABYLON {
  74061. /**
  74062. * Options for the controller physics feature
  74063. */
  74064. export class IWebXRControllerPhysicsOptions {
  74065. /**
  74066. * Should the headset get its own impostor
  74067. */
  74068. enableHeadsetImpostor?: boolean;
  74069. /**
  74070. * Optional parameters for the headset impostor
  74071. */
  74072. headsetImpostorParams?: {
  74073. /**
  74074. * The type of impostor to create. Default is sphere
  74075. */
  74076. impostorType: number;
  74077. /**
  74078. * the size of the impostor. Defaults to 10cm
  74079. */
  74080. impostorSize?: number | {
  74081. width: number;
  74082. height: number;
  74083. depth: number;
  74084. };
  74085. /**
  74086. * Friction definitions
  74087. */
  74088. friction?: number;
  74089. /**
  74090. * Restitution
  74091. */
  74092. restitution?: number;
  74093. };
  74094. /**
  74095. * The physics properties of the future impostors
  74096. */
  74097. physicsProperties?: {
  74098. /**
  74099. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  74100. * Note that this requires a physics engine that supports mesh impostors!
  74101. */
  74102. useControllerMesh?: boolean;
  74103. /**
  74104. * The type of impostor to create. Default is sphere
  74105. */
  74106. impostorType?: number;
  74107. /**
  74108. * the size of the impostor. Defaults to 10cm
  74109. */
  74110. impostorSize?: number | {
  74111. width: number;
  74112. height: number;
  74113. depth: number;
  74114. };
  74115. /**
  74116. * Friction definitions
  74117. */
  74118. friction?: number;
  74119. /**
  74120. * Restitution
  74121. */
  74122. restitution?: number;
  74123. };
  74124. /**
  74125. * the xr input to use with this pointer selection
  74126. */
  74127. xrInput: WebXRInput;
  74128. }
  74129. /**
  74130. * Add physics impostor to your webxr controllers,
  74131. * including naive calculation of their linear and angular velocity
  74132. */
  74133. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  74134. private readonly _options;
  74135. private _attachController;
  74136. private _controllers;
  74137. private _debugMode;
  74138. private _delta;
  74139. private _headsetImpostor?;
  74140. private _headsetMesh?;
  74141. private _lastTimestamp;
  74142. private _tmpQuaternion;
  74143. private _tmpVector;
  74144. /**
  74145. * The module's name
  74146. */
  74147. static readonly Name: string;
  74148. /**
  74149. * The (Babylon) version of this module.
  74150. * This is an integer representing the implementation version.
  74151. * This number does not correspond to the webxr specs version
  74152. */
  74153. static readonly Version: number;
  74154. /**
  74155. * Construct a new Controller Physics Feature
  74156. * @param _xrSessionManager the corresponding xr session manager
  74157. * @param _options options to create this feature with
  74158. */
  74159. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  74160. /**
  74161. * @hidden
  74162. * enable debugging - will show console outputs and the impostor mesh
  74163. */
  74164. _enablePhysicsDebug(): void;
  74165. /**
  74166. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  74167. * @param xrController the controller to add
  74168. */
  74169. addController(xrController: WebXRInputSource): void;
  74170. /**
  74171. * attach this feature
  74172. * Will usually be called by the features manager
  74173. *
  74174. * @returns true if successful.
  74175. */
  74176. attach(): boolean;
  74177. /**
  74178. * detach this feature.
  74179. * Will usually be called by the features manager
  74180. *
  74181. * @returns true if successful.
  74182. */
  74183. detach(): boolean;
  74184. /**
  74185. * Get the headset impostor, if enabled
  74186. * @returns the impostor
  74187. */
  74188. getHeadsetImpostor(): PhysicsImpostor | undefined;
  74189. /**
  74190. * Get the physics impostor of a specific controller.
  74191. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  74192. * @param controller the controller or the controller id of which to get the impostor
  74193. * @returns the impostor or null
  74194. */
  74195. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  74196. /**
  74197. * Update the physics properties provided in the constructor
  74198. * @param newProperties the new properties object
  74199. */
  74200. setPhysicsProperties(newProperties: {
  74201. impostorType?: number;
  74202. impostorSize?: number | {
  74203. width: number;
  74204. height: number;
  74205. depth: number;
  74206. };
  74207. friction?: number;
  74208. restitution?: number;
  74209. }): void;
  74210. protected _onXRFrame(_xrFrame: any): void;
  74211. private _detachController;
  74212. }
  74213. }
  74214. declare module BABYLON {
  74215. /**
  74216. * The motion controller class for all microsoft mixed reality controllers
  74217. */
  74218. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  74219. protected readonly _mapping: {
  74220. defaultButton: {
  74221. valueNodeName: string;
  74222. unpressedNodeName: string;
  74223. pressedNodeName: string;
  74224. };
  74225. defaultAxis: {
  74226. valueNodeName: string;
  74227. minNodeName: string;
  74228. maxNodeName: string;
  74229. };
  74230. buttons: {
  74231. "xr-standard-trigger": {
  74232. rootNodeName: string;
  74233. componentProperty: string;
  74234. states: string[];
  74235. };
  74236. "xr-standard-squeeze": {
  74237. rootNodeName: string;
  74238. componentProperty: string;
  74239. states: string[];
  74240. };
  74241. "xr-standard-touchpad": {
  74242. rootNodeName: string;
  74243. labelAnchorNodeName: string;
  74244. touchPointNodeName: string;
  74245. };
  74246. "xr-standard-thumbstick": {
  74247. rootNodeName: string;
  74248. componentProperty: string;
  74249. states: string[];
  74250. };
  74251. };
  74252. axes: {
  74253. "xr-standard-touchpad": {
  74254. "x-axis": {
  74255. rootNodeName: string;
  74256. };
  74257. "y-axis": {
  74258. rootNodeName: string;
  74259. };
  74260. };
  74261. "xr-standard-thumbstick": {
  74262. "x-axis": {
  74263. rootNodeName: string;
  74264. };
  74265. "y-axis": {
  74266. rootNodeName: string;
  74267. };
  74268. };
  74269. };
  74270. };
  74271. /**
  74272. * The base url used to load the left and right controller models
  74273. */
  74274. static MODEL_BASE_URL: string;
  74275. /**
  74276. * The name of the left controller model file
  74277. */
  74278. static MODEL_LEFT_FILENAME: string;
  74279. /**
  74280. * The name of the right controller model file
  74281. */
  74282. static MODEL_RIGHT_FILENAME: string;
  74283. profileId: string;
  74284. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  74285. protected _getFilenameAndPath(): {
  74286. filename: string;
  74287. path: string;
  74288. };
  74289. protected _getModelLoadingConstraints(): boolean;
  74290. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74291. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74292. protected _updateModel(): void;
  74293. }
  74294. }
  74295. declare module BABYLON {
  74296. /**
  74297. * The motion controller class for oculus touch (quest, rift).
  74298. * This class supports legacy mapping as well the standard xr mapping
  74299. */
  74300. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  74301. private _forceLegacyControllers;
  74302. private _modelRootNode;
  74303. /**
  74304. * The base url used to load the left and right controller models
  74305. */
  74306. static MODEL_BASE_URL: string;
  74307. /**
  74308. * The name of the left controller model file
  74309. */
  74310. static MODEL_LEFT_FILENAME: string;
  74311. /**
  74312. * The name of the right controller model file
  74313. */
  74314. static MODEL_RIGHT_FILENAME: string;
  74315. /**
  74316. * Base Url for the Quest controller model.
  74317. */
  74318. static QUEST_MODEL_BASE_URL: string;
  74319. profileId: string;
  74320. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  74321. protected _getFilenameAndPath(): {
  74322. filename: string;
  74323. path: string;
  74324. };
  74325. protected _getModelLoadingConstraints(): boolean;
  74326. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74327. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74328. protected _updateModel(): void;
  74329. /**
  74330. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  74331. * between the touch and touch 2.
  74332. */
  74333. private _isQuest;
  74334. }
  74335. }
  74336. declare module BABYLON {
  74337. /**
  74338. * The motion controller class for the standard HTC-Vive controllers
  74339. */
  74340. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  74341. private _modelRootNode;
  74342. /**
  74343. * The base url used to load the left and right controller models
  74344. */
  74345. static MODEL_BASE_URL: string;
  74346. /**
  74347. * File name for the controller model.
  74348. */
  74349. static MODEL_FILENAME: string;
  74350. profileId: string;
  74351. /**
  74352. * Create a new Vive motion controller object
  74353. * @param scene the scene to use to create this controller
  74354. * @param gamepadObject the corresponding gamepad object
  74355. * @param handedness the handedness of the controller
  74356. */
  74357. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  74358. protected _getFilenameAndPath(): {
  74359. filename: string;
  74360. path: string;
  74361. };
  74362. protected _getModelLoadingConstraints(): boolean;
  74363. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74364. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74365. protected _updateModel(): void;
  74366. }
  74367. }
  74368. declare module BABYLON {
  74369. /**
  74370. * A cursor which tracks a point on a path
  74371. */
  74372. export class PathCursor {
  74373. private path;
  74374. /**
  74375. * Stores path cursor callbacks for when an onchange event is triggered
  74376. */
  74377. private _onchange;
  74378. /**
  74379. * The value of the path cursor
  74380. */
  74381. value: number;
  74382. /**
  74383. * The animation array of the path cursor
  74384. */
  74385. animations: Animation[];
  74386. /**
  74387. * Initializes the path cursor
  74388. * @param path The path to track
  74389. */
  74390. constructor(path: Path2);
  74391. /**
  74392. * Gets the cursor point on the path
  74393. * @returns A point on the path cursor at the cursor location
  74394. */
  74395. getPoint(): Vector3;
  74396. /**
  74397. * Moves the cursor ahead by the step amount
  74398. * @param step The amount to move the cursor forward
  74399. * @returns This path cursor
  74400. */
  74401. moveAhead(step?: number): PathCursor;
  74402. /**
  74403. * Moves the cursor behind by the step amount
  74404. * @param step The amount to move the cursor back
  74405. * @returns This path cursor
  74406. */
  74407. moveBack(step?: number): PathCursor;
  74408. /**
  74409. * Moves the cursor by the step amount
  74410. * If the step amount is greater than one, an exception is thrown
  74411. * @param step The amount to move the cursor
  74412. * @returns This path cursor
  74413. */
  74414. move(step: number): PathCursor;
  74415. /**
  74416. * Ensures that the value is limited between zero and one
  74417. * @returns This path cursor
  74418. */
  74419. private ensureLimits;
  74420. /**
  74421. * Runs onchange callbacks on change (used by the animation engine)
  74422. * @returns This path cursor
  74423. */
  74424. private raiseOnChange;
  74425. /**
  74426. * Executes a function on change
  74427. * @param f A path cursor onchange callback
  74428. * @returns This path cursor
  74429. */
  74430. onchange(f: (cursor: PathCursor) => void): PathCursor;
  74431. }
  74432. }
  74433. declare module BABYLON {
  74434. /** @hidden */
  74435. export var blurPixelShader: {
  74436. name: string;
  74437. shader: string;
  74438. };
  74439. }
  74440. declare module BABYLON {
  74441. /** @hidden */
  74442. export var pointCloudVertexDeclaration: {
  74443. name: string;
  74444. shader: string;
  74445. };
  74446. }
  74447. // Mixins
  74448. interface Window {
  74449. mozIndexedDB: IDBFactory;
  74450. webkitIndexedDB: IDBFactory;
  74451. msIndexedDB: IDBFactory;
  74452. webkitURL: typeof URL;
  74453. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  74454. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  74455. WebGLRenderingContext: WebGLRenderingContext;
  74456. MSGesture: MSGesture;
  74457. CANNON: any;
  74458. AudioContext: AudioContext;
  74459. webkitAudioContext: AudioContext;
  74460. PointerEvent: any;
  74461. Math: Math;
  74462. Uint8Array: Uint8ArrayConstructor;
  74463. Float32Array: Float32ArrayConstructor;
  74464. mozURL: typeof URL;
  74465. msURL: typeof URL;
  74466. VRFrameData: any; // WebVR, from specs 1.1
  74467. DracoDecoderModule: any;
  74468. setImmediate(handler: (...args: any[]) => void): number;
  74469. }
  74470. interface HTMLCanvasElement {
  74471. requestPointerLock(): void;
  74472. msRequestPointerLock?(): void;
  74473. mozRequestPointerLock?(): void;
  74474. webkitRequestPointerLock?(): void;
  74475. /** Track wether a record is in progress */
  74476. isRecording: boolean;
  74477. /** Capture Stream method defined by some browsers */
  74478. captureStream(fps?: number): MediaStream;
  74479. }
  74480. interface CanvasRenderingContext2D {
  74481. msImageSmoothingEnabled: boolean;
  74482. }
  74483. interface MouseEvent {
  74484. mozMovementX: number;
  74485. mozMovementY: number;
  74486. webkitMovementX: number;
  74487. webkitMovementY: number;
  74488. msMovementX: number;
  74489. msMovementY: number;
  74490. }
  74491. interface Navigator {
  74492. mozGetVRDevices: (any: any) => any;
  74493. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  74494. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  74495. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  74496. webkitGetGamepads(): Gamepad[];
  74497. msGetGamepads(): Gamepad[];
  74498. webkitGamepads(): Gamepad[];
  74499. }
  74500. interface HTMLVideoElement {
  74501. mozSrcObject: any;
  74502. }
  74503. interface Math {
  74504. fround(x: number): number;
  74505. imul(a: number, b: number): number;
  74506. }
  74507. interface WebGLRenderingContext {
  74508. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  74509. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  74510. vertexAttribDivisor(index: number, divisor: number): void;
  74511. createVertexArray(): any;
  74512. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  74513. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  74514. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  74515. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  74516. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  74517. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  74518. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  74519. // Queries
  74520. createQuery(): WebGLQuery;
  74521. deleteQuery(query: WebGLQuery): void;
  74522. beginQuery(target: number, query: WebGLQuery): void;
  74523. endQuery(target: number): void;
  74524. getQueryParameter(query: WebGLQuery, pname: number): any;
  74525. getQuery(target: number, pname: number): any;
  74526. MAX_SAMPLES: number;
  74527. RGBA8: number;
  74528. READ_FRAMEBUFFER: number;
  74529. DRAW_FRAMEBUFFER: number;
  74530. UNIFORM_BUFFER: number;
  74531. HALF_FLOAT_OES: number;
  74532. RGBA16F: number;
  74533. RGBA32F: number;
  74534. R32F: number;
  74535. RG32F: number;
  74536. RGB32F: number;
  74537. R16F: number;
  74538. RG16F: number;
  74539. RGB16F: number;
  74540. RED: number;
  74541. RG: number;
  74542. R8: number;
  74543. RG8: number;
  74544. UNSIGNED_INT_24_8: number;
  74545. DEPTH24_STENCIL8: number;
  74546. MIN: number;
  74547. MAX: number;
  74548. /* Multiple Render Targets */
  74549. drawBuffers(buffers: number[]): void;
  74550. readBuffer(src: number): void;
  74551. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  74552. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  74553. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  74554. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  74555. // Occlusion Query
  74556. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  74557. ANY_SAMPLES_PASSED: number;
  74558. QUERY_RESULT_AVAILABLE: number;
  74559. QUERY_RESULT: number;
  74560. }
  74561. interface WebGLProgram {
  74562. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  74563. }
  74564. interface EXT_disjoint_timer_query {
  74565. QUERY_COUNTER_BITS_EXT: number;
  74566. TIME_ELAPSED_EXT: number;
  74567. TIMESTAMP_EXT: number;
  74568. GPU_DISJOINT_EXT: number;
  74569. QUERY_RESULT_EXT: number;
  74570. QUERY_RESULT_AVAILABLE_EXT: number;
  74571. queryCounterEXT(query: WebGLQuery, target: number): void;
  74572. createQueryEXT(): WebGLQuery;
  74573. beginQueryEXT(target: number, query: WebGLQuery): void;
  74574. endQueryEXT(target: number): void;
  74575. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  74576. deleteQueryEXT(query: WebGLQuery): void;
  74577. }
  74578. interface WebGLUniformLocation {
  74579. _currentState: any;
  74580. }
  74581. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  74582. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  74583. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  74584. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  74585. interface WebGLRenderingContext {
  74586. readonly RASTERIZER_DISCARD: number;
  74587. readonly DEPTH_COMPONENT24: number;
  74588. readonly TEXTURE_3D: number;
  74589. readonly TEXTURE_2D_ARRAY: number;
  74590. readonly TEXTURE_COMPARE_FUNC: number;
  74591. readonly TEXTURE_COMPARE_MODE: number;
  74592. readonly COMPARE_REF_TO_TEXTURE: number;
  74593. readonly TEXTURE_WRAP_R: number;
  74594. readonly HALF_FLOAT: number;
  74595. readonly RGB8: number;
  74596. readonly RED_INTEGER: number;
  74597. readonly RG_INTEGER: number;
  74598. readonly RGB_INTEGER: number;
  74599. readonly RGBA_INTEGER: number;
  74600. readonly R8_SNORM: number;
  74601. readonly RG8_SNORM: number;
  74602. readonly RGB8_SNORM: number;
  74603. readonly RGBA8_SNORM: number;
  74604. readonly R8I: number;
  74605. readonly RG8I: number;
  74606. readonly RGB8I: number;
  74607. readonly RGBA8I: number;
  74608. readonly R8UI: number;
  74609. readonly RG8UI: number;
  74610. readonly RGB8UI: number;
  74611. readonly RGBA8UI: number;
  74612. readonly R16I: number;
  74613. readonly RG16I: number;
  74614. readonly RGB16I: number;
  74615. readonly RGBA16I: number;
  74616. readonly R16UI: number;
  74617. readonly RG16UI: number;
  74618. readonly RGB16UI: number;
  74619. readonly RGBA16UI: number;
  74620. readonly R32I: number;
  74621. readonly RG32I: number;
  74622. readonly RGB32I: number;
  74623. readonly RGBA32I: number;
  74624. readonly R32UI: number;
  74625. readonly RG32UI: number;
  74626. readonly RGB32UI: number;
  74627. readonly RGBA32UI: number;
  74628. readonly RGB10_A2UI: number;
  74629. readonly R11F_G11F_B10F: number;
  74630. readonly RGB9_E5: number;
  74631. readonly RGB10_A2: number;
  74632. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  74633. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  74634. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  74635. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  74636. readonly DEPTH_COMPONENT32F: number;
  74637. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  74638. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  74639. 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;
  74640. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  74641. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  74642. readonly TRANSFORM_FEEDBACK: number;
  74643. readonly INTERLEAVED_ATTRIBS: number;
  74644. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  74645. createTransformFeedback(): WebGLTransformFeedback;
  74646. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  74647. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  74648. beginTransformFeedback(primitiveMode: number): void;
  74649. endTransformFeedback(): void;
  74650. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  74651. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  74652. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  74653. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  74654. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  74655. }
  74656. interface ImageBitmap {
  74657. readonly width: number;
  74658. readonly height: number;
  74659. close(): void;
  74660. }
  74661. interface WebGLQuery extends WebGLObject {
  74662. }
  74663. declare var WebGLQuery: {
  74664. prototype: WebGLQuery;
  74665. new(): WebGLQuery;
  74666. };
  74667. interface WebGLSampler extends WebGLObject {
  74668. }
  74669. declare var WebGLSampler: {
  74670. prototype: WebGLSampler;
  74671. new(): WebGLSampler;
  74672. };
  74673. interface WebGLSync extends WebGLObject {
  74674. }
  74675. declare var WebGLSync: {
  74676. prototype: WebGLSync;
  74677. new(): WebGLSync;
  74678. };
  74679. interface WebGLTransformFeedback extends WebGLObject {
  74680. }
  74681. declare var WebGLTransformFeedback: {
  74682. prototype: WebGLTransformFeedback;
  74683. new(): WebGLTransformFeedback;
  74684. };
  74685. interface WebGLVertexArrayObject extends WebGLObject {
  74686. }
  74687. declare var WebGLVertexArrayObject: {
  74688. prototype: WebGLVertexArrayObject;
  74689. new(): WebGLVertexArrayObject;
  74690. };
  74691. // Type definitions for WebVR API
  74692. // Project: https://w3c.github.io/webvr/
  74693. // Definitions by: six a <https://github.com/lostfictions>
  74694. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  74695. interface VRDisplay extends EventTarget {
  74696. /**
  74697. * Dictionary of capabilities describing the VRDisplay.
  74698. */
  74699. readonly capabilities: VRDisplayCapabilities;
  74700. /**
  74701. * z-depth defining the far plane of the eye view frustum
  74702. * enables mapping of values in the render target depth
  74703. * attachment to scene coordinates. Initially set to 10000.0.
  74704. */
  74705. depthFar: number;
  74706. /**
  74707. * z-depth defining the near plane of the eye view frustum
  74708. * enables mapping of values in the render target depth
  74709. * attachment to scene coordinates. Initially set to 0.01.
  74710. */
  74711. depthNear: number;
  74712. /**
  74713. * An identifier for this distinct VRDisplay. Used as an
  74714. * association point in the Gamepad API.
  74715. */
  74716. readonly displayId: number;
  74717. /**
  74718. * A display name, a user-readable name identifying it.
  74719. */
  74720. readonly displayName: string;
  74721. readonly isConnected: boolean;
  74722. readonly isPresenting: boolean;
  74723. /**
  74724. * If this VRDisplay supports room-scale experiences, the optional
  74725. * stage attribute contains details on the room-scale parameters.
  74726. */
  74727. readonly stageParameters: VRStageParameters | null;
  74728. /**
  74729. * Passing the value returned by `requestAnimationFrame` to
  74730. * `cancelAnimationFrame` will unregister the callback.
  74731. * @param handle Define the hanle of the request to cancel
  74732. */
  74733. cancelAnimationFrame(handle: number): void;
  74734. /**
  74735. * Stops presenting to the VRDisplay.
  74736. * @returns a promise to know when it stopped
  74737. */
  74738. exitPresent(): Promise<void>;
  74739. /**
  74740. * Return the current VREyeParameters for the given eye.
  74741. * @param whichEye Define the eye we want the parameter for
  74742. * @returns the eye parameters
  74743. */
  74744. getEyeParameters(whichEye: string): VREyeParameters;
  74745. /**
  74746. * Populates the passed VRFrameData with the information required to render
  74747. * the current frame.
  74748. * @param frameData Define the data structure to populate
  74749. * @returns true if ok otherwise false
  74750. */
  74751. getFrameData(frameData: VRFrameData): boolean;
  74752. /**
  74753. * Get the layers currently being presented.
  74754. * @returns the list of VR layers
  74755. */
  74756. getLayers(): VRLayer[];
  74757. /**
  74758. * Return a VRPose containing the future predicted pose of the VRDisplay
  74759. * when the current frame will be presented. The value returned will not
  74760. * change until JavaScript has returned control to the browser.
  74761. *
  74762. * The VRPose will contain the position, orientation, velocity,
  74763. * and acceleration of each of these properties.
  74764. * @returns the pose object
  74765. */
  74766. getPose(): VRPose;
  74767. /**
  74768. * Return the current instantaneous pose of the VRDisplay, with no
  74769. * prediction applied.
  74770. * @returns the current instantaneous pose
  74771. */
  74772. getImmediatePose(): VRPose;
  74773. /**
  74774. * The callback passed to `requestAnimationFrame` will be called
  74775. * any time a new frame should be rendered. When the VRDisplay is
  74776. * presenting the callback will be called at the native refresh
  74777. * rate of the HMD. When not presenting this function acts
  74778. * identically to how window.requestAnimationFrame acts. Content should
  74779. * make no assumptions of frame rate or vsync behavior as the HMD runs
  74780. * asynchronously from other displays and at differing refresh rates.
  74781. * @param callback Define the eaction to run next frame
  74782. * @returns the request handle it
  74783. */
  74784. requestAnimationFrame(callback: FrameRequestCallback): number;
  74785. /**
  74786. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  74787. * Repeat calls while already presenting will update the VRLayers being displayed.
  74788. * @param layers Define the list of layer to present
  74789. * @returns a promise to know when the request has been fulfilled
  74790. */
  74791. requestPresent(layers: VRLayer[]): Promise<void>;
  74792. /**
  74793. * Reset the pose for this display, treating its current position and
  74794. * orientation as the "origin/zero" values. VRPose.position,
  74795. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  74796. * updated when calling resetPose(). This should be called in only
  74797. * sitting-space experiences.
  74798. */
  74799. resetPose(): void;
  74800. /**
  74801. * The VRLayer provided to the VRDisplay will be captured and presented
  74802. * in the HMD. Calling this function has the same effect on the source
  74803. * canvas as any other operation that uses its source image, and canvases
  74804. * created without preserveDrawingBuffer set to true will be cleared.
  74805. * @param pose Define the pose to submit
  74806. */
  74807. submitFrame(pose?: VRPose): void;
  74808. }
  74809. declare var VRDisplay: {
  74810. prototype: VRDisplay;
  74811. new(): VRDisplay;
  74812. };
  74813. interface VRLayer {
  74814. leftBounds?: number[] | Float32Array | null;
  74815. rightBounds?: number[] | Float32Array | null;
  74816. source?: HTMLCanvasElement | null;
  74817. }
  74818. interface VRDisplayCapabilities {
  74819. readonly canPresent: boolean;
  74820. readonly hasExternalDisplay: boolean;
  74821. readonly hasOrientation: boolean;
  74822. readonly hasPosition: boolean;
  74823. readonly maxLayers: number;
  74824. }
  74825. interface VREyeParameters {
  74826. /** @deprecated */
  74827. readonly fieldOfView: VRFieldOfView;
  74828. readonly offset: Float32Array;
  74829. readonly renderHeight: number;
  74830. readonly renderWidth: number;
  74831. }
  74832. interface VRFieldOfView {
  74833. readonly downDegrees: number;
  74834. readonly leftDegrees: number;
  74835. readonly rightDegrees: number;
  74836. readonly upDegrees: number;
  74837. }
  74838. interface VRFrameData {
  74839. readonly leftProjectionMatrix: Float32Array;
  74840. readonly leftViewMatrix: Float32Array;
  74841. readonly pose: VRPose;
  74842. readonly rightProjectionMatrix: Float32Array;
  74843. readonly rightViewMatrix: Float32Array;
  74844. readonly timestamp: number;
  74845. }
  74846. interface VRPose {
  74847. readonly angularAcceleration: Float32Array | null;
  74848. readonly angularVelocity: Float32Array | null;
  74849. readonly linearAcceleration: Float32Array | null;
  74850. readonly linearVelocity: Float32Array | null;
  74851. readonly orientation: Float32Array | null;
  74852. readonly position: Float32Array | null;
  74853. readonly timestamp: number;
  74854. }
  74855. interface VRStageParameters {
  74856. sittingToStandingTransform?: Float32Array;
  74857. sizeX?: number;
  74858. sizeY?: number;
  74859. }
  74860. interface Navigator {
  74861. getVRDisplays(): Promise<VRDisplay[]>;
  74862. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  74863. }
  74864. interface Window {
  74865. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  74866. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  74867. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  74868. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  74869. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  74870. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  74871. }
  74872. interface Gamepad {
  74873. readonly displayId: number;
  74874. }
  74875. type XRSessionMode =
  74876. | "inline"
  74877. | "immersive-vr"
  74878. | "immersive-ar";
  74879. type XRReferenceSpaceType =
  74880. | "viewer"
  74881. | "local"
  74882. | "local-floor"
  74883. | "bounded-floor"
  74884. | "unbounded";
  74885. type XREnvironmentBlendMode =
  74886. | "opaque"
  74887. | "additive"
  74888. | "alpha-blend";
  74889. type XRVisibilityState =
  74890. | "visible"
  74891. | "visible-blurred"
  74892. | "hidden";
  74893. type XRHandedness =
  74894. | "none"
  74895. | "left"
  74896. | "right";
  74897. type XRTargetRayMode =
  74898. | "gaze"
  74899. | "tracked-pointer"
  74900. | "screen";
  74901. type XREye =
  74902. | "none"
  74903. | "left"
  74904. | "right";
  74905. type XREventType =
  74906. | "devicechange"
  74907. | "visibilitychange"
  74908. | "end"
  74909. | "inputsourceschange"
  74910. | "select"
  74911. | "selectstart"
  74912. | "selectend"
  74913. | "squeeze"
  74914. | "squeezestart"
  74915. | "squeezeend"
  74916. | "reset";
  74917. interface XRSpace extends EventTarget {
  74918. }
  74919. interface XRRenderState {
  74920. depthNear?: number;
  74921. depthFar?: number;
  74922. inlineVerticalFieldOfView?: number;
  74923. baseLayer?: XRWebGLLayer;
  74924. }
  74925. interface XRInputSource {
  74926. handedness: XRHandedness;
  74927. targetRayMode: XRTargetRayMode;
  74928. targetRaySpace: XRSpace;
  74929. gripSpace: XRSpace | undefined;
  74930. gamepad: Gamepad | undefined;
  74931. profiles: Array<string>;
  74932. }
  74933. interface XRSessionInit {
  74934. optionalFeatures?: string[];
  74935. requiredFeatures?: string[];
  74936. }
  74937. interface XRSession {
  74938. addEventListener: Function;
  74939. removeEventListener: Function;
  74940. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  74941. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  74942. requestAnimationFrame: Function;
  74943. end(): Promise<void>;
  74944. renderState: XRRenderState;
  74945. inputSources: Array<XRInputSource>;
  74946. // hit test
  74947. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  74948. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  74949. // legacy AR hit test
  74950. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  74951. // legacy plane detection
  74952. updateWorldTrackingState(options: {
  74953. planeDetectionState?: { enabled: boolean; }
  74954. }): void;
  74955. }
  74956. interface XRReferenceSpace extends XRSpace {
  74957. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  74958. onreset: any;
  74959. }
  74960. type XRPlaneSet = Set<XRPlane>;
  74961. type XRAnchorSet = Set<XRAnchor>;
  74962. interface XRFrame {
  74963. session: XRSession;
  74964. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  74965. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  74966. // AR
  74967. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  74968. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  74969. // Anchors
  74970. trackedAnchors?: XRAnchorSet;
  74971. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  74972. // Planes
  74973. worldInformation: {
  74974. detectedPlanes?: XRPlaneSet;
  74975. };
  74976. }
  74977. interface XRViewerPose extends XRPose {
  74978. views: Array<XRView>;
  74979. }
  74980. interface XRPose {
  74981. transform: XRRigidTransform;
  74982. emulatedPosition: boolean;
  74983. }
  74984. interface XRWebGLLayerOptions {
  74985. antialias?: boolean;
  74986. depth?: boolean;
  74987. stencil?: boolean;
  74988. alpha?: boolean;
  74989. multiview?: boolean;
  74990. framebufferScaleFactor?: number;
  74991. }
  74992. declare var XRWebGLLayer: {
  74993. prototype: XRWebGLLayer;
  74994. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  74995. };
  74996. interface XRWebGLLayer {
  74997. framebuffer: WebGLFramebuffer;
  74998. framebufferWidth: number;
  74999. framebufferHeight: number;
  75000. getViewport: Function;
  75001. }
  75002. declare class XRRigidTransform {
  75003. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  75004. position: DOMPointReadOnly;
  75005. orientation: DOMPointReadOnly;
  75006. matrix: Float32Array;
  75007. inverse: XRRigidTransform;
  75008. }
  75009. interface XRView {
  75010. eye: XREye;
  75011. projectionMatrix: Float32Array;
  75012. transform: XRRigidTransform;
  75013. }
  75014. interface XRInputSourceChangeEvent {
  75015. session: XRSession;
  75016. removed: Array<XRInputSource>;
  75017. added: Array<XRInputSource>;
  75018. }
  75019. interface XRInputSourceEvent extends Event {
  75020. readonly frame: XRFrame;
  75021. readonly inputSource: XRInputSource;
  75022. }
  75023. // Experimental(er) features
  75024. declare class XRRay {
  75025. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  75026. origin: DOMPointReadOnly;
  75027. direction: DOMPointReadOnly;
  75028. matrix: Float32Array;
  75029. }
  75030. declare enum XRHitTestTrackableType {
  75031. "point",
  75032. "plane"
  75033. }
  75034. interface XRHitResult {
  75035. hitMatrix: Float32Array;
  75036. }
  75037. interface XRTransientInputHitTestResult {
  75038. readonly inputSource: XRInputSource;
  75039. readonly results: Array<XRHitTestResult>;
  75040. }
  75041. interface XRHitTestResult {
  75042. getPose(baseSpace: XRSpace): XRPose | undefined;
  75043. // When anchor system is enabled
  75044. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  75045. }
  75046. interface XRHitTestSource {
  75047. cancel(): void;
  75048. }
  75049. interface XRTransientInputHitTestSource {
  75050. cancel(): void;
  75051. }
  75052. interface XRHitTestOptionsInit {
  75053. space: XRSpace;
  75054. entityTypes?: Array<XRHitTestTrackableType>;
  75055. offsetRay?: XRRay;
  75056. }
  75057. interface XRTransientInputHitTestOptionsInit {
  75058. profile: string;
  75059. entityTypes?: Array<XRHitTestTrackableType>;
  75060. offsetRay?: XRRay;
  75061. }
  75062. interface XRAnchor {
  75063. anchorSpace: XRSpace;
  75064. delete(): void;
  75065. }
  75066. interface XRPlane {
  75067. orientation: "Horizontal" | "Vertical";
  75068. planeSpace: XRSpace;
  75069. polygon: Array<DOMPointReadOnly>;
  75070. lastChangedTime: number;
  75071. }
  75072. /**
  75073. * @ignore
  75074. */
  75075. declare module BABYLON.GLTF2.Exporter {
  75076. }
  75077. /**
  75078. * @ignore
  75079. */
  75080. declare module BABYLON.GLTF1 {
  75081. }
  75082. declare module BABYLON.GUI {
  75083. /**
  75084. * Class used to specific a value and its associated unit
  75085. */
  75086. export class ValueAndUnit {
  75087. /** defines the unit to store */
  75088. unit: number;
  75089. /** defines a boolean indicating if the value can be negative */
  75090. negativeValueAllowed: boolean;
  75091. private _value;
  75092. private _originalUnit;
  75093. /**
  75094. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  75095. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75096. */
  75097. ignoreAdaptiveScaling: boolean;
  75098. /**
  75099. * Creates a new ValueAndUnit
  75100. * @param value defines the value to store
  75101. * @param unit defines the unit to store
  75102. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  75103. */
  75104. constructor(value: number,
  75105. /** defines the unit to store */
  75106. unit?: number,
  75107. /** defines a boolean indicating if the value can be negative */
  75108. negativeValueAllowed?: boolean);
  75109. /** Gets a boolean indicating if the value is a percentage */
  75110. get isPercentage(): boolean;
  75111. /** Gets a boolean indicating if the value is store as pixel */
  75112. get isPixel(): boolean;
  75113. /** Gets direct internal value */
  75114. get internalValue(): number;
  75115. /**
  75116. * Gets value as pixel
  75117. * @param host defines the root host
  75118. * @param refValue defines the reference value for percentages
  75119. * @returns the value as pixel
  75120. */
  75121. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  75122. /**
  75123. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  75124. * @param value defines the value to store
  75125. * @param unit defines the unit to store
  75126. * @returns the current ValueAndUnit
  75127. */
  75128. updateInPlace(value: number, unit?: number): ValueAndUnit;
  75129. /**
  75130. * Gets the value accordingly to its unit
  75131. * @param host defines the root host
  75132. * @returns the value
  75133. */
  75134. getValue(host: AdvancedDynamicTexture): number;
  75135. /**
  75136. * Gets a string representation of the value
  75137. * @param host defines the root host
  75138. * @param decimals defines an optional number of decimals to display
  75139. * @returns a string
  75140. */
  75141. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  75142. /**
  75143. * Store a value parsed from a string
  75144. * @param source defines the source string
  75145. * @returns true if the value was successfully parsed
  75146. */
  75147. fromString(source: string | number): boolean;
  75148. private static _Regex;
  75149. private static _UNITMODE_PERCENTAGE;
  75150. private static _UNITMODE_PIXEL;
  75151. /** UNITMODE_PERCENTAGE */
  75152. static get UNITMODE_PERCENTAGE(): number;
  75153. /** UNITMODE_PIXEL */
  75154. static get UNITMODE_PIXEL(): number;
  75155. }
  75156. }
  75157. declare module BABYLON.GUI {
  75158. /**
  75159. * Define a style used by control to automatically setup properties based on a template.
  75160. * Only support font related properties so far
  75161. */
  75162. export class Style implements BABYLON.IDisposable {
  75163. private _fontFamily;
  75164. private _fontStyle;
  75165. private _fontWeight;
  75166. /** @hidden */
  75167. _host: AdvancedDynamicTexture;
  75168. /** @hidden */
  75169. _fontSize: ValueAndUnit;
  75170. /**
  75171. * BABYLON.Observable raised when the style values are changed
  75172. */
  75173. onChangedObservable: BABYLON.Observable<Style>;
  75174. /**
  75175. * Creates a new style object
  75176. * @param host defines the AdvancedDynamicTexture which hosts this style
  75177. */
  75178. constructor(host: AdvancedDynamicTexture);
  75179. /**
  75180. * Gets or sets the font size
  75181. */
  75182. get fontSize(): string | number;
  75183. set fontSize(value: string | number);
  75184. /**
  75185. * Gets or sets the font family
  75186. */
  75187. get fontFamily(): string;
  75188. set fontFamily(value: string);
  75189. /**
  75190. * Gets or sets the font style
  75191. */
  75192. get fontStyle(): string;
  75193. set fontStyle(value: string);
  75194. /** Gets or sets font weight */
  75195. get fontWeight(): string;
  75196. set fontWeight(value: string);
  75197. /** Dispose all associated resources */
  75198. dispose(): void;
  75199. }
  75200. }
  75201. declare module BABYLON.GUI {
  75202. /**
  75203. * Class used to transport BABYLON.Vector2 information for pointer events
  75204. */
  75205. export class Vector2WithInfo extends BABYLON.Vector2 {
  75206. /** defines the current mouse button index */
  75207. buttonIndex: number;
  75208. /**
  75209. * Creates a new Vector2WithInfo
  75210. * @param source defines the vector2 data to transport
  75211. * @param buttonIndex defines the current mouse button index
  75212. */
  75213. constructor(source: BABYLON.Vector2,
  75214. /** defines the current mouse button index */
  75215. buttonIndex?: number);
  75216. }
  75217. /** Class used to provide 2D matrix features */
  75218. export class Matrix2D {
  75219. /** Gets the internal array of 6 floats used to store matrix data */
  75220. m: Float32Array;
  75221. /**
  75222. * Creates a new matrix
  75223. * @param m00 defines value for (0, 0)
  75224. * @param m01 defines value for (0, 1)
  75225. * @param m10 defines value for (1, 0)
  75226. * @param m11 defines value for (1, 1)
  75227. * @param m20 defines value for (2, 0)
  75228. * @param m21 defines value for (2, 1)
  75229. */
  75230. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  75231. /**
  75232. * Fills the matrix from direct values
  75233. * @param m00 defines value for (0, 0)
  75234. * @param m01 defines value for (0, 1)
  75235. * @param m10 defines value for (1, 0)
  75236. * @param m11 defines value for (1, 1)
  75237. * @param m20 defines value for (2, 0)
  75238. * @param m21 defines value for (2, 1)
  75239. * @returns the current modified matrix
  75240. */
  75241. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  75242. /**
  75243. * Gets matrix determinant
  75244. * @returns the determinant
  75245. */
  75246. determinant(): number;
  75247. /**
  75248. * Inverses the matrix and stores it in a target matrix
  75249. * @param result defines the target matrix
  75250. * @returns the current matrix
  75251. */
  75252. invertToRef(result: Matrix2D): Matrix2D;
  75253. /**
  75254. * Multiplies the current matrix with another one
  75255. * @param other defines the second operand
  75256. * @param result defines the target matrix
  75257. * @returns the current matrix
  75258. */
  75259. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  75260. /**
  75261. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  75262. * @param x defines the x coordinate to transform
  75263. * @param y defines the x coordinate to transform
  75264. * @param result defines the target vector2
  75265. * @returns the current matrix
  75266. */
  75267. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  75268. /**
  75269. * Creates an identity matrix
  75270. * @returns a new matrix
  75271. */
  75272. static Identity(): Matrix2D;
  75273. /**
  75274. * Creates a translation matrix and stores it in a target matrix
  75275. * @param x defines the x coordinate of the translation
  75276. * @param y defines the y coordinate of the translation
  75277. * @param result defines the target matrix
  75278. */
  75279. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  75280. /**
  75281. * Creates a scaling matrix and stores it in a target matrix
  75282. * @param x defines the x coordinate of the scaling
  75283. * @param y defines the y coordinate of the scaling
  75284. * @param result defines the target matrix
  75285. */
  75286. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  75287. /**
  75288. * Creates a rotation matrix and stores it in a target matrix
  75289. * @param angle defines the rotation angle
  75290. * @param result defines the target matrix
  75291. */
  75292. static RotationToRef(angle: number, result: Matrix2D): void;
  75293. private static _TempPreTranslationMatrix;
  75294. private static _TempPostTranslationMatrix;
  75295. private static _TempRotationMatrix;
  75296. private static _TempScalingMatrix;
  75297. private static _TempCompose0;
  75298. private static _TempCompose1;
  75299. private static _TempCompose2;
  75300. /**
  75301. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  75302. * @param tx defines the x coordinate of the translation
  75303. * @param ty defines the y coordinate of the translation
  75304. * @param angle defines the rotation angle
  75305. * @param scaleX defines the x coordinate of the scaling
  75306. * @param scaleY defines the y coordinate of the scaling
  75307. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  75308. * @param result defines the target matrix
  75309. */
  75310. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  75311. }
  75312. }
  75313. declare module BABYLON.GUI {
  75314. /**
  75315. * Class used to store 2D control sizes
  75316. */
  75317. export class Measure {
  75318. /** defines left coordinate */
  75319. left: number;
  75320. /** defines top coordinate */
  75321. top: number;
  75322. /** defines width dimension */
  75323. width: number;
  75324. /** defines height dimension */
  75325. height: number;
  75326. /**
  75327. * Creates a new measure
  75328. * @param left defines left coordinate
  75329. * @param top defines top coordinate
  75330. * @param width defines width dimension
  75331. * @param height defines height dimension
  75332. */
  75333. constructor(
  75334. /** defines left coordinate */
  75335. left: number,
  75336. /** defines top coordinate */
  75337. top: number,
  75338. /** defines width dimension */
  75339. width: number,
  75340. /** defines height dimension */
  75341. height: number);
  75342. /**
  75343. * Copy from another measure
  75344. * @param other defines the other measure to copy from
  75345. */
  75346. copyFrom(other: Measure): void;
  75347. /**
  75348. * Copy from a group of 4 floats
  75349. * @param left defines left coordinate
  75350. * @param top defines top coordinate
  75351. * @param width defines width dimension
  75352. * @param height defines height dimension
  75353. */
  75354. copyFromFloats(left: number, top: number, width: number, height: number): void;
  75355. /**
  75356. * Computes the axis aligned bounding box measure for two given measures
  75357. * @param a Input measure
  75358. * @param b Input measure
  75359. * @param result the resulting bounding measure
  75360. */
  75361. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  75362. /**
  75363. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  75364. * @param transform the matrix to transform the measure before computing the AABB
  75365. * @param result the resulting AABB
  75366. */
  75367. transformToRef(transform: Matrix2D, result: Measure): void;
  75368. /**
  75369. * Check equality between this measure and another one
  75370. * @param other defines the other measures
  75371. * @returns true if both measures are equals
  75372. */
  75373. isEqualsTo(other: Measure): boolean;
  75374. /**
  75375. * Creates an empty measure
  75376. * @returns a new measure
  75377. */
  75378. static Empty(): Measure;
  75379. }
  75380. }
  75381. declare module BABYLON.GUI {
  75382. /**
  75383. * Interface used to define a control that can receive focus
  75384. */
  75385. export interface IFocusableControl {
  75386. /**
  75387. * Function called when the control receives the focus
  75388. */
  75389. onFocus(): void;
  75390. /**
  75391. * Function called when the control loses the focus
  75392. */
  75393. onBlur(): void;
  75394. /**
  75395. * Function called to let the control handle keyboard events
  75396. * @param evt defines the current keyboard event
  75397. */
  75398. processKeyboard(evt: KeyboardEvent): void;
  75399. /**
  75400. * Function called to get the list of controls that should not steal the focus from this control
  75401. * @returns an array of controls
  75402. */
  75403. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  75404. }
  75405. /**
  75406. * Class used to create texture to support 2D GUI elements
  75407. * @see https://doc.babylonjs.com/how_to/gui
  75408. */
  75409. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  75410. private _isDirty;
  75411. private _renderObserver;
  75412. private _resizeObserver;
  75413. private _preKeyboardObserver;
  75414. private _pointerMoveObserver;
  75415. private _pointerObserver;
  75416. private _canvasPointerOutObserver;
  75417. private _background;
  75418. /** @hidden */
  75419. _rootContainer: Container;
  75420. /** @hidden */
  75421. _lastPickedControl: Control;
  75422. /** @hidden */
  75423. _lastControlOver: {
  75424. [pointerId: number]: Control;
  75425. };
  75426. /** @hidden */
  75427. _lastControlDown: {
  75428. [pointerId: number]: Control;
  75429. };
  75430. /** @hidden */
  75431. _capturingControl: {
  75432. [pointerId: number]: Control;
  75433. };
  75434. /** @hidden */
  75435. _shouldBlockPointer: boolean;
  75436. /** @hidden */
  75437. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  75438. /** @hidden */
  75439. _linkedControls: Control[];
  75440. private _isFullscreen;
  75441. private _fullscreenViewport;
  75442. private _idealWidth;
  75443. private _idealHeight;
  75444. private _useSmallestIdeal;
  75445. private _renderAtIdealSize;
  75446. private _focusedControl;
  75447. private _blockNextFocusCheck;
  75448. private _renderScale;
  75449. private _rootElement;
  75450. private _cursorChanged;
  75451. private _defaultMousePointerId;
  75452. /** @hidden */
  75453. _numLayoutCalls: number;
  75454. /** Gets the number of layout calls made the last time the ADT has been rendered */
  75455. get numLayoutCalls(): number;
  75456. /** @hidden */
  75457. _numRenderCalls: number;
  75458. /** Gets the number of render calls made the last time the ADT has been rendered */
  75459. get numRenderCalls(): number;
  75460. /**
  75461. * Define type to string to ensure compatibility across browsers
  75462. * Safari doesn't support DataTransfer constructor
  75463. */
  75464. private _clipboardData;
  75465. /**
  75466. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  75467. */
  75468. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  75469. /**
  75470. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  75471. */
  75472. onControlPickedObservable: BABYLON.Observable<Control>;
  75473. /**
  75474. * BABYLON.Observable event triggered before layout is evaluated
  75475. */
  75476. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75477. /**
  75478. * BABYLON.Observable event triggered after the layout was evaluated
  75479. */
  75480. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75481. /**
  75482. * BABYLON.Observable event triggered before the texture is rendered
  75483. */
  75484. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75485. /**
  75486. * BABYLON.Observable event triggered after the texture was rendered
  75487. */
  75488. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  75489. /**
  75490. * Gets or sets a boolean defining if alpha is stored as premultiplied
  75491. */
  75492. premulAlpha: boolean;
  75493. /**
  75494. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  75495. * Useful when you want more antialiasing
  75496. */
  75497. get renderScale(): number;
  75498. set renderScale(value: number);
  75499. /** Gets or sets the background color */
  75500. get background(): string;
  75501. set background(value: string);
  75502. /**
  75503. * Gets or sets the ideal width used to design controls.
  75504. * The GUI will then rescale everything accordingly
  75505. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75506. */
  75507. get idealWidth(): number;
  75508. set idealWidth(value: number);
  75509. /**
  75510. * Gets or sets the ideal height used to design controls.
  75511. * The GUI will then rescale everything accordingly
  75512. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75513. */
  75514. get idealHeight(): number;
  75515. set idealHeight(value: number);
  75516. /**
  75517. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  75518. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75519. */
  75520. get useSmallestIdeal(): boolean;
  75521. set useSmallestIdeal(value: boolean);
  75522. /**
  75523. * Gets or sets a boolean indicating if adaptive scaling must be used
  75524. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75525. */
  75526. get renderAtIdealSize(): boolean;
  75527. set renderAtIdealSize(value: boolean);
  75528. /**
  75529. * Gets the ratio used when in "ideal mode"
  75530. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  75531. * */
  75532. get idealRatio(): number;
  75533. /**
  75534. * Gets the underlying layer used to render the texture when in fullscreen mode
  75535. */
  75536. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  75537. /**
  75538. * Gets the root container control
  75539. */
  75540. get rootContainer(): Container;
  75541. /**
  75542. * Returns an array containing the root container.
  75543. * This is mostly used to let the Inspector introspects the ADT
  75544. * @returns an array containing the rootContainer
  75545. */
  75546. getChildren(): Array<Container>;
  75547. /**
  75548. * Will return all controls that are inside this texture
  75549. * @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
  75550. * @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
  75551. * @return all child controls
  75552. */
  75553. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  75554. /**
  75555. * Gets or sets the current focused control
  75556. */
  75557. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  75558. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  75559. /**
  75560. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  75561. */
  75562. get isForeground(): boolean;
  75563. set isForeground(value: boolean);
  75564. /**
  75565. * Gets or set information about clipboardData
  75566. */
  75567. get clipboardData(): string;
  75568. set clipboardData(value: string);
  75569. /**
  75570. * Creates a new AdvancedDynamicTexture
  75571. * @param name defines the name of the texture
  75572. * @param width defines the width of the texture
  75573. * @param height defines the height of the texture
  75574. * @param scene defines the hosting scene
  75575. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  75576. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  75577. */
  75578. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  75579. /**
  75580. * Get the current class name of the texture useful for serialization or dynamic coding.
  75581. * @returns "AdvancedDynamicTexture"
  75582. */
  75583. getClassName(): string;
  75584. /**
  75585. * Function used to execute a function on all controls
  75586. * @param func defines the function to execute
  75587. * @param container defines the container where controls belong. If null the root container will be used
  75588. */
  75589. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  75590. private _useInvalidateRectOptimization;
  75591. /**
  75592. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  75593. */
  75594. get useInvalidateRectOptimization(): boolean;
  75595. set useInvalidateRectOptimization(value: boolean);
  75596. private _invalidatedRectangle;
  75597. /**
  75598. * Invalidates a rectangle area on the gui texture
  75599. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  75600. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  75601. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  75602. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  75603. */
  75604. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  75605. /**
  75606. * Marks the texture as dirty forcing a complete update
  75607. */
  75608. markAsDirty(): void;
  75609. /**
  75610. * Helper function used to create a new style
  75611. * @returns a new style
  75612. * @see https://doc.babylonjs.com/how_to/gui#styles
  75613. */
  75614. createStyle(): Style;
  75615. /**
  75616. * Adds a new control to the root container
  75617. * @param control defines the control to add
  75618. * @returns the current texture
  75619. */
  75620. addControl(control: Control): AdvancedDynamicTexture;
  75621. /**
  75622. * Removes a control from the root container
  75623. * @param control defines the control to remove
  75624. * @returns the current texture
  75625. */
  75626. removeControl(control: Control): AdvancedDynamicTexture;
  75627. /**
  75628. * Release all resources
  75629. */
  75630. dispose(): void;
  75631. private _onResize;
  75632. /** @hidden */
  75633. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  75634. /**
  75635. * Get screen coordinates for a vector3
  75636. * @param position defines the position to project
  75637. * @param worldMatrix defines the world matrix to use
  75638. * @returns the projected position
  75639. */
  75640. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  75641. private _checkUpdate;
  75642. private _clearMeasure;
  75643. private _render;
  75644. /** @hidden */
  75645. _changeCursor(cursor: string): void;
  75646. /** @hidden */
  75647. _registerLastControlDown(control: Control, pointerId: number): void;
  75648. private _doPicking;
  75649. /** @hidden */
  75650. _cleanControlAfterRemovalFromList(list: {
  75651. [pointerId: number]: Control;
  75652. }, control: Control): void;
  75653. /** @hidden */
  75654. _cleanControlAfterRemoval(control: Control): void;
  75655. /** Attach to all scene events required to support pointer events */
  75656. attach(): void;
  75657. /** @hidden */
  75658. private onClipboardCopy;
  75659. /** @hidden */
  75660. private onClipboardCut;
  75661. /** @hidden */
  75662. private onClipboardPaste;
  75663. /**
  75664. * Register the clipboard Events onto the canvas
  75665. */
  75666. registerClipboardEvents(): void;
  75667. /**
  75668. * Unregister the clipboard Events from the canvas
  75669. */
  75670. unRegisterClipboardEvents(): void;
  75671. /**
  75672. * Connect the texture to a hosting mesh to enable interactions
  75673. * @param mesh defines the mesh to attach to
  75674. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  75675. */
  75676. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  75677. /**
  75678. * Move the focus to a specific control
  75679. * @param control defines the control which will receive the focus
  75680. */
  75681. moveFocusToControl(control: IFocusableControl): void;
  75682. private _manageFocus;
  75683. private _attachToOnPointerOut;
  75684. /**
  75685. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  75686. * @param mesh defines the mesh which will receive the texture
  75687. * @param width defines the texture width (1024 by default)
  75688. * @param height defines the texture height (1024 by default)
  75689. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  75690. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  75691. * @returns a new AdvancedDynamicTexture
  75692. */
  75693. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  75694. /**
  75695. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  75696. * In this mode the texture will rely on a layer for its rendering.
  75697. * This allows it to be treated like any other layer.
  75698. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  75699. * LayerMask is set through advancedTexture.layer.layerMask
  75700. * @param name defines name for the texture
  75701. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  75702. * @param scene defines the hsoting scene
  75703. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  75704. * @returns a new AdvancedDynamicTexture
  75705. */
  75706. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  75707. }
  75708. }
  75709. declare module BABYLON.GUI {
  75710. /**
  75711. * Root class used for all 2D controls
  75712. * @see https://doc.babylonjs.com/how_to/gui#controls
  75713. */
  75714. export class Control {
  75715. /** defines the name of the control */
  75716. name?: string | undefined;
  75717. /**
  75718. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  75719. */
  75720. static AllowAlphaInheritance: boolean;
  75721. private _alpha;
  75722. private _alphaSet;
  75723. private _zIndex;
  75724. /** @hidden */
  75725. _host: AdvancedDynamicTexture;
  75726. /** Gets or sets the control parent */
  75727. parent: BABYLON.Nullable<Container>;
  75728. /** @hidden */
  75729. _currentMeasure: Measure;
  75730. private _fontFamily;
  75731. private _fontStyle;
  75732. private _fontWeight;
  75733. private _fontSize;
  75734. private _font;
  75735. /** @hidden */
  75736. _width: ValueAndUnit;
  75737. /** @hidden */
  75738. _height: ValueAndUnit;
  75739. /** @hidden */
  75740. protected _fontOffset: {
  75741. ascent: number;
  75742. height: number;
  75743. descent: number;
  75744. };
  75745. private _color;
  75746. private _style;
  75747. private _styleObserver;
  75748. /** @hidden */
  75749. protected _horizontalAlignment: number;
  75750. /** @hidden */
  75751. protected _verticalAlignment: number;
  75752. /** @hidden */
  75753. protected _isDirty: boolean;
  75754. /** @hidden */
  75755. protected _wasDirty: boolean;
  75756. /** @hidden */
  75757. _tempParentMeasure: Measure;
  75758. /** @hidden */
  75759. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  75760. /** @hidden */
  75761. protected _cachedParentMeasure: Measure;
  75762. private _paddingLeft;
  75763. private _paddingRight;
  75764. private _paddingTop;
  75765. private _paddingBottom;
  75766. /** @hidden */
  75767. _left: ValueAndUnit;
  75768. /** @hidden */
  75769. _top: ValueAndUnit;
  75770. private _scaleX;
  75771. private _scaleY;
  75772. private _rotation;
  75773. private _transformCenterX;
  75774. private _transformCenterY;
  75775. /** @hidden */
  75776. _transformMatrix: Matrix2D;
  75777. /** @hidden */
  75778. protected _invertTransformMatrix: Matrix2D;
  75779. /** @hidden */
  75780. protected _transformedPosition: BABYLON.Vector2;
  75781. private _isMatrixDirty;
  75782. private _cachedOffsetX;
  75783. private _cachedOffsetY;
  75784. private _isVisible;
  75785. private _isHighlighted;
  75786. /** @hidden */
  75787. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  75788. private _fontSet;
  75789. private _dummyVector2;
  75790. private _downCount;
  75791. private _enterCount;
  75792. private _doNotRender;
  75793. private _downPointerIds;
  75794. protected _isEnabled: boolean;
  75795. protected _disabledColor: string;
  75796. protected _disabledColorItem: string;
  75797. /** @hidden */
  75798. protected _rebuildLayout: boolean;
  75799. /** @hidden */
  75800. _customData: any;
  75801. /** @hidden */
  75802. _isClipped: boolean;
  75803. /** @hidden */
  75804. _automaticSize: boolean;
  75805. /** @hidden */
  75806. _tag: any;
  75807. /**
  75808. * 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
  75809. */
  75810. uniqueId: number;
  75811. /**
  75812. * Gets or sets an object used to store user defined information for the node
  75813. */
  75814. metadata: any;
  75815. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  75816. isHitTestVisible: boolean;
  75817. /** Gets or sets a boolean indicating if the control can block pointer events */
  75818. isPointerBlocker: boolean;
  75819. /** Gets or sets a boolean indicating if the control can be focusable */
  75820. isFocusInvisible: boolean;
  75821. /**
  75822. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  75823. * 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
  75824. */
  75825. clipChildren: boolean;
  75826. /**
  75827. * Gets or sets a boolean indicating that control content must be clipped
  75828. * 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
  75829. */
  75830. clipContent: boolean;
  75831. /**
  75832. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  75833. */
  75834. useBitmapCache: boolean;
  75835. private _cacheData;
  75836. private _shadowOffsetX;
  75837. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  75838. get shadowOffsetX(): number;
  75839. set shadowOffsetX(value: number);
  75840. private _shadowOffsetY;
  75841. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  75842. get shadowOffsetY(): number;
  75843. set shadowOffsetY(value: number);
  75844. private _shadowBlur;
  75845. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  75846. get shadowBlur(): number;
  75847. set shadowBlur(value: number);
  75848. private _shadowColor;
  75849. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  75850. get shadowColor(): string;
  75851. set shadowColor(value: string);
  75852. /** Gets or sets the cursor to use when the control is hovered */
  75853. hoverCursor: string;
  75854. /** @hidden */
  75855. protected _linkOffsetX: ValueAndUnit;
  75856. /** @hidden */
  75857. protected _linkOffsetY: ValueAndUnit;
  75858. /** Gets the control type name */
  75859. get typeName(): string;
  75860. /**
  75861. * Get the current class name of the control.
  75862. * @returns current class name
  75863. */
  75864. getClassName(): string;
  75865. /**
  75866. * An event triggered when pointer wheel is scrolled
  75867. */
  75868. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  75869. /**
  75870. * An event triggered when the pointer move over the control.
  75871. */
  75872. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  75873. /**
  75874. * An event triggered when the pointer move out of the control.
  75875. */
  75876. onPointerOutObservable: BABYLON.Observable<Control>;
  75877. /**
  75878. * An event triggered when the pointer taps the control
  75879. */
  75880. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  75881. /**
  75882. * An event triggered when pointer up
  75883. */
  75884. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  75885. /**
  75886. * An event triggered when a control is clicked on
  75887. */
  75888. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  75889. /**
  75890. * An event triggered when pointer enters the control
  75891. */
  75892. onPointerEnterObservable: BABYLON.Observable<Control>;
  75893. /**
  75894. * An event triggered when the control is marked as dirty
  75895. */
  75896. onDirtyObservable: BABYLON.Observable<Control>;
  75897. /**
  75898. * An event triggered before drawing the control
  75899. */
  75900. onBeforeDrawObservable: BABYLON.Observable<Control>;
  75901. /**
  75902. * An event triggered after the control was drawn
  75903. */
  75904. onAfterDrawObservable: BABYLON.Observable<Control>;
  75905. /**
  75906. * An event triggered when the control has been disposed
  75907. */
  75908. onDisposeObservable: BABYLON.Observable<Control>;
  75909. /**
  75910. * Get the hosting AdvancedDynamicTexture
  75911. */
  75912. get host(): AdvancedDynamicTexture;
  75913. /** Gets or set information about font offsets (used to render and align text) */
  75914. get fontOffset(): {
  75915. ascent: number;
  75916. height: number;
  75917. descent: number;
  75918. };
  75919. set fontOffset(offset: {
  75920. ascent: number;
  75921. height: number;
  75922. descent: number;
  75923. });
  75924. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  75925. get alpha(): number;
  75926. set alpha(value: number);
  75927. /**
  75928. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  75929. */
  75930. get isHighlighted(): boolean;
  75931. set isHighlighted(value: boolean);
  75932. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  75933. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75934. */
  75935. get scaleX(): number;
  75936. set scaleX(value: number);
  75937. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  75938. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75939. */
  75940. get scaleY(): number;
  75941. set scaleY(value: number);
  75942. /** Gets or sets the rotation angle (0 by default)
  75943. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75944. */
  75945. get rotation(): number;
  75946. set rotation(value: number);
  75947. /** Gets or sets the transformation center on Y axis (0 by default)
  75948. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75949. */
  75950. get transformCenterY(): number;
  75951. set transformCenterY(value: number);
  75952. /** Gets or sets the transformation center on X axis (0 by default)
  75953. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  75954. */
  75955. get transformCenterX(): number;
  75956. set transformCenterX(value: number);
  75957. /**
  75958. * Gets or sets the horizontal alignment
  75959. * @see https://doc.babylonjs.com/how_to/gui#alignments
  75960. */
  75961. get horizontalAlignment(): number;
  75962. set horizontalAlignment(value: number);
  75963. /**
  75964. * Gets or sets the vertical alignment
  75965. * @see https://doc.babylonjs.com/how_to/gui#alignments
  75966. */
  75967. get verticalAlignment(): number;
  75968. set verticalAlignment(value: number);
  75969. /**
  75970. * Gets or sets control width
  75971. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75972. */
  75973. get width(): string | number;
  75974. set width(value: string | number);
  75975. /**
  75976. * Gets or sets the control width in pixel
  75977. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75978. */
  75979. get widthInPixels(): number;
  75980. set widthInPixels(value: number);
  75981. /**
  75982. * Gets or sets control height
  75983. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75984. */
  75985. get height(): string | number;
  75986. set height(value: string | number);
  75987. /**
  75988. * Gets or sets control height in pixel
  75989. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  75990. */
  75991. get heightInPixels(): number;
  75992. set heightInPixels(value: number);
  75993. /** Gets or set font family */
  75994. get fontFamily(): string;
  75995. set fontFamily(value: string);
  75996. /** Gets or sets font style */
  75997. get fontStyle(): string;
  75998. set fontStyle(value: string);
  75999. /** Gets or sets font weight */
  76000. get fontWeight(): string;
  76001. set fontWeight(value: string);
  76002. /**
  76003. * Gets or sets style
  76004. * @see https://doc.babylonjs.com/how_to/gui#styles
  76005. */
  76006. get style(): BABYLON.Nullable<Style>;
  76007. set style(value: BABYLON.Nullable<Style>);
  76008. /** @hidden */
  76009. get _isFontSizeInPercentage(): boolean;
  76010. /** Gets or sets font size in pixels */
  76011. get fontSizeInPixels(): number;
  76012. set fontSizeInPixels(value: number);
  76013. /** Gets or sets font size */
  76014. get fontSize(): string | number;
  76015. set fontSize(value: string | number);
  76016. /** Gets or sets foreground color */
  76017. get color(): string;
  76018. set color(value: string);
  76019. /** Gets or sets z index which is used to reorder controls on the z axis */
  76020. get zIndex(): number;
  76021. set zIndex(value: number);
  76022. /** Gets or sets a boolean indicating if the control can be rendered */
  76023. get notRenderable(): boolean;
  76024. set notRenderable(value: boolean);
  76025. /** Gets or sets a boolean indicating if the control is visible */
  76026. get isVisible(): boolean;
  76027. set isVisible(value: boolean);
  76028. /** Gets a boolean indicating that the control needs to update its rendering */
  76029. get isDirty(): boolean;
  76030. /**
  76031. * Gets the current linked mesh (or null if none)
  76032. */
  76033. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  76034. /**
  76035. * Gets or sets a value indicating the padding to use on the left of the control
  76036. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76037. */
  76038. get paddingLeft(): string | number;
  76039. set paddingLeft(value: string | number);
  76040. /**
  76041. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  76042. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76043. */
  76044. get paddingLeftInPixels(): number;
  76045. set paddingLeftInPixels(value: number);
  76046. /**
  76047. * Gets or sets a value indicating the padding to use on the right of the control
  76048. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76049. */
  76050. get paddingRight(): string | number;
  76051. set paddingRight(value: string | number);
  76052. /**
  76053. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  76054. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76055. */
  76056. get paddingRightInPixels(): number;
  76057. set paddingRightInPixels(value: number);
  76058. /**
  76059. * Gets or sets a value indicating the padding to use on the top of the control
  76060. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76061. */
  76062. get paddingTop(): string | number;
  76063. set paddingTop(value: string | number);
  76064. /**
  76065. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  76066. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76067. */
  76068. get paddingTopInPixels(): number;
  76069. set paddingTopInPixels(value: number);
  76070. /**
  76071. * Gets or sets a value indicating the padding to use on the bottom of the control
  76072. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76073. */
  76074. get paddingBottom(): string | number;
  76075. set paddingBottom(value: string | number);
  76076. /**
  76077. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  76078. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76079. */
  76080. get paddingBottomInPixels(): number;
  76081. set paddingBottomInPixels(value: number);
  76082. /**
  76083. * Gets or sets a value indicating the left coordinate of the control
  76084. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76085. */
  76086. get left(): string | number;
  76087. set left(value: string | number);
  76088. /**
  76089. * Gets or sets a value indicating the left coordinate in pixels of the control
  76090. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76091. */
  76092. get leftInPixels(): number;
  76093. set leftInPixels(value: number);
  76094. /**
  76095. * Gets or sets a value indicating the top coordinate of the control
  76096. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76097. */
  76098. get top(): string | number;
  76099. set top(value: string | number);
  76100. /**
  76101. * Gets or sets a value indicating the top coordinate in pixels of the control
  76102. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  76103. */
  76104. get topInPixels(): number;
  76105. set topInPixels(value: number);
  76106. /**
  76107. * Gets or sets a value indicating the offset on X axis to the linked mesh
  76108. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  76109. */
  76110. get linkOffsetX(): string | number;
  76111. set linkOffsetX(value: string | number);
  76112. /**
  76113. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  76114. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  76115. */
  76116. get linkOffsetXInPixels(): number;
  76117. set linkOffsetXInPixels(value: number);
  76118. /**
  76119. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  76120. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  76121. */
  76122. get linkOffsetY(): string | number;
  76123. set linkOffsetY(value: string | number);
  76124. /**
  76125. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  76126. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  76127. */
  76128. get linkOffsetYInPixels(): number;
  76129. set linkOffsetYInPixels(value: number);
  76130. /** Gets the center coordinate on X axis */
  76131. get centerX(): number;
  76132. /** Gets the center coordinate on Y axis */
  76133. get centerY(): number;
  76134. /** Gets or sets if control is Enabled*/
  76135. get isEnabled(): boolean;
  76136. set isEnabled(value: boolean);
  76137. /** Gets or sets background color of control if it's disabled*/
  76138. get disabledColor(): string;
  76139. set disabledColor(value: string);
  76140. /** Gets or sets front color of control if it's disabled*/
  76141. get disabledColorItem(): string;
  76142. set disabledColorItem(value: string);
  76143. /**
  76144. * Creates a new control
  76145. * @param name defines the name of the control
  76146. */
  76147. constructor(
  76148. /** defines the name of the control */
  76149. name?: string | undefined);
  76150. /** @hidden */
  76151. protected _getTypeName(): string;
  76152. /**
  76153. * Gets the first ascendant in the hierarchy of the given type
  76154. * @param className defines the required type
  76155. * @returns the ascendant or null if not found
  76156. */
  76157. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  76158. /** @hidden */
  76159. _resetFontCache(): void;
  76160. /**
  76161. * Determines if a container is an ascendant of the current control
  76162. * @param container defines the container to look for
  76163. * @returns true if the container is one of the ascendant of the control
  76164. */
  76165. isAscendant(container: Control): boolean;
  76166. /**
  76167. * Gets coordinates in local control space
  76168. * @param globalCoordinates defines the coordinates to transform
  76169. * @returns the new coordinates in local space
  76170. */
  76171. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  76172. /**
  76173. * Gets coordinates in local control space
  76174. * @param globalCoordinates defines the coordinates to transform
  76175. * @param result defines the target vector2 where to store the result
  76176. * @returns the current control
  76177. */
  76178. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  76179. /**
  76180. * Gets coordinates in parent local control space
  76181. * @param globalCoordinates defines the coordinates to transform
  76182. * @returns the new coordinates in parent local space
  76183. */
  76184. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  76185. /**
  76186. * Move the current control to a vector3 position projected onto the screen.
  76187. * @param position defines the target position
  76188. * @param scene defines the hosting scene
  76189. */
  76190. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  76191. /**
  76192. * Will store all controls that have this control as ascendant in a given array
  76193. * @param results defines the array where to store the descendants
  76194. * @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
  76195. * @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
  76196. */
  76197. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  76198. /**
  76199. * Will return all controls that have this control as ascendant
  76200. * @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
  76201. * @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
  76202. * @return all child controls
  76203. */
  76204. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  76205. /**
  76206. * Link current control with a target mesh
  76207. * @param mesh defines the mesh to link with
  76208. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  76209. */
  76210. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  76211. /** @hidden */
  76212. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  76213. /** @hidden */
  76214. _offsetLeft(offset: number): void;
  76215. /** @hidden */
  76216. _offsetTop(offset: number): void;
  76217. /** @hidden */
  76218. _markMatrixAsDirty(): void;
  76219. /** @hidden */
  76220. _flagDescendantsAsMatrixDirty(): void;
  76221. /** @hidden */
  76222. _intersectsRect(rect: Measure): boolean;
  76223. /** @hidden */
  76224. protected invalidateRect(): void;
  76225. /** @hidden */
  76226. _markAsDirty(force?: boolean): void;
  76227. /** @hidden */
  76228. _markAllAsDirty(): void;
  76229. /** @hidden */
  76230. _link(host: AdvancedDynamicTexture): void;
  76231. /** @hidden */
  76232. protected _transform(context?: CanvasRenderingContext2D): void;
  76233. /** @hidden */
  76234. _renderHighlight(context: CanvasRenderingContext2D): void;
  76235. /** @hidden */
  76236. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  76237. /** @hidden */
  76238. protected _applyStates(context: CanvasRenderingContext2D): void;
  76239. /** @hidden */
  76240. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  76241. /** @hidden */
  76242. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76243. protected _evaluateClippingState(parentMeasure: Measure): void;
  76244. /** @hidden */
  76245. _measure(): void;
  76246. /** @hidden */
  76247. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76248. /** @hidden */
  76249. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76250. /** @hidden */
  76251. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76252. /** @hidden */
  76253. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  76254. private static _ClipMeasure;
  76255. private _tmpMeasureA;
  76256. private _clip;
  76257. /** @hidden */
  76258. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  76259. /** @hidden */
  76260. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76261. /**
  76262. * Tests if a given coordinates belong to the current control
  76263. * @param x defines x coordinate to test
  76264. * @param y defines y coordinate to test
  76265. * @returns true if the coordinates are inside the control
  76266. */
  76267. contains(x: number, y: number): boolean;
  76268. /** @hidden */
  76269. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  76270. /** @hidden */
  76271. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  76272. /** @hidden */
  76273. _onPointerEnter(target: Control): boolean;
  76274. /** @hidden */
  76275. _onPointerOut(target: Control, force?: boolean): void;
  76276. /** @hidden */
  76277. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76278. /** @hidden */
  76279. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76280. /** @hidden */
  76281. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  76282. /** @hidden */
  76283. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  76284. /** @hidden */
  76285. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  76286. private _prepareFont;
  76287. /** Releases associated resources */
  76288. dispose(): void;
  76289. private static _HORIZONTAL_ALIGNMENT_LEFT;
  76290. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  76291. private static _HORIZONTAL_ALIGNMENT_CENTER;
  76292. private static _VERTICAL_ALIGNMENT_TOP;
  76293. private static _VERTICAL_ALIGNMENT_BOTTOM;
  76294. private static _VERTICAL_ALIGNMENT_CENTER;
  76295. /** HORIZONTAL_ALIGNMENT_LEFT */
  76296. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  76297. /** HORIZONTAL_ALIGNMENT_RIGHT */
  76298. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  76299. /** HORIZONTAL_ALIGNMENT_CENTER */
  76300. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  76301. /** VERTICAL_ALIGNMENT_TOP */
  76302. static get VERTICAL_ALIGNMENT_TOP(): number;
  76303. /** VERTICAL_ALIGNMENT_BOTTOM */
  76304. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  76305. /** VERTICAL_ALIGNMENT_CENTER */
  76306. static get VERTICAL_ALIGNMENT_CENTER(): number;
  76307. private static _FontHeightSizes;
  76308. /** @hidden */
  76309. static _GetFontOffset(font: string): {
  76310. ascent: number;
  76311. height: number;
  76312. descent: number;
  76313. };
  76314. /**
  76315. * Creates a stack panel that can be used to render headers
  76316. * @param control defines the control to associate with the header
  76317. * @param text defines the text of the header
  76318. * @param size defines the size of the header
  76319. * @param options defines options used to configure the header
  76320. * @returns a new StackPanel
  76321. * @ignore
  76322. * @hidden
  76323. */
  76324. static AddHeader: (control: Control, text: string, size: string | number, options: {
  76325. isHorizontal: boolean;
  76326. controlFirst: boolean;
  76327. }) => any;
  76328. /** @hidden */
  76329. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  76330. }
  76331. }
  76332. declare module BABYLON.GUI {
  76333. /**
  76334. * Root class for 2D containers
  76335. * @see https://doc.babylonjs.com/how_to/gui#containers
  76336. */
  76337. export class Container extends Control {
  76338. name?: string | undefined;
  76339. /** @hidden */
  76340. _children: Control[];
  76341. /** @hidden */
  76342. protected _measureForChildren: Measure;
  76343. /** @hidden */
  76344. protected _background: string;
  76345. /** @hidden */
  76346. protected _adaptWidthToChildren: boolean;
  76347. /** @hidden */
  76348. protected _adaptHeightToChildren: boolean;
  76349. /**
  76350. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  76351. */
  76352. logLayoutCycleErrors: boolean;
  76353. /**
  76354. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  76355. */
  76356. maxLayoutCycle: number;
  76357. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  76358. get adaptHeightToChildren(): boolean;
  76359. set adaptHeightToChildren(value: boolean);
  76360. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  76361. get adaptWidthToChildren(): boolean;
  76362. set adaptWidthToChildren(value: boolean);
  76363. /** Gets or sets background color */
  76364. get background(): string;
  76365. set background(value: string);
  76366. /** Gets the list of children */
  76367. get children(): Control[];
  76368. /**
  76369. * Creates a new Container
  76370. * @param name defines the name of the container
  76371. */
  76372. constructor(name?: string | undefined);
  76373. protected _getTypeName(): string;
  76374. _flagDescendantsAsMatrixDirty(): void;
  76375. /**
  76376. * Gets a child using its name
  76377. * @param name defines the child name to look for
  76378. * @returns the child control if found
  76379. */
  76380. getChildByName(name: string): BABYLON.Nullable<Control>;
  76381. /**
  76382. * Gets a child using its type and its name
  76383. * @param name defines the child name to look for
  76384. * @param type defines the child type to look for
  76385. * @returns the child control if found
  76386. */
  76387. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  76388. /**
  76389. * Search for a specific control in children
  76390. * @param control defines the control to look for
  76391. * @returns true if the control is in child list
  76392. */
  76393. containsControl(control: Control): boolean;
  76394. /**
  76395. * Adds a new control to the current container
  76396. * @param control defines the control to add
  76397. * @returns the current container
  76398. */
  76399. addControl(control: BABYLON.Nullable<Control>): Container;
  76400. /**
  76401. * Removes all controls from the current container
  76402. * @returns the current container
  76403. */
  76404. clearControls(): Container;
  76405. /**
  76406. * Removes a control from the current container
  76407. * @param control defines the control to remove
  76408. * @returns the current container
  76409. */
  76410. removeControl(control: Control): Container;
  76411. /** @hidden */
  76412. _reOrderControl(control: Control): void;
  76413. /** @hidden */
  76414. _offsetLeft(offset: number): void;
  76415. /** @hidden */
  76416. _offsetTop(offset: number): void;
  76417. /** @hidden */
  76418. _markAllAsDirty(): void;
  76419. /** @hidden */
  76420. protected _localDraw(context: CanvasRenderingContext2D): void;
  76421. /** @hidden */
  76422. _link(host: AdvancedDynamicTexture): void;
  76423. /** @hidden */
  76424. protected _beforeLayout(): void;
  76425. /** @hidden */
  76426. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76427. /** @hidden */
  76428. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  76429. protected _postMeasure(): void;
  76430. /** @hidden */
  76431. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  76432. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  76433. /** @hidden */
  76434. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  76435. /** @hidden */
  76436. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76437. /** Releases associated resources */
  76438. dispose(): void;
  76439. }
  76440. }
  76441. declare module BABYLON.GUI {
  76442. /** Class used to create rectangle container */
  76443. export class Rectangle extends Container {
  76444. name?: string | undefined;
  76445. private _thickness;
  76446. private _cornerRadius;
  76447. /** Gets or sets border thickness */
  76448. get thickness(): number;
  76449. set thickness(value: number);
  76450. /** Gets or sets the corner radius angle */
  76451. get cornerRadius(): number;
  76452. set cornerRadius(value: number);
  76453. /**
  76454. * Creates a new Rectangle
  76455. * @param name defines the control name
  76456. */
  76457. constructor(name?: string | undefined);
  76458. protected _getTypeName(): string;
  76459. protected _localDraw(context: CanvasRenderingContext2D): void;
  76460. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76461. private _drawRoundedRect;
  76462. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  76463. }
  76464. }
  76465. declare module BABYLON.GUI {
  76466. /**
  76467. * Enum that determines the text-wrapping mode to use.
  76468. */
  76469. export enum TextWrapping {
  76470. /**
  76471. * Clip the text when it's larger than Control.width; this is the default mode.
  76472. */
  76473. Clip = 0,
  76474. /**
  76475. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  76476. */
  76477. WordWrap = 1,
  76478. /**
  76479. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  76480. */
  76481. Ellipsis = 2
  76482. }
  76483. /**
  76484. * Class used to create text block control
  76485. */
  76486. export class TextBlock extends Control {
  76487. /**
  76488. * Defines the name of the control
  76489. */
  76490. name?: string | undefined;
  76491. private _text;
  76492. private _textWrapping;
  76493. private _textHorizontalAlignment;
  76494. private _textVerticalAlignment;
  76495. private _lines;
  76496. private _resizeToFit;
  76497. private _lineSpacing;
  76498. private _outlineWidth;
  76499. private _outlineColor;
  76500. /**
  76501. * An event triggered after the text is changed
  76502. */
  76503. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  76504. /**
  76505. * An event triggered after the text was broken up into lines
  76506. */
  76507. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  76508. /**
  76509. * Function used to split a string into words. By default, a string is split at each space character found
  76510. */
  76511. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  76512. /**
  76513. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  76514. */
  76515. get lines(): any[];
  76516. /**
  76517. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  76518. */
  76519. get resizeToFit(): boolean;
  76520. /**
  76521. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  76522. */
  76523. set resizeToFit(value: boolean);
  76524. /**
  76525. * Gets or sets a boolean indicating if text must be wrapped
  76526. */
  76527. get textWrapping(): TextWrapping | boolean;
  76528. /**
  76529. * Gets or sets a boolean indicating if text must be wrapped
  76530. */
  76531. set textWrapping(value: TextWrapping | boolean);
  76532. /**
  76533. * Gets or sets text to display
  76534. */
  76535. get text(): string;
  76536. /**
  76537. * Gets or sets text to display
  76538. */
  76539. set text(value: string);
  76540. /**
  76541. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  76542. */
  76543. get textHorizontalAlignment(): number;
  76544. /**
  76545. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  76546. */
  76547. set textHorizontalAlignment(value: number);
  76548. /**
  76549. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  76550. */
  76551. get textVerticalAlignment(): number;
  76552. /**
  76553. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  76554. */
  76555. set textVerticalAlignment(value: number);
  76556. /**
  76557. * Gets or sets line spacing value
  76558. */
  76559. set lineSpacing(value: string | number);
  76560. /**
  76561. * Gets or sets line spacing value
  76562. */
  76563. get lineSpacing(): string | number;
  76564. /**
  76565. * Gets or sets outlineWidth of the text to display
  76566. */
  76567. get outlineWidth(): number;
  76568. /**
  76569. * Gets or sets outlineWidth of the text to display
  76570. */
  76571. set outlineWidth(value: number);
  76572. /**
  76573. * Gets or sets outlineColor of the text to display
  76574. */
  76575. get outlineColor(): string;
  76576. /**
  76577. * Gets or sets outlineColor of the text to display
  76578. */
  76579. set outlineColor(value: string);
  76580. /**
  76581. * Creates a new TextBlock object
  76582. * @param name defines the name of the control
  76583. * @param text defines the text to display (emptry string by default)
  76584. */
  76585. constructor(
  76586. /**
  76587. * Defines the name of the control
  76588. */
  76589. name?: string | undefined, text?: string);
  76590. protected _getTypeName(): string;
  76591. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76592. private _drawText;
  76593. /** @hidden */
  76594. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76595. protected _applyStates(context: CanvasRenderingContext2D): void;
  76596. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  76597. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  76598. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  76599. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  76600. protected _renderLines(context: CanvasRenderingContext2D): void;
  76601. /**
  76602. * Given a width constraint applied on the text block, find the expected height
  76603. * @returns expected height
  76604. */
  76605. computeExpectedHeight(): number;
  76606. dispose(): void;
  76607. }
  76608. }
  76609. declare module BABYLON.GUI {
  76610. /**
  76611. * Class used to create 2D images
  76612. */
  76613. export class Image extends Control {
  76614. name?: string | undefined;
  76615. private _workingCanvas;
  76616. private _domImage;
  76617. private _imageWidth;
  76618. private _imageHeight;
  76619. private _loaded;
  76620. private _stretch;
  76621. private _source;
  76622. private _autoScale;
  76623. private _sourceLeft;
  76624. private _sourceTop;
  76625. private _sourceWidth;
  76626. private _sourceHeight;
  76627. private _svgAttributesComputationCompleted;
  76628. private _isSVG;
  76629. private _cellWidth;
  76630. private _cellHeight;
  76631. private _cellId;
  76632. private _populateNinePatchSlicesFromImage;
  76633. private _sliceLeft;
  76634. private _sliceRight;
  76635. private _sliceTop;
  76636. private _sliceBottom;
  76637. private _detectPointerOnOpaqueOnly;
  76638. /**
  76639. * BABYLON.Observable notified when the content is loaded
  76640. */
  76641. onImageLoadedObservable: BABYLON.Observable<Image>;
  76642. /**
  76643. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  76644. */
  76645. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  76646. /**
  76647. * Gets a boolean indicating that the content is loaded
  76648. */
  76649. get isLoaded(): boolean;
  76650. /**
  76651. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  76652. */
  76653. get populateNinePatchSlicesFromImage(): boolean;
  76654. set populateNinePatchSlicesFromImage(value: boolean);
  76655. /**
  76656. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  76657. * Beware using this as this will comsume more memory as the image has to be stored twice
  76658. */
  76659. get detectPointerOnOpaqueOnly(): boolean;
  76660. set detectPointerOnOpaqueOnly(value: boolean);
  76661. /**
  76662. * Gets or sets the left value for slicing (9-patch)
  76663. */
  76664. get sliceLeft(): number;
  76665. set sliceLeft(value: number);
  76666. /**
  76667. * Gets or sets the right value for slicing (9-patch)
  76668. */
  76669. get sliceRight(): number;
  76670. set sliceRight(value: number);
  76671. /**
  76672. * Gets or sets the top value for slicing (9-patch)
  76673. */
  76674. get sliceTop(): number;
  76675. set sliceTop(value: number);
  76676. /**
  76677. * Gets or sets the bottom value for slicing (9-patch)
  76678. */
  76679. get sliceBottom(): number;
  76680. set sliceBottom(value: number);
  76681. /**
  76682. * Gets or sets the left coordinate in the source image
  76683. */
  76684. get sourceLeft(): number;
  76685. set sourceLeft(value: number);
  76686. /**
  76687. * Gets or sets the top coordinate in the source image
  76688. */
  76689. get sourceTop(): number;
  76690. set sourceTop(value: number);
  76691. /**
  76692. * Gets or sets the width to capture in the source image
  76693. */
  76694. get sourceWidth(): number;
  76695. set sourceWidth(value: number);
  76696. /**
  76697. * Gets or sets the height to capture in the source image
  76698. */
  76699. get sourceHeight(): number;
  76700. set sourceHeight(value: number);
  76701. /** Indicates if the format of the image is SVG */
  76702. get isSVG(): boolean;
  76703. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  76704. get svgAttributesComputationCompleted(): boolean;
  76705. /**
  76706. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  76707. * @see https://doc.babylonjs.com/how_to/gui#image
  76708. */
  76709. get autoScale(): boolean;
  76710. set autoScale(value: boolean);
  76711. /** Gets or sets the streching mode used by the image */
  76712. get stretch(): number;
  76713. set stretch(value: number);
  76714. /** @hidden */
  76715. _rotate90(n: number, preserveProperties?: boolean): Image;
  76716. private _handleRotationForSVGImage;
  76717. private _rotate90SourceProperties;
  76718. /**
  76719. * Gets or sets the internal DOM image used to render the control
  76720. */
  76721. set domImage(value: HTMLImageElement);
  76722. get domImage(): HTMLImageElement;
  76723. private _onImageLoaded;
  76724. private _extractNinePatchSliceDataFromImage;
  76725. /**
  76726. * Gets or sets image source url
  76727. */
  76728. set source(value: BABYLON.Nullable<string>);
  76729. /**
  76730. * Checks for svg document with icon id present
  76731. */
  76732. private _svgCheck;
  76733. /**
  76734. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  76735. * given external svg file and icon id
  76736. */
  76737. private _getSVGAttribs;
  76738. /**
  76739. * Gets or sets the cell width to use when animation sheet is enabled
  76740. * @see https://doc.babylonjs.com/how_to/gui#image
  76741. */
  76742. get cellWidth(): number;
  76743. set cellWidth(value: number);
  76744. /**
  76745. * Gets or sets the cell height to use when animation sheet is enabled
  76746. * @see https://doc.babylonjs.com/how_to/gui#image
  76747. */
  76748. get cellHeight(): number;
  76749. set cellHeight(value: number);
  76750. /**
  76751. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  76752. * @see https://doc.babylonjs.com/how_to/gui#image
  76753. */
  76754. get cellId(): number;
  76755. set cellId(value: number);
  76756. /**
  76757. * Creates a new Image
  76758. * @param name defines the control name
  76759. * @param url defines the image url
  76760. */
  76761. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  76762. /**
  76763. * Tests if a given coordinates belong to the current control
  76764. * @param x defines x coordinate to test
  76765. * @param y defines y coordinate to test
  76766. * @returns true if the coordinates are inside the control
  76767. */
  76768. contains(x: number, y: number): boolean;
  76769. protected _getTypeName(): string;
  76770. /** Force the control to synchronize with its content */
  76771. synchronizeSizeWithContent(): void;
  76772. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76773. private _prepareWorkingCanvasForOpaqueDetection;
  76774. private _drawImage;
  76775. _draw(context: CanvasRenderingContext2D): void;
  76776. private _renderCornerPatch;
  76777. private _renderNinePatch;
  76778. dispose(): void;
  76779. /** STRETCH_NONE */
  76780. static readonly STRETCH_NONE: number;
  76781. /** STRETCH_FILL */
  76782. static readonly STRETCH_FILL: number;
  76783. /** STRETCH_UNIFORM */
  76784. static readonly STRETCH_UNIFORM: number;
  76785. /** STRETCH_EXTEND */
  76786. static readonly STRETCH_EXTEND: number;
  76787. /** NINE_PATCH */
  76788. static readonly STRETCH_NINE_PATCH: number;
  76789. }
  76790. }
  76791. declare module BABYLON.GUI {
  76792. /**
  76793. * Class used to create 2D buttons
  76794. */
  76795. export class Button extends Rectangle {
  76796. name?: string | undefined;
  76797. /**
  76798. * Function called to generate a pointer enter animation
  76799. */
  76800. pointerEnterAnimation: () => void;
  76801. /**
  76802. * Function called to generate a pointer out animation
  76803. */
  76804. pointerOutAnimation: () => void;
  76805. /**
  76806. * Function called to generate a pointer down animation
  76807. */
  76808. pointerDownAnimation: () => void;
  76809. /**
  76810. * Function called to generate a pointer up animation
  76811. */
  76812. pointerUpAnimation: () => void;
  76813. /**
  76814. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  76815. */
  76816. delegatePickingToChildren: boolean;
  76817. private _image;
  76818. /**
  76819. * Returns the image part of the button (if any)
  76820. */
  76821. get image(): BABYLON.Nullable<Image>;
  76822. private _textBlock;
  76823. /**
  76824. * Returns the image part of the button (if any)
  76825. */
  76826. get textBlock(): BABYLON.Nullable<TextBlock>;
  76827. /**
  76828. * Creates a new Button
  76829. * @param name defines the name of the button
  76830. */
  76831. constructor(name?: string | undefined);
  76832. protected _getTypeName(): string;
  76833. /** @hidden */
  76834. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  76835. /** @hidden */
  76836. _onPointerEnter(target: Control): boolean;
  76837. /** @hidden */
  76838. _onPointerOut(target: Control, force?: boolean): void;
  76839. /** @hidden */
  76840. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76841. /** @hidden */
  76842. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  76843. /**
  76844. * Creates a new button made with an image and a text
  76845. * @param name defines the name of the button
  76846. * @param text defines the text of the button
  76847. * @param imageUrl defines the url of the image
  76848. * @returns a new Button
  76849. */
  76850. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  76851. /**
  76852. * Creates a new button made with an image
  76853. * @param name defines the name of the button
  76854. * @param imageUrl defines the url of the image
  76855. * @returns a new Button
  76856. */
  76857. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  76858. /**
  76859. * Creates a new button made with a text
  76860. * @param name defines the name of the button
  76861. * @param text defines the text of the button
  76862. * @returns a new Button
  76863. */
  76864. static CreateSimpleButton(name: string, text: string): Button;
  76865. /**
  76866. * Creates a new button made with an image and a centered text
  76867. * @param name defines the name of the button
  76868. * @param text defines the text of the button
  76869. * @param imageUrl defines the url of the image
  76870. * @returns a new Button
  76871. */
  76872. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  76873. }
  76874. }
  76875. declare module BABYLON.GUI {
  76876. /**
  76877. * Class used to create a 2D stack panel container
  76878. */
  76879. export class StackPanel extends Container {
  76880. name?: string | undefined;
  76881. private _isVertical;
  76882. private _manualWidth;
  76883. private _manualHeight;
  76884. private _doNotTrackManualChanges;
  76885. /**
  76886. * Gets or sets a boolean indicating that layou warnings should be ignored
  76887. */
  76888. ignoreLayoutWarnings: boolean;
  76889. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  76890. get isVertical(): boolean;
  76891. set isVertical(value: boolean);
  76892. /**
  76893. * Gets or sets panel width.
  76894. * This value should not be set when in horizontal mode as it will be computed automatically
  76895. */
  76896. set width(value: string | number);
  76897. get width(): string | number;
  76898. /**
  76899. * Gets or sets panel height.
  76900. * This value should not be set when in vertical mode as it will be computed automatically
  76901. */
  76902. set height(value: string | number);
  76903. get height(): string | number;
  76904. /**
  76905. * Creates a new StackPanel
  76906. * @param name defines control name
  76907. */
  76908. constructor(name?: string | undefined);
  76909. protected _getTypeName(): string;
  76910. /** @hidden */
  76911. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76912. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  76913. protected _postMeasure(): void;
  76914. }
  76915. }
  76916. declare module BABYLON.GUI {
  76917. /**
  76918. * Class used to represent a 2D checkbox
  76919. */
  76920. export class Checkbox extends Control {
  76921. name?: string | undefined;
  76922. private _isChecked;
  76923. private _background;
  76924. private _checkSizeRatio;
  76925. private _thickness;
  76926. /** Gets or sets border thickness */
  76927. get thickness(): number;
  76928. set thickness(value: number);
  76929. /**
  76930. * BABYLON.Observable raised when isChecked property changes
  76931. */
  76932. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  76933. /** Gets or sets a value indicating the ratio between overall size and check size */
  76934. get checkSizeRatio(): number;
  76935. set checkSizeRatio(value: number);
  76936. /** Gets or sets background color */
  76937. get background(): string;
  76938. set background(value: string);
  76939. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  76940. get isChecked(): boolean;
  76941. set isChecked(value: boolean);
  76942. /**
  76943. * Creates a new CheckBox
  76944. * @param name defines the control name
  76945. */
  76946. constructor(name?: string | undefined);
  76947. protected _getTypeName(): string;
  76948. /** @hidden */
  76949. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  76950. /** @hidden */
  76951. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  76952. /**
  76953. * Utility function to easily create a checkbox with a header
  76954. * @param title defines the label to use for the header
  76955. * @param onValueChanged defines the callback to call when value changes
  76956. * @returns a StackPanel containing the checkbox and a textBlock
  76957. */
  76958. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  76959. }
  76960. }
  76961. declare module BABYLON.GUI {
  76962. /**
  76963. * Class used to store key control properties
  76964. */
  76965. export class KeyPropertySet {
  76966. /** Width */
  76967. width?: string;
  76968. /** Height */
  76969. height?: string;
  76970. /** Left padding */
  76971. paddingLeft?: string;
  76972. /** Right padding */
  76973. paddingRight?: string;
  76974. /** Top padding */
  76975. paddingTop?: string;
  76976. /** Bottom padding */
  76977. paddingBottom?: string;
  76978. /** Foreground color */
  76979. color?: string;
  76980. /** Background color */
  76981. background?: string;
  76982. }
  76983. /**
  76984. * Class used to create virtual keyboard
  76985. */
  76986. export class VirtualKeyboard extends StackPanel {
  76987. /** BABYLON.Observable raised when a key is pressed */
  76988. onKeyPressObservable: BABYLON.Observable<string>;
  76989. /** Gets or sets default key button width */
  76990. defaultButtonWidth: string;
  76991. /** Gets or sets default key button height */
  76992. defaultButtonHeight: string;
  76993. /** Gets or sets default key button left padding */
  76994. defaultButtonPaddingLeft: string;
  76995. /** Gets or sets default key button right padding */
  76996. defaultButtonPaddingRight: string;
  76997. /** Gets or sets default key button top padding */
  76998. defaultButtonPaddingTop: string;
  76999. /** Gets or sets default key button bottom padding */
  77000. defaultButtonPaddingBottom: string;
  77001. /** Gets or sets default key button foreground color */
  77002. defaultButtonColor: string;
  77003. /** Gets or sets default key button background color */
  77004. defaultButtonBackground: string;
  77005. /** Gets or sets shift button foreground color */
  77006. shiftButtonColor: string;
  77007. /** Gets or sets shift button thickness*/
  77008. selectedShiftThickness: number;
  77009. /** Gets shift key state */
  77010. shiftState: number;
  77011. protected _getTypeName(): string;
  77012. private _createKey;
  77013. /**
  77014. * Adds a new row of keys
  77015. * @param keys defines the list of keys to add
  77016. * @param propertySets defines the associated property sets
  77017. */
  77018. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  77019. /**
  77020. * Set the shift key to a specific state
  77021. * @param shiftState defines the new shift state
  77022. */
  77023. applyShiftState(shiftState: number): void;
  77024. private _currentlyConnectedInputText;
  77025. private _connectedInputTexts;
  77026. private _onKeyPressObserver;
  77027. /** Gets the input text control currently attached to the keyboard */
  77028. get connectedInputText(): BABYLON.Nullable<InputText>;
  77029. /**
  77030. * Connects the keyboard with an input text control
  77031. *
  77032. * @param input defines the target control
  77033. */
  77034. connect(input: InputText): void;
  77035. /**
  77036. * Disconnects the keyboard from connected InputText controls
  77037. *
  77038. * @param input optionally defines a target control, otherwise all are disconnected
  77039. */
  77040. disconnect(input?: InputText): void;
  77041. private _removeConnectedInputObservables;
  77042. /**
  77043. * Release all resources
  77044. */
  77045. dispose(): void;
  77046. /**
  77047. * Creates a new keyboard using a default layout
  77048. *
  77049. * @param name defines control name
  77050. * @returns a new VirtualKeyboard
  77051. */
  77052. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  77053. }
  77054. }
  77055. declare module BABYLON.GUI {
  77056. /**
  77057. * Class used to create input text control
  77058. */
  77059. export class InputText extends Control implements IFocusableControl {
  77060. name?: string | undefined;
  77061. private _text;
  77062. private _placeholderText;
  77063. private _background;
  77064. private _focusedBackground;
  77065. private _focusedColor;
  77066. private _placeholderColor;
  77067. private _thickness;
  77068. private _margin;
  77069. private _autoStretchWidth;
  77070. private _maxWidth;
  77071. private _isFocused;
  77072. private _blinkTimeout;
  77073. private _blinkIsEven;
  77074. private _cursorOffset;
  77075. private _scrollLeft;
  77076. private _textWidth;
  77077. private _clickedCoordinate;
  77078. private _deadKey;
  77079. private _addKey;
  77080. private _currentKey;
  77081. private _isTextHighlightOn;
  77082. private _textHighlightColor;
  77083. private _highligherOpacity;
  77084. private _highlightedText;
  77085. private _startHighlightIndex;
  77086. private _endHighlightIndex;
  77087. private _cursorIndex;
  77088. private _onFocusSelectAll;
  77089. private _isPointerDown;
  77090. private _onClipboardObserver;
  77091. private _onPointerDblTapObserver;
  77092. /** @hidden */
  77093. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  77094. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  77095. promptMessage: string;
  77096. /** Force disable prompt on mobile device */
  77097. disableMobilePrompt: boolean;
  77098. /** BABYLON.Observable raised when the text changes */
  77099. onTextChangedObservable: BABYLON.Observable<InputText>;
  77100. /** BABYLON.Observable raised just before an entered character is to be added */
  77101. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  77102. /** BABYLON.Observable raised when the control gets the focus */
  77103. onFocusObservable: BABYLON.Observable<InputText>;
  77104. /** BABYLON.Observable raised when the control loses the focus */
  77105. onBlurObservable: BABYLON.Observable<InputText>;
  77106. /**Observable raised when the text is highlighted */
  77107. onTextHighlightObservable: BABYLON.Observable<InputText>;
  77108. /**Observable raised when copy event is triggered */
  77109. onTextCopyObservable: BABYLON.Observable<InputText>;
  77110. /** BABYLON.Observable raised when cut event is triggered */
  77111. onTextCutObservable: BABYLON.Observable<InputText>;
  77112. /** BABYLON.Observable raised when paste event is triggered */
  77113. onTextPasteObservable: BABYLON.Observable<InputText>;
  77114. /** BABYLON.Observable raised when a key event was processed */
  77115. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  77116. /** Gets or sets the maximum width allowed by the control */
  77117. get maxWidth(): string | number;
  77118. /** Gets the maximum width allowed by the control in pixels */
  77119. get maxWidthInPixels(): number;
  77120. set maxWidth(value: string | number);
  77121. /** Gets or sets the text highlighter transparency; default: 0.4 */
  77122. get highligherOpacity(): number;
  77123. set highligherOpacity(value: number);
  77124. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  77125. get onFocusSelectAll(): boolean;
  77126. set onFocusSelectAll(value: boolean);
  77127. /** Gets or sets the text hightlight color */
  77128. get textHighlightColor(): string;
  77129. set textHighlightColor(value: string);
  77130. /** Gets or sets control margin */
  77131. get margin(): string;
  77132. /** Gets control margin in pixels */
  77133. get marginInPixels(): number;
  77134. set margin(value: string);
  77135. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  77136. get autoStretchWidth(): boolean;
  77137. set autoStretchWidth(value: boolean);
  77138. /** Gets or sets border thickness */
  77139. get thickness(): number;
  77140. set thickness(value: number);
  77141. /** Gets or sets the background color when focused */
  77142. get focusedBackground(): string;
  77143. set focusedBackground(value: string);
  77144. /** Gets or sets the background color when focused */
  77145. get focusedColor(): string;
  77146. set focusedColor(value: string);
  77147. /** Gets or sets the background color */
  77148. get background(): string;
  77149. set background(value: string);
  77150. /** Gets or sets the placeholder color */
  77151. get placeholderColor(): string;
  77152. set placeholderColor(value: string);
  77153. /** Gets or sets the text displayed when the control is empty */
  77154. get placeholderText(): string;
  77155. set placeholderText(value: string);
  77156. /** Gets or sets the dead key flag */
  77157. get deadKey(): boolean;
  77158. set deadKey(flag: boolean);
  77159. /** Gets or sets the highlight text */
  77160. get highlightedText(): string;
  77161. set highlightedText(text: string);
  77162. /** Gets or sets if the current key should be added */
  77163. get addKey(): boolean;
  77164. set addKey(flag: boolean);
  77165. /** Gets or sets the value of the current key being entered */
  77166. get currentKey(): string;
  77167. set currentKey(key: string);
  77168. /** Gets or sets the text displayed in the control */
  77169. get text(): string;
  77170. set text(value: string);
  77171. /** Gets or sets control width */
  77172. get width(): string | number;
  77173. set width(value: string | number);
  77174. /**
  77175. * Creates a new InputText
  77176. * @param name defines the control name
  77177. * @param text defines the text of the control
  77178. */
  77179. constructor(name?: string | undefined, text?: string);
  77180. /** @hidden */
  77181. onBlur(): void;
  77182. /** @hidden */
  77183. onFocus(): void;
  77184. protected _getTypeName(): string;
  77185. /**
  77186. * Function called to get the list of controls that should not steal the focus from this control
  77187. * @returns an array of controls
  77188. */
  77189. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  77190. /** @hidden */
  77191. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  77192. /** @hidden */
  77193. private _updateValueFromCursorIndex;
  77194. /** @hidden */
  77195. private _processDblClick;
  77196. /** @hidden */
  77197. private _selectAllText;
  77198. /**
  77199. * Handles the keyboard event
  77200. * @param evt Defines the KeyboardEvent
  77201. */
  77202. processKeyboard(evt: KeyboardEvent): void;
  77203. /** @hidden */
  77204. private _onCopyText;
  77205. /** @hidden */
  77206. private _onCutText;
  77207. /** @hidden */
  77208. private _onPasteText;
  77209. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77210. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77211. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  77212. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77213. protected _beforeRenderText(text: string): string;
  77214. dispose(): void;
  77215. }
  77216. }
  77217. declare module BABYLON.GUI {
  77218. /**
  77219. * Class used to create a 2D grid container
  77220. */
  77221. export class Grid extends Container {
  77222. name?: string | undefined;
  77223. private _rowDefinitions;
  77224. private _columnDefinitions;
  77225. private _cells;
  77226. private _childControls;
  77227. /**
  77228. * Gets the number of columns
  77229. */
  77230. get columnCount(): number;
  77231. /**
  77232. * Gets the number of rows
  77233. */
  77234. get rowCount(): number;
  77235. /** Gets the list of children */
  77236. get children(): Control[];
  77237. /** Gets the list of cells (e.g. the containers) */
  77238. get cells(): {
  77239. [key: string]: Container;
  77240. };
  77241. /**
  77242. * Gets the definition of a specific row
  77243. * @param index defines the index of the row
  77244. * @returns the row definition
  77245. */
  77246. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  77247. /**
  77248. * Gets the definition of a specific column
  77249. * @param index defines the index of the column
  77250. * @returns the column definition
  77251. */
  77252. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  77253. /**
  77254. * Adds a new row to the grid
  77255. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  77256. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  77257. * @returns the current grid
  77258. */
  77259. addRowDefinition(height: number, isPixel?: boolean): Grid;
  77260. /**
  77261. * Adds a new column to the grid
  77262. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  77263. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  77264. * @returns the current grid
  77265. */
  77266. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  77267. /**
  77268. * Update a row definition
  77269. * @param index defines the index of the row to update
  77270. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  77271. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  77272. * @returns the current grid
  77273. */
  77274. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  77275. /**
  77276. * Update a column definition
  77277. * @param index defines the index of the column to update
  77278. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  77279. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  77280. * @returns the current grid
  77281. */
  77282. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  77283. /**
  77284. * Gets the list of children stored in a specific cell
  77285. * @param row defines the row to check
  77286. * @param column defines the column to check
  77287. * @returns the list of controls
  77288. */
  77289. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  77290. /**
  77291. * Gets a string representing the child cell info (row x column)
  77292. * @param child defines the control to get info from
  77293. * @returns a string containing the child cell info (row x column)
  77294. */
  77295. getChildCellInfo(child: Control): string;
  77296. private _removeCell;
  77297. private _offsetCell;
  77298. /**
  77299. * Remove a column definition at specified index
  77300. * @param index defines the index of the column to remove
  77301. * @returns the current grid
  77302. */
  77303. removeColumnDefinition(index: number): Grid;
  77304. /**
  77305. * Remove a row definition at specified index
  77306. * @param index defines the index of the row to remove
  77307. * @returns the current grid
  77308. */
  77309. removeRowDefinition(index: number): Grid;
  77310. /**
  77311. * Adds a new control to the current grid
  77312. * @param control defines the control to add
  77313. * @param row defines the row where to add the control (0 by default)
  77314. * @param column defines the column where to add the control (0 by default)
  77315. * @returns the current grid
  77316. */
  77317. addControl(control: Control, row?: number, column?: number): Grid;
  77318. /**
  77319. * Removes a control from the current container
  77320. * @param control defines the control to remove
  77321. * @returns the current container
  77322. */
  77323. removeControl(control: Control): Container;
  77324. /**
  77325. * Creates a new Grid
  77326. * @param name defines control name
  77327. */
  77328. constructor(name?: string | undefined);
  77329. protected _getTypeName(): string;
  77330. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  77331. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77332. _flagDescendantsAsMatrixDirty(): void;
  77333. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  77334. /** Releases associated resources */
  77335. dispose(): void;
  77336. }
  77337. }
  77338. declare module BABYLON.GUI {
  77339. /** Class used to create color pickers */
  77340. export class ColorPicker extends Control {
  77341. name?: string | undefined;
  77342. private static _Epsilon;
  77343. private _colorWheelCanvas;
  77344. private _value;
  77345. private _tmpColor;
  77346. private _pointerStartedOnSquare;
  77347. private _pointerStartedOnWheel;
  77348. private _squareLeft;
  77349. private _squareTop;
  77350. private _squareSize;
  77351. private _h;
  77352. private _s;
  77353. private _v;
  77354. private _lastPointerDownID;
  77355. /**
  77356. * BABYLON.Observable raised when the value changes
  77357. */
  77358. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  77359. /** Gets or sets the color of the color picker */
  77360. get value(): BABYLON.Color3;
  77361. set value(value: BABYLON.Color3);
  77362. /**
  77363. * Gets or sets control width
  77364. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77365. */
  77366. get width(): string | number;
  77367. set width(value: string | number);
  77368. /**
  77369. * Gets or sets control height
  77370. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77371. */
  77372. get height(): string | number;
  77373. /** Gets or sets control height */
  77374. set height(value: string | number);
  77375. /** Gets or sets control size */
  77376. get size(): string | number;
  77377. set size(value: string | number);
  77378. /**
  77379. * Creates a new ColorPicker
  77380. * @param name defines the control name
  77381. */
  77382. constructor(name?: string | undefined);
  77383. protected _getTypeName(): string;
  77384. /** @hidden */
  77385. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77386. private _updateSquareProps;
  77387. private _drawGradientSquare;
  77388. private _drawCircle;
  77389. private _createColorWheelCanvas;
  77390. /** @hidden */
  77391. _draw(context: CanvasRenderingContext2D): void;
  77392. private _pointerIsDown;
  77393. private _updateValueFromPointer;
  77394. private _isPointOnSquare;
  77395. private _isPointOnWheel;
  77396. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77397. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  77398. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77399. /**
  77400. * This function expands the color picker by creating a color picker dialog with manual
  77401. * color value input and the ability to save colors into an array to be used later in
  77402. * subsequent launches of the dialogue.
  77403. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  77404. * @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.
  77405. * @returns picked color as a hex string and the saved colors array as hex strings.
  77406. */
  77407. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  77408. pickerWidth?: string;
  77409. pickerHeight?: string;
  77410. headerHeight?: string;
  77411. lastColor?: string;
  77412. swatchLimit?: number;
  77413. numSwatchesPerLine?: number;
  77414. savedColors?: Array<string>;
  77415. }): Promise<{
  77416. savedColors?: string[];
  77417. pickedColor: string;
  77418. }>;
  77419. }
  77420. }
  77421. declare module BABYLON.GUI {
  77422. /** Class used to create 2D ellipse containers */
  77423. export class Ellipse extends Container {
  77424. name?: string | undefined;
  77425. private _thickness;
  77426. /** Gets or sets border thickness */
  77427. get thickness(): number;
  77428. set thickness(value: number);
  77429. /**
  77430. * Creates a new Ellipse
  77431. * @param name defines the control name
  77432. */
  77433. constructor(name?: string | undefined);
  77434. protected _getTypeName(): string;
  77435. protected _localDraw(context: CanvasRenderingContext2D): void;
  77436. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77437. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  77438. }
  77439. }
  77440. declare module BABYLON.GUI {
  77441. /**
  77442. * Class used to create a password control
  77443. */
  77444. export class InputPassword extends InputText {
  77445. protected _beforeRenderText(text: string): string;
  77446. }
  77447. }
  77448. declare module BABYLON.GUI {
  77449. /** Class used to render 2D lines */
  77450. export class Line extends Control {
  77451. name?: string | undefined;
  77452. private _lineWidth;
  77453. private _x1;
  77454. private _y1;
  77455. private _x2;
  77456. private _y2;
  77457. private _dash;
  77458. private _connectedControl;
  77459. private _connectedControlDirtyObserver;
  77460. /** Gets or sets the dash pattern */
  77461. get dash(): Array<number>;
  77462. set dash(value: Array<number>);
  77463. /** Gets or sets the control connected with the line end */
  77464. get connectedControl(): Control;
  77465. set connectedControl(value: Control);
  77466. /** Gets or sets start coordinates on X axis */
  77467. get x1(): string | number;
  77468. set x1(value: string | number);
  77469. /** Gets or sets start coordinates on Y axis */
  77470. get y1(): string | number;
  77471. set y1(value: string | number);
  77472. /** Gets or sets end coordinates on X axis */
  77473. get x2(): string | number;
  77474. set x2(value: string | number);
  77475. /** Gets or sets end coordinates on Y axis */
  77476. get y2(): string | number;
  77477. set y2(value: string | number);
  77478. /** Gets or sets line width */
  77479. get lineWidth(): number;
  77480. set lineWidth(value: number);
  77481. /** Gets or sets horizontal alignment */
  77482. set horizontalAlignment(value: number);
  77483. /** Gets or sets vertical alignment */
  77484. set verticalAlignment(value: number);
  77485. private get _effectiveX2();
  77486. private get _effectiveY2();
  77487. /**
  77488. * Creates a new Line
  77489. * @param name defines the control name
  77490. */
  77491. constructor(name?: string | undefined);
  77492. protected _getTypeName(): string;
  77493. _draw(context: CanvasRenderingContext2D): void;
  77494. _measure(): void;
  77495. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77496. /**
  77497. * Move one end of the line given 3D cartesian coordinates.
  77498. * @param position Targeted world position
  77499. * @param scene BABYLON.Scene
  77500. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  77501. */
  77502. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  77503. /**
  77504. * Move one end of the line to a position in screen absolute space.
  77505. * @param projectedPosition Position in screen absolute space (X, Y)
  77506. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  77507. */
  77508. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  77509. }
  77510. }
  77511. declare module BABYLON.GUI {
  77512. /**
  77513. * Class used to store a point for a MultiLine object.
  77514. * The point can be pure 2D coordinates, a mesh or a control
  77515. */
  77516. export class MultiLinePoint {
  77517. private _multiLine;
  77518. private _x;
  77519. private _y;
  77520. private _control;
  77521. private _mesh;
  77522. private _controlObserver;
  77523. private _meshObserver;
  77524. /** @hidden */
  77525. _point: BABYLON.Vector2;
  77526. /**
  77527. * Creates a new MultiLinePoint
  77528. * @param multiLine defines the source MultiLine object
  77529. */
  77530. constructor(multiLine: MultiLine);
  77531. /** Gets or sets x coordinate */
  77532. get x(): string | number;
  77533. set x(value: string | number);
  77534. /** Gets or sets y coordinate */
  77535. get y(): string | number;
  77536. set y(value: string | number);
  77537. /** Gets or sets the control associated with this point */
  77538. get control(): BABYLON.Nullable<Control>;
  77539. set control(value: BABYLON.Nullable<Control>);
  77540. /** Gets or sets the mesh associated with this point */
  77541. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  77542. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  77543. /** Resets links */
  77544. resetLinks(): void;
  77545. /**
  77546. * Gets a translation vector
  77547. * @returns the translation vector
  77548. */
  77549. translate(): BABYLON.Vector2;
  77550. private _translatePoint;
  77551. /** Release associated resources */
  77552. dispose(): void;
  77553. }
  77554. }
  77555. declare module BABYLON.GUI {
  77556. /**
  77557. * Class used to create multi line control
  77558. */
  77559. export class MultiLine extends Control {
  77560. name?: string | undefined;
  77561. private _lineWidth;
  77562. private _dash;
  77563. private _points;
  77564. private _minX;
  77565. private _minY;
  77566. private _maxX;
  77567. private _maxY;
  77568. /**
  77569. * Creates a new MultiLine
  77570. * @param name defines the control name
  77571. */
  77572. constructor(name?: string | undefined);
  77573. /** Gets or sets dash pattern */
  77574. get dash(): Array<number>;
  77575. set dash(value: Array<number>);
  77576. /**
  77577. * Gets point stored at specified index
  77578. * @param index defines the index to look for
  77579. * @returns the requested point if found
  77580. */
  77581. getAt(index: number): MultiLinePoint;
  77582. /** Function called when a point is updated */
  77583. onPointUpdate: () => void;
  77584. /**
  77585. * Adds new points to the point collection
  77586. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  77587. * @returns the list of created MultiLinePoint
  77588. */
  77589. add(...items: (AbstractMesh | Control | {
  77590. x: string | number;
  77591. y: string | number;
  77592. })[]): MultiLinePoint[];
  77593. /**
  77594. * Adds a new point to the point collection
  77595. * @param item defines the item (mesh, control or 2d coordiantes) to add
  77596. * @returns the created MultiLinePoint
  77597. */
  77598. push(item?: (AbstractMesh | Control | {
  77599. x: string | number;
  77600. y: string | number;
  77601. })): MultiLinePoint;
  77602. /**
  77603. * Remove a specific value or point from the active point collection
  77604. * @param value defines the value or point to remove
  77605. */
  77606. remove(value: number | MultiLinePoint): void;
  77607. /**
  77608. * Resets this object to initial state (no point)
  77609. */
  77610. reset(): void;
  77611. /**
  77612. * Resets all links
  77613. */
  77614. resetLinks(): void;
  77615. /** Gets or sets line width */
  77616. get lineWidth(): number;
  77617. set lineWidth(value: number);
  77618. set horizontalAlignment(value: number);
  77619. set verticalAlignment(value: number);
  77620. protected _getTypeName(): string;
  77621. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77622. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77623. _measure(): void;
  77624. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77625. dispose(): void;
  77626. }
  77627. }
  77628. declare module BABYLON.GUI {
  77629. /**
  77630. * Class used to create radio button controls
  77631. */
  77632. export class RadioButton extends Control {
  77633. name?: string | undefined;
  77634. private _isChecked;
  77635. private _background;
  77636. private _checkSizeRatio;
  77637. private _thickness;
  77638. /** Gets or sets border thickness */
  77639. get thickness(): number;
  77640. set thickness(value: number);
  77641. /** Gets or sets group name */
  77642. group: string;
  77643. /** BABYLON.Observable raised when isChecked is changed */
  77644. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  77645. /** Gets or sets a value indicating the ratio between overall size and check size */
  77646. get checkSizeRatio(): number;
  77647. set checkSizeRatio(value: number);
  77648. /** Gets or sets background color */
  77649. get background(): string;
  77650. set background(value: string);
  77651. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  77652. get isChecked(): boolean;
  77653. set isChecked(value: boolean);
  77654. /**
  77655. * Creates a new RadioButton
  77656. * @param name defines the control name
  77657. */
  77658. constructor(name?: string | undefined);
  77659. protected _getTypeName(): string;
  77660. _draw(context: CanvasRenderingContext2D): void;
  77661. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77662. /**
  77663. * Utility function to easily create a radio button with a header
  77664. * @param title defines the label to use for the header
  77665. * @param group defines the group to use for the radio button
  77666. * @param isChecked defines the initial state of the radio button
  77667. * @param onValueChanged defines the callback to call when value changes
  77668. * @returns a StackPanel containing the radio button and a textBlock
  77669. */
  77670. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  77671. }
  77672. }
  77673. declare module BABYLON.GUI {
  77674. /**
  77675. * Class used to create slider controls
  77676. */
  77677. export class BaseSlider extends Control {
  77678. name?: string | undefined;
  77679. protected _thumbWidth: ValueAndUnit;
  77680. private _minimum;
  77681. private _maximum;
  77682. private _value;
  77683. private _isVertical;
  77684. protected _barOffset: ValueAndUnit;
  77685. private _isThumbClamped;
  77686. protected _displayThumb: boolean;
  77687. private _step;
  77688. private _lastPointerDownID;
  77689. protected _effectiveBarOffset: number;
  77690. protected _renderLeft: number;
  77691. protected _renderTop: number;
  77692. protected _renderWidth: number;
  77693. protected _renderHeight: number;
  77694. protected _backgroundBoxLength: number;
  77695. protected _backgroundBoxThickness: number;
  77696. protected _effectiveThumbThickness: number;
  77697. /** BABYLON.Observable raised when the sldier value changes */
  77698. onValueChangedObservable: BABYLON.Observable<number>;
  77699. /** Gets or sets a boolean indicating if the thumb must be rendered */
  77700. get displayThumb(): boolean;
  77701. set displayThumb(value: boolean);
  77702. /** Gets or sets a step to apply to values (0 by default) */
  77703. get step(): number;
  77704. set step(value: number);
  77705. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  77706. get barOffset(): string | number;
  77707. /** Gets main bar offset in pixels*/
  77708. get barOffsetInPixels(): number;
  77709. set barOffset(value: string | number);
  77710. /** Gets or sets thumb width */
  77711. get thumbWidth(): string | number;
  77712. /** Gets thumb width in pixels */
  77713. get thumbWidthInPixels(): number;
  77714. set thumbWidth(value: string | number);
  77715. /** Gets or sets minimum value */
  77716. get minimum(): number;
  77717. set minimum(value: number);
  77718. /** Gets or sets maximum value */
  77719. get maximum(): number;
  77720. set maximum(value: number);
  77721. /** Gets or sets current value */
  77722. get value(): number;
  77723. set value(value: number);
  77724. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  77725. get isVertical(): boolean;
  77726. set isVertical(value: boolean);
  77727. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  77728. get isThumbClamped(): boolean;
  77729. set isThumbClamped(value: boolean);
  77730. /**
  77731. * Creates a new BaseSlider
  77732. * @param name defines the control name
  77733. */
  77734. constructor(name?: string | undefined);
  77735. protected _getTypeName(): string;
  77736. protected _getThumbPosition(): number;
  77737. protected _getThumbThickness(type: string): number;
  77738. protected _prepareRenderingData(type: string): void;
  77739. private _pointerIsDown;
  77740. /** @hidden */
  77741. protected _updateValueFromPointer(x: number, y: number): void;
  77742. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  77743. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  77744. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  77745. }
  77746. }
  77747. declare module BABYLON.GUI {
  77748. /**
  77749. * Class used to create slider controls
  77750. */
  77751. export class Slider extends BaseSlider {
  77752. name?: string | undefined;
  77753. private _background;
  77754. private _borderColor;
  77755. private _isThumbCircle;
  77756. protected _displayValueBar: boolean;
  77757. /** Gets or sets a boolean indicating if the value bar must be rendered */
  77758. get displayValueBar(): boolean;
  77759. set displayValueBar(value: boolean);
  77760. /** Gets or sets border color */
  77761. get borderColor(): string;
  77762. set borderColor(value: string);
  77763. /** Gets or sets background color */
  77764. get background(): string;
  77765. set background(value: string);
  77766. /** Gets or sets a boolean indicating if the thumb should be round or square */
  77767. get isThumbCircle(): boolean;
  77768. set isThumbCircle(value: boolean);
  77769. /**
  77770. * Creates a new Slider
  77771. * @param name defines the control name
  77772. */
  77773. constructor(name?: string | undefined);
  77774. protected _getTypeName(): string;
  77775. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77776. }
  77777. }
  77778. declare module BABYLON.GUI {
  77779. /** Class used to create a RadioGroup
  77780. * which contains groups of radio buttons
  77781. */
  77782. export class SelectorGroup {
  77783. /** name of SelectorGroup */
  77784. name: string;
  77785. private _groupPanel;
  77786. private _selectors;
  77787. private _groupHeader;
  77788. /**
  77789. * Creates a new SelectorGroup
  77790. * @param name of group, used as a group heading
  77791. */
  77792. constructor(
  77793. /** name of SelectorGroup */
  77794. name: string);
  77795. /** Gets the groupPanel of the SelectorGroup */
  77796. get groupPanel(): StackPanel;
  77797. /** Gets the selectors array */
  77798. get selectors(): StackPanel[];
  77799. /** Gets and sets the group header */
  77800. get header(): string;
  77801. set header(label: string);
  77802. /** @hidden */
  77803. private _addGroupHeader;
  77804. /** @hidden*/
  77805. _getSelector(selectorNb: number): StackPanel | undefined;
  77806. /** Removes the selector at the given position
  77807. * @param selectorNb the position of the selector within the group
  77808. */
  77809. removeSelector(selectorNb: number): void;
  77810. }
  77811. /** Class used to create a CheckboxGroup
  77812. * which contains groups of checkbox buttons
  77813. */
  77814. export class CheckboxGroup extends SelectorGroup {
  77815. /** Adds a checkbox as a control
  77816. * @param text is the label for the selector
  77817. * @param func is the function called when the Selector is checked
  77818. * @param checked is true when Selector is checked
  77819. */
  77820. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  77821. /** @hidden */
  77822. _setSelectorLabel(selectorNb: number, label: string): void;
  77823. /** @hidden */
  77824. _setSelectorLabelColor(selectorNb: number, color: string): void;
  77825. /** @hidden */
  77826. _setSelectorButtonColor(selectorNb: number, color: string): void;
  77827. /** @hidden */
  77828. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  77829. }
  77830. /** Class used to create a RadioGroup
  77831. * which contains groups of radio buttons
  77832. */
  77833. export class RadioGroup extends SelectorGroup {
  77834. private _selectNb;
  77835. /** Adds a radio button as a control
  77836. * @param label is the label for the selector
  77837. * @param func is the function called when the Selector is checked
  77838. * @param checked is true when Selector is checked
  77839. */
  77840. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  77841. /** @hidden */
  77842. _setSelectorLabel(selectorNb: number, label: string): void;
  77843. /** @hidden */
  77844. _setSelectorLabelColor(selectorNb: number, color: string): void;
  77845. /** @hidden */
  77846. _setSelectorButtonColor(selectorNb: number, color: string): void;
  77847. /** @hidden */
  77848. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  77849. }
  77850. /** Class used to create a SliderGroup
  77851. * which contains groups of slider buttons
  77852. */
  77853. export class SliderGroup extends SelectorGroup {
  77854. /**
  77855. * Adds a slider to the SelectorGroup
  77856. * @param label is the label for the SliderBar
  77857. * @param func is the function called when the Slider moves
  77858. * @param unit is a string describing the units used, eg degrees or metres
  77859. * @param min is the minimum value for the Slider
  77860. * @param max is the maximum value for the Slider
  77861. * @param value is the start value for the Slider between min and max
  77862. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  77863. */
  77864. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  77865. /** @hidden */
  77866. _setSelectorLabel(selectorNb: number, label: string): void;
  77867. /** @hidden */
  77868. _setSelectorLabelColor(selectorNb: number, color: string): void;
  77869. /** @hidden */
  77870. _setSelectorButtonColor(selectorNb: number, color: string): void;
  77871. /** @hidden */
  77872. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  77873. }
  77874. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  77875. * @see https://doc.babylonjs.com/how_to/selector
  77876. */
  77877. export class SelectionPanel extends Rectangle {
  77878. /** name of SelectionPanel */
  77879. name: string;
  77880. /** an array of SelectionGroups */
  77881. groups: SelectorGroup[];
  77882. private _panel;
  77883. private _buttonColor;
  77884. private _buttonBackground;
  77885. private _headerColor;
  77886. private _barColor;
  77887. private _barHeight;
  77888. private _spacerHeight;
  77889. private _labelColor;
  77890. private _groups;
  77891. private _bars;
  77892. /**
  77893. * Creates a new SelectionPanel
  77894. * @param name of SelectionPanel
  77895. * @param groups is an array of SelectionGroups
  77896. */
  77897. constructor(
  77898. /** name of SelectionPanel */
  77899. name: string,
  77900. /** an array of SelectionGroups */
  77901. groups?: SelectorGroup[]);
  77902. protected _getTypeName(): string;
  77903. /** Gets or sets the headerColor */
  77904. get headerColor(): string;
  77905. set headerColor(color: string);
  77906. private _setHeaderColor;
  77907. /** Gets or sets the button color */
  77908. get buttonColor(): string;
  77909. set buttonColor(color: string);
  77910. private _setbuttonColor;
  77911. /** Gets or sets the label color */
  77912. get labelColor(): string;
  77913. set labelColor(color: string);
  77914. private _setLabelColor;
  77915. /** Gets or sets the button background */
  77916. get buttonBackground(): string;
  77917. set buttonBackground(color: string);
  77918. private _setButtonBackground;
  77919. /** Gets or sets the color of separator bar */
  77920. get barColor(): string;
  77921. set barColor(color: string);
  77922. private _setBarColor;
  77923. /** Gets or sets the height of separator bar */
  77924. get barHeight(): string;
  77925. set barHeight(value: string);
  77926. private _setBarHeight;
  77927. /** Gets or sets the height of spacers*/
  77928. get spacerHeight(): string;
  77929. set spacerHeight(value: string);
  77930. private _setSpacerHeight;
  77931. /** Adds a bar between groups */
  77932. private _addSpacer;
  77933. /** Add a group to the selection panel
  77934. * @param group is the selector group to add
  77935. */
  77936. addGroup(group: SelectorGroup): void;
  77937. /** Remove the group from the given position
  77938. * @param groupNb is the position of the group in the list
  77939. */
  77940. removeGroup(groupNb: number): void;
  77941. /** Change a group header label
  77942. * @param label is the new group header label
  77943. * @param groupNb is the number of the group to relabel
  77944. * */
  77945. setHeaderName(label: string, groupNb: number): void;
  77946. /** Change selector label to the one given
  77947. * @param label is the new selector label
  77948. * @param groupNb is the number of the groupcontaining the selector
  77949. * @param selectorNb is the number of the selector within a group to relabel
  77950. * */
  77951. relabel(label: string, groupNb: number, selectorNb: number): void;
  77952. /** For a given group position remove the selector at the given position
  77953. * @param groupNb is the number of the group to remove the selector from
  77954. * @param selectorNb is the number of the selector within the group
  77955. */
  77956. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  77957. /** For a given group position of correct type add a checkbox button
  77958. * @param groupNb is the number of the group to remove the selector from
  77959. * @param label is the label for the selector
  77960. * @param func is the function called when the Selector is checked
  77961. * @param checked is true when Selector is checked
  77962. */
  77963. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  77964. /** For a given group position of correct type add a radio button
  77965. * @param groupNb is the number of the group to remove the selector from
  77966. * @param label is the label for the selector
  77967. * @param func is the function called when the Selector is checked
  77968. * @param checked is true when Selector is checked
  77969. */
  77970. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  77971. /**
  77972. * For a given slider group add a slider
  77973. * @param groupNb is the number of the group to add the slider to
  77974. * @param label is the label for the Slider
  77975. * @param func is the function called when the Slider moves
  77976. * @param unit is a string describing the units used, eg degrees or metres
  77977. * @param min is the minimum value for the Slider
  77978. * @param max is the maximum value for the Slider
  77979. * @param value is the start value for the Slider between min and max
  77980. * @param onVal is the function used to format the value displayed, eg radians to degrees
  77981. */
  77982. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  77983. }
  77984. }
  77985. declare module BABYLON.GUI {
  77986. /**
  77987. * Class used to hold a the container for ScrollViewer
  77988. * @hidden
  77989. */
  77990. export class _ScrollViewerWindow extends Container {
  77991. parentClientWidth: number;
  77992. parentClientHeight: number;
  77993. private _freezeControls;
  77994. private _parentMeasure;
  77995. private _oldLeft;
  77996. private _oldTop;
  77997. get freezeControls(): boolean;
  77998. set freezeControls(value: boolean);
  77999. private _bucketWidth;
  78000. private _bucketHeight;
  78001. private _buckets;
  78002. private _bucketLen;
  78003. get bucketWidth(): number;
  78004. get bucketHeight(): number;
  78005. setBucketSizes(width: number, height: number): void;
  78006. private _useBuckets;
  78007. private _makeBuckets;
  78008. private _dispatchInBuckets;
  78009. private _updateMeasures;
  78010. private _updateChildrenMeasures;
  78011. private _restoreMeasures;
  78012. /**
  78013. * Creates a new ScrollViewerWindow
  78014. * @param name of ScrollViewerWindow
  78015. */
  78016. constructor(name?: string);
  78017. protected _getTypeName(): string;
  78018. /** @hidden */
  78019. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78020. /** @hidden */
  78021. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  78022. private _scrollChildren;
  78023. private _scrollChildrenWithBuckets;
  78024. /** @hidden */
  78025. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  78026. protected _postMeasure(): void;
  78027. }
  78028. }
  78029. declare module BABYLON.GUI {
  78030. /**
  78031. * Class used to create slider controls
  78032. */
  78033. export class ScrollBar extends BaseSlider {
  78034. name?: string | undefined;
  78035. private _background;
  78036. private _borderColor;
  78037. private _tempMeasure;
  78038. /** Gets or sets border color */
  78039. get borderColor(): string;
  78040. set borderColor(value: string);
  78041. /** Gets or sets background color */
  78042. get background(): string;
  78043. set background(value: string);
  78044. /**
  78045. * Creates a new Slider
  78046. * @param name defines the control name
  78047. */
  78048. constructor(name?: string | undefined);
  78049. protected _getTypeName(): string;
  78050. protected _getThumbThickness(): number;
  78051. _draw(context: CanvasRenderingContext2D): void;
  78052. private _first;
  78053. private _originX;
  78054. private _originY;
  78055. /** @hidden */
  78056. protected _updateValueFromPointer(x: number, y: number): void;
  78057. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78058. }
  78059. }
  78060. declare module BABYLON.GUI {
  78061. /**
  78062. * Class used to create slider controls
  78063. */
  78064. export class ImageScrollBar extends BaseSlider {
  78065. name?: string | undefined;
  78066. private _backgroundBaseImage;
  78067. private _backgroundImage;
  78068. private _thumbImage;
  78069. private _thumbBaseImage;
  78070. private _thumbLength;
  78071. private _thumbHeight;
  78072. private _barImageHeight;
  78073. private _tempMeasure;
  78074. /** Number of 90° rotation to apply on the images when in vertical mode */
  78075. num90RotationInVerticalMode: number;
  78076. /**
  78077. * Gets or sets the image used to render the background for horizontal bar
  78078. */
  78079. get backgroundImage(): Image;
  78080. set backgroundImage(value: Image);
  78081. /**
  78082. * Gets or sets the image used to render the thumb
  78083. */
  78084. get thumbImage(): Image;
  78085. set thumbImage(value: Image);
  78086. /**
  78087. * Gets or sets the length of the thumb
  78088. */
  78089. get thumbLength(): number;
  78090. set thumbLength(value: number);
  78091. /**
  78092. * Gets or sets the height of the thumb
  78093. */
  78094. get thumbHeight(): number;
  78095. set thumbHeight(value: number);
  78096. /**
  78097. * Gets or sets the height of the bar image
  78098. */
  78099. get barImageHeight(): number;
  78100. set barImageHeight(value: number);
  78101. /**
  78102. * Creates a new ImageScrollBar
  78103. * @param name defines the control name
  78104. */
  78105. constructor(name?: string | undefined);
  78106. protected _getTypeName(): string;
  78107. protected _getThumbThickness(): number;
  78108. _draw(context: CanvasRenderingContext2D): void;
  78109. private _first;
  78110. private _originX;
  78111. private _originY;
  78112. /** @hidden */
  78113. protected _updateValueFromPointer(x: number, y: number): void;
  78114. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78115. }
  78116. }
  78117. declare module BABYLON.GUI {
  78118. /**
  78119. * Class used to hold a viewer window and sliders in a grid
  78120. */
  78121. export class ScrollViewer extends Rectangle {
  78122. private _grid;
  78123. private _horizontalBarSpace;
  78124. private _verticalBarSpace;
  78125. private _dragSpace;
  78126. private _horizontalBar;
  78127. private _verticalBar;
  78128. private _barColor;
  78129. private _barBackground;
  78130. private _barImage;
  78131. private _horizontalBarImage;
  78132. private _verticalBarImage;
  78133. private _barBackgroundImage;
  78134. private _horizontalBarBackgroundImage;
  78135. private _verticalBarBackgroundImage;
  78136. private _barSize;
  78137. private _window;
  78138. private _pointerIsOver;
  78139. private _wheelPrecision;
  78140. private _onWheelObserver;
  78141. private _clientWidth;
  78142. private _clientHeight;
  78143. private _useImageBar;
  78144. private _thumbLength;
  78145. private _thumbHeight;
  78146. private _barImageHeight;
  78147. private _horizontalBarImageHeight;
  78148. private _verticalBarImageHeight;
  78149. private _oldWindowContentsWidth;
  78150. private _oldWindowContentsHeight;
  78151. /**
  78152. * Gets the horizontal scrollbar
  78153. */
  78154. get horizontalBar(): ScrollBar | ImageScrollBar;
  78155. /**
  78156. * Gets the vertical scrollbar
  78157. */
  78158. get verticalBar(): ScrollBar | ImageScrollBar;
  78159. /**
  78160. * Adds a new control to the current container
  78161. * @param control defines the control to add
  78162. * @returns the current container
  78163. */
  78164. addControl(control: BABYLON.Nullable<Control>): Container;
  78165. /**
  78166. * Removes a control from the current container
  78167. * @param control defines the control to remove
  78168. * @returns the current container
  78169. */
  78170. removeControl(control: Control): Container;
  78171. /** Gets the list of children */
  78172. get children(): Control[];
  78173. _flagDescendantsAsMatrixDirty(): void;
  78174. /**
  78175. * Freezes or unfreezes the controls in the window.
  78176. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  78177. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  78178. */
  78179. get freezeControls(): boolean;
  78180. set freezeControls(value: boolean);
  78181. /** Gets the bucket width */
  78182. get bucketWidth(): number;
  78183. /** Gets the bucket height */
  78184. get bucketHeight(): number;
  78185. /**
  78186. * Sets the bucket sizes.
  78187. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  78188. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  78189. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  78190. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  78191. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  78192. * used), that's why it is not enabled by default.
  78193. * @param width width of the bucket
  78194. * @param height height of the bucket
  78195. */
  78196. setBucketSizes(width: number, height: number): void;
  78197. private _forceHorizontalBar;
  78198. private _forceVerticalBar;
  78199. /**
  78200. * Forces the horizontal scroll bar to be displayed
  78201. */
  78202. get forceHorizontalBar(): boolean;
  78203. set forceHorizontalBar(value: boolean);
  78204. /**
  78205. * Forces the vertical scroll bar to be displayed
  78206. */
  78207. get forceVerticalBar(): boolean;
  78208. set forceVerticalBar(value: boolean);
  78209. /**
  78210. * Creates a new ScrollViewer
  78211. * @param name of ScrollViewer
  78212. */
  78213. constructor(name?: string, isImageBased?: boolean);
  78214. /** Reset the scroll viewer window to initial size */
  78215. resetWindow(): void;
  78216. protected _getTypeName(): string;
  78217. private _buildClientSizes;
  78218. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78219. protected _postMeasure(): void;
  78220. /**
  78221. * Gets or sets the mouse wheel precision
  78222. * from 0 to 1 with a default value of 0.05
  78223. * */
  78224. get wheelPrecision(): number;
  78225. set wheelPrecision(value: number);
  78226. /** Gets or sets the scroll bar container background color */
  78227. get scrollBackground(): string;
  78228. set scrollBackground(color: string);
  78229. /** Gets or sets the bar color */
  78230. get barColor(): string;
  78231. set barColor(color: string);
  78232. /** Gets or sets the bar image */
  78233. get thumbImage(): Image;
  78234. set thumbImage(value: Image);
  78235. /** Gets or sets the horizontal bar image */
  78236. get horizontalThumbImage(): Image;
  78237. set horizontalThumbImage(value: Image);
  78238. /** Gets or sets the vertical bar image */
  78239. get verticalThumbImage(): Image;
  78240. set verticalThumbImage(value: Image);
  78241. /** Gets or sets the size of the bar */
  78242. get barSize(): number;
  78243. set barSize(value: number);
  78244. /** Gets or sets the length of the thumb */
  78245. get thumbLength(): number;
  78246. set thumbLength(value: number);
  78247. /** Gets or sets the height of the thumb */
  78248. get thumbHeight(): number;
  78249. set thumbHeight(value: number);
  78250. /** Gets or sets the height of the bar image */
  78251. get barImageHeight(): number;
  78252. set barImageHeight(value: number);
  78253. /** Gets or sets the height of the horizontal bar image */
  78254. get horizontalBarImageHeight(): number;
  78255. set horizontalBarImageHeight(value: number);
  78256. /** Gets or sets the height of the vertical bar image */
  78257. get verticalBarImageHeight(): number;
  78258. set verticalBarImageHeight(value: number);
  78259. /** Gets or sets the bar background */
  78260. get barBackground(): string;
  78261. set barBackground(color: string);
  78262. /** Gets or sets the bar background image */
  78263. get barImage(): Image;
  78264. set barImage(value: Image);
  78265. /** Gets or sets the horizontal bar background image */
  78266. get horizontalBarImage(): Image;
  78267. set horizontalBarImage(value: Image);
  78268. /** Gets or sets the vertical bar background image */
  78269. get verticalBarImage(): Image;
  78270. set verticalBarImage(value: Image);
  78271. private _setWindowPosition;
  78272. /** @hidden */
  78273. private _updateScroller;
  78274. _link(host: AdvancedDynamicTexture): void;
  78275. /** @hidden */
  78276. private _addBar;
  78277. /** @hidden */
  78278. private _attachWheel;
  78279. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  78280. /** Releases associated resources */
  78281. dispose(): void;
  78282. }
  78283. }
  78284. declare module BABYLON.GUI {
  78285. /** Class used to render a grid */
  78286. export class DisplayGrid extends Control {
  78287. name?: string | undefined;
  78288. private _cellWidth;
  78289. private _cellHeight;
  78290. private _minorLineTickness;
  78291. private _minorLineColor;
  78292. private _majorLineTickness;
  78293. private _majorLineColor;
  78294. private _majorLineFrequency;
  78295. private _background;
  78296. private _displayMajorLines;
  78297. private _displayMinorLines;
  78298. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  78299. get displayMinorLines(): boolean;
  78300. set displayMinorLines(value: boolean);
  78301. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  78302. get displayMajorLines(): boolean;
  78303. set displayMajorLines(value: boolean);
  78304. /** Gets or sets background color (Black by default) */
  78305. get background(): string;
  78306. set background(value: string);
  78307. /** Gets or sets the width of each cell (20 by default) */
  78308. get cellWidth(): number;
  78309. set cellWidth(value: number);
  78310. /** Gets or sets the height of each cell (20 by default) */
  78311. get cellHeight(): number;
  78312. set cellHeight(value: number);
  78313. /** Gets or sets the tickness of minor lines (1 by default) */
  78314. get minorLineTickness(): number;
  78315. set minorLineTickness(value: number);
  78316. /** Gets or sets the color of minor lines (DarkGray by default) */
  78317. get minorLineColor(): string;
  78318. set minorLineColor(value: string);
  78319. /** Gets or sets the tickness of major lines (2 by default) */
  78320. get majorLineTickness(): number;
  78321. set majorLineTickness(value: number);
  78322. /** Gets or sets the color of major lines (White by default) */
  78323. get majorLineColor(): string;
  78324. set majorLineColor(value: string);
  78325. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  78326. get majorLineFrequency(): number;
  78327. set majorLineFrequency(value: number);
  78328. /**
  78329. * Creates a new GridDisplayRectangle
  78330. * @param name defines the control name
  78331. */
  78332. constructor(name?: string | undefined);
  78333. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78334. protected _getTypeName(): string;
  78335. }
  78336. }
  78337. declare module BABYLON.GUI {
  78338. /**
  78339. * Class used to create slider controls based on images
  78340. */
  78341. export class ImageBasedSlider extends BaseSlider {
  78342. name?: string | undefined;
  78343. private _backgroundImage;
  78344. private _thumbImage;
  78345. private _valueBarImage;
  78346. private _tempMeasure;
  78347. get displayThumb(): boolean;
  78348. set displayThumb(value: boolean);
  78349. /**
  78350. * Gets or sets the image used to render the background
  78351. */
  78352. get backgroundImage(): Image;
  78353. set backgroundImage(value: Image);
  78354. /**
  78355. * Gets or sets the image used to render the value bar
  78356. */
  78357. get valueBarImage(): Image;
  78358. set valueBarImage(value: Image);
  78359. /**
  78360. * Gets or sets the image used to render the thumb
  78361. */
  78362. get thumbImage(): Image;
  78363. set thumbImage(value: Image);
  78364. /**
  78365. * Creates a new ImageBasedSlider
  78366. * @param name defines the control name
  78367. */
  78368. constructor(name?: string | undefined);
  78369. protected _getTypeName(): string;
  78370. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78371. }
  78372. }
  78373. declare module BABYLON.GUI {
  78374. /**
  78375. * Forcing an export so that this code will execute
  78376. * @hidden
  78377. */
  78378. const name = "Statics";
  78379. }
  78380. declare module BABYLON.GUI {
  78381. /**
  78382. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  78383. */
  78384. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  78385. /**
  78386. * Define the instrumented AdvancedDynamicTexture.
  78387. */
  78388. texture: AdvancedDynamicTexture;
  78389. private _captureRenderTime;
  78390. private _renderTime;
  78391. private _captureLayoutTime;
  78392. private _layoutTime;
  78393. private _onBeginRenderObserver;
  78394. private _onEndRenderObserver;
  78395. private _onBeginLayoutObserver;
  78396. private _onEndLayoutObserver;
  78397. /**
  78398. * Gets the perf counter used to capture render time
  78399. */
  78400. get renderTimeCounter(): BABYLON.PerfCounter;
  78401. /**
  78402. * Gets the perf counter used to capture layout time
  78403. */
  78404. get layoutTimeCounter(): BABYLON.PerfCounter;
  78405. /**
  78406. * Enable or disable the render time capture
  78407. */
  78408. get captureRenderTime(): boolean;
  78409. set captureRenderTime(value: boolean);
  78410. /**
  78411. * Enable or disable the layout time capture
  78412. */
  78413. get captureLayoutTime(): boolean;
  78414. set captureLayoutTime(value: boolean);
  78415. /**
  78416. * Instantiates a new advanced dynamic texture instrumentation.
  78417. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  78418. * @param texture Defines the AdvancedDynamicTexture to instrument
  78419. */
  78420. constructor(
  78421. /**
  78422. * Define the instrumented AdvancedDynamicTexture.
  78423. */
  78424. texture: AdvancedDynamicTexture);
  78425. /**
  78426. * Dispose and release associated resources.
  78427. */
  78428. dispose(): void;
  78429. }
  78430. }
  78431. declare module BABYLON.GUI {
  78432. /**
  78433. * Class used to load GUI via XML.
  78434. */
  78435. export class XmlLoader {
  78436. private _nodes;
  78437. private _nodeTypes;
  78438. private _isLoaded;
  78439. private _objectAttributes;
  78440. private _parentClass;
  78441. /**
  78442. * Create a new xml loader
  78443. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  78444. */
  78445. constructor(parentClass?: null);
  78446. private _getChainElement;
  78447. private _getClassAttribute;
  78448. private _createGuiElement;
  78449. private _parseGrid;
  78450. private _parseElement;
  78451. private _prepareSourceElement;
  78452. private _parseElementsFromSource;
  78453. private _parseXml;
  78454. /**
  78455. * Gets if the loading has finished.
  78456. * @returns whether the loading has finished or not
  78457. */
  78458. isLoaded(): boolean;
  78459. /**
  78460. * Gets a loaded node / control by id.
  78461. * @param id the Controls id set in the xml
  78462. * @returns element of type Control
  78463. */
  78464. getNodeById(id: string): any;
  78465. /**
  78466. * Gets all loaded nodes / controls
  78467. * @returns Array of controls
  78468. */
  78469. getNodes(): any;
  78470. /**
  78471. * Initiates the xml layout loading
  78472. * @param xmlFile defines the xml layout to load
  78473. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  78474. * @param callback defines the callback called on layout load.
  78475. */
  78476. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  78477. }
  78478. }
  78479. declare module BABYLON.GUI {
  78480. /**
  78481. * Class used to create containers for controls
  78482. */
  78483. export class Container3D extends Control3D {
  78484. private _blockLayout;
  78485. /**
  78486. * Gets the list of child controls
  78487. */
  78488. protected _children: Control3D[];
  78489. /**
  78490. * Gets the list of child controls
  78491. */
  78492. get children(): Array<Control3D>;
  78493. /**
  78494. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  78495. * This is helpful to optimize layout operation when adding multiple children in a row
  78496. */
  78497. get blockLayout(): boolean;
  78498. set blockLayout(value: boolean);
  78499. /**
  78500. * Creates a new container
  78501. * @param name defines the container name
  78502. */
  78503. constructor(name?: string);
  78504. /**
  78505. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  78506. * @returns the current container
  78507. */
  78508. updateLayout(): Container3D;
  78509. /**
  78510. * Gets a boolean indicating if the given control is in the children of this control
  78511. * @param control defines the control to check
  78512. * @returns true if the control is in the child list
  78513. */
  78514. containsControl(control: Control3D): boolean;
  78515. /**
  78516. * Adds a control to the children of this control
  78517. * @param control defines the control to add
  78518. * @returns the current container
  78519. */
  78520. addControl(control: Control3D): Container3D;
  78521. /**
  78522. * This function will be called everytime a new control is added
  78523. */
  78524. protected _arrangeChildren(): void;
  78525. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  78526. /**
  78527. * Removes a control from the children of this control
  78528. * @param control defines the control to remove
  78529. * @returns the current container
  78530. */
  78531. removeControl(control: Control3D): Container3D;
  78532. protected _getTypeName(): string;
  78533. /**
  78534. * Releases all associated resources
  78535. */
  78536. dispose(): void;
  78537. /** Control rotation will remain unchanged */
  78538. static readonly UNSET_ORIENTATION: number;
  78539. /** Control will rotate to make it look at sphere central axis */
  78540. static readonly FACEORIGIN_ORIENTATION: number;
  78541. /** Control will rotate to make it look back at sphere central axis */
  78542. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  78543. /** Control will rotate to look at z axis (0, 0, 1) */
  78544. static readonly FACEFORWARD_ORIENTATION: number;
  78545. /** Control will rotate to look at negative z axis (0, 0, -1) */
  78546. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  78547. }
  78548. }
  78549. declare module BABYLON.GUI {
  78550. /**
  78551. * Class used to manage 3D user interface
  78552. * @see https://doc.babylonjs.com/how_to/gui3d
  78553. */
  78554. export class GUI3DManager implements BABYLON.IDisposable {
  78555. private _scene;
  78556. private _sceneDisposeObserver;
  78557. private _utilityLayer;
  78558. private _rootContainer;
  78559. private _pointerObserver;
  78560. private _pointerOutObserver;
  78561. /** @hidden */
  78562. _lastPickedControl: Control3D;
  78563. /** @hidden */
  78564. _lastControlOver: {
  78565. [pointerId: number]: Control3D;
  78566. };
  78567. /** @hidden */
  78568. _lastControlDown: {
  78569. [pointerId: number]: Control3D;
  78570. };
  78571. /**
  78572. * BABYLON.Observable raised when the point picked by the pointer events changed
  78573. */
  78574. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  78575. /** @hidden */
  78576. _sharedMaterials: {
  78577. [key: string]: BABYLON.Material;
  78578. };
  78579. /** Gets the hosting scene */
  78580. get scene(): BABYLON.Scene;
  78581. /** Gets associated utility layer */
  78582. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  78583. /**
  78584. * Creates a new GUI3DManager
  78585. * @param scene
  78586. */
  78587. constructor(scene?: BABYLON.Scene);
  78588. private _handlePointerOut;
  78589. private _doPicking;
  78590. /**
  78591. * Gets the root container
  78592. */
  78593. get rootContainer(): Container3D;
  78594. /**
  78595. * Gets a boolean indicating if the given control is in the root child list
  78596. * @param control defines the control to check
  78597. * @returns true if the control is in the root child list
  78598. */
  78599. containsControl(control: Control3D): boolean;
  78600. /**
  78601. * Adds a control to the root child list
  78602. * @param control defines the control to add
  78603. * @returns the current manager
  78604. */
  78605. addControl(control: Control3D): GUI3DManager;
  78606. /**
  78607. * Removes a control from the root child list
  78608. * @param control defines the control to remove
  78609. * @returns the current container
  78610. */
  78611. removeControl(control: Control3D): GUI3DManager;
  78612. /**
  78613. * Releases all associated resources
  78614. */
  78615. dispose(): void;
  78616. }
  78617. }
  78618. declare module BABYLON.GUI {
  78619. /**
  78620. * Class used to transport BABYLON.Vector3 information for pointer events
  78621. */
  78622. export class Vector3WithInfo extends BABYLON.Vector3 {
  78623. /** defines the current mouse button index */
  78624. buttonIndex: number;
  78625. /**
  78626. * Creates a new Vector3WithInfo
  78627. * @param source defines the vector3 data to transport
  78628. * @param buttonIndex defines the current mouse button index
  78629. */
  78630. constructor(source: BABYLON.Vector3,
  78631. /** defines the current mouse button index */
  78632. buttonIndex?: number);
  78633. }
  78634. }
  78635. declare module BABYLON.GUI {
  78636. /**
  78637. * Class used as base class for controls
  78638. */
  78639. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  78640. /** Defines the control name */
  78641. name?: string | undefined;
  78642. /** @hidden */
  78643. _host: GUI3DManager;
  78644. private _node;
  78645. private _downCount;
  78646. private _enterCount;
  78647. private _downPointerIds;
  78648. private _isVisible;
  78649. /** Gets or sets the control position in world space */
  78650. get position(): BABYLON.Vector3;
  78651. set position(value: BABYLON.Vector3);
  78652. /** Gets or sets the control scaling in world space */
  78653. get scaling(): BABYLON.Vector3;
  78654. set scaling(value: BABYLON.Vector3);
  78655. /** Callback used to start pointer enter animation */
  78656. pointerEnterAnimation: () => void;
  78657. /** Callback used to start pointer out animation */
  78658. pointerOutAnimation: () => void;
  78659. /** Callback used to start pointer down animation */
  78660. pointerDownAnimation: () => void;
  78661. /** Callback used to start pointer up animation */
  78662. pointerUpAnimation: () => void;
  78663. /**
  78664. * An event triggered when the pointer move over the control
  78665. */
  78666. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  78667. /**
  78668. * An event triggered when the pointer move out of the control
  78669. */
  78670. onPointerOutObservable: BABYLON.Observable<Control3D>;
  78671. /**
  78672. * An event triggered when the pointer taps the control
  78673. */
  78674. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  78675. /**
  78676. * An event triggered when pointer is up
  78677. */
  78678. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  78679. /**
  78680. * An event triggered when a control is clicked on (with a mouse)
  78681. */
  78682. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  78683. /**
  78684. * An event triggered when pointer enters the control
  78685. */
  78686. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  78687. /**
  78688. * Gets or sets the parent container
  78689. */
  78690. parent: BABYLON.Nullable<Container3D>;
  78691. private _behaviors;
  78692. /**
  78693. * Gets the list of attached behaviors
  78694. * @see https://doc.babylonjs.com/features/behaviour
  78695. */
  78696. get behaviors(): BABYLON.Behavior<Control3D>[];
  78697. /**
  78698. * Attach a behavior to the control
  78699. * @see https://doc.babylonjs.com/features/behaviour
  78700. * @param behavior defines the behavior to attach
  78701. * @returns the current control
  78702. */
  78703. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  78704. /**
  78705. * Remove an attached behavior
  78706. * @see https://doc.babylonjs.com/features/behaviour
  78707. * @param behavior defines the behavior to attach
  78708. * @returns the current control
  78709. */
  78710. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  78711. /**
  78712. * Gets an attached behavior by name
  78713. * @param name defines the name of the behavior to look for
  78714. * @see https://doc.babylonjs.com/features/behaviour
  78715. * @returns null if behavior was not found else the requested behavior
  78716. */
  78717. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  78718. /** Gets or sets a boolean indicating if the control is visible */
  78719. get isVisible(): boolean;
  78720. set isVisible(value: boolean);
  78721. /**
  78722. * Creates a new control
  78723. * @param name defines the control name
  78724. */
  78725. constructor(
  78726. /** Defines the control name */
  78727. name?: string | undefined);
  78728. /**
  78729. * Gets a string representing the class name
  78730. */
  78731. get typeName(): string;
  78732. /**
  78733. * Get the current class name of the control.
  78734. * @returns current class name
  78735. */
  78736. getClassName(): string;
  78737. protected _getTypeName(): string;
  78738. /**
  78739. * Gets the transform node used by this control
  78740. */
  78741. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  78742. /**
  78743. * Gets the mesh used to render this control
  78744. */
  78745. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  78746. /**
  78747. * Link the control as child of the given node
  78748. * @param node defines the node to link to. Use null to unlink the control
  78749. * @returns the current control
  78750. */
  78751. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  78752. /** @hidden **/
  78753. _prepareNode(scene: BABYLON.Scene): void;
  78754. /**
  78755. * Node creation.
  78756. * Can be overriden by children
  78757. * @param scene defines the scene where the node must be attached
  78758. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  78759. */
  78760. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  78761. /**
  78762. * Affect a material to the given mesh
  78763. * @param mesh defines the mesh which will represent the control
  78764. */
  78765. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  78766. /** @hidden */
  78767. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  78768. /** @hidden */
  78769. _onPointerEnter(target: Control3D): boolean;
  78770. /** @hidden */
  78771. _onPointerOut(target: Control3D): void;
  78772. /** @hidden */
  78773. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  78774. /** @hidden */
  78775. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78776. /** @hidden */
  78777. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  78778. /** @hidden */
  78779. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  78780. /** @hidden */
  78781. _disposeNode(): void;
  78782. /**
  78783. * Releases all associated resources
  78784. */
  78785. dispose(): void;
  78786. }
  78787. }
  78788. declare module BABYLON.GUI {
  78789. /**
  78790. * Class used as a root to all buttons
  78791. */
  78792. export class AbstractButton3D extends Control3D {
  78793. /**
  78794. * Creates a new button
  78795. * @param name defines the control name
  78796. */
  78797. constructor(name?: string);
  78798. protected _getTypeName(): string;
  78799. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78800. }
  78801. }
  78802. declare module BABYLON.GUI {
  78803. /**
  78804. * Class used to create a button in 3D
  78805. */
  78806. export class Button3D extends AbstractButton3D {
  78807. /** @hidden */
  78808. protected _currentMaterial: BABYLON.Material;
  78809. private _facadeTexture;
  78810. private _content;
  78811. private _contentResolution;
  78812. private _contentScaleRatio;
  78813. /**
  78814. * Gets or sets the texture resolution used to render content (512 by default)
  78815. */
  78816. get contentResolution(): BABYLON.int;
  78817. set contentResolution(value: BABYLON.int);
  78818. /**
  78819. * Gets or sets the texture scale ratio used to render content (2 by default)
  78820. */
  78821. get contentScaleRatio(): number;
  78822. set contentScaleRatio(value: number);
  78823. protected _disposeFacadeTexture(): void;
  78824. protected _resetContent(): void;
  78825. /**
  78826. * Creates a new button
  78827. * @param name defines the control name
  78828. */
  78829. constructor(name?: string);
  78830. /**
  78831. * Gets or sets the GUI 2D content used to display the button's facade
  78832. */
  78833. get content(): Control;
  78834. set content(value: Control);
  78835. /**
  78836. * Apply the facade texture (created from the content property).
  78837. * This function can be overloaded by child classes
  78838. * @param facadeTexture defines the AdvancedDynamicTexture to use
  78839. */
  78840. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  78841. protected _getTypeName(): string;
  78842. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  78843. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  78844. /**
  78845. * Releases all associated resources
  78846. */
  78847. dispose(): void;
  78848. }
  78849. }
  78850. declare module BABYLON.GUI {
  78851. /**
  78852. * Abstract class used to create a container panel deployed on the surface of a volume
  78853. */
  78854. export abstract class VolumeBasedPanel extends Container3D {
  78855. private _columns;
  78856. private _rows;
  78857. private _rowThenColum;
  78858. private _orientation;
  78859. protected _cellWidth: number;
  78860. protected _cellHeight: number;
  78861. /**
  78862. * Gets or sets the distance between elements
  78863. */
  78864. margin: number;
  78865. /**
  78866. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  78867. * | Value | Type | Description |
  78868. * | ----- | ----------------------------------- | ----------- |
  78869. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  78870. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  78871. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  78872. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  78873. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  78874. */
  78875. get orientation(): number;
  78876. set orientation(value: number);
  78877. /**
  78878. * Gets or sets the number of columns requested (10 by default).
  78879. * The panel will automatically compute the number of rows based on number of child controls.
  78880. */
  78881. get columns(): BABYLON.int;
  78882. set columns(value: BABYLON.int);
  78883. /**
  78884. * Gets or sets a the number of rows requested.
  78885. * The panel will automatically compute the number of columns based on number of child controls.
  78886. */
  78887. get rows(): BABYLON.int;
  78888. set rows(value: BABYLON.int);
  78889. /**
  78890. * Creates new VolumeBasedPanel
  78891. */
  78892. constructor();
  78893. protected _arrangeChildren(): void;
  78894. /** Child classes must implement this function to provide correct control positioning */
  78895. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78896. /** Child classes can implement this function to provide additional processing */
  78897. protected _finalProcessing(): void;
  78898. }
  78899. }
  78900. declare module BABYLON.GUI {
  78901. /**
  78902. * Class used to create a container panel deployed on the surface of a cylinder
  78903. */
  78904. export class CylinderPanel extends VolumeBasedPanel {
  78905. private _radius;
  78906. /**
  78907. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  78908. */
  78909. get radius(): BABYLON.float;
  78910. set radius(value: BABYLON.float);
  78911. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  78912. private _cylindricalMapping;
  78913. }
  78914. }
  78915. declare module BABYLON.GUI {
  78916. /** @hidden */
  78917. export var fluentVertexShader: {
  78918. name: string;
  78919. shader: string;
  78920. };
  78921. }
  78922. declare module BABYLON.GUI {
  78923. /** @hidden */
  78924. export var fluentPixelShader: {
  78925. name: string;
  78926. shader: string;
  78927. };
  78928. }
  78929. declare module BABYLON.GUI {
  78930. /** @hidden */
  78931. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  78932. INNERGLOW: boolean;
  78933. BORDER: boolean;
  78934. HOVERLIGHT: boolean;
  78935. TEXTURE: boolean;
  78936. constructor();
  78937. }
  78938. /**
  78939. * Class used to render controls with fluent desgin
  78940. */
  78941. export class FluentMaterial extends BABYLON.PushMaterial {
  78942. /**
  78943. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  78944. */
  78945. innerGlowColorIntensity: number;
  78946. /**
  78947. * Gets or sets the inner glow color (white by default)
  78948. */
  78949. innerGlowColor: BABYLON.Color3;
  78950. /**
  78951. * Gets or sets alpha value (default is 1.0)
  78952. */
  78953. alpha: number;
  78954. /**
  78955. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  78956. */
  78957. albedoColor: BABYLON.Color3;
  78958. /**
  78959. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  78960. */
  78961. renderBorders: boolean;
  78962. /**
  78963. * Gets or sets border width (default is 0.5)
  78964. */
  78965. borderWidth: number;
  78966. /**
  78967. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  78968. */
  78969. edgeSmoothingValue: number;
  78970. /**
  78971. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  78972. */
  78973. borderMinValue: number;
  78974. /**
  78975. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  78976. */
  78977. renderHoverLight: boolean;
  78978. /**
  78979. * Gets or sets the radius used to render the hover light (default is 1.0)
  78980. */
  78981. hoverRadius: number;
  78982. /**
  78983. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  78984. */
  78985. hoverColor: BABYLON.Color4;
  78986. /**
  78987. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  78988. */
  78989. hoverPosition: BABYLON.Vector3;
  78990. private _albedoTexture;
  78991. /** Gets or sets the texture to use for albedo color */
  78992. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  78993. /**
  78994. * Creates a new Fluent material
  78995. * @param name defines the name of the material
  78996. * @param scene defines the hosting scene
  78997. */
  78998. constructor(name: string, scene: BABYLON.Scene);
  78999. needAlphaBlending(): boolean;
  79000. needAlphaTesting(): boolean;
  79001. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  79002. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  79003. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  79004. getActiveTextures(): BABYLON.BaseTexture[];
  79005. hasTexture(texture: BABYLON.BaseTexture): boolean;
  79006. dispose(forceDisposeEffect?: boolean): void;
  79007. clone(name: string): FluentMaterial;
  79008. serialize(): any;
  79009. getClassName(): string;
  79010. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  79011. }
  79012. }
  79013. declare module BABYLON.GUI {
  79014. /**
  79015. * Class used to create a holographic button in 3D
  79016. */
  79017. export class HolographicButton extends Button3D {
  79018. private _backPlate;
  79019. private _textPlate;
  79020. private _frontPlate;
  79021. private _text;
  79022. private _imageUrl;
  79023. private _shareMaterials;
  79024. private _frontMaterial;
  79025. private _backMaterial;
  79026. private _plateMaterial;
  79027. private _pickedPointObserver;
  79028. private _tooltipFade;
  79029. private _tooltipTextBlock;
  79030. private _tooltipTexture;
  79031. private _tooltipMesh;
  79032. private _tooltipHoverObserver;
  79033. private _tooltipOutObserver;
  79034. private _disposeTooltip;
  79035. /**
  79036. * Rendering ground id of all the mesh in the button
  79037. */
  79038. set renderingGroupId(id: number);
  79039. get renderingGroupId(): number;
  79040. /**
  79041. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  79042. */
  79043. set tooltipText(text: BABYLON.Nullable<string>);
  79044. get tooltipText(): BABYLON.Nullable<string>;
  79045. /**
  79046. * Gets or sets text for the button
  79047. */
  79048. get text(): string;
  79049. set text(value: string);
  79050. /**
  79051. * Gets or sets the image url for the button
  79052. */
  79053. get imageUrl(): string;
  79054. set imageUrl(value: string);
  79055. /**
  79056. * Gets the back material used by this button
  79057. */
  79058. get backMaterial(): FluentMaterial;
  79059. /**
  79060. * Gets the front material used by this button
  79061. */
  79062. get frontMaterial(): FluentMaterial;
  79063. /**
  79064. * Gets the plate material used by this button
  79065. */
  79066. get plateMaterial(): BABYLON.StandardMaterial;
  79067. /**
  79068. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  79069. */
  79070. get shareMaterials(): boolean;
  79071. /**
  79072. * Creates a new button
  79073. * @param name defines the control name
  79074. */
  79075. constructor(name?: string, shareMaterials?: boolean);
  79076. protected _getTypeName(): string;
  79077. private _rebuildContent;
  79078. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  79079. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  79080. private _createBackMaterial;
  79081. private _createFrontMaterial;
  79082. private _createPlateMaterial;
  79083. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  79084. /**
  79085. * Releases all associated resources
  79086. */
  79087. dispose(): void;
  79088. }
  79089. }
  79090. declare module BABYLON.GUI {
  79091. /**
  79092. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  79093. */
  79094. export class MeshButton3D extends Button3D {
  79095. /** @hidden */
  79096. protected _currentMesh: BABYLON.Mesh;
  79097. /**
  79098. * Creates a new 3D button based on a mesh
  79099. * @param mesh mesh to become a 3D button
  79100. * @param name defines the control name
  79101. */
  79102. constructor(mesh: BABYLON.Mesh, name?: string);
  79103. protected _getTypeName(): string;
  79104. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  79105. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  79106. }
  79107. }
  79108. declare module BABYLON.GUI {
  79109. /**
  79110. * Class used to create a container panel deployed on the surface of a plane
  79111. */
  79112. export class PlanePanel extends VolumeBasedPanel {
  79113. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  79114. }
  79115. }
  79116. declare module BABYLON.GUI {
  79117. /**
  79118. * Class used to create a container panel where items get randomized planar mapping
  79119. */
  79120. export class ScatterPanel extends VolumeBasedPanel {
  79121. private _iteration;
  79122. /**
  79123. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  79124. */
  79125. get iteration(): BABYLON.float;
  79126. set iteration(value: BABYLON.float);
  79127. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  79128. private _scatterMapping;
  79129. protected _finalProcessing(): void;
  79130. }
  79131. }
  79132. declare module BABYLON.GUI {
  79133. /**
  79134. * Class used to create a container panel deployed on the surface of a sphere
  79135. */
  79136. export class SpherePanel extends VolumeBasedPanel {
  79137. private _radius;
  79138. /**
  79139. * Gets or sets the radius of the sphere where to project controls (5 by default)
  79140. */
  79141. get radius(): BABYLON.float;
  79142. set radius(value: BABYLON.float);
  79143. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  79144. private _sphericalMapping;
  79145. }
  79146. }
  79147. declare module BABYLON.GUI {
  79148. /**
  79149. * Class used to create a stack panel in 3D on XY plane
  79150. */
  79151. export class StackPanel3D extends Container3D {
  79152. private _isVertical;
  79153. /**
  79154. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  79155. */
  79156. get isVertical(): boolean;
  79157. set isVertical(value: boolean);
  79158. /**
  79159. * Gets or sets the distance between elements
  79160. */
  79161. margin: number;
  79162. /**
  79163. * Creates new StackPanel
  79164. * @param isVertical
  79165. */
  79166. constructor(isVertical?: boolean);
  79167. protected _arrangeChildren(): void;
  79168. }
  79169. }
  79170. declare module BABYLON {
  79171. /**
  79172. * Configuration for glTF validation
  79173. */
  79174. export interface IGLTFValidationConfiguration {
  79175. /**
  79176. * The url of the glTF validator.
  79177. */
  79178. url: string;
  79179. }
  79180. /**
  79181. * glTF validation
  79182. */
  79183. export class GLTFValidation {
  79184. /**
  79185. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  79186. */
  79187. static Configuration: IGLTFValidationConfiguration;
  79188. private static _LoadScriptPromise;
  79189. /**
  79190. * Validate a glTF asset using the glTF-Validator.
  79191. * @param data The JSON of a glTF or the array buffer of a binary glTF
  79192. * @param rootUrl The root url for the glTF
  79193. * @param fileName The file name for the glTF
  79194. * @param getExternalResource The callback to get external resources for the glTF validator
  79195. * @returns A promise that resolves with the glTF validation results once complete
  79196. */
  79197. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  79198. }
  79199. }
  79200. declare module BABYLON {
  79201. /**
  79202. * Mode that determines the coordinate system to use.
  79203. */
  79204. export enum GLTFLoaderCoordinateSystemMode {
  79205. /**
  79206. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  79207. */
  79208. AUTO = 0,
  79209. /**
  79210. * Sets the useRightHandedSystem flag on the scene.
  79211. */
  79212. FORCE_RIGHT_HANDED = 1
  79213. }
  79214. /**
  79215. * Mode that determines what animations will start.
  79216. */
  79217. export enum GLTFLoaderAnimationStartMode {
  79218. /**
  79219. * No animation will start.
  79220. */
  79221. NONE = 0,
  79222. /**
  79223. * The first animation will start.
  79224. */
  79225. FIRST = 1,
  79226. /**
  79227. * All animations will start.
  79228. */
  79229. ALL = 2
  79230. }
  79231. /**
  79232. * Interface that contains the data for the glTF asset.
  79233. */
  79234. export interface IGLTFLoaderData {
  79235. /**
  79236. * The object that represents the glTF JSON.
  79237. */
  79238. json: Object;
  79239. /**
  79240. * The BIN chunk of a binary glTF.
  79241. */
  79242. bin: Nullable<IDataBuffer>;
  79243. }
  79244. /**
  79245. * Interface for extending the loader.
  79246. */
  79247. export interface IGLTFLoaderExtension {
  79248. /**
  79249. * The name of this extension.
  79250. */
  79251. readonly name: string;
  79252. /**
  79253. * Defines whether this extension is enabled.
  79254. */
  79255. enabled: boolean;
  79256. /**
  79257. * Defines the order of this extension.
  79258. * The loader sorts the extensions using these values when loading.
  79259. */
  79260. order?: number;
  79261. }
  79262. /**
  79263. * Loader state.
  79264. */
  79265. export enum GLTFLoaderState {
  79266. /**
  79267. * The asset is loading.
  79268. */
  79269. LOADING = 0,
  79270. /**
  79271. * The asset is ready for rendering.
  79272. */
  79273. READY = 1,
  79274. /**
  79275. * The asset is completely loaded.
  79276. */
  79277. COMPLETE = 2
  79278. }
  79279. /** @hidden */
  79280. export interface IImportMeshAsyncOutput {
  79281. meshes: AbstractMesh[];
  79282. particleSystems: IParticleSystem[];
  79283. skeletons: Skeleton[];
  79284. animationGroups: AnimationGroup[];
  79285. lights: Light[];
  79286. transformNodes: TransformNode[];
  79287. }
  79288. /** @hidden */
  79289. export interface IGLTFLoader extends IDisposable {
  79290. readonly state: Nullable<GLTFLoaderState>;
  79291. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  79292. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  79293. }
  79294. /**
  79295. * File loader for loading glTF files into a scene.
  79296. */
  79297. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  79298. /** @hidden */
  79299. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  79300. /** @hidden */
  79301. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  79302. /**
  79303. * Raised when the asset has been parsed
  79304. */
  79305. onParsedObservable: Observable<IGLTFLoaderData>;
  79306. private _onParsedObserver;
  79307. /**
  79308. * Raised when the asset has been parsed
  79309. */
  79310. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  79311. /**
  79312. * 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.
  79313. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  79314. * Defaults to true.
  79315. * @hidden
  79316. */
  79317. static IncrementalLoading: boolean;
  79318. /**
  79319. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  79320. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  79321. * @hidden
  79322. */
  79323. static HomogeneousCoordinates: boolean;
  79324. /**
  79325. * The coordinate system mode. Defaults to AUTO.
  79326. */
  79327. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  79328. /**
  79329. * The animation start mode. Defaults to FIRST.
  79330. */
  79331. animationStartMode: GLTFLoaderAnimationStartMode;
  79332. /**
  79333. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  79334. */
  79335. compileMaterials: boolean;
  79336. /**
  79337. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  79338. */
  79339. useClipPlane: boolean;
  79340. /**
  79341. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  79342. */
  79343. compileShadowGenerators: boolean;
  79344. /**
  79345. * Defines if the Alpha blended materials are only applied as coverage.
  79346. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  79347. * If true, no extra effects are applied to transparent pixels.
  79348. */
  79349. transparencyAsCoverage: boolean;
  79350. /**
  79351. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  79352. * Enabling will disable offline support and glTF validator.
  79353. * Defaults to false.
  79354. */
  79355. useRangeRequests: boolean;
  79356. /**
  79357. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  79358. */
  79359. createInstances: boolean;
  79360. /**
  79361. * 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.
  79362. */
  79363. alwaysComputeBoundingBox: boolean;
  79364. /**
  79365. * Function called before loading a url referenced by the asset.
  79366. */
  79367. preprocessUrlAsync: (url: string) => Promise<string>;
  79368. /**
  79369. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  79370. */
  79371. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  79372. private _onMeshLoadedObserver;
  79373. /**
  79374. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  79375. */
  79376. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  79377. /**
  79378. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  79379. */
  79380. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  79381. private _onTextureLoadedObserver;
  79382. /**
  79383. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  79384. */
  79385. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  79386. /**
  79387. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  79388. */
  79389. readonly onMaterialLoadedObservable: Observable<Material>;
  79390. private _onMaterialLoadedObserver;
  79391. /**
  79392. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  79393. */
  79394. set onMaterialLoaded(callback: (material: Material) => void);
  79395. /**
  79396. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  79397. */
  79398. readonly onCameraLoadedObservable: Observable<Camera>;
  79399. private _onCameraLoadedObserver;
  79400. /**
  79401. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  79402. */
  79403. set onCameraLoaded(callback: (camera: Camera) => void);
  79404. /**
  79405. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  79406. * For assets with LODs, raised when all of the LODs are complete.
  79407. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  79408. */
  79409. readonly onCompleteObservable: Observable<void>;
  79410. private _onCompleteObserver;
  79411. /**
  79412. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  79413. * For assets with LODs, raised when all of the LODs are complete.
  79414. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  79415. */
  79416. set onComplete(callback: () => void);
  79417. /**
  79418. * Observable raised when an error occurs.
  79419. */
  79420. readonly onErrorObservable: Observable<any>;
  79421. private _onErrorObserver;
  79422. /**
  79423. * Callback raised when an error occurs.
  79424. */
  79425. set onError(callback: (reason: any) => void);
  79426. /**
  79427. * Observable raised after the loader is disposed.
  79428. */
  79429. readonly onDisposeObservable: Observable<void>;
  79430. private _onDisposeObserver;
  79431. /**
  79432. * Callback raised after the loader is disposed.
  79433. */
  79434. set onDispose(callback: () => void);
  79435. /**
  79436. * Observable raised after a loader extension is created.
  79437. * Set additional options for a loader extension in this event.
  79438. */
  79439. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  79440. private _onExtensionLoadedObserver;
  79441. /**
  79442. * Callback raised after a loader extension is created.
  79443. */
  79444. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  79445. /**
  79446. * Defines if the loader logging is enabled.
  79447. */
  79448. get loggingEnabled(): boolean;
  79449. set loggingEnabled(value: boolean);
  79450. /**
  79451. * Defines if the loader should capture performance counters.
  79452. */
  79453. get capturePerformanceCounters(): boolean;
  79454. set capturePerformanceCounters(value: boolean);
  79455. /**
  79456. * Defines if the loader should validate the asset.
  79457. */
  79458. validate: boolean;
  79459. /**
  79460. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  79461. */
  79462. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  79463. private _onValidatedObserver;
  79464. /**
  79465. * Callback raised after a loader extension is created.
  79466. */
  79467. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  79468. private _loader;
  79469. private _progressCallback?;
  79470. private _requests;
  79471. private static magicBase64Encoded;
  79472. /**
  79473. * Name of the loader ("gltf")
  79474. */
  79475. name: string;
  79476. /** @hidden */
  79477. extensions: ISceneLoaderPluginExtensions;
  79478. /**
  79479. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  79480. */
  79481. dispose(): void;
  79482. /** @hidden */
  79483. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  79484. /** @hidden */
  79485. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  79486. /** @hidden */
  79487. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  79488. meshes: AbstractMesh[];
  79489. particleSystems: IParticleSystem[];
  79490. skeletons: Skeleton[];
  79491. animationGroups: AnimationGroup[];
  79492. }>;
  79493. /** @hidden */
  79494. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  79495. /** @hidden */
  79496. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  79497. /** @hidden */
  79498. canDirectLoad(data: string): boolean;
  79499. /** @hidden */
  79500. directLoad(scene: Scene, data: string): Promise<any>;
  79501. /**
  79502. * The callback that allows custom handling of the root url based on the response url.
  79503. * @param rootUrl the original root url
  79504. * @param responseURL the response url if available
  79505. * @returns the new root url
  79506. */
  79507. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  79508. /** @hidden */
  79509. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  79510. /**
  79511. * The loader state or null if the loader is not active.
  79512. */
  79513. get loaderState(): Nullable<GLTFLoaderState>;
  79514. /**
  79515. * Returns a promise that resolves when the asset is completely loaded.
  79516. * @returns a promise that resolves when the asset is completely loaded.
  79517. */
  79518. whenCompleteAsync(): Promise<void>;
  79519. /** @hidden */
  79520. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  79521. /** @hidden */
  79522. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  79523. private _onProgress;
  79524. private _validate;
  79525. private _getLoader;
  79526. private _parseJson;
  79527. private _unpackBinaryAsync;
  79528. private _unpackBinaryV1Async;
  79529. private _unpackBinaryV2Async;
  79530. private static _parseVersion;
  79531. private static _compareVersion;
  79532. private static readonly _logSpaces;
  79533. private _logIndentLevel;
  79534. private _loggingEnabled;
  79535. /** @hidden */
  79536. _log: (message: string) => void;
  79537. /** @hidden */
  79538. _logOpen(message: string): void;
  79539. /** @hidden */
  79540. _logClose(): void;
  79541. private _logEnabled;
  79542. private _logDisabled;
  79543. private _capturePerformanceCounters;
  79544. /** @hidden */
  79545. _startPerformanceCounter: (counterName: string) => void;
  79546. /** @hidden */
  79547. _endPerformanceCounter: (counterName: string) => void;
  79548. private _startPerformanceCounterEnabled;
  79549. private _startPerformanceCounterDisabled;
  79550. private _endPerformanceCounterEnabled;
  79551. private _endPerformanceCounterDisabled;
  79552. }
  79553. }
  79554. declare module BABYLON.GLTF1 {
  79555. /**
  79556. * Enums
  79557. * @hidden
  79558. */
  79559. export enum EComponentType {
  79560. BYTE = 5120,
  79561. UNSIGNED_BYTE = 5121,
  79562. SHORT = 5122,
  79563. UNSIGNED_SHORT = 5123,
  79564. FLOAT = 5126
  79565. }
  79566. /** @hidden */
  79567. export enum EShaderType {
  79568. FRAGMENT = 35632,
  79569. VERTEX = 35633
  79570. }
  79571. /** @hidden */
  79572. export enum EParameterType {
  79573. BYTE = 5120,
  79574. UNSIGNED_BYTE = 5121,
  79575. SHORT = 5122,
  79576. UNSIGNED_SHORT = 5123,
  79577. INT = 5124,
  79578. UNSIGNED_INT = 5125,
  79579. FLOAT = 5126,
  79580. FLOAT_VEC2 = 35664,
  79581. FLOAT_VEC3 = 35665,
  79582. FLOAT_VEC4 = 35666,
  79583. INT_VEC2 = 35667,
  79584. INT_VEC3 = 35668,
  79585. INT_VEC4 = 35669,
  79586. BOOL = 35670,
  79587. BOOL_VEC2 = 35671,
  79588. BOOL_VEC3 = 35672,
  79589. BOOL_VEC4 = 35673,
  79590. FLOAT_MAT2 = 35674,
  79591. FLOAT_MAT3 = 35675,
  79592. FLOAT_MAT4 = 35676,
  79593. SAMPLER_2D = 35678
  79594. }
  79595. /** @hidden */
  79596. export enum ETextureWrapMode {
  79597. CLAMP_TO_EDGE = 33071,
  79598. MIRRORED_REPEAT = 33648,
  79599. REPEAT = 10497
  79600. }
  79601. /** @hidden */
  79602. export enum ETextureFilterType {
  79603. NEAREST = 9728,
  79604. LINEAR = 9728,
  79605. NEAREST_MIPMAP_NEAREST = 9984,
  79606. LINEAR_MIPMAP_NEAREST = 9985,
  79607. NEAREST_MIPMAP_LINEAR = 9986,
  79608. LINEAR_MIPMAP_LINEAR = 9987
  79609. }
  79610. /** @hidden */
  79611. export enum ETextureFormat {
  79612. ALPHA = 6406,
  79613. RGB = 6407,
  79614. RGBA = 6408,
  79615. LUMINANCE = 6409,
  79616. LUMINANCE_ALPHA = 6410
  79617. }
  79618. /** @hidden */
  79619. export enum ECullingType {
  79620. FRONT = 1028,
  79621. BACK = 1029,
  79622. FRONT_AND_BACK = 1032
  79623. }
  79624. /** @hidden */
  79625. export enum EBlendingFunction {
  79626. ZERO = 0,
  79627. ONE = 1,
  79628. SRC_COLOR = 768,
  79629. ONE_MINUS_SRC_COLOR = 769,
  79630. DST_COLOR = 774,
  79631. ONE_MINUS_DST_COLOR = 775,
  79632. SRC_ALPHA = 770,
  79633. ONE_MINUS_SRC_ALPHA = 771,
  79634. DST_ALPHA = 772,
  79635. ONE_MINUS_DST_ALPHA = 773,
  79636. CONSTANT_COLOR = 32769,
  79637. ONE_MINUS_CONSTANT_COLOR = 32770,
  79638. CONSTANT_ALPHA = 32771,
  79639. ONE_MINUS_CONSTANT_ALPHA = 32772,
  79640. SRC_ALPHA_SATURATE = 776
  79641. }
  79642. /** @hidden */
  79643. export interface IGLTFProperty {
  79644. extensions?: {
  79645. [key: string]: any;
  79646. };
  79647. extras?: Object;
  79648. }
  79649. /** @hidden */
  79650. export interface IGLTFChildRootProperty extends IGLTFProperty {
  79651. name?: string;
  79652. }
  79653. /** @hidden */
  79654. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  79655. bufferView: string;
  79656. byteOffset: number;
  79657. byteStride: number;
  79658. count: number;
  79659. type: string;
  79660. componentType: EComponentType;
  79661. max?: number[];
  79662. min?: number[];
  79663. name?: string;
  79664. }
  79665. /** @hidden */
  79666. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  79667. buffer: string;
  79668. byteOffset: number;
  79669. byteLength: number;
  79670. byteStride: number;
  79671. target?: number;
  79672. }
  79673. /** @hidden */
  79674. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  79675. uri: string;
  79676. byteLength?: number;
  79677. type?: string;
  79678. }
  79679. /** @hidden */
  79680. export interface IGLTFShader extends IGLTFChildRootProperty {
  79681. uri: string;
  79682. type: EShaderType;
  79683. }
  79684. /** @hidden */
  79685. export interface IGLTFProgram extends IGLTFChildRootProperty {
  79686. attributes: string[];
  79687. fragmentShader: string;
  79688. vertexShader: string;
  79689. }
  79690. /** @hidden */
  79691. export interface IGLTFTechniqueParameter {
  79692. type: number;
  79693. count?: number;
  79694. semantic?: string;
  79695. node?: string;
  79696. value?: number | boolean | string | Array<any>;
  79697. source?: string;
  79698. babylonValue?: any;
  79699. }
  79700. /** @hidden */
  79701. export interface IGLTFTechniqueCommonProfile {
  79702. lightingModel: string;
  79703. texcoordBindings: Object;
  79704. parameters?: Array<any>;
  79705. }
  79706. /** @hidden */
  79707. export interface IGLTFTechniqueStatesFunctions {
  79708. blendColor?: number[];
  79709. blendEquationSeparate?: number[];
  79710. blendFuncSeparate?: number[];
  79711. colorMask: boolean[];
  79712. cullFace: number[];
  79713. }
  79714. /** @hidden */
  79715. export interface IGLTFTechniqueStates {
  79716. enable: number[];
  79717. functions: IGLTFTechniqueStatesFunctions;
  79718. }
  79719. /** @hidden */
  79720. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  79721. parameters: {
  79722. [key: string]: IGLTFTechniqueParameter;
  79723. };
  79724. program: string;
  79725. attributes: {
  79726. [key: string]: string;
  79727. };
  79728. uniforms: {
  79729. [key: string]: string;
  79730. };
  79731. states: IGLTFTechniqueStates;
  79732. }
  79733. /** @hidden */
  79734. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  79735. technique?: string;
  79736. values: string[];
  79737. }
  79738. /** @hidden */
  79739. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  79740. attributes: {
  79741. [key: string]: string;
  79742. };
  79743. indices: string;
  79744. material: string;
  79745. mode?: number;
  79746. }
  79747. /** @hidden */
  79748. export interface IGLTFMesh extends IGLTFChildRootProperty {
  79749. primitives: IGLTFMeshPrimitive[];
  79750. }
  79751. /** @hidden */
  79752. export interface IGLTFImage extends IGLTFChildRootProperty {
  79753. uri: string;
  79754. }
  79755. /** @hidden */
  79756. export interface IGLTFSampler extends IGLTFChildRootProperty {
  79757. magFilter?: number;
  79758. minFilter?: number;
  79759. wrapS?: number;
  79760. wrapT?: number;
  79761. }
  79762. /** @hidden */
  79763. export interface IGLTFTexture extends IGLTFChildRootProperty {
  79764. sampler: string;
  79765. source: string;
  79766. format?: ETextureFormat;
  79767. internalFormat?: ETextureFormat;
  79768. target?: number;
  79769. type?: number;
  79770. babylonTexture?: Texture;
  79771. }
  79772. /** @hidden */
  79773. export interface IGLTFAmbienLight {
  79774. color?: number[];
  79775. }
  79776. /** @hidden */
  79777. export interface IGLTFDirectionalLight {
  79778. color?: number[];
  79779. }
  79780. /** @hidden */
  79781. export interface IGLTFPointLight {
  79782. color?: number[];
  79783. constantAttenuation?: number;
  79784. linearAttenuation?: number;
  79785. quadraticAttenuation?: number;
  79786. }
  79787. /** @hidden */
  79788. export interface IGLTFSpotLight {
  79789. color?: number[];
  79790. constantAttenuation?: number;
  79791. fallOfAngle?: number;
  79792. fallOffExponent?: number;
  79793. linearAttenuation?: number;
  79794. quadraticAttenuation?: number;
  79795. }
  79796. /** @hidden */
  79797. export interface IGLTFLight extends IGLTFChildRootProperty {
  79798. type: string;
  79799. }
  79800. /** @hidden */
  79801. export interface IGLTFCameraOrthographic {
  79802. xmag: number;
  79803. ymag: number;
  79804. zfar: number;
  79805. znear: number;
  79806. }
  79807. /** @hidden */
  79808. export interface IGLTFCameraPerspective {
  79809. aspectRatio: number;
  79810. yfov: number;
  79811. zfar: number;
  79812. znear: number;
  79813. }
  79814. /** @hidden */
  79815. export interface IGLTFCamera extends IGLTFChildRootProperty {
  79816. type: string;
  79817. }
  79818. /** @hidden */
  79819. export interface IGLTFAnimationChannelTarget {
  79820. id: string;
  79821. path: string;
  79822. }
  79823. /** @hidden */
  79824. export interface IGLTFAnimationChannel {
  79825. sampler: string;
  79826. target: IGLTFAnimationChannelTarget;
  79827. }
  79828. /** @hidden */
  79829. export interface IGLTFAnimationSampler {
  79830. input: string;
  79831. output: string;
  79832. interpolation?: string;
  79833. }
  79834. /** @hidden */
  79835. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  79836. channels?: IGLTFAnimationChannel[];
  79837. parameters?: {
  79838. [key: string]: string;
  79839. };
  79840. samplers?: {
  79841. [key: string]: IGLTFAnimationSampler;
  79842. };
  79843. }
  79844. /** @hidden */
  79845. export interface IGLTFNodeInstanceSkin {
  79846. skeletons: string[];
  79847. skin: string;
  79848. meshes: string[];
  79849. }
  79850. /** @hidden */
  79851. export interface IGLTFSkins extends IGLTFChildRootProperty {
  79852. bindShapeMatrix: number[];
  79853. inverseBindMatrices: string;
  79854. jointNames: string[];
  79855. babylonSkeleton?: Skeleton;
  79856. }
  79857. /** @hidden */
  79858. export interface IGLTFNode extends IGLTFChildRootProperty {
  79859. camera?: string;
  79860. children: string[];
  79861. skin?: string;
  79862. jointName?: string;
  79863. light?: string;
  79864. matrix: number[];
  79865. mesh?: string;
  79866. meshes?: string[];
  79867. rotation?: number[];
  79868. scale?: number[];
  79869. translation?: number[];
  79870. babylonNode?: Node;
  79871. }
  79872. /** @hidden */
  79873. export interface IGLTFScene extends IGLTFChildRootProperty {
  79874. nodes: string[];
  79875. }
  79876. /** @hidden */
  79877. export interface IGLTFRuntime {
  79878. extensions: {
  79879. [key: string]: any;
  79880. };
  79881. accessors: {
  79882. [key: string]: IGLTFAccessor;
  79883. };
  79884. buffers: {
  79885. [key: string]: IGLTFBuffer;
  79886. };
  79887. bufferViews: {
  79888. [key: string]: IGLTFBufferView;
  79889. };
  79890. meshes: {
  79891. [key: string]: IGLTFMesh;
  79892. };
  79893. lights: {
  79894. [key: string]: IGLTFLight;
  79895. };
  79896. cameras: {
  79897. [key: string]: IGLTFCamera;
  79898. };
  79899. nodes: {
  79900. [key: string]: IGLTFNode;
  79901. };
  79902. images: {
  79903. [key: string]: IGLTFImage;
  79904. };
  79905. textures: {
  79906. [key: string]: IGLTFTexture;
  79907. };
  79908. shaders: {
  79909. [key: string]: IGLTFShader;
  79910. };
  79911. programs: {
  79912. [key: string]: IGLTFProgram;
  79913. };
  79914. samplers: {
  79915. [key: string]: IGLTFSampler;
  79916. };
  79917. techniques: {
  79918. [key: string]: IGLTFTechnique;
  79919. };
  79920. materials: {
  79921. [key: string]: IGLTFMaterial;
  79922. };
  79923. animations: {
  79924. [key: string]: IGLTFAnimation;
  79925. };
  79926. skins: {
  79927. [key: string]: IGLTFSkins;
  79928. };
  79929. currentScene?: Object;
  79930. scenes: {
  79931. [key: string]: IGLTFScene;
  79932. };
  79933. extensionsUsed: string[];
  79934. extensionsRequired?: string[];
  79935. buffersCount: number;
  79936. shaderscount: number;
  79937. scene: Scene;
  79938. rootUrl: string;
  79939. loadedBufferCount: number;
  79940. loadedBufferViews: {
  79941. [name: string]: ArrayBufferView;
  79942. };
  79943. loadedShaderCount: number;
  79944. importOnlyMeshes: boolean;
  79945. importMeshesNames?: string[];
  79946. dummyNodes: Node[];
  79947. forAssetContainer: boolean;
  79948. }
  79949. /** @hidden */
  79950. export interface INodeToRoot {
  79951. bone: Bone;
  79952. node: IGLTFNode;
  79953. id: string;
  79954. }
  79955. /** @hidden */
  79956. export interface IJointNode {
  79957. node: IGLTFNode;
  79958. id: string;
  79959. }
  79960. }
  79961. declare module BABYLON.GLTF1 {
  79962. /**
  79963. * Utils functions for GLTF
  79964. * @hidden
  79965. */
  79966. export class GLTFUtils {
  79967. /**
  79968. * Sets the given "parameter" matrix
  79969. * @param scene: the Scene object
  79970. * @param source: the source node where to pick the matrix
  79971. * @param parameter: the GLTF technique parameter
  79972. * @param uniformName: the name of the shader's uniform
  79973. * @param shaderMaterial: the shader material
  79974. */
  79975. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  79976. /**
  79977. * Sets the given "parameter" matrix
  79978. * @param shaderMaterial: the shader material
  79979. * @param uniform: the name of the shader's uniform
  79980. * @param value: the value of the uniform
  79981. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  79982. */
  79983. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  79984. /**
  79985. * Returns the wrap mode of the texture
  79986. * @param mode: the mode value
  79987. */
  79988. static GetWrapMode(mode: number): number;
  79989. /**
  79990. * Returns the byte stride giving an accessor
  79991. * @param accessor: the GLTF accessor objet
  79992. */
  79993. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  79994. /**
  79995. * Returns the texture filter mode giving a mode value
  79996. * @param mode: the filter mode value
  79997. */
  79998. static GetTextureFilterMode(mode: number): ETextureFilterType;
  79999. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  80000. /**
  80001. * Returns a buffer from its accessor
  80002. * @param gltfRuntime: the GLTF runtime
  80003. * @param accessor: the GLTF accessor
  80004. */
  80005. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  80006. /**
  80007. * Decodes a buffer view into a string
  80008. * @param view: the buffer view
  80009. */
  80010. static DecodeBufferToText(view: ArrayBufferView): string;
  80011. /**
  80012. * Returns the default material of gltf. Related to
  80013. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  80014. * @param scene: the Babylon.js scene
  80015. */
  80016. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  80017. private static _DefaultMaterial;
  80018. }
  80019. }
  80020. declare module BABYLON.GLTF1 {
  80021. /**
  80022. * Implementation of the base glTF spec
  80023. * @hidden
  80024. */
  80025. export class GLTFLoaderBase {
  80026. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  80027. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  80028. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  80029. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  80030. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  80031. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  80032. }
  80033. /**
  80034. * glTF V1 Loader
  80035. * @hidden
  80036. */
  80037. export class GLTFLoader implements IGLTFLoader {
  80038. static Extensions: {
  80039. [name: string]: GLTFLoaderExtension;
  80040. };
  80041. static RegisterExtension(extension: GLTFLoaderExtension): void;
  80042. state: Nullable<GLTFLoaderState>;
  80043. dispose(): void;
  80044. private _importMeshAsync;
  80045. /**
  80046. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  80047. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  80048. * @param scene the scene the meshes should be added to
  80049. * @param forAssetContainer defines if the entities must be stored in the scene
  80050. * @param data gltf data containing information of the meshes in a loaded file
  80051. * @param rootUrl root url to load from
  80052. * @param onProgress event that fires when loading progress has occured
  80053. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  80054. */
  80055. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  80056. private _loadAsync;
  80057. /**
  80058. * Imports all objects from a loaded gltf file and adds them to the scene
  80059. * @param scene the scene the objects should be added to
  80060. * @param data gltf data containing information of the meshes in a loaded file
  80061. * @param rootUrl root url to load from
  80062. * @param onProgress event that fires when loading progress has occured
  80063. * @returns a promise which completes when objects have been loaded to the scene
  80064. */
  80065. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  80066. private _loadShadersAsync;
  80067. private _loadBuffersAsync;
  80068. private _createNodes;
  80069. }
  80070. /** @hidden */
  80071. export abstract class GLTFLoaderExtension {
  80072. private _name;
  80073. constructor(name: string);
  80074. get name(): string;
  80075. /**
  80076. * Defines an override for loading the runtime
  80077. * Return true to stop further extensions from loading the runtime
  80078. */
  80079. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  80080. /**
  80081. * Defines an onverride for creating gltf runtime
  80082. * Return true to stop further extensions from creating the runtime
  80083. */
  80084. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  80085. /**
  80086. * Defines an override for loading buffers
  80087. * Return true to stop further extensions from loading this buffer
  80088. */
  80089. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  80090. /**
  80091. * Defines an override for loading texture buffers
  80092. * Return true to stop further extensions from loading this texture data
  80093. */
  80094. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  80095. /**
  80096. * Defines an override for creating textures
  80097. * Return true to stop further extensions from loading this texture
  80098. */
  80099. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  80100. /**
  80101. * Defines an override for loading shader strings
  80102. * Return true to stop further extensions from loading this shader data
  80103. */
  80104. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  80105. /**
  80106. * Defines an override for loading materials
  80107. * Return true to stop further extensions from loading this material
  80108. */
  80109. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  80110. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  80111. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  80112. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  80113. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  80114. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  80115. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  80116. private static LoadTextureBufferAsync;
  80117. private static CreateTextureAsync;
  80118. private static ApplyExtensions;
  80119. }
  80120. }
  80121. declare module BABYLON.GLTF1 {
  80122. /** @hidden */
  80123. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  80124. private _bin;
  80125. constructor();
  80126. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  80127. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  80128. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  80129. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  80130. }
  80131. }
  80132. declare module BABYLON.GLTF1 {
  80133. /** @hidden */
  80134. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  80135. constructor();
  80136. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  80137. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  80138. private _loadTexture;
  80139. }
  80140. }
  80141. declare module BABYLON.GLTF2.Loader {
  80142. /**
  80143. * Loader interface with an index field.
  80144. */
  80145. export interface IArrayItem {
  80146. /**
  80147. * The index of this item in the array.
  80148. */
  80149. index: number;
  80150. }
  80151. /**
  80152. * Loader interface with additional members.
  80153. */
  80154. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  80155. /** @hidden */
  80156. _data?: Promise<ArrayBufferView>;
  80157. /** @hidden */
  80158. _babylonVertexBuffer?: Promise<VertexBuffer>;
  80159. }
  80160. /**
  80161. * Loader interface with additional members.
  80162. */
  80163. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  80164. }
  80165. /** @hidden */
  80166. export interface _IAnimationSamplerData {
  80167. input: Float32Array;
  80168. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  80169. output: Float32Array;
  80170. }
  80171. /**
  80172. * Loader interface with additional members.
  80173. */
  80174. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  80175. /** @hidden */
  80176. _data?: Promise<_IAnimationSamplerData>;
  80177. }
  80178. /**
  80179. * Loader interface with additional members.
  80180. */
  80181. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  80182. channels: IAnimationChannel[];
  80183. samplers: IAnimationSampler[];
  80184. /** @hidden */
  80185. _babylonAnimationGroup?: AnimationGroup;
  80186. }
  80187. /**
  80188. * Loader interface with additional members.
  80189. */
  80190. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  80191. /** @hidden */
  80192. _data?: Promise<ArrayBufferView>;
  80193. }
  80194. /**
  80195. * Loader interface with additional members.
  80196. */
  80197. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  80198. /** @hidden */
  80199. _data?: Promise<ArrayBufferView>;
  80200. /** @hidden */
  80201. _babylonBuffer?: Promise<Buffer>;
  80202. }
  80203. /**
  80204. * Loader interface with additional members.
  80205. */
  80206. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  80207. }
  80208. /**
  80209. * Loader interface with additional members.
  80210. */
  80211. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  80212. /** @hidden */
  80213. _data?: Promise<ArrayBufferView>;
  80214. }
  80215. /**
  80216. * Loader interface with additional members.
  80217. */
  80218. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  80219. }
  80220. /**
  80221. * Loader interface with additional members.
  80222. */
  80223. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  80224. }
  80225. /**
  80226. * Loader interface with additional members.
  80227. */
  80228. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  80229. baseColorTexture?: ITextureInfo;
  80230. metallicRoughnessTexture?: ITextureInfo;
  80231. }
  80232. /**
  80233. * Loader interface with additional members.
  80234. */
  80235. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  80236. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  80237. normalTexture?: IMaterialNormalTextureInfo;
  80238. occlusionTexture?: IMaterialOcclusionTextureInfo;
  80239. emissiveTexture?: ITextureInfo;
  80240. /** @hidden */
  80241. _data?: {
  80242. [babylonDrawMode: number]: {
  80243. babylonMaterial: Material;
  80244. babylonMeshes: AbstractMesh[];
  80245. promise: Promise<void>;
  80246. };
  80247. };
  80248. }
  80249. /**
  80250. * Loader interface with additional members.
  80251. */
  80252. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  80253. primitives: IMeshPrimitive[];
  80254. }
  80255. /**
  80256. * Loader interface with additional members.
  80257. */
  80258. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  80259. /** @hidden */
  80260. _instanceData?: {
  80261. babylonSourceMesh: Mesh;
  80262. promise: Promise<any>;
  80263. };
  80264. }
  80265. /**
  80266. * Loader interface with additional members.
  80267. */
  80268. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  80269. /**
  80270. * The parent glTF node.
  80271. */
  80272. parent?: INode;
  80273. /** @hidden */
  80274. _babylonTransformNode?: TransformNode;
  80275. /** @hidden */
  80276. _primitiveBabylonMeshes?: AbstractMesh[];
  80277. /** @hidden */
  80278. _babylonBones?: Bone[];
  80279. /** @hidden */
  80280. _numMorphTargets?: number;
  80281. }
  80282. /** @hidden */
  80283. export interface _ISamplerData {
  80284. noMipMaps: boolean;
  80285. samplingMode: number;
  80286. wrapU: number;
  80287. wrapV: number;
  80288. }
  80289. /**
  80290. * Loader interface with additional members.
  80291. */
  80292. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  80293. /** @hidden */
  80294. _data?: _ISamplerData;
  80295. }
  80296. /**
  80297. * Loader interface with additional members.
  80298. */
  80299. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  80300. }
  80301. /**
  80302. * Loader interface with additional members.
  80303. */
  80304. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  80305. /** @hidden */
  80306. _data?: {
  80307. babylonSkeleton: Skeleton;
  80308. promise: Promise<void>;
  80309. };
  80310. }
  80311. /**
  80312. * Loader interface with additional members.
  80313. */
  80314. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  80315. }
  80316. /**
  80317. * Loader interface with additional members.
  80318. */
  80319. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  80320. }
  80321. /**
  80322. * Loader interface with additional members.
  80323. */
  80324. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  80325. accessors?: IAccessor[];
  80326. animations?: IAnimation[];
  80327. buffers?: IBuffer[];
  80328. bufferViews?: IBufferView[];
  80329. cameras?: ICamera[];
  80330. images?: IImage[];
  80331. materials?: IMaterial[];
  80332. meshes?: IMesh[];
  80333. nodes?: INode[];
  80334. samplers?: ISampler[];
  80335. scenes?: IScene[];
  80336. skins?: ISkin[];
  80337. textures?: ITexture[];
  80338. }
  80339. }
  80340. declare module BABYLON.GLTF2 {
  80341. /**
  80342. * Interface for a glTF loader extension.
  80343. */
  80344. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  80345. /**
  80346. * Called after the loader state changes to LOADING.
  80347. */
  80348. onLoading?(): void;
  80349. /**
  80350. * Called after the loader state changes to READY.
  80351. */
  80352. onReady?(): void;
  80353. /**
  80354. * Define this method to modify the default behavior when loading scenes.
  80355. * @param context The context when loading the asset
  80356. * @param scene The glTF scene property
  80357. * @returns A promise that resolves when the load is complete or null if not handled
  80358. */
  80359. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  80360. /**
  80361. * Define this method to modify the default behavior when loading nodes.
  80362. * @param context The context when loading the asset
  80363. * @param node The glTF node property
  80364. * @param assign A function called synchronously after parsing the glTF properties
  80365. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  80366. */
  80367. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80368. /**
  80369. * Define this method to modify the default behavior when loading cameras.
  80370. * @param context The context when loading the asset
  80371. * @param camera The glTF camera property
  80372. * @param assign A function called synchronously after parsing the glTF properties
  80373. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  80374. */
  80375. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  80376. /**
  80377. * @hidden
  80378. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  80379. * @param context The context when loading the asset
  80380. * @param primitive The glTF mesh primitive property
  80381. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  80382. */
  80383. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  80384. /**
  80385. * @hidden
  80386. * Define this method to modify the default behavior when loading data for mesh primitives.
  80387. * @param context The context when loading the asset
  80388. * @param name The mesh name when loading the asset
  80389. * @param node The glTF node when loading the asset
  80390. * @param mesh The glTF mesh when loading the asset
  80391. * @param primitive The glTF mesh primitive property
  80392. * @param assign A function called synchronously after parsing the glTF properties
  80393. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  80394. */
  80395. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  80396. /**
  80397. * @hidden
  80398. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  80399. * @param context The context when loading the asset
  80400. * @param material The glTF material property
  80401. * @param assign A function called synchronously after parsing the glTF properties
  80402. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  80403. */
  80404. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  80405. /**
  80406. * Define this method to modify the default behavior when creating materials.
  80407. * @param context The context when loading the asset
  80408. * @param material The glTF material property
  80409. * @param babylonDrawMode The draw mode for the Babylon material
  80410. * @returns The Babylon material or null if not handled
  80411. */
  80412. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  80413. /**
  80414. * Define this method to modify the default behavior when loading material properties.
  80415. * @param context The context when loading the asset
  80416. * @param material The glTF material property
  80417. * @param babylonMaterial The Babylon material
  80418. * @returns A promise that resolves when the load is complete or null if not handled
  80419. */
  80420. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80421. /**
  80422. * Define this method to modify the default behavior when loading texture infos.
  80423. * @param context The context when loading the asset
  80424. * @param textureInfo The glTF texture info property
  80425. * @param assign A function called synchronously after parsing the glTF properties
  80426. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  80427. */
  80428. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80429. /**
  80430. * @hidden
  80431. * Define this method to modify the default behavior when loading textures.
  80432. * @param context The context when loading the asset
  80433. * @param texture The glTF texture property
  80434. * @param assign A function called synchronously after parsing the glTF properties
  80435. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  80436. */
  80437. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  80438. /**
  80439. * Define this method to modify the default behavior when loading animations.
  80440. * @param context The context when loading the asset
  80441. * @param animation The glTF animation property
  80442. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  80443. */
  80444. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  80445. /**
  80446. * @hidden
  80447. * Define this method to modify the default behavior when loading skins.
  80448. * @param context The context when loading the asset
  80449. * @param node The glTF node property
  80450. * @param skin The glTF skin property
  80451. * @returns A promise that resolves when the load is complete or null if not handled
  80452. */
  80453. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  80454. /**
  80455. * @hidden
  80456. * Define this method to modify the default behavior when loading uris.
  80457. * @param context The context when loading the asset
  80458. * @param property The glTF property associated with the uri
  80459. * @param uri The uri to load
  80460. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  80461. */
  80462. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  80463. /**
  80464. * Define this method to modify the default behavior when loading buffer views.
  80465. * @param context The context when loading the asset
  80466. * @param bufferView The glTF buffer view property
  80467. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  80468. */
  80469. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  80470. /**
  80471. * Define this method to modify the default behavior when loading buffers.
  80472. * @param context The context when loading the asset
  80473. * @param buffer The glTF buffer property
  80474. * @param byteOffset The byte offset to load
  80475. * @param byteLength The byte length to load
  80476. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  80477. */
  80478. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  80479. }
  80480. }
  80481. declare module BABYLON.GLTF2 {
  80482. /**
  80483. * Helper class for working with arrays when loading the glTF asset
  80484. */
  80485. export class ArrayItem {
  80486. /**
  80487. * Gets an item from the given array.
  80488. * @param context The context when loading the asset
  80489. * @param array The array to get the item from
  80490. * @param index The index to the array
  80491. * @returns The array item
  80492. */
  80493. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  80494. /**
  80495. * Assign an `index` field to each item of the given array.
  80496. * @param array The array of items
  80497. */
  80498. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  80499. }
  80500. /**
  80501. * The glTF 2.0 loader
  80502. */
  80503. export class GLTFLoader implements IGLTFLoader {
  80504. /** @hidden */
  80505. _completePromises: Promise<any>[];
  80506. /** @hidden */
  80507. _forAssetContainer: boolean;
  80508. /** Storage */
  80509. _babylonLights: Light[];
  80510. /** @hidden */
  80511. _disableInstancedMesh: number;
  80512. private _disposed;
  80513. private _parent;
  80514. private _state;
  80515. private _extensions;
  80516. private _rootUrl;
  80517. private _fileName;
  80518. private _uniqueRootUrl;
  80519. private _gltf;
  80520. private _bin;
  80521. private _babylonScene;
  80522. private _rootBabylonMesh;
  80523. private _defaultBabylonMaterialData;
  80524. private static _RegisteredExtensions;
  80525. /**
  80526. * The default glTF sampler.
  80527. */
  80528. static readonly DefaultSampler: ISampler;
  80529. /**
  80530. * Registers a loader extension.
  80531. * @param name The name of the loader extension.
  80532. * @param factory The factory function that creates the loader extension.
  80533. */
  80534. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  80535. /**
  80536. * Unregisters a loader extension.
  80537. * @param name The name of the loader extension.
  80538. * @returns A boolean indicating whether the extension has been unregistered
  80539. */
  80540. static UnregisterExtension(name: string): boolean;
  80541. /**
  80542. * The loader state.
  80543. */
  80544. get state(): Nullable<GLTFLoaderState>;
  80545. /**
  80546. * The object that represents the glTF JSON.
  80547. */
  80548. get gltf(): IGLTF;
  80549. /**
  80550. * The BIN chunk of a binary glTF.
  80551. */
  80552. get bin(): Nullable<IDataBuffer>;
  80553. /**
  80554. * The parent file loader.
  80555. */
  80556. get parent(): GLTFFileLoader;
  80557. /**
  80558. * The Babylon scene when loading the asset.
  80559. */
  80560. get babylonScene(): Scene;
  80561. /**
  80562. * The root Babylon mesh when loading the asset.
  80563. */
  80564. get rootBabylonMesh(): Mesh;
  80565. /** @hidden */
  80566. constructor(parent: GLTFFileLoader);
  80567. /** @hidden */
  80568. dispose(): void;
  80569. /** @hidden */
  80570. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  80571. /** @hidden */
  80572. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  80573. private _loadAsync;
  80574. private _loadData;
  80575. private _setupData;
  80576. private _loadExtensions;
  80577. private _checkExtensions;
  80578. private _setState;
  80579. private _createRootNode;
  80580. /**
  80581. * Loads a glTF scene.
  80582. * @param context The context when loading the asset
  80583. * @param scene The glTF scene property
  80584. * @returns A promise that resolves when the load is complete
  80585. */
  80586. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  80587. private _forEachPrimitive;
  80588. private _getMeshes;
  80589. private _getTransformNodes;
  80590. private _getSkeletons;
  80591. private _getAnimationGroups;
  80592. private _startAnimations;
  80593. /**
  80594. * Loads a glTF node.
  80595. * @param context The context when loading the asset
  80596. * @param node The glTF node property
  80597. * @param assign A function called synchronously after parsing the glTF properties
  80598. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  80599. */
  80600. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  80601. private _loadMeshAsync;
  80602. /**
  80603. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  80604. * @param context The context when loading the asset
  80605. * @param name The mesh name when loading the asset
  80606. * @param node The glTF node when loading the asset
  80607. * @param mesh The glTF mesh when loading the asset
  80608. * @param primitive The glTF mesh primitive property
  80609. * @param assign A function called synchronously after parsing the glTF properties
  80610. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  80611. */
  80612. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  80613. private _loadVertexDataAsync;
  80614. private _createMorphTargets;
  80615. private _loadMorphTargetsAsync;
  80616. private _loadMorphTargetVertexDataAsync;
  80617. private static _LoadTransform;
  80618. private _loadSkinAsync;
  80619. private _loadBones;
  80620. private _loadBone;
  80621. private _loadSkinInverseBindMatricesDataAsync;
  80622. private _updateBoneMatrices;
  80623. private _getNodeMatrix;
  80624. /**
  80625. * Loads a glTF camera.
  80626. * @param context The context when loading the asset
  80627. * @param camera The glTF camera property
  80628. * @param assign A function called synchronously after parsing the glTF properties
  80629. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  80630. */
  80631. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  80632. private _loadAnimationsAsync;
  80633. /**
  80634. * Loads a glTF animation.
  80635. * @param context The context when loading the asset
  80636. * @param animation The glTF animation property
  80637. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  80638. */
  80639. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  80640. /**
  80641. * @hidden Loads a glTF animation channel.
  80642. * @param context The context when loading the asset
  80643. * @param animationContext The context of the animation when loading the asset
  80644. * @param animation The glTF animation property
  80645. * @param channel The glTF animation channel property
  80646. * @param babylonAnimationGroup The babylon animation group property
  80647. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  80648. * @returns A void promise when the channel load is complete
  80649. */
  80650. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  80651. private _loadAnimationSamplerAsync;
  80652. private _loadBufferAsync;
  80653. /**
  80654. * Loads a glTF buffer view.
  80655. * @param context The context when loading the asset
  80656. * @param bufferView The glTF buffer view property
  80657. * @returns A promise that resolves with the loaded data when the load is complete
  80658. */
  80659. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  80660. private _loadAccessorAsync;
  80661. /** @hidden */
  80662. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  80663. private _loadIndicesAccessorAsync;
  80664. private _loadVertexBufferViewAsync;
  80665. private _loadVertexAccessorAsync;
  80666. private _loadMaterialMetallicRoughnessPropertiesAsync;
  80667. /** @hidden */
  80668. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  80669. private _createDefaultMaterial;
  80670. /**
  80671. * Creates a Babylon material from a glTF material.
  80672. * @param context The context when loading the asset
  80673. * @param material The glTF material property
  80674. * @param babylonDrawMode The draw mode for the Babylon material
  80675. * @returns The Babylon material
  80676. */
  80677. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  80678. /**
  80679. * Loads properties from a glTF material into a Babylon material.
  80680. * @param context The context when loading the asset
  80681. * @param material The glTF material property
  80682. * @param babylonMaterial The Babylon material
  80683. * @returns A promise that resolves when the load is complete
  80684. */
  80685. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  80686. /**
  80687. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  80688. * @param context The context when loading the asset
  80689. * @param material The glTF material property
  80690. * @param babylonMaterial The Babylon material
  80691. * @returns A promise that resolves when the load is complete
  80692. */
  80693. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  80694. /**
  80695. * Loads the alpha properties from a glTF material into a Babylon material.
  80696. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  80697. * @param context The context when loading the asset
  80698. * @param material The glTF material property
  80699. * @param babylonMaterial The Babylon material
  80700. */
  80701. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  80702. /**
  80703. * Loads a glTF texture info.
  80704. * @param context The context when loading the asset
  80705. * @param textureInfo The glTF texture info property
  80706. * @param assign A function called synchronously after parsing the glTF properties
  80707. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  80708. */
  80709. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  80710. /** @hidden */
  80711. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  80712. /** @hidden */
  80713. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  80714. private _loadSampler;
  80715. /**
  80716. * Loads a glTF image.
  80717. * @param context The context when loading the asset
  80718. * @param image The glTF image property
  80719. * @returns A promise that resolves with the loaded data when the load is complete
  80720. */
  80721. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  80722. /**
  80723. * Loads a glTF uri.
  80724. * @param context The context when loading the asset
  80725. * @param property The glTF property associated with the uri
  80726. * @param uri The base64 or relative uri
  80727. * @returns A promise that resolves with the loaded data when the load is complete
  80728. */
  80729. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  80730. /**
  80731. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  80732. * @param babylonObject the Babylon object with metadata
  80733. * @param pointer the JSON pointer
  80734. */
  80735. static AddPointerMetadata(babylonObject: {
  80736. metadata: any;
  80737. }, pointer: string): void;
  80738. private static _GetTextureWrapMode;
  80739. private static _GetTextureSamplingMode;
  80740. private static _GetTypedArrayConstructor;
  80741. private static _GetTypedArray;
  80742. private static _GetNumComponents;
  80743. private static _ValidateUri;
  80744. /** @hidden */
  80745. static _GetDrawMode(context: string, mode: number | undefined): number;
  80746. private _compileMaterialsAsync;
  80747. private _compileShadowGeneratorsAsync;
  80748. private _forEachExtensions;
  80749. private _applyExtensions;
  80750. private _extensionsOnLoading;
  80751. private _extensionsOnReady;
  80752. private _extensionsLoadSceneAsync;
  80753. private _extensionsLoadNodeAsync;
  80754. private _extensionsLoadCameraAsync;
  80755. private _extensionsLoadVertexDataAsync;
  80756. private _extensionsLoadMeshPrimitiveAsync;
  80757. private _extensionsLoadMaterialAsync;
  80758. private _extensionsCreateMaterial;
  80759. private _extensionsLoadMaterialPropertiesAsync;
  80760. private _extensionsLoadTextureInfoAsync;
  80761. private _extensionsLoadTextureAsync;
  80762. private _extensionsLoadAnimationAsync;
  80763. private _extensionsLoadSkinAsync;
  80764. private _extensionsLoadUriAsync;
  80765. private _extensionsLoadBufferViewAsync;
  80766. private _extensionsLoadBufferAsync;
  80767. /**
  80768. * Helper method called by a loader extension to load an glTF extension.
  80769. * @param context The context when loading the asset
  80770. * @param property The glTF property to load the extension from
  80771. * @param extensionName The name of the extension to load
  80772. * @param actionAsync The action to run
  80773. * @returns The promise returned by actionAsync or null if the extension does not exist
  80774. */
  80775. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  80776. /**
  80777. * Helper method called by a loader extension to load a glTF extra.
  80778. * @param context The context when loading the asset
  80779. * @param property The glTF property to load the extra from
  80780. * @param extensionName The name of the extension to load
  80781. * @param actionAsync The action to run
  80782. * @returns The promise returned by actionAsync or null if the extra does not exist
  80783. */
  80784. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  80785. /**
  80786. * Checks for presence of an extension.
  80787. * @param name The name of the extension to check
  80788. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  80789. */
  80790. isExtensionUsed(name: string): boolean;
  80791. /**
  80792. * Increments the indentation level and logs a message.
  80793. * @param message The message to log
  80794. */
  80795. logOpen(message: string): void;
  80796. /**
  80797. * Decrements the indentation level.
  80798. */
  80799. logClose(): void;
  80800. /**
  80801. * Logs a message
  80802. * @param message The message to log
  80803. */
  80804. log(message: string): void;
  80805. /**
  80806. * Starts a performance counter.
  80807. * @param counterName The name of the performance counter
  80808. */
  80809. startPerformanceCounter(counterName: string): void;
  80810. /**
  80811. * Ends a performance counter.
  80812. * @param counterName The name of the performance counter
  80813. */
  80814. endPerformanceCounter(counterName: string): void;
  80815. }
  80816. }
  80817. declare module BABYLON.GLTF2.Loader.Extensions {
  80818. /** @hidden */
  80819. interface IEXTLightsImageBased_LightImageBased {
  80820. _babylonTexture?: BaseTexture;
  80821. _loaded?: Promise<void>;
  80822. }
  80823. /**
  80824. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  80825. */
  80826. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  80827. /**
  80828. * The name of this extension.
  80829. */
  80830. readonly name: string;
  80831. /**
  80832. * Defines whether this extension is enabled.
  80833. */
  80834. enabled: boolean;
  80835. private _loader;
  80836. private _lights?;
  80837. /** @hidden */
  80838. constructor(loader: GLTFLoader);
  80839. /** @hidden */
  80840. dispose(): void;
  80841. /** @hidden */
  80842. onLoading(): void;
  80843. /** @hidden */
  80844. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  80845. private _loadLightAsync;
  80846. }
  80847. }
  80848. declare module BABYLON.GLTF2.Loader.Extensions {
  80849. /**
  80850. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  80851. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  80852. * !!! Experimental Extension Subject to Changes !!!
  80853. */
  80854. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  80855. /**
  80856. * The name of this extension.
  80857. */
  80858. readonly name: string;
  80859. /**
  80860. * Defines whether this extension is enabled.
  80861. */
  80862. enabled: boolean;
  80863. private _loader;
  80864. /** @hidden */
  80865. constructor(loader: GLTFLoader);
  80866. /** @hidden */
  80867. dispose(): void;
  80868. /** @hidden */
  80869. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80870. }
  80871. }
  80872. declare module BABYLON.GLTF2.Loader.Extensions {
  80873. /**
  80874. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  80875. */
  80876. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  80877. /**
  80878. * The name of this extension.
  80879. */
  80880. readonly name: string;
  80881. /**
  80882. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  80883. */
  80884. dracoCompression?: DracoCompression;
  80885. /**
  80886. * Defines whether this extension is enabled.
  80887. */
  80888. enabled: boolean;
  80889. private _loader;
  80890. /** @hidden */
  80891. constructor(loader: GLTFLoader);
  80892. /** @hidden */
  80893. dispose(): void;
  80894. /** @hidden */
  80895. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  80896. }
  80897. }
  80898. declare module BABYLON.GLTF2.Loader.Extensions {
  80899. /**
  80900. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  80901. */
  80902. export class KHR_lights implements IGLTFLoaderExtension {
  80903. /**
  80904. * The name of this extension.
  80905. */
  80906. readonly name: string;
  80907. /**
  80908. * Defines whether this extension is enabled.
  80909. */
  80910. enabled: boolean;
  80911. private _loader;
  80912. private _lights?;
  80913. /** @hidden */
  80914. constructor(loader: GLTFLoader);
  80915. /** @hidden */
  80916. dispose(): void;
  80917. /** @hidden */
  80918. onLoading(): void;
  80919. /** @hidden */
  80920. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  80921. }
  80922. }
  80923. declare module BABYLON.GLTF2.Loader.Extensions {
  80924. /**
  80925. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  80926. */
  80927. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  80928. /**
  80929. * The name of this extension.
  80930. */
  80931. readonly name: string;
  80932. /**
  80933. * Defines whether this extension is enabled.
  80934. */
  80935. enabled: boolean;
  80936. /**
  80937. * Defines a number that determines the order the extensions are applied.
  80938. */
  80939. order: number;
  80940. private _loader;
  80941. /** @hidden */
  80942. constructor(loader: GLTFLoader);
  80943. /** @hidden */
  80944. dispose(): void;
  80945. /** @hidden */
  80946. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80947. private _loadSpecularGlossinessPropertiesAsync;
  80948. }
  80949. }
  80950. declare module BABYLON.GLTF2.Loader.Extensions {
  80951. /**
  80952. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  80953. */
  80954. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  80955. /**
  80956. * The name of this extension.
  80957. */
  80958. readonly name: string;
  80959. /**
  80960. * Defines whether this extension is enabled.
  80961. */
  80962. enabled: boolean;
  80963. /**
  80964. * Defines a number that determines the order the extensions are applied.
  80965. */
  80966. order: number;
  80967. private _loader;
  80968. /** @hidden */
  80969. constructor(loader: GLTFLoader);
  80970. /** @hidden */
  80971. dispose(): void;
  80972. /** @hidden */
  80973. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  80974. private _loadUnlitPropertiesAsync;
  80975. }
  80976. }
  80977. declare module BABYLON.GLTF2.Loader.Extensions {
  80978. /**
  80979. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  80980. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  80981. * !!! Experimental Extension Subject to Changes !!!
  80982. */
  80983. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  80984. /**
  80985. * The name of this extension.
  80986. */
  80987. readonly name: string;
  80988. /**
  80989. * Defines whether this extension is enabled.
  80990. */
  80991. enabled: boolean;
  80992. /**
  80993. * Defines a number that determines the order the extensions are applied.
  80994. */
  80995. order: number;
  80996. private _loader;
  80997. /** @hidden */
  80998. constructor(loader: GLTFLoader);
  80999. /** @hidden */
  81000. dispose(): void;
  81001. /** @hidden */
  81002. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81003. private _loadClearCoatPropertiesAsync;
  81004. }
  81005. }
  81006. declare module BABYLON.GLTF2.Loader.Extensions {
  81007. /**
  81008. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  81009. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  81010. * !!! Experimental Extension Subject to Changes !!!
  81011. */
  81012. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  81013. /**
  81014. * The name of this extension.
  81015. */
  81016. readonly name: string;
  81017. /**
  81018. * Defines whether this extension is enabled.
  81019. */
  81020. enabled: boolean;
  81021. /**
  81022. * Defines a number that determines the order the extensions are applied.
  81023. */
  81024. order: number;
  81025. private _loader;
  81026. /** @hidden */
  81027. constructor(loader: GLTFLoader);
  81028. /** @hidden */
  81029. dispose(): void;
  81030. /** @hidden */
  81031. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81032. private _loadSheenPropertiesAsync;
  81033. }
  81034. }
  81035. declare module BABYLON.GLTF2.Loader.Extensions {
  81036. /**
  81037. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  81038. * !!! Experimental Extension Subject to Changes !!!
  81039. */
  81040. export class KHR_materials_specular implements IGLTFLoaderExtension {
  81041. /**
  81042. * The name of this extension.
  81043. */
  81044. readonly name: string;
  81045. /**
  81046. * Defines whether this extension is enabled.
  81047. */
  81048. enabled: boolean;
  81049. /**
  81050. * Defines a number that determines the order the extensions are applied.
  81051. */
  81052. order: number;
  81053. private _loader;
  81054. /** @hidden */
  81055. constructor(loader: GLTFLoader);
  81056. /** @hidden */
  81057. dispose(): void;
  81058. /** @hidden */
  81059. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81060. private _loadSpecularPropertiesAsync;
  81061. }
  81062. }
  81063. declare module BABYLON.GLTF2.Loader.Extensions {
  81064. /**
  81065. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  81066. * !!! Experimental Extension Subject to Changes !!!
  81067. */
  81068. export class KHR_materials_ior implements IGLTFLoaderExtension {
  81069. /**
  81070. * Default ior Value from the spec.
  81071. */
  81072. private static readonly _DEFAULT_IOR;
  81073. /**
  81074. * The name of this extension.
  81075. */
  81076. readonly name: string;
  81077. /**
  81078. * Defines whether this extension is enabled.
  81079. */
  81080. enabled: boolean;
  81081. /**
  81082. * Defines a number that determines the order the extensions are applied.
  81083. */
  81084. order: number;
  81085. private _loader;
  81086. /** @hidden */
  81087. constructor(loader: GLTFLoader);
  81088. /** @hidden */
  81089. dispose(): void;
  81090. /** @hidden */
  81091. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81092. private _loadIorPropertiesAsync;
  81093. }
  81094. }
  81095. declare module BABYLON.GLTF2.Loader.Extensions {
  81096. /**
  81097. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  81098. * !!! Experimental Extension Subject to Changes !!!
  81099. */
  81100. export class KHR_materials_variants implements IGLTFLoaderExtension {
  81101. /**
  81102. * The name of this extension.
  81103. */
  81104. readonly name: string;
  81105. /**
  81106. * Defines whether this extension is enabled.
  81107. */
  81108. enabled: boolean;
  81109. private _loader;
  81110. /** @hidden */
  81111. constructor(loader: GLTFLoader);
  81112. /** @hidden */
  81113. dispose(): void;
  81114. /**
  81115. * Gets the list of available variant names for this asset.
  81116. * @param rootMesh The glTF root mesh
  81117. * @returns the list of all the variant names for this model
  81118. */
  81119. static GetAvailableVariants(rootMesh: Mesh): string[];
  81120. /**
  81121. * Gets the list of available variant names for this asset.
  81122. * @param rootMesh The glTF root mesh
  81123. * @returns the list of all the variant names for this model
  81124. */
  81125. getAvailableVariants(rootMesh: Mesh): string[];
  81126. /**
  81127. * Select a variant given a variant name or a list of variant names.
  81128. * @param rootMesh The glTF root mesh
  81129. * @param variantName The variant name(s) to select.
  81130. */
  81131. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  81132. /**
  81133. * Select a variant given a variant name or a list of variant names.
  81134. * @param rootMesh The glTF root mesh
  81135. * @param variantName The variant name(s) to select.
  81136. */
  81137. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  81138. /**
  81139. * Reset back to the original before selecting a variant.
  81140. * @param rootMesh The glTF root mesh
  81141. */
  81142. static Reset(rootMesh: Mesh): void;
  81143. /**
  81144. * Reset back to the original before selecting a variant.
  81145. * @param rootMesh The glTF root mesh
  81146. */
  81147. reset(rootMesh: Mesh): void;
  81148. /**
  81149. * Gets the last selected variant name(s) or null if original.
  81150. * @param rootMesh The glTF root mesh
  81151. * @returns The selected variant name(s).
  81152. */
  81153. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  81154. /**
  81155. * Gets the last selected variant name(s) or null if original.
  81156. * @param rootMesh The glTF root mesh
  81157. * @returns The selected variant name(s).
  81158. */
  81159. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  81160. private static _GetExtensionMetadata;
  81161. /** @hidden */
  81162. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  81163. }
  81164. }
  81165. declare module BABYLON.GLTF2.Loader.Extensions {
  81166. /**
  81167. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  81168. * !!! Experimental Extension Subject to Changes !!!
  81169. */
  81170. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  81171. /**
  81172. * The name of this extension.
  81173. */
  81174. readonly name: string;
  81175. /**
  81176. * Defines whether this extension is enabled.
  81177. */
  81178. enabled: boolean;
  81179. /**
  81180. * Defines a number that determines the order the extensions are applied.
  81181. */
  81182. order: number;
  81183. private _loader;
  81184. /** @hidden */
  81185. constructor(loader: GLTFLoader);
  81186. /** @hidden */
  81187. dispose(): void;
  81188. /** @hidden */
  81189. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81190. private _loadTransparentPropertiesAsync;
  81191. }
  81192. }
  81193. declare module BABYLON.GLTF2.Loader.Extensions {
  81194. /**
  81195. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  81196. */
  81197. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  81198. /**
  81199. * The name of this extension.
  81200. */
  81201. readonly name: string;
  81202. /**
  81203. * Defines whether this extension is enabled.
  81204. */
  81205. enabled: boolean;
  81206. /** @hidden */
  81207. constructor(loader: GLTFLoader);
  81208. /** @hidden */
  81209. dispose(): void;
  81210. }
  81211. }
  81212. declare module BABYLON.GLTF2.Loader.Extensions {
  81213. /**
  81214. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  81215. * !!! Experimental Extension Subject to Changes !!!
  81216. */
  81217. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  81218. /** The name of this extension. */
  81219. readonly name: string;
  81220. /** Defines whether this extension is enabled. */
  81221. enabled: boolean;
  81222. private _loader;
  81223. /** @hidden */
  81224. constructor(loader: GLTFLoader);
  81225. /** @hidden */
  81226. dispose(): void;
  81227. /** @hidden */
  81228. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  81229. }
  81230. }
  81231. declare module BABYLON.GLTF2.Loader.Extensions {
  81232. /**
  81233. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  81234. */
  81235. export class KHR_texture_transform implements IGLTFLoaderExtension {
  81236. /**
  81237. * The name of this extension.
  81238. */
  81239. readonly name: string;
  81240. /**
  81241. * Defines whether this extension is enabled.
  81242. */
  81243. enabled: boolean;
  81244. private _loader;
  81245. /** @hidden */
  81246. constructor(loader: GLTFLoader);
  81247. /** @hidden */
  81248. dispose(): void;
  81249. /** @hidden */
  81250. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  81251. }
  81252. }
  81253. declare module BABYLON.GLTF2.Loader.Extensions {
  81254. /**
  81255. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  81256. * !!! Experimental Extension Subject to Changes !!!
  81257. */
  81258. export class KHR_xmp implements IGLTFLoaderExtension {
  81259. /**
  81260. * The name of this extension.
  81261. */
  81262. readonly name: string;
  81263. /**
  81264. * Defines whether this extension is enabled.
  81265. */
  81266. enabled: boolean;
  81267. /**
  81268. * Defines a number that determines the order the extensions are applied.
  81269. */
  81270. order: number;
  81271. private _loader;
  81272. /** @hidden */
  81273. constructor(loader: GLTFLoader);
  81274. /** @hidden */
  81275. dispose(): void;
  81276. /**
  81277. * Called after the loader state changes to LOADING.
  81278. */
  81279. onLoading(): void;
  81280. }
  81281. }
  81282. declare module BABYLON.GLTF2.Loader.Extensions {
  81283. /**
  81284. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  81285. */
  81286. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  81287. /**
  81288. * The name of this extension.
  81289. */
  81290. readonly name: string;
  81291. /**
  81292. * Defines whether this extension is enabled.
  81293. */
  81294. enabled: boolean;
  81295. private _loader;
  81296. private _clips;
  81297. private _emitters;
  81298. /** @hidden */
  81299. constructor(loader: GLTFLoader);
  81300. /** @hidden */
  81301. dispose(): void;
  81302. /** @hidden */
  81303. onLoading(): void;
  81304. /** @hidden */
  81305. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  81306. /** @hidden */
  81307. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81308. /** @hidden */
  81309. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  81310. private _loadClipAsync;
  81311. private _loadEmitterAsync;
  81312. private _getEventAction;
  81313. private _loadAnimationEventAsync;
  81314. }
  81315. }
  81316. declare module BABYLON.GLTF2.Loader.Extensions {
  81317. /**
  81318. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  81319. */
  81320. export class MSFT_lod implements IGLTFLoaderExtension {
  81321. /**
  81322. * The name of this extension.
  81323. */
  81324. readonly name: string;
  81325. /**
  81326. * Defines whether this extension is enabled.
  81327. */
  81328. enabled: boolean;
  81329. /**
  81330. * Defines a number that determines the order the extensions are applied.
  81331. */
  81332. order: number;
  81333. /**
  81334. * Maximum number of LODs to load, starting from the lowest LOD.
  81335. */
  81336. maxLODsToLoad: number;
  81337. /**
  81338. * Observable raised when all node LODs of one level are loaded.
  81339. * The event data is the index of the loaded LOD starting from zero.
  81340. * Dispose the loader to cancel the loading of the next level of LODs.
  81341. */
  81342. onNodeLODsLoadedObservable: Observable<number>;
  81343. /**
  81344. * Observable raised when all material LODs of one level are loaded.
  81345. * The event data is the index of the loaded LOD starting from zero.
  81346. * Dispose the loader to cancel the loading of the next level of LODs.
  81347. */
  81348. onMaterialLODsLoadedObservable: Observable<number>;
  81349. private _loader;
  81350. private _bufferLODs;
  81351. private _nodeIndexLOD;
  81352. private _nodeSignalLODs;
  81353. private _nodePromiseLODs;
  81354. private _nodeBufferLODs;
  81355. private _materialIndexLOD;
  81356. private _materialSignalLODs;
  81357. private _materialPromiseLODs;
  81358. private _materialBufferLODs;
  81359. /** @hidden */
  81360. constructor(loader: GLTFLoader);
  81361. /** @hidden */
  81362. dispose(): void;
  81363. /** @hidden */
  81364. onReady(): void;
  81365. /** @hidden */
  81366. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  81367. /** @hidden */
  81368. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81369. /** @hidden */
  81370. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  81371. /** @hidden */
  81372. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  81373. /** @hidden */
  81374. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  81375. private _loadBufferLOD;
  81376. /**
  81377. * Gets an array of LOD properties from lowest to highest.
  81378. */
  81379. private _getLODs;
  81380. private _disposeTransformNode;
  81381. private _disposeMaterials;
  81382. }
  81383. }
  81384. declare module BABYLON.GLTF2.Loader.Extensions {
  81385. /** @hidden */
  81386. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  81387. readonly name: string;
  81388. enabled: boolean;
  81389. private _loader;
  81390. constructor(loader: GLTFLoader);
  81391. dispose(): void;
  81392. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81393. }
  81394. }
  81395. declare module BABYLON.GLTF2.Loader.Extensions {
  81396. /** @hidden */
  81397. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  81398. readonly name: string;
  81399. enabled: boolean;
  81400. private _loader;
  81401. constructor(loader: GLTFLoader);
  81402. dispose(): void;
  81403. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  81404. }
  81405. }
  81406. declare module BABYLON.GLTF2.Loader.Extensions {
  81407. /**
  81408. * Store glTF extras (if present) in BJS objects' metadata
  81409. */
  81410. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  81411. /**
  81412. * The name of this extension.
  81413. */
  81414. readonly name: string;
  81415. /**
  81416. * Defines whether this extension is enabled.
  81417. */
  81418. enabled: boolean;
  81419. private _loader;
  81420. private _assignExtras;
  81421. /** @hidden */
  81422. constructor(loader: GLTFLoader);
  81423. /** @hidden */
  81424. dispose(): void;
  81425. /** @hidden */
  81426. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  81427. /** @hidden */
  81428. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  81429. /** @hidden */
  81430. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  81431. }
  81432. }
  81433. declare module BABYLON {
  81434. /**
  81435. * Class reading and parsing the MTL file bundled with the obj file.
  81436. */
  81437. export class MTLFileLoader {
  81438. /**
  81439. * Invert Y-Axis of referenced textures on load
  81440. */
  81441. static INVERT_TEXTURE_Y: boolean;
  81442. /**
  81443. * All material loaded from the mtl will be set here
  81444. */
  81445. materials: StandardMaterial[];
  81446. /**
  81447. * This function will read the mtl file and create each material described inside
  81448. * This function could be improve by adding :
  81449. * -some component missing (Ni, Tf...)
  81450. * -including the specific options available
  81451. *
  81452. * @param scene defines the scene the material will be created in
  81453. * @param data defines the mtl data to parse
  81454. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  81455. * @param forAssetContainer defines if the material should be registered in the scene
  81456. */
  81457. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  81458. /**
  81459. * Gets the texture for the material.
  81460. *
  81461. * If the material is imported from input file,
  81462. * We sanitize the url to ensure it takes the textre from aside the material.
  81463. *
  81464. * @param rootUrl The root url to load from
  81465. * @param value The value stored in the mtl
  81466. * @return The Texture
  81467. */
  81468. private static _getTexture;
  81469. }
  81470. }
  81471. declare module BABYLON {
  81472. /**
  81473. * Options for loading OBJ/MTL files
  81474. */
  81475. type MeshLoadOptions = {
  81476. /**
  81477. * Defines if UVs are optimized by default during load.
  81478. */
  81479. OptimizeWithUV: boolean;
  81480. /**
  81481. * Defines custom scaling of UV coordinates of loaded meshes.
  81482. */
  81483. UVScaling: Vector2;
  81484. /**
  81485. * Invert model on y-axis (does a model scaling inversion)
  81486. */
  81487. InvertY: boolean;
  81488. /**
  81489. * Invert Y-Axis of referenced textures on load
  81490. */
  81491. InvertTextureY: boolean;
  81492. /**
  81493. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  81494. */
  81495. ImportVertexColors: boolean;
  81496. /**
  81497. * Compute the normals for the model, even if normals are present in the file.
  81498. */
  81499. ComputeNormals: boolean;
  81500. /**
  81501. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  81502. */
  81503. SkipMaterials: boolean;
  81504. /**
  81505. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  81506. */
  81507. MaterialLoadingFailsSilently: boolean;
  81508. };
  81509. /**
  81510. * OBJ file type loader.
  81511. * This is a babylon scene loader plugin.
  81512. */
  81513. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  81514. /**
  81515. * Defines if UVs are optimized by default during load.
  81516. */
  81517. static OPTIMIZE_WITH_UV: boolean;
  81518. /**
  81519. * Invert model on y-axis (does a model scaling inversion)
  81520. */
  81521. static INVERT_Y: boolean;
  81522. /**
  81523. * Invert Y-Axis of referenced textures on load
  81524. */
  81525. static get INVERT_TEXTURE_Y(): boolean;
  81526. static set INVERT_TEXTURE_Y(value: boolean);
  81527. /**
  81528. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  81529. */
  81530. static IMPORT_VERTEX_COLORS: boolean;
  81531. /**
  81532. * Compute the normals for the model, even if normals are present in the file.
  81533. */
  81534. static COMPUTE_NORMALS: boolean;
  81535. /**
  81536. * Defines custom scaling of UV coordinates of loaded meshes.
  81537. */
  81538. static UV_SCALING: Vector2;
  81539. /**
  81540. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  81541. */
  81542. static SKIP_MATERIALS: boolean;
  81543. /**
  81544. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  81545. *
  81546. * Defaults to true for backwards compatibility.
  81547. */
  81548. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  81549. /**
  81550. * Defines the name of the plugin.
  81551. */
  81552. name: string;
  81553. /**
  81554. * Defines the extension the plugin is able to load.
  81555. */
  81556. extensions: string;
  81557. /** @hidden */
  81558. obj: RegExp;
  81559. /** @hidden */
  81560. group: RegExp;
  81561. /** @hidden */
  81562. mtllib: RegExp;
  81563. /** @hidden */
  81564. usemtl: RegExp;
  81565. /** @hidden */
  81566. smooth: RegExp;
  81567. /** @hidden */
  81568. vertexPattern: RegExp;
  81569. /** @hidden */
  81570. normalPattern: RegExp;
  81571. /** @hidden */
  81572. uvPattern: RegExp;
  81573. /** @hidden */
  81574. facePattern1: RegExp;
  81575. /** @hidden */
  81576. facePattern2: RegExp;
  81577. /** @hidden */
  81578. facePattern3: RegExp;
  81579. /** @hidden */
  81580. facePattern4: RegExp;
  81581. /** @hidden */
  81582. facePattern5: RegExp;
  81583. private _forAssetContainer;
  81584. private _meshLoadOptions;
  81585. /**
  81586. * Creates loader for .OBJ files
  81587. *
  81588. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  81589. */
  81590. constructor(meshLoadOptions?: MeshLoadOptions);
  81591. private static get currentMeshLoadOptions();
  81592. /**
  81593. * Calls synchronously the MTL file attached to this obj.
  81594. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  81595. * Without this function materials are not displayed in the first frame (but displayed after).
  81596. * In consequence it is impossible to get material information in your HTML file
  81597. *
  81598. * @param url The URL of the MTL file
  81599. * @param rootUrl
  81600. * @param onSuccess Callback function to be called when the MTL file is loaded
  81601. * @private
  81602. */
  81603. private _loadMTL;
  81604. /**
  81605. * Instantiates a OBJ file loader plugin.
  81606. * @returns the created plugin
  81607. */
  81608. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  81609. /**
  81610. * If the data string can be loaded directly.
  81611. *
  81612. * @param data string containing the file data
  81613. * @returns if the data can be loaded directly
  81614. */
  81615. canDirectLoad(data: string): boolean;
  81616. /**
  81617. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  81618. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  81619. * @param scene the scene the meshes should be added to
  81620. * @param data the OBJ data to load
  81621. * @param rootUrl root url to load from
  81622. * @param onProgress event that fires when loading progress has occured
  81623. * @param fileName Defines the name of the file to load
  81624. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  81625. */
  81626. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  81627. meshes: AbstractMesh[];
  81628. particleSystems: IParticleSystem[];
  81629. skeletons: Skeleton[];
  81630. animationGroups: AnimationGroup[];
  81631. }>;
  81632. /**
  81633. * Imports all objects from the loaded OBJ data and adds them to the scene
  81634. * @param scene the scene the objects should be added to
  81635. * @param data the OBJ data to load
  81636. * @param rootUrl root url to load from
  81637. * @param onProgress event that fires when loading progress has occured
  81638. * @param fileName Defines the name of the file to load
  81639. * @returns a promise which completes when objects have been loaded to the scene
  81640. */
  81641. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  81642. /**
  81643. * Load into an asset container.
  81644. * @param scene The scene to load into
  81645. * @param data The data to import
  81646. * @param rootUrl The root url for scene and resources
  81647. * @param onProgress The callback when the load progresses
  81648. * @param fileName Defines the name of the file to load
  81649. * @returns The loaded asset container
  81650. */
  81651. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  81652. /**
  81653. * Read the OBJ file and create an Array of meshes.
  81654. * Each mesh contains all information given by the OBJ and the MTL file.
  81655. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  81656. *
  81657. * @param meshesNames
  81658. * @param scene Scene The scene where are displayed the data
  81659. * @param data String The content of the obj file
  81660. * @param rootUrl String The path to the folder
  81661. * @returns Array<AbstractMesh>
  81662. * @private
  81663. */
  81664. private _parseSolid;
  81665. }
  81666. }
  81667. declare module BABYLON {
  81668. /**
  81669. * STL file type loader.
  81670. * This is a babylon scene loader plugin.
  81671. */
  81672. export class STLFileLoader implements ISceneLoaderPlugin {
  81673. /** @hidden */
  81674. solidPattern: RegExp;
  81675. /** @hidden */
  81676. facetsPattern: RegExp;
  81677. /** @hidden */
  81678. normalPattern: RegExp;
  81679. /** @hidden */
  81680. vertexPattern: RegExp;
  81681. /**
  81682. * Defines the name of the plugin.
  81683. */
  81684. name: string;
  81685. /**
  81686. * Defines the extensions the stl loader is able to load.
  81687. * force data to come in as an ArrayBuffer
  81688. * we'll convert to string if it looks like it's an ASCII .stl
  81689. */
  81690. extensions: ISceneLoaderPluginExtensions;
  81691. /**
  81692. * Import meshes into a scene.
  81693. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  81694. * @param scene The scene to import into
  81695. * @param data The data to import
  81696. * @param rootUrl The root url for scene and resources
  81697. * @param meshes The meshes array to import into
  81698. * @param particleSystems The particle systems array to import into
  81699. * @param skeletons The skeletons array to import into
  81700. * @param onError The callback when import fails
  81701. * @returns True if successful or false otherwise
  81702. */
  81703. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  81704. /**
  81705. * Load into a scene.
  81706. * @param scene The scene to load into
  81707. * @param data The data to import
  81708. * @param rootUrl The root url for scene and resources
  81709. * @param onError The callback when import fails
  81710. * @returns true if successful or false otherwise
  81711. */
  81712. load(scene: Scene, data: any, rootUrl: string): boolean;
  81713. /**
  81714. * Load into an asset container.
  81715. * @param scene The scene to load into
  81716. * @param data The data to import
  81717. * @param rootUrl The root url for scene and resources
  81718. * @param onError The callback when import fails
  81719. * @returns The loaded asset container
  81720. */
  81721. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  81722. private _isBinary;
  81723. private _parseBinary;
  81724. private _parseASCII;
  81725. }
  81726. }
  81727. declare module BABYLON {
  81728. /**
  81729. * Class for generating OBJ data from a Babylon scene.
  81730. */
  81731. export class OBJExport {
  81732. /**
  81733. * Exports the geometry of a Mesh array in .OBJ file format (text)
  81734. * @param mesh defines the list of meshes to serialize
  81735. * @param materials defines if materials should be exported
  81736. * @param matlibname defines the name of the associated mtl file
  81737. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  81738. * @returns the OBJ content
  81739. */
  81740. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  81741. /**
  81742. * Exports the material(s) of a mesh in .MTL file format (text)
  81743. * @param mesh defines the mesh to extract the material from
  81744. * @returns the mtl content
  81745. */
  81746. static MTL(mesh: Mesh): string;
  81747. }
  81748. }
  81749. declare module BABYLON {
  81750. /** @hidden */
  81751. export var __IGLTFExporterExtension: number;
  81752. /**
  81753. * Interface for extending the exporter
  81754. * @hidden
  81755. */
  81756. export interface IGLTFExporterExtension {
  81757. /**
  81758. * The name of this extension
  81759. */
  81760. readonly name: string;
  81761. /**
  81762. * Defines whether this extension is enabled
  81763. */
  81764. enabled: boolean;
  81765. /**
  81766. * Defines whether this extension is required
  81767. */
  81768. required: boolean;
  81769. }
  81770. }
  81771. declare module BABYLON.GLTF2.Exporter {
  81772. /** @hidden */
  81773. export var __IGLTFExporterExtensionV2: number;
  81774. /**
  81775. * Interface for a glTF exporter extension
  81776. * @hidden
  81777. */
  81778. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  81779. /**
  81780. * Define this method to modify the default behavior before exporting a texture
  81781. * @param context The context when loading the asset
  81782. * @param babylonTexture The Babylon.js texture
  81783. * @param mimeType The mime-type of the generated image
  81784. * @returns A promise that resolves with the exported texture
  81785. */
  81786. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  81787. /**
  81788. * Define this method to get notified when a texture info is created
  81789. * @param context The context when loading the asset
  81790. * @param textureInfo The glTF texture info
  81791. * @param babylonTexture The Babylon.js texture
  81792. */
  81793. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  81794. /**
  81795. * Define this method to modify the default behavior when exporting texture info
  81796. * @param context The context when loading the asset
  81797. * @param meshPrimitive glTF mesh primitive
  81798. * @param babylonSubMesh Babylon submesh
  81799. * @param binaryWriter glTF serializer binary writer instance
  81800. * @returns nullable IMeshPrimitive promise
  81801. */
  81802. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  81803. /**
  81804. * Define this method to modify the default behavior when exporting a node
  81805. * @param context The context when exporting the node
  81806. * @param node glTF node
  81807. * @param babylonNode BabylonJS node
  81808. * @returns nullable INode promise
  81809. */
  81810. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  81811. [key: number]: number;
  81812. }): Promise<Nullable<INode>>;
  81813. /**
  81814. * Define this method to modify the default behavior when exporting a material
  81815. * @param material glTF material
  81816. * @param babylonMaterial BabylonJS material
  81817. * @returns nullable IMaterial promise
  81818. */
  81819. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  81820. /**
  81821. * Define this method to return additional textures to export from a material
  81822. * @param material glTF material
  81823. * @param babylonMaterial BabylonJS material
  81824. * @returns List of textures
  81825. */
  81826. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  81827. /** Gets a boolean indicating that this extension was used */
  81828. wasUsed: boolean;
  81829. /** Gets a boolean indicating that this extension is required for the file to work */
  81830. required: boolean;
  81831. /**
  81832. * Called after the exporter state changes to EXPORTING
  81833. */
  81834. onExporting?(): void;
  81835. }
  81836. }
  81837. declare module BABYLON.GLTF2.Exporter {
  81838. /**
  81839. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  81840. * @hidden
  81841. */
  81842. export class _GLTFMaterialExporter {
  81843. /**
  81844. * Represents the dielectric specular values for R, G and B
  81845. */
  81846. private static readonly _DielectricSpecular;
  81847. /**
  81848. * Allows the maximum specular power to be defined for material calculations
  81849. */
  81850. private static readonly _MaxSpecularPower;
  81851. /**
  81852. * Mapping to store textures
  81853. */
  81854. private _textureMap;
  81855. /**
  81856. * Numeric tolerance value
  81857. */
  81858. private static readonly _Epsilon;
  81859. /**
  81860. * Reference to the glTF Exporter
  81861. */
  81862. private _exporter;
  81863. constructor(exporter: _Exporter);
  81864. /**
  81865. * Specifies if two colors are approximately equal in value
  81866. * @param color1 first color to compare to
  81867. * @param color2 second color to compare to
  81868. * @param epsilon threshold value
  81869. */
  81870. private static FuzzyEquals;
  81871. /**
  81872. * Gets the materials from a Babylon scene and converts them to glTF materials
  81873. * @param scene babylonjs scene
  81874. * @param mimeType texture mime type
  81875. * @param images array of images
  81876. * @param textures array of textures
  81877. * @param materials array of materials
  81878. * @param imageData mapping of texture names to base64 textures
  81879. * @param hasTextureCoords specifies if texture coordinates are present on the material
  81880. */
  81881. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  81882. /**
  81883. * Makes a copy of the glTF material without the texture parameters
  81884. * @param originalMaterial original glTF material
  81885. * @returns glTF material without texture parameters
  81886. */
  81887. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  81888. /**
  81889. * Specifies if the material has any texture parameters present
  81890. * @param material glTF Material
  81891. * @returns boolean specifying if texture parameters are present
  81892. */
  81893. _hasTexturesPresent(material: IMaterial): boolean;
  81894. /**
  81895. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  81896. * @param babylonStandardMaterial
  81897. * @returns glTF Metallic Roughness Material representation
  81898. */
  81899. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  81900. /**
  81901. * Computes the metallic factor
  81902. * @param diffuse diffused value
  81903. * @param specular specular value
  81904. * @param oneMinusSpecularStrength one minus the specular strength
  81905. * @returns metallic value
  81906. */
  81907. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  81908. /**
  81909. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  81910. * @param glTFMaterial glTF material
  81911. * @param babylonMaterial Babylon material
  81912. */
  81913. private static _SetAlphaMode;
  81914. /**
  81915. * Converts a Babylon Standard Material to a glTF Material
  81916. * @param babylonStandardMaterial BJS Standard Material
  81917. * @param mimeType mime type to use for the textures
  81918. * @param images array of glTF image interfaces
  81919. * @param textures array of glTF texture interfaces
  81920. * @param materials array of glTF material interfaces
  81921. * @param imageData map of image file name to data
  81922. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81923. */
  81924. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  81925. private _finishMaterial;
  81926. /**
  81927. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  81928. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  81929. * @param mimeType mime type to use for the textures
  81930. * @param images array of glTF image interfaces
  81931. * @param textures array of glTF texture interfaces
  81932. * @param materials array of glTF material interfaces
  81933. * @param imageData map of image file name to data
  81934. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  81935. */
  81936. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  81937. /**
  81938. * Converts an image typed array buffer to a base64 image
  81939. * @param buffer typed array buffer
  81940. * @param width width of the image
  81941. * @param height height of the image
  81942. * @param mimeType mimetype of the image
  81943. * @returns base64 image string
  81944. */
  81945. private _createBase64FromCanvasAsync;
  81946. /**
  81947. * Generates a white texture based on the specified width and height
  81948. * @param width width of the texture in pixels
  81949. * @param height height of the texture in pixels
  81950. * @param scene babylonjs scene
  81951. * @returns white texture
  81952. */
  81953. private _createWhiteTexture;
  81954. /**
  81955. * 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
  81956. * @param texture1 first texture to resize
  81957. * @param texture2 second texture to resize
  81958. * @param scene babylonjs scene
  81959. * @returns resized textures or null
  81960. */
  81961. private _resizeTexturesToSameDimensions;
  81962. /**
  81963. * Converts an array of pixels to a Float32Array
  81964. * Throws an error if the pixel format is not supported
  81965. * @param pixels - array buffer containing pixel values
  81966. * @returns Float32 of pixels
  81967. */
  81968. private _convertPixelArrayToFloat32;
  81969. /**
  81970. * Convert Specular Glossiness Textures to Metallic Roughness
  81971. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  81972. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  81973. * @param diffuseTexture texture used to store diffuse information
  81974. * @param specularGlossinessTexture texture used to store specular and glossiness information
  81975. * @param factors specular glossiness material factors
  81976. * @param mimeType the mime type to use for the texture
  81977. * @returns pbr metallic roughness interface or null
  81978. */
  81979. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  81980. /**
  81981. * Converts specular glossiness material properties to metallic roughness
  81982. * @param specularGlossiness interface with specular glossiness material properties
  81983. * @returns interface with metallic roughness material properties
  81984. */
  81985. private _convertSpecularGlossinessToMetallicRoughness;
  81986. /**
  81987. * Calculates the surface reflectance, independent of lighting conditions
  81988. * @param color Color source to calculate brightness from
  81989. * @returns number representing the perceived brightness, or zero if color is undefined
  81990. */
  81991. private _getPerceivedBrightness;
  81992. /**
  81993. * Returns the maximum color component value
  81994. * @param color
  81995. * @returns maximum color component value, or zero if color is null or undefined
  81996. */
  81997. private _getMaxComponent;
  81998. /**
  81999. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  82000. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  82001. * @param mimeType mime type to use for the textures
  82002. * @param images array of glTF image interfaces
  82003. * @param textures array of glTF texture interfaces
  82004. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  82005. * @param imageData map of image file name to data
  82006. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82007. * @returns glTF PBR Metallic Roughness factors
  82008. */
  82009. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  82010. private _getGLTFTextureSampler;
  82011. private _getGLTFTextureWrapMode;
  82012. private _getGLTFTextureWrapModesSampler;
  82013. /**
  82014. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  82015. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  82016. * @param mimeType mime type to use for the textures
  82017. * @param images array of glTF image interfaces
  82018. * @param textures array of glTF texture interfaces
  82019. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  82020. * @param imageData map of image file name to data
  82021. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82022. * @returns glTF PBR Metallic Roughness factors
  82023. */
  82024. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  82025. /**
  82026. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  82027. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  82028. * @param mimeType mime type to use for the textures
  82029. * @param images array of glTF image interfaces
  82030. * @param textures array of glTF texture interfaces
  82031. * @param materials array of glTF material interfaces
  82032. * @param imageData map of image file name to data
  82033. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  82034. */
  82035. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  82036. private setMetallicRoughnessPbrMaterial;
  82037. private getPixelsFromTexture;
  82038. /**
  82039. * Extracts a texture from a Babylon texture into file data and glTF data
  82040. * @param babylonTexture Babylon texture to extract
  82041. * @param mimeType Mime Type of the babylonTexture
  82042. * @return glTF texture info, or null if the texture format is not supported
  82043. */
  82044. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  82045. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  82046. /**
  82047. * Builds a texture from base64 string
  82048. * @param base64Texture base64 texture string
  82049. * @param baseTextureName Name to use for the texture
  82050. * @param mimeType image mime type for the texture
  82051. * @param images array of images
  82052. * @param textures array of textures
  82053. * @param imageData map of image data
  82054. * @returns glTF texture info, or null if the texture format is not supported
  82055. */
  82056. private _getTextureInfoFromBase64;
  82057. }
  82058. }
  82059. declare module BABYLON {
  82060. /**
  82061. * Class for holding and downloading glTF file data
  82062. */
  82063. export class GLTFData {
  82064. /**
  82065. * Object which contains the file name as the key and its data as the value
  82066. */
  82067. glTFFiles: {
  82068. [fileName: string]: string | Blob;
  82069. };
  82070. /**
  82071. * Initializes the glTF file object
  82072. */
  82073. constructor();
  82074. /**
  82075. * Downloads the glTF data as files based on their names and data
  82076. */
  82077. downloadFiles(): void;
  82078. }
  82079. }
  82080. declare module BABYLON {
  82081. /**
  82082. * Holds a collection of exporter options and parameters
  82083. */
  82084. export interface IExportOptions {
  82085. /**
  82086. * Function which indicates whether a babylon node should be exported or not
  82087. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  82088. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  82089. */
  82090. shouldExportNode?(node: Node): boolean;
  82091. /**
  82092. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  82093. * @param metadata source metadata to read from
  82094. * @returns the data to store to glTF node extras
  82095. */
  82096. metadataSelector?(metadata: any): any;
  82097. /**
  82098. * The sample rate to bake animation curves
  82099. */
  82100. animationSampleRate?: number;
  82101. /**
  82102. * Begin serialization without waiting for the scene to be ready
  82103. */
  82104. exportWithoutWaitingForScene?: boolean;
  82105. /**
  82106. * Indicates if coordinate system swapping root nodes should be included in export
  82107. */
  82108. includeCoordinateSystemConversionNodes?: boolean;
  82109. }
  82110. /**
  82111. * Class for generating glTF data from a Babylon scene.
  82112. */
  82113. export class GLTF2Export {
  82114. /**
  82115. * Exports the geometry of the scene to .gltf file format asynchronously
  82116. * @param scene Babylon scene with scene hierarchy information
  82117. * @param filePrefix File prefix to use when generating the glTF file
  82118. * @param options Exporter options
  82119. * @returns Returns an object with a .gltf file and associates texture names
  82120. * as keys and their data and paths as values
  82121. */
  82122. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  82123. private static _PreExportAsync;
  82124. private static _PostExportAsync;
  82125. /**
  82126. * Exports the geometry of the scene to .glb file format asychronously
  82127. * @param scene Babylon scene with scene hierarchy information
  82128. * @param filePrefix File prefix to use when generating glb file
  82129. * @param options Exporter options
  82130. * @returns Returns an object with a .glb filename as key and data as value
  82131. */
  82132. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  82133. }
  82134. }
  82135. declare module BABYLON.GLTF2.Exporter {
  82136. /**
  82137. * @hidden
  82138. */
  82139. export class _GLTFUtilities {
  82140. /**
  82141. * Creates a buffer view based on the supplied arguments
  82142. * @param bufferIndex index value of the specified buffer
  82143. * @param byteOffset byte offset value
  82144. * @param byteLength byte length of the bufferView
  82145. * @param byteStride byte distance between conequential elements
  82146. * @param name name of the buffer view
  82147. * @returns bufferView for glTF
  82148. */
  82149. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  82150. /**
  82151. * Creates an accessor based on the supplied arguments
  82152. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  82153. * @param name The name of the accessor
  82154. * @param type The type of the accessor
  82155. * @param componentType The datatype of components in the attribute
  82156. * @param count The number of attributes referenced by this accessor
  82157. * @param byteOffset The offset relative to the start of the bufferView in bytes
  82158. * @param min Minimum value of each component in this attribute
  82159. * @param max Maximum value of each component in this attribute
  82160. * @returns accessor for glTF
  82161. */
  82162. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  82163. /**
  82164. * Calculates the minimum and maximum values of an array of position floats
  82165. * @param positions Positions array of a mesh
  82166. * @param vertexStart Starting vertex offset to calculate min and max values
  82167. * @param vertexCount Number of vertices to check for min and max values
  82168. * @returns min number array and max number array
  82169. */
  82170. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  82171. min: number[];
  82172. max: number[];
  82173. };
  82174. /**
  82175. * Converts a new right-handed Vector3
  82176. * @param vector vector3 array
  82177. * @returns right-handed Vector3
  82178. */
  82179. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  82180. /**
  82181. * Converts a Vector3 to right-handed
  82182. * @param vector Vector3 to convert to right-handed
  82183. */
  82184. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  82185. /**
  82186. * Converts a three element number array to right-handed
  82187. * @param vector number array to convert to right-handed
  82188. */
  82189. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  82190. /**
  82191. * Converts a new right-handed Vector3
  82192. * @param vector vector3 array
  82193. * @returns right-handed Vector3
  82194. */
  82195. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  82196. /**
  82197. * Converts a Vector3 to right-handed
  82198. * @param vector Vector3 to convert to right-handed
  82199. */
  82200. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  82201. /**
  82202. * Converts a three element number array to right-handed
  82203. * @param vector number array to convert to right-handed
  82204. */
  82205. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  82206. /**
  82207. * Converts a Vector4 to right-handed
  82208. * @param vector Vector4 to convert to right-handed
  82209. */
  82210. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  82211. /**
  82212. * Converts a Vector4 to right-handed
  82213. * @param vector Vector4 to convert to right-handed
  82214. */
  82215. static _GetRightHandedArray4FromRef(vector: number[]): void;
  82216. /**
  82217. * Converts a Quaternion to right-handed
  82218. * @param quaternion Source quaternion to convert to right-handed
  82219. */
  82220. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  82221. /**
  82222. * Converts a Quaternion to right-handed
  82223. * @param quaternion Source quaternion to convert to right-handed
  82224. */
  82225. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  82226. static _NormalizeTangentFromRef(tangent: Vector4): void;
  82227. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  82228. }
  82229. }
  82230. declare module BABYLON.GLTF2.Exporter {
  82231. /**
  82232. * Converts Babylon Scene into glTF 2.0.
  82233. * @hidden
  82234. */
  82235. export class _Exporter {
  82236. /**
  82237. * Stores the glTF to export
  82238. */
  82239. _glTF: IGLTF;
  82240. /**
  82241. * Stores all generated buffer views, which represents views into the main glTF buffer data
  82242. */
  82243. _bufferViews: IBufferView[];
  82244. /**
  82245. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  82246. */
  82247. _accessors: IAccessor[];
  82248. /**
  82249. * Stores all the generated nodes, which contains transform and/or mesh information per node
  82250. */
  82251. _nodes: INode[];
  82252. /**
  82253. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  82254. */
  82255. private _scenes;
  82256. /**
  82257. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  82258. */
  82259. private _meshes;
  82260. /**
  82261. * Stores all the generated material information, which represents the appearance of each primitive
  82262. */
  82263. _materials: IMaterial[];
  82264. _materialMap: {
  82265. [materialID: number]: number;
  82266. };
  82267. /**
  82268. * Stores all the generated texture information, which is referenced by glTF materials
  82269. */
  82270. _textures: ITexture[];
  82271. /**
  82272. * Stores all the generated image information, which is referenced by glTF textures
  82273. */
  82274. _images: IImage[];
  82275. /**
  82276. * Stores all the texture samplers
  82277. */
  82278. _samplers: ISampler[];
  82279. /**
  82280. * Stores all the generated glTF skins
  82281. */
  82282. _skins: ISkin[];
  82283. /**
  82284. * Stores all the generated animation samplers, which is referenced by glTF animations
  82285. */
  82286. /**
  82287. * Stores the animations for glTF models
  82288. */
  82289. private _animations;
  82290. /**
  82291. * Stores the total amount of bytes stored in the glTF buffer
  82292. */
  82293. private _totalByteLength;
  82294. /**
  82295. * Stores a reference to the Babylon scene containing the source geometry and material information
  82296. */
  82297. _babylonScene: Scene;
  82298. /**
  82299. * Stores a map of the image data, where the key is the file name and the value
  82300. * is the image data
  82301. */
  82302. _imageData: {
  82303. [fileName: string]: {
  82304. data: Uint8Array;
  82305. mimeType: ImageMimeType;
  82306. };
  82307. };
  82308. /**
  82309. * Stores a map of the unique id of a node to its index in the node array
  82310. */
  82311. _nodeMap: {
  82312. [key: number]: number;
  82313. };
  82314. /**
  82315. * Specifies if the source Babylon scene was left handed, and needed conversion.
  82316. */
  82317. _convertToRightHandedSystem: boolean;
  82318. /**
  82319. * Specifies if a Babylon node should be converted to right-handed on export
  82320. */
  82321. _convertToRightHandedSystemMap: {
  82322. [nodeId: number]: boolean;
  82323. };
  82324. _includeCoordinateSystemConversionNodes: boolean;
  82325. /**
  82326. * Baked animation sample rate
  82327. */
  82328. private _animationSampleRate;
  82329. private _options;
  82330. private _localEngine;
  82331. _glTFMaterialExporter: _GLTFMaterialExporter;
  82332. private _extensions;
  82333. private static _ExtensionNames;
  82334. private static _ExtensionFactories;
  82335. private _applyExtension;
  82336. private _applyExtensions;
  82337. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  82338. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  82339. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  82340. [key: number]: number;
  82341. }): Promise<Nullable<INode>>;
  82342. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  82343. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  82344. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  82345. private _forEachExtensions;
  82346. private _extensionsOnExporting;
  82347. /**
  82348. * Load glTF serializer extensions
  82349. */
  82350. private _loadExtensions;
  82351. /**
  82352. * Creates a glTF Exporter instance, which can accept optional exporter options
  82353. * @param babylonScene Babylon scene object
  82354. * @param options Options to modify the behavior of the exporter
  82355. */
  82356. constructor(babylonScene: Scene, options?: IExportOptions);
  82357. dispose(): void;
  82358. /**
  82359. * Registers a glTF exporter extension
  82360. * @param name Name of the extension to export
  82361. * @param factory The factory function that creates the exporter extension
  82362. */
  82363. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  82364. /**
  82365. * Un-registers an exporter extension
  82366. * @param name The name fo the exporter extension
  82367. * @returns A boolean indicating whether the extension has been un-registered
  82368. */
  82369. static UnregisterExtension(name: string): boolean;
  82370. /**
  82371. * Lazy load a local engine
  82372. */
  82373. _getLocalEngine(): Engine;
  82374. private reorderIndicesBasedOnPrimitiveMode;
  82375. /**
  82376. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  82377. * clock-wise during export to glTF
  82378. * @param submesh BabylonJS submesh
  82379. * @param primitiveMode Primitive mode of the mesh
  82380. * @param sideOrientation the winding order of the submesh
  82381. * @param vertexBufferKind The type of vertex attribute
  82382. * @param meshAttributeArray The vertex attribute data
  82383. * @param byteOffset The offset to the binary data
  82384. * @param binaryWriter The binary data for the glTF file
  82385. * @param convertToRightHandedSystem Converts the values to right-handed
  82386. */
  82387. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  82388. /**
  82389. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  82390. * clock-wise during export to glTF
  82391. * @param submesh BabylonJS submesh
  82392. * @param primitiveMode Primitive mode of the mesh
  82393. * @param sideOrientation the winding order of the submesh
  82394. * @param vertexBufferKind The type of vertex attribute
  82395. * @param meshAttributeArray The vertex attribute data
  82396. * @param byteOffset The offset to the binary data
  82397. * @param binaryWriter The binary data for the glTF file
  82398. * @param convertToRightHandedSystem Converts the values to right-handed
  82399. */
  82400. private reorderTriangleFillMode;
  82401. /**
  82402. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  82403. * clock-wise during export to glTF
  82404. * @param submesh BabylonJS submesh
  82405. * @param primitiveMode Primitive mode of the mesh
  82406. * @param sideOrientation the winding order of the submesh
  82407. * @param vertexBufferKind The type of vertex attribute
  82408. * @param meshAttributeArray The vertex attribute data
  82409. * @param byteOffset The offset to the binary data
  82410. * @param binaryWriter The binary data for the glTF file
  82411. * @param convertToRightHandedSystem Converts the values to right-handed
  82412. */
  82413. private reorderTriangleStripDrawMode;
  82414. /**
  82415. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  82416. * clock-wise during export to glTF
  82417. * @param submesh BabylonJS submesh
  82418. * @param primitiveMode Primitive mode of the mesh
  82419. * @param sideOrientation the winding order of the submesh
  82420. * @param vertexBufferKind The type of vertex attribute
  82421. * @param meshAttributeArray The vertex attribute data
  82422. * @param byteOffset The offset to the binary data
  82423. * @param binaryWriter The binary data for the glTF file
  82424. * @param convertToRightHandedSystem Converts the values to right-handed
  82425. */
  82426. private reorderTriangleFanMode;
  82427. /**
  82428. * Writes the vertex attribute data to binary
  82429. * @param vertices The vertices to write to the binary writer
  82430. * @param byteOffset The offset into the binary writer to overwrite binary data
  82431. * @param vertexAttributeKind The vertex attribute type
  82432. * @param meshAttributeArray The vertex attribute data
  82433. * @param binaryWriter The writer containing the binary data
  82434. * @param convertToRightHandedSystem Converts the values to right-handed
  82435. */
  82436. private writeVertexAttributeData;
  82437. /**
  82438. * Writes mesh attribute data to a data buffer
  82439. * Returns the bytelength of the data
  82440. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  82441. * @param meshAttributeArray Array containing the attribute data
  82442. * @param byteStride Specifies the space between data
  82443. * @param binaryWriter The buffer to write the binary data to
  82444. * @param convertToRightHandedSystem Converts the values to right-handed
  82445. */
  82446. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  82447. /**
  82448. * Generates glTF json data
  82449. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  82450. * @param glTFPrefix Text to use when prefixing a glTF file
  82451. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  82452. * @returns json data as string
  82453. */
  82454. private generateJSON;
  82455. /**
  82456. * Generates data for .gltf and .bin files based on the glTF prefix string
  82457. * @param glTFPrefix Text to use when prefixing a glTF file
  82458. * @param dispose Dispose the exporter
  82459. * @returns GLTFData with glTF file data
  82460. */
  82461. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  82462. /**
  82463. * Creates a binary buffer for glTF
  82464. * @returns array buffer for binary data
  82465. */
  82466. private _generateBinaryAsync;
  82467. /**
  82468. * Pads the number to a multiple of 4
  82469. * @param num number to pad
  82470. * @returns padded number
  82471. */
  82472. private _getPadding;
  82473. /**
  82474. * @hidden
  82475. */
  82476. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  82477. /**
  82478. * Sets the TRS for each node
  82479. * @param node glTF Node for storing the transformation data
  82480. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  82481. * @param convertToRightHandedSystem Converts the values to right-handed
  82482. */
  82483. private setNodeTransformation;
  82484. private getVertexBufferFromMesh;
  82485. /**
  82486. * Creates a bufferview based on the vertices type for the Babylon mesh
  82487. * @param kind Indicates the type of vertices data
  82488. * @param componentType Indicates the numerical type used to store the data
  82489. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  82490. * @param binaryWriter The buffer to write the bufferview data to
  82491. * @param convertToRightHandedSystem Converts the values to right-handed
  82492. */
  82493. private createBufferViewKind;
  82494. /**
  82495. * The primitive mode of the Babylon mesh
  82496. * @param babylonMesh The BabylonJS mesh
  82497. */
  82498. private getMeshPrimitiveMode;
  82499. /**
  82500. * Sets the primitive mode of the glTF mesh primitive
  82501. * @param meshPrimitive glTF mesh primitive
  82502. * @param primitiveMode The primitive mode
  82503. */
  82504. private setPrimitiveMode;
  82505. /**
  82506. * Sets the vertex attribute accessor based of the glTF mesh primitive
  82507. * @param meshPrimitive glTF mesh primitive
  82508. * @param attributeKind vertex attribute
  82509. * @returns boolean specifying if uv coordinates are present
  82510. */
  82511. private setAttributeKind;
  82512. /**
  82513. * Sets data for the primitive attributes of each submesh
  82514. * @param mesh glTF Mesh object to store the primitive attribute information
  82515. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  82516. * @param binaryWriter Buffer to write the attribute data to
  82517. * @param convertToRightHandedSystem Converts the values to right-handed
  82518. */
  82519. private setPrimitiveAttributesAsync;
  82520. /**
  82521. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  82522. * @param node The node to check
  82523. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  82524. */
  82525. private isBabylonCoordinateSystemConvertingNode;
  82526. /**
  82527. * Creates a glTF scene based on the array of meshes
  82528. * Returns the the total byte offset
  82529. * @param babylonScene Babylon scene to get the mesh data from
  82530. * @param binaryWriter Buffer to write binary data to
  82531. */
  82532. private createSceneAsync;
  82533. /**
  82534. * Creates a mapping of Node unique id to node index and handles animations
  82535. * @param babylonScene Babylon Scene
  82536. * @param nodes Babylon transform nodes
  82537. * @param binaryWriter Buffer to write binary data to
  82538. * @returns Node mapping of unique id to index
  82539. */
  82540. private createNodeMapAndAnimationsAsync;
  82541. /**
  82542. * Creates a glTF node from a Babylon mesh
  82543. * @param babylonMesh Source Babylon mesh
  82544. * @param binaryWriter Buffer for storing geometry data
  82545. * @param convertToRightHandedSystem Converts the values to right-handed
  82546. * @param nodeMap Node mapping of unique id to glTF node index
  82547. * @returns glTF node
  82548. */
  82549. private createNodeAsync;
  82550. /**
  82551. * Creates a glTF skin from a Babylon skeleton
  82552. * @param babylonScene Babylon Scene
  82553. * @param nodes Babylon transform nodes
  82554. * @param binaryWriter Buffer to write binary data to
  82555. * @returns Node mapping of unique id to index
  82556. */
  82557. private createSkinsAsync;
  82558. }
  82559. /**
  82560. * @hidden
  82561. *
  82562. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  82563. */
  82564. export class _BinaryWriter {
  82565. /**
  82566. * Array buffer which stores all binary data
  82567. */
  82568. private _arrayBuffer;
  82569. /**
  82570. * View of the array buffer
  82571. */
  82572. private _dataView;
  82573. /**
  82574. * byte offset of data in array buffer
  82575. */
  82576. private _byteOffset;
  82577. /**
  82578. * Initialize binary writer with an initial byte length
  82579. * @param byteLength Initial byte length of the array buffer
  82580. */
  82581. constructor(byteLength: number);
  82582. /**
  82583. * Resize the array buffer to the specified byte length
  82584. * @param byteLength
  82585. */
  82586. private resizeBuffer;
  82587. /**
  82588. * Get an array buffer with the length of the byte offset
  82589. * @returns ArrayBuffer resized to the byte offset
  82590. */
  82591. getArrayBuffer(): ArrayBuffer;
  82592. /**
  82593. * Get the byte offset of the array buffer
  82594. * @returns byte offset
  82595. */
  82596. getByteOffset(): number;
  82597. /**
  82598. * Stores an UInt8 in the array buffer
  82599. * @param entry
  82600. * @param byteOffset If defined, specifies where to set the value as an offset.
  82601. */
  82602. setUInt8(entry: number, byteOffset?: number): void;
  82603. /**
  82604. * Stores an UInt16 in the array buffer
  82605. * @param entry
  82606. * @param byteOffset If defined, specifies where to set the value as an offset.
  82607. */
  82608. setUInt16(entry: number, byteOffset?: number): void;
  82609. /**
  82610. * Gets an UInt32 in the array buffer
  82611. * @param entry
  82612. * @param byteOffset If defined, specifies where to set the value as an offset.
  82613. */
  82614. getUInt32(byteOffset: number): number;
  82615. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  82616. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  82617. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  82618. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  82619. /**
  82620. * Stores a Float32 in the array buffer
  82621. * @param entry
  82622. */
  82623. setFloat32(entry: number, byteOffset?: number): void;
  82624. /**
  82625. * Stores an UInt32 in the array buffer
  82626. * @param entry
  82627. * @param byteOffset If defined, specifies where to set the value as an offset.
  82628. */
  82629. setUInt32(entry: number, byteOffset?: number): void;
  82630. }
  82631. }
  82632. declare module BABYLON.GLTF2.Exporter {
  82633. /**
  82634. * @hidden
  82635. * Interface to store animation data.
  82636. */
  82637. export interface _IAnimationData {
  82638. /**
  82639. * Keyframe data.
  82640. */
  82641. inputs: number[];
  82642. /**
  82643. * Value data.
  82644. */
  82645. outputs: number[][];
  82646. /**
  82647. * Animation interpolation data.
  82648. */
  82649. samplerInterpolation: AnimationSamplerInterpolation;
  82650. /**
  82651. * Minimum keyframe value.
  82652. */
  82653. inputsMin: number;
  82654. /**
  82655. * Maximum keyframe value.
  82656. */
  82657. inputsMax: number;
  82658. }
  82659. /**
  82660. * @hidden
  82661. */
  82662. export interface _IAnimationInfo {
  82663. /**
  82664. * The target channel for the animation
  82665. */
  82666. animationChannelTargetPath: AnimationChannelTargetPath;
  82667. /**
  82668. * The glTF accessor type for the data.
  82669. */
  82670. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  82671. /**
  82672. * Specifies if quaternions should be used.
  82673. */
  82674. useQuaternion: boolean;
  82675. }
  82676. /**
  82677. * @hidden
  82678. * Utility class for generating glTF animation data from BabylonJS.
  82679. */
  82680. export class _GLTFAnimation {
  82681. /**
  82682. * @ignore
  82683. *
  82684. * Creates glTF channel animation from BabylonJS animation.
  82685. * @param babylonTransformNode - BabylonJS mesh.
  82686. * @param animation - animation.
  82687. * @param animationChannelTargetPath - The target animation channel.
  82688. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  82689. * @param useQuaternion - Specifies if quaternions are used.
  82690. * @returns nullable IAnimationData
  82691. */
  82692. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  82693. private static _DeduceAnimationInfo;
  82694. /**
  82695. * @ignore
  82696. * Create node animations from the transform node animations
  82697. * @param babylonNode
  82698. * @param runtimeGLTFAnimation
  82699. * @param idleGLTFAnimations
  82700. * @param nodeMap
  82701. * @param nodes
  82702. * @param binaryWriter
  82703. * @param bufferViews
  82704. * @param accessors
  82705. * @param convertToRightHandedSystem
  82706. * @param animationSampleRate
  82707. */
  82708. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  82709. [key: number]: number;
  82710. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  82711. /**
  82712. * @ignore
  82713. * Create node animations from the animation groups
  82714. * @param babylonScene
  82715. * @param glTFAnimations
  82716. * @param nodeMap
  82717. * @param nodes
  82718. * @param binaryWriter
  82719. * @param bufferViews
  82720. * @param accessors
  82721. * @param convertToRightHandedSystemMap
  82722. * @param animationSampleRate
  82723. */
  82724. static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  82725. [key: number]: number;
  82726. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  82727. [nodeId: number]: boolean;
  82728. }, animationSampleRate: number): void;
  82729. private static AddAnimation;
  82730. /**
  82731. * Create a baked animation
  82732. * @param babylonTransformNode BabylonJS mesh
  82733. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  82734. * @param animationChannelTargetPath animation target channel
  82735. * @param minFrame minimum animation frame
  82736. * @param maxFrame maximum animation frame
  82737. * @param fps frames per second of the animation
  82738. * @param inputs input key frames of the animation
  82739. * @param outputs output key frame data of the animation
  82740. * @param convertToRightHandedSystem converts the values to right-handed
  82741. * @param useQuaternion specifies if quaternions should be used
  82742. */
  82743. private static _CreateBakedAnimation;
  82744. private static _ConvertFactorToVector3OrQuaternion;
  82745. private static _SetInterpolatedValue;
  82746. /**
  82747. * Creates linear animation from the animation key frames
  82748. * @param babylonTransformNode BabylonJS mesh
  82749. * @param animation BabylonJS animation
  82750. * @param animationChannelTargetPath The target animation channel
  82751. * @param frameDelta The difference between the last and first frame of the animation
  82752. * @param inputs Array to store the key frame times
  82753. * @param outputs Array to store the key frame data
  82754. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  82755. * @param useQuaternion Specifies if quaternions are used in the animation
  82756. */
  82757. private static _CreateLinearOrStepAnimation;
  82758. /**
  82759. * Creates cubic spline animation from the animation key frames
  82760. * @param babylonTransformNode BabylonJS mesh
  82761. * @param animation BabylonJS animation
  82762. * @param animationChannelTargetPath The target animation channel
  82763. * @param frameDelta The difference between the last and first frame of the animation
  82764. * @param inputs Array to store the key frame times
  82765. * @param outputs Array to store the key frame data
  82766. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  82767. * @param useQuaternion Specifies if quaternions are used in the animation
  82768. */
  82769. private static _CreateCubicSplineAnimation;
  82770. private static _GetBasePositionRotationOrScale;
  82771. /**
  82772. * Adds a key frame value
  82773. * @param keyFrame
  82774. * @param animation
  82775. * @param outputs
  82776. * @param animationChannelTargetPath
  82777. * @param basePositionRotationOrScale
  82778. * @param convertToRightHandedSystem
  82779. * @param useQuaternion
  82780. */
  82781. private static _AddKeyframeValue;
  82782. /**
  82783. * Determine the interpolation based on the key frames
  82784. * @param keyFrames
  82785. * @param animationChannelTargetPath
  82786. * @param useQuaternion
  82787. */
  82788. private static _DeduceInterpolation;
  82789. /**
  82790. * Adds an input tangent or output tangent to the output data
  82791. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  82792. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  82793. * @param outputs The animation data by keyframe
  82794. * @param animationChannelTargetPath The target animation channel
  82795. * @param interpolation The interpolation type
  82796. * @param keyFrame The key frame with the animation data
  82797. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  82798. * @param useQuaternion Specifies if quaternions are used
  82799. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  82800. */
  82801. private static AddSplineTangent;
  82802. /**
  82803. * Get the minimum and maximum key frames' frame values
  82804. * @param keyFrames animation key frames
  82805. * @returns the minimum and maximum key frame value
  82806. */
  82807. private static calculateMinMaxKeyFrames;
  82808. }
  82809. }
  82810. declare module BABYLON.GLTF2.Exporter {
  82811. /** @hidden */
  82812. export var textureTransformPixelShader: {
  82813. name: string;
  82814. shader: string;
  82815. };
  82816. }
  82817. declare module BABYLON.GLTF2.Exporter.Extensions {
  82818. /**
  82819. * @hidden
  82820. */
  82821. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  82822. private _recordedTextures;
  82823. /** Name of this extension */
  82824. readonly name: string;
  82825. /** Defines whether this extension is enabled */
  82826. enabled: boolean;
  82827. /** Defines whether this extension is required */
  82828. required: boolean;
  82829. /** Reference to the glTF exporter */
  82830. private _wasUsed;
  82831. constructor(exporter: _Exporter);
  82832. dispose(): void;
  82833. /** @hidden */
  82834. get wasUsed(): boolean;
  82835. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  82836. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  82837. /**
  82838. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  82839. * @param babylonTexture
  82840. * @param offset
  82841. * @param rotation
  82842. * @param scale
  82843. * @param scene
  82844. */
  82845. private _textureTransformTextureAsync;
  82846. }
  82847. }
  82848. declare module BABYLON.GLTF2.Exporter.Extensions {
  82849. /**
  82850. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  82851. */
  82852. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  82853. /** The name of this extension. */
  82854. readonly name: string;
  82855. /** Defines whether this extension is enabled. */
  82856. enabled: boolean;
  82857. /** Defines whether this extension is required */
  82858. required: boolean;
  82859. /** Reference to the glTF exporter */
  82860. private _exporter;
  82861. private _lights;
  82862. /** @hidden */
  82863. constructor(exporter: _Exporter);
  82864. /** @hidden */
  82865. dispose(): void;
  82866. /** @hidden */
  82867. get wasUsed(): boolean;
  82868. /** @hidden */
  82869. onExporting(): void;
  82870. /**
  82871. * Define this method to modify the default behavior when exporting a node
  82872. * @param context The context when exporting the node
  82873. * @param node glTF node
  82874. * @param babylonNode BabylonJS node
  82875. * @param nodeMap Node mapping of unique id to glTF node index
  82876. * @returns nullable INode promise
  82877. */
  82878. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  82879. [key: number]: number;
  82880. }): Promise<Nullable<INode>>;
  82881. }
  82882. }
  82883. declare module BABYLON.GLTF2.Exporter.Extensions {
  82884. /**
  82885. * @hidden
  82886. */
  82887. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  82888. /** Name of this extension */
  82889. readonly name: string;
  82890. /** Defines whether this extension is enabled */
  82891. enabled: boolean;
  82892. /** Defines whether this extension is required */
  82893. required: boolean;
  82894. /** Reference to the glTF exporter */
  82895. private _textureInfos;
  82896. private _exportedTextures;
  82897. private _wasUsed;
  82898. constructor(exporter: _Exporter);
  82899. dispose(): void;
  82900. /** @hidden */
  82901. get wasUsed(): boolean;
  82902. private _getTextureIndex;
  82903. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  82904. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  82905. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  82906. }
  82907. }
  82908. declare module BABYLON.GLTF2.Exporter.Extensions {
  82909. /**
  82910. * @hidden
  82911. */
  82912. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  82913. /** Name of this extension */
  82914. readonly name: string;
  82915. /** Defines whether this extension is enabled */
  82916. enabled: boolean;
  82917. /** Defines whether this extension is required */
  82918. required: boolean;
  82919. private _wasUsed;
  82920. constructor(exporter: _Exporter);
  82921. /** @hidden */
  82922. get wasUsed(): boolean;
  82923. dispose(): void;
  82924. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  82925. }
  82926. }
  82927. declare module BABYLON {
  82928. /**
  82929. * Class for generating STL data from a Babylon scene.
  82930. */
  82931. export class STLExport {
  82932. /**
  82933. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  82934. * @param meshes list defines the mesh to serialize
  82935. * @param download triggers the automatic download of the file.
  82936. * @param fileName changes the downloads fileName.
  82937. * @param binary changes the STL to a binary type.
  82938. * @param isLittleEndian toggle for binary type exporter.
  82939. * @returns the STL as UTF8 string
  82940. */
  82941. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  82942. }
  82943. }
  82944. declare module "babylonjs-gltf2interface" {
  82945. export = BABYLON.GLTF2;
  82946. }
  82947. /**
  82948. * Module for glTF 2.0 Interface
  82949. */
  82950. declare module BABYLON.GLTF2 {
  82951. /**
  82952. * The datatype of the components in the attribute
  82953. */
  82954. const enum AccessorComponentType {
  82955. /**
  82956. * Byte
  82957. */
  82958. BYTE = 5120,
  82959. /**
  82960. * Unsigned Byte
  82961. */
  82962. UNSIGNED_BYTE = 5121,
  82963. /**
  82964. * Short
  82965. */
  82966. SHORT = 5122,
  82967. /**
  82968. * Unsigned Short
  82969. */
  82970. UNSIGNED_SHORT = 5123,
  82971. /**
  82972. * Unsigned Int
  82973. */
  82974. UNSIGNED_INT = 5125,
  82975. /**
  82976. * Float
  82977. */
  82978. FLOAT = 5126,
  82979. }
  82980. /**
  82981. * Specifies if the attirbute is a scalar, vector, or matrix
  82982. */
  82983. const enum AccessorType {
  82984. /**
  82985. * Scalar
  82986. */
  82987. SCALAR = "SCALAR",
  82988. /**
  82989. * Vector2
  82990. */
  82991. VEC2 = "VEC2",
  82992. /**
  82993. * Vector3
  82994. */
  82995. VEC3 = "VEC3",
  82996. /**
  82997. * Vector4
  82998. */
  82999. VEC4 = "VEC4",
  83000. /**
  83001. * Matrix2x2
  83002. */
  83003. MAT2 = "MAT2",
  83004. /**
  83005. * Matrix3x3
  83006. */
  83007. MAT3 = "MAT3",
  83008. /**
  83009. * Matrix4x4
  83010. */
  83011. MAT4 = "MAT4",
  83012. }
  83013. /**
  83014. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  83015. */
  83016. const enum AnimationChannelTargetPath {
  83017. /**
  83018. * Translation
  83019. */
  83020. TRANSLATION = "translation",
  83021. /**
  83022. * Rotation
  83023. */
  83024. ROTATION = "rotation",
  83025. /**
  83026. * Scale
  83027. */
  83028. SCALE = "scale",
  83029. /**
  83030. * Weights
  83031. */
  83032. WEIGHTS = "weights",
  83033. }
  83034. /**
  83035. * Interpolation algorithm
  83036. */
  83037. const enum AnimationSamplerInterpolation {
  83038. /**
  83039. * The animated values are linearly interpolated between keyframes
  83040. */
  83041. LINEAR = "LINEAR",
  83042. /**
  83043. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  83044. */
  83045. STEP = "STEP",
  83046. /**
  83047. * The animation's interpolation is computed using a cubic spline with specified tangents
  83048. */
  83049. CUBICSPLINE = "CUBICSPLINE",
  83050. }
  83051. /**
  83052. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  83053. */
  83054. const enum CameraType {
  83055. /**
  83056. * A perspective camera containing properties to create a perspective projection matrix
  83057. */
  83058. PERSPECTIVE = "perspective",
  83059. /**
  83060. * An orthographic camera containing properties to create an orthographic projection matrix
  83061. */
  83062. ORTHOGRAPHIC = "orthographic",
  83063. }
  83064. /**
  83065. * The mime-type of the image
  83066. */
  83067. const enum ImageMimeType {
  83068. /**
  83069. * JPEG Mime-type
  83070. */
  83071. JPEG = "image/jpeg",
  83072. /**
  83073. * PNG Mime-type
  83074. */
  83075. PNG = "image/png",
  83076. }
  83077. /**
  83078. * The alpha rendering mode of the material
  83079. */
  83080. const enum MaterialAlphaMode {
  83081. /**
  83082. * The alpha value is ignored and the rendered output is fully opaque
  83083. */
  83084. OPAQUE = "OPAQUE",
  83085. /**
  83086. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  83087. */
  83088. MASK = "MASK",
  83089. /**
  83090. * 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)
  83091. */
  83092. BLEND = "BLEND",
  83093. }
  83094. /**
  83095. * The type of the primitives to render
  83096. */
  83097. const enum MeshPrimitiveMode {
  83098. /**
  83099. * Points
  83100. */
  83101. POINTS = 0,
  83102. /**
  83103. * Lines
  83104. */
  83105. LINES = 1,
  83106. /**
  83107. * Line Loop
  83108. */
  83109. LINE_LOOP = 2,
  83110. /**
  83111. * Line Strip
  83112. */
  83113. LINE_STRIP = 3,
  83114. /**
  83115. * Triangles
  83116. */
  83117. TRIANGLES = 4,
  83118. /**
  83119. * Triangle Strip
  83120. */
  83121. TRIANGLE_STRIP = 5,
  83122. /**
  83123. * Triangle Fan
  83124. */
  83125. TRIANGLE_FAN = 6,
  83126. }
  83127. /**
  83128. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  83129. */
  83130. const enum TextureMagFilter {
  83131. /**
  83132. * Nearest
  83133. */
  83134. NEAREST = 9728,
  83135. /**
  83136. * Linear
  83137. */
  83138. LINEAR = 9729,
  83139. }
  83140. /**
  83141. * Minification filter. All valid values correspond to WebGL enums
  83142. */
  83143. const enum TextureMinFilter {
  83144. /**
  83145. * Nearest
  83146. */
  83147. NEAREST = 9728,
  83148. /**
  83149. * Linear
  83150. */
  83151. LINEAR = 9729,
  83152. /**
  83153. * Nearest Mip-Map Nearest
  83154. */
  83155. NEAREST_MIPMAP_NEAREST = 9984,
  83156. /**
  83157. * Linear Mipmap Nearest
  83158. */
  83159. LINEAR_MIPMAP_NEAREST = 9985,
  83160. /**
  83161. * Nearest Mipmap Linear
  83162. */
  83163. NEAREST_MIPMAP_LINEAR = 9986,
  83164. /**
  83165. * Linear Mipmap Linear
  83166. */
  83167. LINEAR_MIPMAP_LINEAR = 9987,
  83168. }
  83169. /**
  83170. * S (U) wrapping mode. All valid values correspond to WebGL enums
  83171. */
  83172. const enum TextureWrapMode {
  83173. /**
  83174. * Clamp to Edge
  83175. */
  83176. CLAMP_TO_EDGE = 33071,
  83177. /**
  83178. * Mirrored Repeat
  83179. */
  83180. MIRRORED_REPEAT = 33648,
  83181. /**
  83182. * Repeat
  83183. */
  83184. REPEAT = 10497,
  83185. }
  83186. /**
  83187. * glTF Property
  83188. */
  83189. interface IProperty {
  83190. /**
  83191. * Dictionary object with extension-specific objects
  83192. */
  83193. extensions?: {
  83194. [key: string]: any;
  83195. };
  83196. /**
  83197. * Application-Specific data
  83198. */
  83199. extras?: any;
  83200. }
  83201. /**
  83202. * glTF Child of Root Property
  83203. */
  83204. interface IChildRootProperty extends IProperty {
  83205. /**
  83206. * The user-defined name of this object
  83207. */
  83208. name?: string;
  83209. }
  83210. /**
  83211. * Indices of those attributes that deviate from their initialization value
  83212. */
  83213. interface IAccessorSparseIndices extends IProperty {
  83214. /**
  83215. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  83216. */
  83217. bufferView: number;
  83218. /**
  83219. * The offset relative to the start of the bufferView in bytes. Must be aligned
  83220. */
  83221. byteOffset?: number;
  83222. /**
  83223. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  83224. */
  83225. componentType: AccessorComponentType;
  83226. }
  83227. /**
  83228. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  83229. */
  83230. interface IAccessorSparseValues extends IProperty {
  83231. /**
  83232. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  83233. */
  83234. bufferView: number;
  83235. /**
  83236. * The offset relative to the start of the bufferView in bytes. Must be aligned
  83237. */
  83238. byteOffset?: number;
  83239. }
  83240. /**
  83241. * Sparse storage of attributes that deviate from their initialization value
  83242. */
  83243. interface IAccessorSparse extends IProperty {
  83244. /**
  83245. * The number of attributes encoded in this sparse accessor
  83246. */
  83247. count: number;
  83248. /**
  83249. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  83250. */
  83251. indices: IAccessorSparseIndices;
  83252. /**
  83253. * 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
  83254. */
  83255. values: IAccessorSparseValues;
  83256. }
  83257. /**
  83258. * 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
  83259. */
  83260. interface IAccessor extends IChildRootProperty {
  83261. /**
  83262. * The index of the bufferview
  83263. */
  83264. bufferView?: number;
  83265. /**
  83266. * The offset relative to the start of the bufferView in bytes
  83267. */
  83268. byteOffset?: number;
  83269. /**
  83270. * The datatype of components in the attribute
  83271. */
  83272. componentType: AccessorComponentType;
  83273. /**
  83274. * Specifies whether integer data values should be normalized
  83275. */
  83276. normalized?: boolean;
  83277. /**
  83278. * The number of attributes referenced by this accessor
  83279. */
  83280. count: number;
  83281. /**
  83282. * Specifies if the attribute is a scalar, vector, or matrix
  83283. */
  83284. type: AccessorType;
  83285. /**
  83286. * Maximum value of each component in this attribute
  83287. */
  83288. max?: number[];
  83289. /**
  83290. * Minimum value of each component in this attribute
  83291. */
  83292. min?: number[];
  83293. /**
  83294. * Sparse storage of attributes that deviate from their initialization value
  83295. */
  83296. sparse?: IAccessorSparse;
  83297. }
  83298. /**
  83299. * Targets an animation's sampler at a node's property
  83300. */
  83301. interface IAnimationChannel extends IProperty {
  83302. /**
  83303. * The index of a sampler in this animation used to compute the value for the target
  83304. */
  83305. sampler: number;
  83306. /**
  83307. * The index of the node and TRS property to target
  83308. */
  83309. target: IAnimationChannelTarget;
  83310. }
  83311. /**
  83312. * The index of the node and TRS property that an animation channel targets
  83313. */
  83314. interface IAnimationChannelTarget extends IProperty {
  83315. /**
  83316. * The index of the node to target
  83317. */
  83318. node: number;
  83319. /**
  83320. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  83321. */
  83322. path: AnimationChannelTargetPath;
  83323. }
  83324. /**
  83325. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  83326. */
  83327. interface IAnimationSampler extends IProperty {
  83328. /**
  83329. * The index of an accessor containing keyframe input values, e.g., time
  83330. */
  83331. input: number;
  83332. /**
  83333. * Interpolation algorithm
  83334. */
  83335. interpolation?: AnimationSamplerInterpolation;
  83336. /**
  83337. * The index of an accessor, containing keyframe output values
  83338. */
  83339. output: number;
  83340. }
  83341. /**
  83342. * A keyframe animation
  83343. */
  83344. interface IAnimation extends IChildRootProperty {
  83345. /**
  83346. * An array of channels, each of which targets an animation's sampler at a node's property
  83347. */
  83348. channels: IAnimationChannel[];
  83349. /**
  83350. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  83351. */
  83352. samplers: IAnimationSampler[];
  83353. }
  83354. /**
  83355. * Metadata about the glTF asset
  83356. */
  83357. interface IAsset extends IChildRootProperty {
  83358. /**
  83359. * A copyright message suitable for display to credit the content creator
  83360. */
  83361. copyright?: string;
  83362. /**
  83363. * Tool that generated this glTF model. Useful for debugging
  83364. */
  83365. generator?: string;
  83366. /**
  83367. * The glTF version that this asset targets
  83368. */
  83369. version: string;
  83370. /**
  83371. * The minimum glTF version that this asset targets
  83372. */
  83373. minVersion?: string;
  83374. }
  83375. /**
  83376. * A buffer points to binary geometry, animation, or skins
  83377. */
  83378. interface IBuffer extends IChildRootProperty {
  83379. /**
  83380. * 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
  83381. */
  83382. uri?: string;
  83383. /**
  83384. * The length of the buffer in bytes
  83385. */
  83386. byteLength: number;
  83387. }
  83388. /**
  83389. * A view into a buffer generally representing a subset of the buffer
  83390. */
  83391. interface IBufferView extends IChildRootProperty {
  83392. /**
  83393. * The index of the buffer
  83394. */
  83395. buffer: number;
  83396. /**
  83397. * The offset into the buffer in bytes
  83398. */
  83399. byteOffset?: number;
  83400. /**
  83401. * The lenth of the bufferView in bytes
  83402. */
  83403. byteLength: number;
  83404. /**
  83405. * The stride, in bytes
  83406. */
  83407. byteStride?: number;
  83408. }
  83409. /**
  83410. * An orthographic camera containing properties to create an orthographic projection matrix
  83411. */
  83412. interface ICameraOrthographic extends IProperty {
  83413. /**
  83414. * The floating-point horizontal magnification of the view. Must not be zero
  83415. */
  83416. xmag: number;
  83417. /**
  83418. * The floating-point vertical magnification of the view. Must not be zero
  83419. */
  83420. ymag: number;
  83421. /**
  83422. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  83423. */
  83424. zfar: number;
  83425. /**
  83426. * The floating-point distance to the near clipping plane
  83427. */
  83428. znear: number;
  83429. }
  83430. /**
  83431. * A perspective camera containing properties to create a perspective projection matrix
  83432. */
  83433. interface ICameraPerspective extends IProperty {
  83434. /**
  83435. * The floating-point aspect ratio of the field of view
  83436. */
  83437. aspectRatio?: number;
  83438. /**
  83439. * The floating-point vertical field of view in radians
  83440. */
  83441. yfov: number;
  83442. /**
  83443. * The floating-point distance to the far clipping plane
  83444. */
  83445. zfar?: number;
  83446. /**
  83447. * The floating-point distance to the near clipping plane
  83448. */
  83449. znear: number;
  83450. }
  83451. /**
  83452. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  83453. */
  83454. interface ICamera extends IChildRootProperty {
  83455. /**
  83456. * An orthographic camera containing properties to create an orthographic projection matrix
  83457. */
  83458. orthographic?: ICameraOrthographic;
  83459. /**
  83460. * A perspective camera containing properties to create a perspective projection matrix
  83461. */
  83462. perspective?: ICameraPerspective;
  83463. /**
  83464. * Specifies if the camera uses a perspective or orthographic projection
  83465. */
  83466. type: CameraType;
  83467. }
  83468. /**
  83469. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  83470. */
  83471. interface IImage extends IChildRootProperty {
  83472. /**
  83473. * 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
  83474. */
  83475. uri?: string;
  83476. /**
  83477. * The image's MIME type
  83478. */
  83479. mimeType?: ImageMimeType;
  83480. /**
  83481. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  83482. */
  83483. bufferView?: number;
  83484. }
  83485. /**
  83486. * Material Normal Texture Info
  83487. */
  83488. interface IMaterialNormalTextureInfo extends ITextureInfo {
  83489. /**
  83490. * The scalar multiplier applied to each normal vector of the normal texture
  83491. */
  83492. scale?: number;
  83493. }
  83494. /**
  83495. * Material Occlusion Texture Info
  83496. */
  83497. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  83498. /**
  83499. * A scalar multiplier controlling the amount of occlusion applied
  83500. */
  83501. strength?: number;
  83502. }
  83503. /**
  83504. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  83505. */
  83506. interface IMaterialPbrMetallicRoughness {
  83507. /**
  83508. * The material's base color factor
  83509. */
  83510. baseColorFactor?: number[];
  83511. /**
  83512. * The base color texture
  83513. */
  83514. baseColorTexture?: ITextureInfo;
  83515. /**
  83516. * The metalness of the material
  83517. */
  83518. metallicFactor?: number;
  83519. /**
  83520. * The roughness of the material
  83521. */
  83522. roughnessFactor?: number;
  83523. /**
  83524. * The metallic-roughness texture
  83525. */
  83526. metallicRoughnessTexture?: ITextureInfo;
  83527. }
  83528. /**
  83529. * The material appearance of a primitive
  83530. */
  83531. interface IMaterial extends IChildRootProperty {
  83532. /**
  83533. * 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
  83534. */
  83535. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  83536. /**
  83537. * The normal map texture
  83538. */
  83539. normalTexture?: IMaterialNormalTextureInfo;
  83540. /**
  83541. * The occlusion map texture
  83542. */
  83543. occlusionTexture?: IMaterialOcclusionTextureInfo;
  83544. /**
  83545. * The emissive map texture
  83546. */
  83547. emissiveTexture?: ITextureInfo;
  83548. /**
  83549. * 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
  83550. */
  83551. emissiveFactor?: number[];
  83552. /**
  83553. * The alpha rendering mode of the material
  83554. */
  83555. alphaMode?: MaterialAlphaMode;
  83556. /**
  83557. * The alpha cutoff value of the material
  83558. */
  83559. alphaCutoff?: number;
  83560. /**
  83561. * Specifies whether the material is double sided
  83562. */
  83563. doubleSided?: boolean;
  83564. }
  83565. /**
  83566. * Geometry to be rendered with the given material
  83567. */
  83568. interface IMeshPrimitive extends IProperty {
  83569. /**
  83570. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  83571. */
  83572. attributes: {
  83573. [name: string]: number;
  83574. };
  83575. /**
  83576. * The index of the accessor that contains the indices
  83577. */
  83578. indices?: number;
  83579. /**
  83580. * The index of the material to apply to this primitive when rendering
  83581. */
  83582. material?: number;
  83583. /**
  83584. * The type of primitives to render. All valid values correspond to WebGL enums
  83585. */
  83586. mode?: MeshPrimitiveMode;
  83587. /**
  83588. * 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
  83589. */
  83590. targets?: {
  83591. [name: string]: number;
  83592. }[];
  83593. }
  83594. /**
  83595. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  83596. */
  83597. interface IMesh extends IChildRootProperty {
  83598. /**
  83599. * An array of primitives, each defining geometry to be rendered with a material
  83600. */
  83601. primitives: IMeshPrimitive[];
  83602. /**
  83603. * Array of weights to be applied to the Morph Targets
  83604. */
  83605. weights?: number[];
  83606. }
  83607. /**
  83608. * A node in the node hierarchy
  83609. */
  83610. interface INode extends IChildRootProperty {
  83611. /**
  83612. * The index of the camera referenced by this node
  83613. */
  83614. camera?: number;
  83615. /**
  83616. * The indices of this node's children
  83617. */
  83618. children?: number[];
  83619. /**
  83620. * The index of the skin referenced by this node
  83621. */
  83622. skin?: number;
  83623. /**
  83624. * A floating-point 4x4 transformation matrix stored in column-major order
  83625. */
  83626. matrix?: number[];
  83627. /**
  83628. * The index of the mesh in this node
  83629. */
  83630. mesh?: number;
  83631. /**
  83632. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  83633. */
  83634. rotation?: number[];
  83635. /**
  83636. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  83637. */
  83638. scale?: number[];
  83639. /**
  83640. * The node's translation along the x, y, and z axes
  83641. */
  83642. translation?: number[];
  83643. /**
  83644. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  83645. */
  83646. weights?: number[];
  83647. }
  83648. /**
  83649. * Texture sampler properties for filtering and wrapping modes
  83650. */
  83651. interface ISampler extends IChildRootProperty {
  83652. /**
  83653. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  83654. */
  83655. magFilter?: TextureMagFilter;
  83656. /**
  83657. * Minification filter. All valid values correspond to WebGL enums
  83658. */
  83659. minFilter?: TextureMinFilter;
  83660. /**
  83661. * S (U) wrapping mode. All valid values correspond to WebGL enums
  83662. */
  83663. wrapS?: TextureWrapMode;
  83664. /**
  83665. * T (V) wrapping mode. All valid values correspond to WebGL enums
  83666. */
  83667. wrapT?: TextureWrapMode;
  83668. }
  83669. /**
  83670. * The root nodes of a scene
  83671. */
  83672. interface IScene extends IChildRootProperty {
  83673. /**
  83674. * The indices of each root node
  83675. */
  83676. nodes: number[];
  83677. }
  83678. /**
  83679. * Joints and matrices defining a skin
  83680. */
  83681. interface ISkin extends IChildRootProperty {
  83682. /**
  83683. * 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
  83684. */
  83685. inverseBindMatrices?: number;
  83686. /**
  83687. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  83688. */
  83689. skeleton?: number;
  83690. /**
  83691. * 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)
  83692. */
  83693. joints: number[];
  83694. }
  83695. /**
  83696. * A texture and its sampler
  83697. */
  83698. interface ITexture extends IChildRootProperty {
  83699. /**
  83700. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  83701. */
  83702. sampler?: number;
  83703. /**
  83704. * The index of the image used by this texture
  83705. */
  83706. source: number;
  83707. }
  83708. /**
  83709. * Reference to a texture
  83710. */
  83711. interface ITextureInfo extends IProperty {
  83712. /**
  83713. * The index of the texture
  83714. */
  83715. index: number;
  83716. /**
  83717. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  83718. */
  83719. texCoord?: number;
  83720. }
  83721. /**
  83722. * The root object for a glTF asset
  83723. */
  83724. interface IGLTF extends IProperty {
  83725. /**
  83726. * An array of accessors. An accessor is a typed view into a bufferView
  83727. */
  83728. accessors?: IAccessor[];
  83729. /**
  83730. * An array of keyframe animations
  83731. */
  83732. animations?: IAnimation[];
  83733. /**
  83734. * Metadata about the glTF asset
  83735. */
  83736. asset: IAsset;
  83737. /**
  83738. * An array of buffers. A buffer points to binary geometry, animation, or skins
  83739. */
  83740. buffers?: IBuffer[];
  83741. /**
  83742. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  83743. */
  83744. bufferViews?: IBufferView[];
  83745. /**
  83746. * An array of cameras
  83747. */
  83748. cameras?: ICamera[];
  83749. /**
  83750. * Names of glTF extensions used somewhere in this asset
  83751. */
  83752. extensionsUsed?: string[];
  83753. /**
  83754. * Names of glTF extensions required to properly load this asset
  83755. */
  83756. extensionsRequired?: string[];
  83757. /**
  83758. * An array of images. An image defines data used to create a texture
  83759. */
  83760. images?: IImage[];
  83761. /**
  83762. * An array of materials. A material defines the appearance of a primitive
  83763. */
  83764. materials?: IMaterial[];
  83765. /**
  83766. * An array of meshes. A mesh is a set of primitives to be rendered
  83767. */
  83768. meshes?: IMesh[];
  83769. /**
  83770. * An array of nodes
  83771. */
  83772. nodes?: INode[];
  83773. /**
  83774. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  83775. */
  83776. samplers?: ISampler[];
  83777. /**
  83778. * The index of the default scene
  83779. */
  83780. scene?: number;
  83781. /**
  83782. * An array of scenes
  83783. */
  83784. scenes?: IScene[];
  83785. /**
  83786. * An array of skins. A skin is defined by joints and matrices
  83787. */
  83788. skins?: ISkin[];
  83789. /**
  83790. * An array of textures
  83791. */
  83792. textures?: ITexture[];
  83793. }
  83794. /**
  83795. * The glTF validation results
  83796. * @ignore
  83797. */
  83798. interface IGLTFValidationResults {
  83799. info: {
  83800. generator: string;
  83801. hasAnimations: boolean;
  83802. hasDefaultScene: boolean;
  83803. hasMaterials: boolean;
  83804. hasMorphTargets: boolean;
  83805. hasSkins: boolean;
  83806. hasTextures: boolean;
  83807. maxAttributesUsed: number;
  83808. primitivesCount: number
  83809. };
  83810. issues: {
  83811. messages: Array<string>;
  83812. numErrors: number;
  83813. numHints: number;
  83814. numInfos: number;
  83815. numWarnings: number;
  83816. truncated: boolean
  83817. };
  83818. mimeType: string;
  83819. uri: string;
  83820. validatedAt: string;
  83821. validatorVersion: string;
  83822. }
  83823. /**
  83824. * The glTF validation options
  83825. */
  83826. interface IGLTFValidationOptions {
  83827. /** Uri to use */
  83828. uri?: string;
  83829. /** Function used to load external resources */
  83830. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  83831. /** Boolean indicating that we need to validate accessor data */
  83832. validateAccessorData?: boolean;
  83833. /** max number of issues allowed */
  83834. maxIssues?: number;
  83835. /** Ignored issues */
  83836. ignoredIssues?: Array<string>;
  83837. /** Value to override severy settings */
  83838. severityOverrides?: Object;
  83839. }
  83840. /**
  83841. * The glTF validator object
  83842. * @ignore
  83843. */
  83844. interface IGLTFValidator {
  83845. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  83846. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  83847. }
  83848. /**
  83849. * Interfaces from the EXT_lights_image_based extension
  83850. */
  83851. /** @hidden */
  83852. interface IEXTLightsImageBased_LightReferenceImageBased {
  83853. light: number;
  83854. }
  83855. /** @hidden */
  83856. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  83857. intensity: number;
  83858. rotation: number[];
  83859. specularImageSize: number;
  83860. specularImages: number[][];
  83861. irradianceCoefficients: number[][];
  83862. }
  83863. /** @hidden */
  83864. interface IEXTLightsImageBased {
  83865. lights: IEXTLightsImageBased_LightImageBased[];
  83866. }
  83867. /**
  83868. * Interfaces from the EXT_mesh_gpu_instancing extension
  83869. * !!! Experimental Extension Subject to Changes !!!
  83870. */
  83871. /** @hidden */
  83872. interface IEXTMeshGpuInstancing {
  83873. mesh?: number;
  83874. attributes: { [name: string]: number };
  83875. }
  83876. /**
  83877. * Interfaces from the KHR_draco_mesh_compression extension
  83878. */
  83879. /** @hidden */
  83880. interface IKHRDracoMeshCompression {
  83881. bufferView: number;
  83882. attributes: { [name: string]: number };
  83883. }
  83884. /**
  83885. * Interfaces from the KHR_lights_punctual extension
  83886. */
  83887. /** @hidden */
  83888. const enum IKHRLightsPunctual_LightType {
  83889. DIRECTIONAL = "directional",
  83890. POINT = "point",
  83891. SPOT = "spot"
  83892. }
  83893. /** @hidden */
  83894. interface IKHRLightsPunctual_LightReference {
  83895. light: number;
  83896. }
  83897. /** @hidden */
  83898. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  83899. type: IKHRLightsPunctual_LightType;
  83900. color?: number[];
  83901. intensity?: number;
  83902. range?: number;
  83903. spot?: {
  83904. innerConeAngle?: number;
  83905. outerConeAngle?: number;
  83906. };
  83907. }
  83908. /** @hidden */
  83909. interface IKHRLightsPunctual {
  83910. lights: IKHRLightsPunctual_Light[];
  83911. }
  83912. /**
  83913. * Interfaces from the KHR_materials_clearcoat extension
  83914. * !!! Experimental Extension Subject to Changes !!!
  83915. */
  83916. /** @hidden */
  83917. interface IKHRMaterialsClearcoat {
  83918. clearcoatFactor: number;
  83919. clearcoatTexture: ITextureInfo;
  83920. clearcoatRoughnessFactor: number;
  83921. clearcoatRoughnessTexture: ITextureInfo;
  83922. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  83923. }
  83924. /**
  83925. * Interfaces from the KHR_materials_ior extension
  83926. * !!! Experimental Extension Subject to Changes !!!
  83927. */
  83928. /** @hidden */
  83929. interface IKHRMaterialsIor {
  83930. ior: number;
  83931. }
  83932. /**
  83933. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  83934. */
  83935. /** @hidden */
  83936. interface IKHRMaterialsPbrSpecularGlossiness {
  83937. diffuseFactor: number[];
  83938. diffuseTexture: ITextureInfo;
  83939. specularFactor: number[];
  83940. glossinessFactor: number;
  83941. specularGlossinessTexture: ITextureInfo;
  83942. }
  83943. /**
  83944. * Interfaces from the KHR_materials_sheen extension
  83945. * !!! Experimental Extension Subject to Changes !!!
  83946. */
  83947. /** @hidden */
  83948. interface IKHRMaterialsSheen {
  83949. sheenColorFactor?: number[];
  83950. sheenTexture?: ITextureInfo;
  83951. sheenRoughnessFactor?: number;
  83952. }
  83953. /**
  83954. * Interfaces from the KHR_materials_specular extension
  83955. * !!! Experimental Extension Subject to Changes !!!
  83956. */
  83957. /** @hidden */
  83958. interface IKHRMaterialsSpecular {
  83959. specularFactor: number;
  83960. specularColorFactor: number[];
  83961. specularTexture: ITextureInfo;
  83962. }
  83963. /**
  83964. * Interfaces from the KHR_materials_transmission extension
  83965. * !!! Experimental Extension Subject to Changes !!!
  83966. */
  83967. /** @hidden */
  83968. interface IKHRMaterialsTransmission {
  83969. transmissionFactor?: number;
  83970. transmissionTexture?: ITextureInfo;
  83971. }
  83972. /**
  83973. * Interfaces from the KHR_materials_variants extension
  83974. * !!! Experimental Extension Subject to Changes !!!
  83975. */
  83976. /** @hidden */
  83977. interface IKHRMaterialVariants_Mapping {
  83978. variants: string[];
  83979. material: number;
  83980. }
  83981. /** @hidden */
  83982. interface IKHRMaterialVariants {
  83983. mapping: IKHRMaterialVariants_Mapping[];
  83984. }
  83985. /**
  83986. * Interfaces from the KHR_texture_basisu extension
  83987. * !!! Experimental Extension Subject to Changes !!!
  83988. */
  83989. /** @hidden */
  83990. interface IKHRTextureBasisU {
  83991. source: number;
  83992. }
  83993. /**
  83994. * Interfaces from the KHR_texture_transform extension
  83995. */
  83996. /** @hidden */
  83997. interface IKHRTextureTransform {
  83998. offset?: number[];
  83999. rotation?: number;
  84000. scale?: number[];
  84001. texCoord?: number;
  84002. }
  84003. /**
  84004. * Interfaces from the KHR_xmp extension
  84005. * !!! Experimental Extension Subject to Changes !!!
  84006. */
  84007. /** @hidden */
  84008. interface IKHRXmp_Data {
  84009. [key: string]: unknown;
  84010. }
  84011. /** @hidden */
  84012. interface IKHRXmp_Gltf {
  84013. packets: IKHRXmp_Data[];
  84014. }
  84015. /** @hidden */
  84016. interface IKHRXmp_Node {
  84017. packet: number;
  84018. }
  84019. /**
  84020. * Interfaces from the MSFT_audio_emitter extension
  84021. */
  84022. /** @hidden */
  84023. interface IMSFTAudioEmitter_ClipReference {
  84024. clip: number;
  84025. weight?: number;
  84026. }
  84027. /** @hidden */
  84028. interface IMSFTAudioEmitter_EmittersReference {
  84029. emitters: number[];
  84030. }
  84031. /** @hidden */
  84032. const enum IMSFTAudioEmitter_DistanceModel {
  84033. linear = "linear",
  84034. inverse = "inverse",
  84035. exponential = "exponential",
  84036. }
  84037. /** @hidden */
  84038. interface IMSFTAudioEmitter_Emitter {
  84039. name?: string;
  84040. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  84041. refDistance?: number;
  84042. maxDistance?: number;
  84043. rolloffFactor?: number;
  84044. innerAngle?: number;
  84045. outerAngle?: number;
  84046. loop?: boolean;
  84047. volume?: number;
  84048. clips: IMSFTAudioEmitter_ClipReference[];
  84049. }
  84050. /** @hidden */
  84051. const enum IMSFTAudioEmitter_AudioMimeType {
  84052. WAV = "audio/wav",
  84053. }
  84054. /** @hidden */
  84055. interface IMSFTAudioEmitter_Clip extends IProperty {
  84056. uri?: string;
  84057. bufferView?: number;
  84058. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  84059. }
  84060. /** @hidden */
  84061. const enum IMSFTAudioEmitter_AnimationEventAction {
  84062. play = "play",
  84063. pause = "pause",
  84064. stop = "stop",
  84065. }
  84066. /** @hidden */
  84067. interface IMSFTAudioEmitter_AnimationEvent {
  84068. action: IMSFTAudioEmitter_AnimationEventAction;
  84069. emitter: number;
  84070. time: number;
  84071. startOffset?: number;
  84072. }
  84073. /**
  84074. * Interfaces from the MSFT_lod extension
  84075. */
  84076. /** @hidden */
  84077. interface IMSFTLOD {
  84078. ids: number[];
  84079. }
  84080. }
  84081. declare module BABYLON {
  84082. /** @hidden */
  84083. export var cellPixelShader: {
  84084. name: string;
  84085. shader: string;
  84086. };
  84087. }
  84088. declare module BABYLON {
  84089. /** @hidden */
  84090. export var cellVertexShader: {
  84091. name: string;
  84092. shader: string;
  84093. };
  84094. }
  84095. declare module BABYLON {
  84096. export class CellMaterial extends BABYLON.PushMaterial {
  84097. private _diffuseTexture;
  84098. diffuseTexture: BABYLON.BaseTexture;
  84099. diffuseColor: BABYLON.Color3;
  84100. _computeHighLevel: boolean;
  84101. computeHighLevel: boolean;
  84102. private _disableLighting;
  84103. disableLighting: boolean;
  84104. private _maxSimultaneousLights;
  84105. maxSimultaneousLights: number;
  84106. constructor(name: string, scene: BABYLON.Scene);
  84107. needAlphaBlending(): boolean;
  84108. needAlphaTesting(): boolean;
  84109. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84110. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84111. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84112. getAnimatables(): BABYLON.IAnimatable[];
  84113. getActiveTextures(): BABYLON.BaseTexture[];
  84114. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84115. dispose(forceDisposeEffect?: boolean): void;
  84116. getClassName(): string;
  84117. clone(name: string): CellMaterial;
  84118. serialize(): any;
  84119. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  84120. }
  84121. }
  84122. declare module BABYLON {
  84123. export class CustomShaderStructure {
  84124. FragmentStore: string;
  84125. VertexStore: string;
  84126. constructor();
  84127. }
  84128. export class ShaderSpecialParts {
  84129. constructor();
  84130. Fragment_Begin: string;
  84131. Fragment_Definitions: string;
  84132. Fragment_MainBegin: string;
  84133. Fragment_Custom_Diffuse: string;
  84134. Fragment_Before_Lights: string;
  84135. Fragment_Before_Fog: string;
  84136. Fragment_Custom_Alpha: string;
  84137. Fragment_Before_FragColor: string;
  84138. Vertex_Begin: string;
  84139. Vertex_Definitions: string;
  84140. Vertex_MainBegin: string;
  84141. Vertex_Before_PositionUpdated: string;
  84142. Vertex_Before_NormalUpdated: string;
  84143. Vertex_After_WorldPosComputed: string;
  84144. Vertex_MainEnd: string;
  84145. }
  84146. export class CustomMaterial extends BABYLON.StandardMaterial {
  84147. static ShaderIndexer: number;
  84148. CustomParts: ShaderSpecialParts;
  84149. _isCreatedShader: boolean;
  84150. _createdShaderName: string;
  84151. _customUniform: string[];
  84152. _newUniforms: string[];
  84153. _newUniformInstances: {
  84154. [name: string]: any;
  84155. };
  84156. _newSamplerInstances: {
  84157. [name: string]: BABYLON.Texture;
  84158. };
  84159. _customAttributes: string[];
  84160. FragmentShader: string;
  84161. VertexShader: string;
  84162. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  84163. ReviewUniform(name: string, arr: string[]): string[];
  84164. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  84165. constructor(name: string, scene: BABYLON.Scene);
  84166. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  84167. AddAttribute(name: string): CustomMaterial;
  84168. Fragment_Begin(shaderPart: string): CustomMaterial;
  84169. Fragment_Definitions(shaderPart: string): CustomMaterial;
  84170. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  84171. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  84172. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  84173. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  84174. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  84175. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  84176. Vertex_Begin(shaderPart: string): CustomMaterial;
  84177. Vertex_Definitions(shaderPart: string): CustomMaterial;
  84178. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  84179. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  84180. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  84181. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  84182. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  84183. }
  84184. }
  84185. declare module BABYLON {
  84186. export class ShaderAlebdoParts {
  84187. constructor();
  84188. Fragment_Begin: string;
  84189. Fragment_Definitions: string;
  84190. Fragment_MainBegin: string;
  84191. Fragment_Custom_Albedo: string;
  84192. Fragment_Before_Lights: string;
  84193. Fragment_Custom_MetallicRoughness: string;
  84194. Fragment_Custom_MicroSurface: string;
  84195. Fragment_Before_Fog: string;
  84196. Fragment_Custom_Alpha: string;
  84197. Fragment_Before_FragColor: string;
  84198. Vertex_Begin: string;
  84199. Vertex_Definitions: string;
  84200. Vertex_MainBegin: string;
  84201. Vertex_Before_PositionUpdated: string;
  84202. Vertex_Before_NormalUpdated: string;
  84203. Vertex_After_WorldPosComputed: string;
  84204. Vertex_MainEnd: string;
  84205. }
  84206. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  84207. static ShaderIndexer: number;
  84208. CustomParts: ShaderAlebdoParts;
  84209. _isCreatedShader: boolean;
  84210. _createdShaderName: string;
  84211. _customUniform: string[];
  84212. _newUniforms: string[];
  84213. _newUniformInstances: {
  84214. [name: string]: any;
  84215. };
  84216. _newSamplerInstances: {
  84217. [name: string]: BABYLON.Texture;
  84218. };
  84219. _customAttributes: string[];
  84220. FragmentShader: string;
  84221. VertexShader: string;
  84222. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  84223. ReviewUniform(name: string, arr: string[]): string[];
  84224. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  84225. constructor(name: string, scene: BABYLON.Scene);
  84226. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  84227. AddAttribute(name: string): PBRCustomMaterial;
  84228. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  84229. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  84230. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  84231. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  84232. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  84233. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  84234. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  84235. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  84236. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  84237. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  84238. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  84239. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  84240. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  84241. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  84242. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  84243. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  84244. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  84245. }
  84246. }
  84247. declare module BABYLON {
  84248. /** @hidden */
  84249. export var firePixelShader: {
  84250. name: string;
  84251. shader: string;
  84252. };
  84253. }
  84254. declare module BABYLON {
  84255. /** @hidden */
  84256. export var fireVertexShader: {
  84257. name: string;
  84258. shader: string;
  84259. };
  84260. }
  84261. declare module BABYLON {
  84262. export class FireMaterial extends BABYLON.PushMaterial {
  84263. private _diffuseTexture;
  84264. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  84265. private _distortionTexture;
  84266. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  84267. private _opacityTexture;
  84268. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  84269. diffuseColor: BABYLON.Color3;
  84270. speed: number;
  84271. private _scaledDiffuse;
  84272. private _lastTime;
  84273. constructor(name: string, scene: BABYLON.Scene);
  84274. needAlphaBlending(): boolean;
  84275. needAlphaTesting(): boolean;
  84276. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84277. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84278. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84279. getAnimatables(): BABYLON.IAnimatable[];
  84280. getActiveTextures(): BABYLON.BaseTexture[];
  84281. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84282. getClassName(): string;
  84283. dispose(forceDisposeEffect?: boolean): void;
  84284. clone(name: string): FireMaterial;
  84285. serialize(): any;
  84286. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  84287. }
  84288. }
  84289. declare module BABYLON {
  84290. /** @hidden */
  84291. export var furPixelShader: {
  84292. name: string;
  84293. shader: string;
  84294. };
  84295. }
  84296. declare module BABYLON {
  84297. /** @hidden */
  84298. export var furVertexShader: {
  84299. name: string;
  84300. shader: string;
  84301. };
  84302. }
  84303. declare module BABYLON {
  84304. export class FurMaterial extends BABYLON.PushMaterial {
  84305. private _diffuseTexture;
  84306. diffuseTexture: BABYLON.BaseTexture;
  84307. private _heightTexture;
  84308. heightTexture: BABYLON.BaseTexture;
  84309. diffuseColor: BABYLON.Color3;
  84310. furLength: number;
  84311. furAngle: number;
  84312. furColor: BABYLON.Color3;
  84313. furOffset: number;
  84314. furSpacing: number;
  84315. furGravity: BABYLON.Vector3;
  84316. furSpeed: number;
  84317. furDensity: number;
  84318. furOcclusion: number;
  84319. furTexture: BABYLON.DynamicTexture;
  84320. private _disableLighting;
  84321. disableLighting: boolean;
  84322. private _maxSimultaneousLights;
  84323. maxSimultaneousLights: number;
  84324. highLevelFur: boolean;
  84325. _meshes: BABYLON.AbstractMesh[];
  84326. private _furTime;
  84327. constructor(name: string, scene: BABYLON.Scene);
  84328. get furTime(): number;
  84329. set furTime(furTime: number);
  84330. needAlphaBlending(): boolean;
  84331. needAlphaTesting(): boolean;
  84332. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84333. updateFur(): void;
  84334. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84335. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84336. getAnimatables(): BABYLON.IAnimatable[];
  84337. getActiveTextures(): BABYLON.BaseTexture[];
  84338. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84339. dispose(forceDisposeEffect?: boolean): void;
  84340. clone(name: string): FurMaterial;
  84341. serialize(): any;
  84342. getClassName(): string;
  84343. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  84344. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  84345. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  84346. }
  84347. }
  84348. declare module BABYLON {
  84349. /** @hidden */
  84350. export var gradientPixelShader: {
  84351. name: string;
  84352. shader: string;
  84353. };
  84354. }
  84355. declare module BABYLON {
  84356. /** @hidden */
  84357. export var gradientVertexShader: {
  84358. name: string;
  84359. shader: string;
  84360. };
  84361. }
  84362. declare module BABYLON {
  84363. export class GradientMaterial extends BABYLON.PushMaterial {
  84364. private _maxSimultaneousLights;
  84365. maxSimultaneousLights: number;
  84366. topColor: BABYLON.Color3;
  84367. topColorAlpha: number;
  84368. bottomColor: BABYLON.Color3;
  84369. bottomColorAlpha: number;
  84370. offset: number;
  84371. scale: number;
  84372. smoothness: number;
  84373. private _disableLighting;
  84374. disableLighting: boolean;
  84375. constructor(name: string, scene: BABYLON.Scene);
  84376. needAlphaBlending(): boolean;
  84377. needAlphaTesting(): boolean;
  84378. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84379. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84380. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84381. getAnimatables(): BABYLON.IAnimatable[];
  84382. dispose(forceDisposeEffect?: boolean): void;
  84383. clone(name: string): GradientMaterial;
  84384. serialize(): any;
  84385. getClassName(): string;
  84386. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  84387. }
  84388. }
  84389. declare module BABYLON {
  84390. /** @hidden */
  84391. export var gridPixelShader: {
  84392. name: string;
  84393. shader: string;
  84394. };
  84395. }
  84396. declare module BABYLON {
  84397. /** @hidden */
  84398. export var gridVertexShader: {
  84399. name: string;
  84400. shader: string;
  84401. };
  84402. }
  84403. declare module BABYLON {
  84404. /**
  84405. * The grid materials allows you to wrap any shape with a grid.
  84406. * Colors are customizable.
  84407. */
  84408. export class GridMaterial extends BABYLON.PushMaterial {
  84409. /**
  84410. * Main color of the grid (e.g. between lines)
  84411. */
  84412. mainColor: BABYLON.Color3;
  84413. /**
  84414. * Color of the grid lines.
  84415. */
  84416. lineColor: BABYLON.Color3;
  84417. /**
  84418. * The scale of the grid compared to unit.
  84419. */
  84420. gridRatio: number;
  84421. /**
  84422. * Allows setting an offset for the grid lines.
  84423. */
  84424. gridOffset: BABYLON.Vector3;
  84425. /**
  84426. * The frequency of thicker lines.
  84427. */
  84428. majorUnitFrequency: number;
  84429. /**
  84430. * The visibility of minor units in the grid.
  84431. */
  84432. minorUnitVisibility: number;
  84433. /**
  84434. * The grid opacity outside of the lines.
  84435. */
  84436. opacity: number;
  84437. /**
  84438. * Determine RBG output is premultiplied by alpha value.
  84439. */
  84440. preMultiplyAlpha: boolean;
  84441. private _opacityTexture;
  84442. opacityTexture: BABYLON.BaseTexture;
  84443. private _gridControl;
  84444. /**
  84445. * constructor
  84446. * @param name The name given to the material in order to identify it afterwards.
  84447. * @param scene The scene the material is used in.
  84448. */
  84449. constructor(name: string, scene: BABYLON.Scene);
  84450. /**
  84451. * Returns wehter or not the grid requires alpha blending.
  84452. */
  84453. needAlphaBlending(): boolean;
  84454. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  84455. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84456. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84457. /**
  84458. * Dispose the material and its associated resources.
  84459. * @param forceDisposeEffect will also dispose the used effect when true
  84460. */
  84461. dispose(forceDisposeEffect?: boolean): void;
  84462. clone(name: string): GridMaterial;
  84463. serialize(): any;
  84464. getClassName(): string;
  84465. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  84466. }
  84467. }
  84468. declare module BABYLON {
  84469. /** @hidden */
  84470. export var lavaPixelShader: {
  84471. name: string;
  84472. shader: string;
  84473. };
  84474. }
  84475. declare module BABYLON {
  84476. /** @hidden */
  84477. export var lavaVertexShader: {
  84478. name: string;
  84479. shader: string;
  84480. };
  84481. }
  84482. declare module BABYLON {
  84483. export class LavaMaterial extends BABYLON.PushMaterial {
  84484. private _diffuseTexture;
  84485. diffuseTexture: BABYLON.BaseTexture;
  84486. noiseTexture: BABYLON.BaseTexture;
  84487. fogColor: BABYLON.Color3;
  84488. speed: number;
  84489. movingSpeed: number;
  84490. lowFrequencySpeed: number;
  84491. fogDensity: number;
  84492. private _lastTime;
  84493. diffuseColor: BABYLON.Color3;
  84494. private _disableLighting;
  84495. disableLighting: boolean;
  84496. private _unlit;
  84497. unlit: boolean;
  84498. private _maxSimultaneousLights;
  84499. maxSimultaneousLights: number;
  84500. private _scaledDiffuse;
  84501. constructor(name: string, scene: BABYLON.Scene);
  84502. needAlphaBlending(): boolean;
  84503. needAlphaTesting(): boolean;
  84504. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84505. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84506. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84507. getAnimatables(): BABYLON.IAnimatable[];
  84508. getActiveTextures(): BABYLON.BaseTexture[];
  84509. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84510. dispose(forceDisposeEffect?: boolean): void;
  84511. clone(name: string): LavaMaterial;
  84512. serialize(): any;
  84513. getClassName(): string;
  84514. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  84515. }
  84516. }
  84517. declare module BABYLON {
  84518. /** @hidden */
  84519. export var mixPixelShader: {
  84520. name: string;
  84521. shader: string;
  84522. };
  84523. }
  84524. declare module BABYLON {
  84525. /** @hidden */
  84526. export var mixVertexShader: {
  84527. name: string;
  84528. shader: string;
  84529. };
  84530. }
  84531. declare module BABYLON {
  84532. export class MixMaterial extends BABYLON.PushMaterial {
  84533. /**
  84534. * Mix textures
  84535. */
  84536. private _mixTexture1;
  84537. mixTexture1: BABYLON.BaseTexture;
  84538. private _mixTexture2;
  84539. mixTexture2: BABYLON.BaseTexture;
  84540. /**
  84541. * Diffuse textures
  84542. */
  84543. private _diffuseTexture1;
  84544. diffuseTexture1: BABYLON.Texture;
  84545. private _diffuseTexture2;
  84546. diffuseTexture2: BABYLON.Texture;
  84547. private _diffuseTexture3;
  84548. diffuseTexture3: BABYLON.Texture;
  84549. private _diffuseTexture4;
  84550. diffuseTexture4: BABYLON.Texture;
  84551. private _diffuseTexture5;
  84552. diffuseTexture5: BABYLON.Texture;
  84553. private _diffuseTexture6;
  84554. diffuseTexture6: BABYLON.Texture;
  84555. private _diffuseTexture7;
  84556. diffuseTexture7: BABYLON.Texture;
  84557. private _diffuseTexture8;
  84558. diffuseTexture8: BABYLON.Texture;
  84559. /**
  84560. * Uniforms
  84561. */
  84562. diffuseColor: BABYLON.Color3;
  84563. specularColor: BABYLON.Color3;
  84564. specularPower: number;
  84565. private _disableLighting;
  84566. disableLighting: boolean;
  84567. private _maxSimultaneousLights;
  84568. maxSimultaneousLights: number;
  84569. constructor(name: string, scene: BABYLON.Scene);
  84570. needAlphaBlending(): boolean;
  84571. needAlphaTesting(): boolean;
  84572. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84573. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84574. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84575. getAnimatables(): BABYLON.IAnimatable[];
  84576. getActiveTextures(): BABYLON.BaseTexture[];
  84577. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84578. dispose(forceDisposeEffect?: boolean): void;
  84579. clone(name: string): MixMaterial;
  84580. serialize(): any;
  84581. getClassName(): string;
  84582. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  84583. }
  84584. }
  84585. declare module BABYLON {
  84586. /** @hidden */
  84587. export var normalPixelShader: {
  84588. name: string;
  84589. shader: string;
  84590. };
  84591. }
  84592. declare module BABYLON {
  84593. /** @hidden */
  84594. export var normalVertexShader: {
  84595. name: string;
  84596. shader: string;
  84597. };
  84598. }
  84599. declare module BABYLON {
  84600. export class NormalMaterial extends BABYLON.PushMaterial {
  84601. private _diffuseTexture;
  84602. diffuseTexture: BABYLON.BaseTexture;
  84603. diffuseColor: BABYLON.Color3;
  84604. private _disableLighting;
  84605. disableLighting: boolean;
  84606. private _maxSimultaneousLights;
  84607. maxSimultaneousLights: number;
  84608. constructor(name: string, scene: BABYLON.Scene);
  84609. needAlphaBlending(): boolean;
  84610. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  84611. needAlphaTesting(): boolean;
  84612. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84613. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84614. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84615. getAnimatables(): BABYLON.IAnimatable[];
  84616. getActiveTextures(): BABYLON.BaseTexture[];
  84617. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84618. dispose(forceDisposeEffect?: boolean): void;
  84619. clone(name: string): NormalMaterial;
  84620. serialize(): any;
  84621. getClassName(): string;
  84622. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  84623. }
  84624. }
  84625. declare module BABYLON {
  84626. /** @hidden */
  84627. export var shadowOnlyPixelShader: {
  84628. name: string;
  84629. shader: string;
  84630. };
  84631. }
  84632. declare module BABYLON {
  84633. /** @hidden */
  84634. export var shadowOnlyVertexShader: {
  84635. name: string;
  84636. shader: string;
  84637. };
  84638. }
  84639. declare module BABYLON {
  84640. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  84641. private _activeLight;
  84642. private _needAlphaBlending;
  84643. constructor(name: string, scene: BABYLON.Scene);
  84644. shadowColor: BABYLON.Color3;
  84645. needAlphaBlending(): boolean;
  84646. needAlphaTesting(): boolean;
  84647. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84648. get activeLight(): BABYLON.IShadowLight;
  84649. set activeLight(light: BABYLON.IShadowLight);
  84650. private _getFirstShadowLightForMesh;
  84651. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84652. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84653. clone(name: string): ShadowOnlyMaterial;
  84654. serialize(): any;
  84655. getClassName(): string;
  84656. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  84657. }
  84658. }
  84659. declare module BABYLON {
  84660. /** @hidden */
  84661. export var simplePixelShader: {
  84662. name: string;
  84663. shader: string;
  84664. };
  84665. }
  84666. declare module BABYLON {
  84667. /** @hidden */
  84668. export var simpleVertexShader: {
  84669. name: string;
  84670. shader: string;
  84671. };
  84672. }
  84673. declare module BABYLON {
  84674. export class SimpleMaterial extends BABYLON.PushMaterial {
  84675. private _diffuseTexture;
  84676. diffuseTexture: BABYLON.BaseTexture;
  84677. diffuseColor: BABYLON.Color3;
  84678. private _disableLighting;
  84679. disableLighting: boolean;
  84680. private _maxSimultaneousLights;
  84681. maxSimultaneousLights: number;
  84682. constructor(name: string, scene: BABYLON.Scene);
  84683. needAlphaBlending(): boolean;
  84684. needAlphaTesting(): boolean;
  84685. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84686. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84687. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84688. getAnimatables(): BABYLON.IAnimatable[];
  84689. getActiveTextures(): BABYLON.BaseTexture[];
  84690. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84691. dispose(forceDisposeEffect?: boolean): void;
  84692. clone(name: string): SimpleMaterial;
  84693. serialize(): any;
  84694. getClassName(): string;
  84695. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  84696. }
  84697. }
  84698. declare module BABYLON {
  84699. /** @hidden */
  84700. export var skyPixelShader: {
  84701. name: string;
  84702. shader: string;
  84703. };
  84704. }
  84705. declare module BABYLON {
  84706. /** @hidden */
  84707. export var skyVertexShader: {
  84708. name: string;
  84709. shader: string;
  84710. };
  84711. }
  84712. declare module BABYLON {
  84713. /**
  84714. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  84715. * @see https://doc.babylonjs.com/extensions/sky
  84716. */
  84717. export class SkyMaterial extends BABYLON.PushMaterial {
  84718. /**
  84719. * Defines the overall luminance of sky in interval ]0, 1[.
  84720. */
  84721. luminance: number;
  84722. /**
  84723. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  84724. */
  84725. turbidity: number;
  84726. /**
  84727. * Defines the sky appearance (light intensity).
  84728. */
  84729. rayleigh: number;
  84730. /**
  84731. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  84732. */
  84733. mieCoefficient: number;
  84734. /**
  84735. * Defines the amount of haze particles following the Mie scattering theory.
  84736. */
  84737. mieDirectionalG: number;
  84738. /**
  84739. * Defines the distance of the sun according to the active scene camera.
  84740. */
  84741. distance: number;
  84742. /**
  84743. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  84744. * "inclined".
  84745. */
  84746. inclination: number;
  84747. /**
  84748. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  84749. * an object direction and a reference direction.
  84750. */
  84751. azimuth: number;
  84752. /**
  84753. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  84754. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  84755. */
  84756. sunPosition: BABYLON.Vector3;
  84757. /**
  84758. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  84759. * .sunPosition property.
  84760. */
  84761. useSunPosition: boolean;
  84762. /**
  84763. * Defines an offset vector used to get a horizon offset.
  84764. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  84765. */
  84766. cameraOffset: BABYLON.Vector3;
  84767. private _cameraPosition;
  84768. /**
  84769. * Instantiates a new sky material.
  84770. * This material allows to create dynamic and texture free
  84771. * effects for skyboxes by taking care of the atmosphere state.
  84772. * @see https://doc.babylonjs.com/extensions/sky
  84773. * @param name Define the name of the material in the scene
  84774. * @param scene Define the scene the material belong to
  84775. */
  84776. constructor(name: string, scene: BABYLON.Scene);
  84777. /**
  84778. * Specifies if the material will require alpha blending
  84779. * @returns a boolean specifying if alpha blending is needed
  84780. */
  84781. needAlphaBlending(): boolean;
  84782. /**
  84783. * Specifies if this material should be rendered in alpha test mode
  84784. * @returns false as the sky material doesn't need alpha testing.
  84785. */
  84786. needAlphaTesting(): boolean;
  84787. /**
  84788. * Get the texture used for alpha test purpose.
  84789. * @returns null as the sky material has no texture.
  84790. */
  84791. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84792. /**
  84793. * Get if the submesh is ready to be used and all its information available.
  84794. * Child classes can use it to update shaders
  84795. * @param mesh defines the mesh to check
  84796. * @param subMesh defines which submesh to check
  84797. * @param useInstances specifies that instances should be used
  84798. * @returns a boolean indicating that the submesh is ready or not
  84799. */
  84800. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84801. /**
  84802. * Binds the submesh to this material by preparing the effect and shader to draw
  84803. * @param world defines the world transformation matrix
  84804. * @param mesh defines the mesh containing the submesh
  84805. * @param subMesh defines the submesh to bind the material to
  84806. */
  84807. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84808. /**
  84809. * Get the list of animatables in the material.
  84810. * @returns the list of animatables object used in the material
  84811. */
  84812. getAnimatables(): BABYLON.IAnimatable[];
  84813. /**
  84814. * Disposes the material
  84815. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  84816. */
  84817. dispose(forceDisposeEffect?: boolean): void;
  84818. /**
  84819. * Makes a duplicate of the material, and gives it a new name
  84820. * @param name defines the new name for the duplicated material
  84821. * @returns the cloned material
  84822. */
  84823. clone(name: string): SkyMaterial;
  84824. /**
  84825. * Serializes this material in a JSON representation
  84826. * @returns the serialized material object
  84827. */
  84828. serialize(): any;
  84829. /**
  84830. * Gets the current class name of the material e.g. "SkyMaterial"
  84831. * Mainly use in serialization.
  84832. * @returns the class name
  84833. */
  84834. getClassName(): string;
  84835. /**
  84836. * Creates a sky material from parsed material data
  84837. * @param source defines the JSON representation of the material
  84838. * @param scene defines the hosting scene
  84839. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  84840. * @returns a new sky material
  84841. */
  84842. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  84843. }
  84844. }
  84845. declare module BABYLON {
  84846. /** @hidden */
  84847. export var terrainPixelShader: {
  84848. name: string;
  84849. shader: string;
  84850. };
  84851. }
  84852. declare module BABYLON {
  84853. /** @hidden */
  84854. export var terrainVertexShader: {
  84855. name: string;
  84856. shader: string;
  84857. };
  84858. }
  84859. declare module BABYLON {
  84860. export class TerrainMaterial extends BABYLON.PushMaterial {
  84861. private _mixTexture;
  84862. mixTexture: BABYLON.BaseTexture;
  84863. private _diffuseTexture1;
  84864. diffuseTexture1: BABYLON.Texture;
  84865. private _diffuseTexture2;
  84866. diffuseTexture2: BABYLON.Texture;
  84867. private _diffuseTexture3;
  84868. diffuseTexture3: BABYLON.Texture;
  84869. private _bumpTexture1;
  84870. bumpTexture1: BABYLON.Texture;
  84871. private _bumpTexture2;
  84872. bumpTexture2: BABYLON.Texture;
  84873. private _bumpTexture3;
  84874. bumpTexture3: BABYLON.Texture;
  84875. diffuseColor: BABYLON.Color3;
  84876. specularColor: BABYLON.Color3;
  84877. specularPower: number;
  84878. private _disableLighting;
  84879. disableLighting: boolean;
  84880. private _maxSimultaneousLights;
  84881. maxSimultaneousLights: number;
  84882. constructor(name: string, scene: BABYLON.Scene);
  84883. needAlphaBlending(): boolean;
  84884. needAlphaTesting(): boolean;
  84885. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84886. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84887. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84888. getAnimatables(): BABYLON.IAnimatable[];
  84889. getActiveTextures(): BABYLON.BaseTexture[];
  84890. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84891. dispose(forceDisposeEffect?: boolean): void;
  84892. clone(name: string): TerrainMaterial;
  84893. serialize(): any;
  84894. getClassName(): string;
  84895. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  84896. }
  84897. }
  84898. declare module BABYLON {
  84899. /** @hidden */
  84900. export var triplanarPixelShader: {
  84901. name: string;
  84902. shader: string;
  84903. };
  84904. }
  84905. declare module BABYLON {
  84906. /** @hidden */
  84907. export var triplanarVertexShader: {
  84908. name: string;
  84909. shader: string;
  84910. };
  84911. }
  84912. declare module BABYLON {
  84913. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  84914. mixTexture: BABYLON.BaseTexture;
  84915. private _diffuseTextureX;
  84916. diffuseTextureX: BABYLON.BaseTexture;
  84917. private _diffuseTextureY;
  84918. diffuseTextureY: BABYLON.BaseTexture;
  84919. private _diffuseTextureZ;
  84920. diffuseTextureZ: BABYLON.BaseTexture;
  84921. private _normalTextureX;
  84922. normalTextureX: BABYLON.BaseTexture;
  84923. private _normalTextureY;
  84924. normalTextureY: BABYLON.BaseTexture;
  84925. private _normalTextureZ;
  84926. normalTextureZ: BABYLON.BaseTexture;
  84927. tileSize: number;
  84928. diffuseColor: BABYLON.Color3;
  84929. specularColor: BABYLON.Color3;
  84930. specularPower: number;
  84931. private _disableLighting;
  84932. disableLighting: boolean;
  84933. private _maxSimultaneousLights;
  84934. maxSimultaneousLights: number;
  84935. constructor(name: string, scene: BABYLON.Scene);
  84936. needAlphaBlending(): boolean;
  84937. needAlphaTesting(): boolean;
  84938. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  84939. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  84940. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  84941. getAnimatables(): BABYLON.IAnimatable[];
  84942. getActiveTextures(): BABYLON.BaseTexture[];
  84943. hasTexture(texture: BABYLON.BaseTexture): boolean;
  84944. dispose(forceDisposeEffect?: boolean): void;
  84945. clone(name: string): TriPlanarMaterial;
  84946. serialize(): any;
  84947. getClassName(): string;
  84948. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  84949. }
  84950. }
  84951. declare module BABYLON {
  84952. /** @hidden */
  84953. export var waterPixelShader: {
  84954. name: string;
  84955. shader: string;
  84956. };
  84957. }
  84958. declare module BABYLON {
  84959. /** @hidden */
  84960. export var waterVertexShader: {
  84961. name: string;
  84962. shader: string;
  84963. };
  84964. }
  84965. declare module BABYLON {
  84966. export class WaterMaterial extends BABYLON.PushMaterial {
  84967. renderTargetSize: BABYLON.Vector2;
  84968. private _bumpTexture;
  84969. bumpTexture: BABYLON.BaseTexture;
  84970. diffuseColor: BABYLON.Color3;
  84971. specularColor: BABYLON.Color3;
  84972. specularPower: number;
  84973. private _disableLighting;
  84974. disableLighting: boolean;
  84975. private _maxSimultaneousLights;
  84976. maxSimultaneousLights: number;
  84977. /**
  84978. * @param {number}: Represents the wind force
  84979. */
  84980. windForce: number;
  84981. /**
  84982. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  84983. */
  84984. windDirection: BABYLON.Vector2;
  84985. /**
  84986. * @param {number}: Wave height, represents the height of the waves
  84987. */
  84988. waveHeight: number;
  84989. /**
  84990. * @param {number}: Bump height, represents the bump height related to the bump map
  84991. */
  84992. bumpHeight: number;
  84993. /**
  84994. * @param {boolean}: Add a smaller moving bump to less steady waves.
  84995. */
  84996. private _bumpSuperimpose;
  84997. bumpSuperimpose: boolean;
  84998. /**
  84999. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  85000. */
  85001. private _fresnelSeparate;
  85002. fresnelSeparate: boolean;
  85003. /**
  85004. * @param {boolean}: bump Waves modify the reflection.
  85005. */
  85006. private _bumpAffectsReflection;
  85007. bumpAffectsReflection: boolean;
  85008. /**
  85009. * @param {number}: The water color blended with the refraction (near)
  85010. */
  85011. waterColor: BABYLON.Color3;
  85012. /**
  85013. * @param {number}: The blend factor related to the water color
  85014. */
  85015. colorBlendFactor: number;
  85016. /**
  85017. * @param {number}: The water color blended with the reflection (far)
  85018. */
  85019. waterColor2: BABYLON.Color3;
  85020. /**
  85021. * @param {number}: The blend factor related to the water color (reflection, far)
  85022. */
  85023. colorBlendFactor2: number;
  85024. /**
  85025. * @param {number}: Represents the maximum length of a wave
  85026. */
  85027. waveLength: number;
  85028. /**
  85029. * @param {number}: Defines the waves speed
  85030. */
  85031. waveSpeed: number;
  85032. /**
  85033. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  85034. * will avoid calculating useless pixels in the pixel shader of the water material.
  85035. */
  85036. disableClipPlane: boolean;
  85037. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  85038. private _mesh;
  85039. private _refractionRTT;
  85040. private _reflectionRTT;
  85041. private _reflectionTransform;
  85042. private _lastTime;
  85043. private _lastDeltaTime;
  85044. private _useLogarithmicDepth;
  85045. private _waitingRenderList;
  85046. private _imageProcessingConfiguration;
  85047. private _imageProcessingObserver;
  85048. /**
  85049. * Gets a boolean indicating that current material needs to register RTT
  85050. */
  85051. get hasRenderTargetTextures(): boolean;
  85052. /**
  85053. * Constructor
  85054. */
  85055. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  85056. get useLogarithmicDepth(): boolean;
  85057. set useLogarithmicDepth(value: boolean);
  85058. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  85059. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  85060. addToRenderList(node: any): void;
  85061. enableRenderTargets(enable: boolean): void;
  85062. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  85063. get renderTargetsEnabled(): boolean;
  85064. needAlphaBlending(): boolean;
  85065. needAlphaTesting(): boolean;
  85066. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85067. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85068. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85069. private _createRenderTargets;
  85070. getAnimatables(): BABYLON.IAnimatable[];
  85071. getActiveTextures(): BABYLON.BaseTexture[];
  85072. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85073. dispose(forceDisposeEffect?: boolean): void;
  85074. clone(name: string): WaterMaterial;
  85075. serialize(): any;
  85076. getClassName(): string;
  85077. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  85078. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  85079. }
  85080. }
  85081. declare module BABYLON {
  85082. /** @hidden */
  85083. export var asciiartPixelShader: {
  85084. name: string;
  85085. shader: string;
  85086. };
  85087. }
  85088. declare module BABYLON {
  85089. /**
  85090. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  85091. *
  85092. * It basically takes care rendering the font front the given font size to a texture.
  85093. * This is used later on in the postprocess.
  85094. */
  85095. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  85096. private _font;
  85097. private _text;
  85098. private _charSize;
  85099. /**
  85100. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  85101. */
  85102. get charSize(): number;
  85103. /**
  85104. * Create a new instance of the Ascii Art FontTexture class
  85105. * @param name the name of the texture
  85106. * @param font the font to use, use the W3C CSS notation
  85107. * @param text the caracter set to use in the rendering.
  85108. * @param scene the scene that owns the texture
  85109. */
  85110. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  85111. /**
  85112. * Gets the max char width of a font.
  85113. * @param font the font to use, use the W3C CSS notation
  85114. * @return the max char width
  85115. */
  85116. private getFontWidth;
  85117. /**
  85118. * Gets the max char height of a font.
  85119. * @param font the font to use, use the W3C CSS notation
  85120. * @return the max char height
  85121. */
  85122. private getFontHeight;
  85123. /**
  85124. * Clones the current AsciiArtTexture.
  85125. * @return the clone of the texture.
  85126. */
  85127. clone(): AsciiArtFontTexture;
  85128. /**
  85129. * Parses a json object representing the texture and returns an instance of it.
  85130. * @param source the source JSON representation
  85131. * @param scene the scene to create the texture for
  85132. * @return the parsed texture
  85133. */
  85134. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  85135. }
  85136. /**
  85137. * Option available in the Ascii Art Post Process.
  85138. */
  85139. export interface IAsciiArtPostProcessOptions {
  85140. /**
  85141. * The font to use following the w3c font definition.
  85142. */
  85143. font?: string;
  85144. /**
  85145. * The character set to use in the postprocess.
  85146. */
  85147. characterSet?: string;
  85148. /**
  85149. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  85150. * This number is defined between 0 and 1;
  85151. */
  85152. mixToTile?: number;
  85153. /**
  85154. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  85155. * This number is defined between 0 and 1;
  85156. */
  85157. mixToNormal?: number;
  85158. }
  85159. /**
  85160. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  85161. *
  85162. * Simmply add it to your scene and let the nerd that lives in you have fun.
  85163. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  85164. */
  85165. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  85166. /**
  85167. * The font texture used to render the char in the post process.
  85168. */
  85169. private _asciiArtFontTexture;
  85170. /**
  85171. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  85172. * This number is defined between 0 and 1;
  85173. */
  85174. mixToTile: number;
  85175. /**
  85176. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  85177. * This number is defined between 0 and 1;
  85178. */
  85179. mixToNormal: number;
  85180. /**
  85181. * Instantiates a new Ascii Art Post Process.
  85182. * @param name the name to give to the postprocess
  85183. * @camera the camera to apply the post process to.
  85184. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  85185. */
  85186. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  85187. }
  85188. }
  85189. declare module BABYLON {
  85190. /** @hidden */
  85191. export var digitalrainPixelShader: {
  85192. name: string;
  85193. shader: string;
  85194. };
  85195. }
  85196. declare module BABYLON {
  85197. /**
  85198. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  85199. *
  85200. * It basically takes care rendering the font front the given font size to a texture.
  85201. * This is used later on in the postprocess.
  85202. */
  85203. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  85204. private _font;
  85205. private _text;
  85206. private _charSize;
  85207. /**
  85208. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  85209. */
  85210. get charSize(): number;
  85211. /**
  85212. * Create a new instance of the Digital Rain FontTexture class
  85213. * @param name the name of the texture
  85214. * @param font the font to use, use the W3C CSS notation
  85215. * @param text the caracter set to use in the rendering.
  85216. * @param scene the scene that owns the texture
  85217. */
  85218. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  85219. /**
  85220. * Gets the max char width of a font.
  85221. * @param font the font to use, use the W3C CSS notation
  85222. * @return the max char width
  85223. */
  85224. private getFontWidth;
  85225. /**
  85226. * Gets the max char height of a font.
  85227. * @param font the font to use, use the W3C CSS notation
  85228. * @return the max char height
  85229. */
  85230. private getFontHeight;
  85231. /**
  85232. * Clones the current DigitalRainFontTexture.
  85233. * @return the clone of the texture.
  85234. */
  85235. clone(): DigitalRainFontTexture;
  85236. /**
  85237. * Parses a json object representing the texture and returns an instance of it.
  85238. * @param source the source JSON representation
  85239. * @param scene the scene to create the texture for
  85240. * @return the parsed texture
  85241. */
  85242. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  85243. }
  85244. /**
  85245. * Option available in the Digital Rain Post Process.
  85246. */
  85247. export interface IDigitalRainPostProcessOptions {
  85248. /**
  85249. * The font to use following the w3c font definition.
  85250. */
  85251. font?: string;
  85252. /**
  85253. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  85254. * This number is defined between 0 and 1;
  85255. */
  85256. mixToTile?: number;
  85257. /**
  85258. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  85259. * This number is defined between 0 and 1;
  85260. */
  85261. mixToNormal?: number;
  85262. }
  85263. /**
  85264. * DigitalRainPostProcess helps rendering everithing in digital rain.
  85265. *
  85266. * Simmply add it to your scene and let the nerd that lives in you have fun.
  85267. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  85268. */
  85269. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  85270. /**
  85271. * The font texture used to render the char in the post process.
  85272. */
  85273. private _digitalRainFontTexture;
  85274. /**
  85275. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  85276. * This number is defined between 0 and 1;
  85277. */
  85278. mixToTile: number;
  85279. /**
  85280. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  85281. * This number is defined between 0 and 1;
  85282. */
  85283. mixToNormal: number;
  85284. /**
  85285. * Instantiates a new Digital Rain Post Process.
  85286. * @param name the name to give to the postprocess
  85287. * @camera the camera to apply the post process to.
  85288. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  85289. */
  85290. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  85291. }
  85292. }
  85293. declare module BABYLON {
  85294. /** @hidden */
  85295. export var brickProceduralTexturePixelShader: {
  85296. name: string;
  85297. shader: string;
  85298. };
  85299. }
  85300. declare module BABYLON {
  85301. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  85302. private _numberOfBricksHeight;
  85303. private _numberOfBricksWidth;
  85304. private _jointColor;
  85305. private _brickColor;
  85306. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85307. updateShaderUniforms(): void;
  85308. get numberOfBricksHeight(): number;
  85309. set numberOfBricksHeight(value: number);
  85310. get numberOfBricksWidth(): number;
  85311. set numberOfBricksWidth(value: number);
  85312. get jointColor(): BABYLON.Color3;
  85313. set jointColor(value: BABYLON.Color3);
  85314. get brickColor(): BABYLON.Color3;
  85315. set brickColor(value: BABYLON.Color3);
  85316. /**
  85317. * Serializes this brick procedural texture
  85318. * @returns a serialized brick procedural texture object
  85319. */
  85320. serialize(): any;
  85321. /**
  85322. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  85323. * @param parsedTexture defines parsed texture data
  85324. * @param scene defines the current scene
  85325. * @param rootUrl defines the root URL containing brick procedural texture information
  85326. * @returns a parsed Brick Procedural BABYLON.Texture
  85327. */
  85328. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  85329. }
  85330. }
  85331. declare module BABYLON {
  85332. /** @hidden */
  85333. export var cloudProceduralTexturePixelShader: {
  85334. name: string;
  85335. shader: string;
  85336. };
  85337. }
  85338. declare module BABYLON {
  85339. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  85340. private _skyColor;
  85341. private _cloudColor;
  85342. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85343. updateShaderUniforms(): void;
  85344. get skyColor(): BABYLON.Color4;
  85345. set skyColor(value: BABYLON.Color4);
  85346. get cloudColor(): BABYLON.Color4;
  85347. set cloudColor(value: BABYLON.Color4);
  85348. /**
  85349. * Serializes this cloud procedural texture
  85350. * @returns a serialized cloud procedural texture object
  85351. */
  85352. serialize(): any;
  85353. /**
  85354. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  85355. * @param parsedTexture defines parsed texture data
  85356. * @param scene defines the current scene
  85357. * @param rootUrl defines the root URL containing cloud procedural texture information
  85358. * @returns a parsed Cloud Procedural BABYLON.Texture
  85359. */
  85360. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  85361. }
  85362. }
  85363. declare module BABYLON {
  85364. /** @hidden */
  85365. export var fireProceduralTexturePixelShader: {
  85366. name: string;
  85367. shader: string;
  85368. };
  85369. }
  85370. declare module BABYLON {
  85371. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  85372. private _time;
  85373. private _speed;
  85374. private _autoGenerateTime;
  85375. private _fireColors;
  85376. private _alphaThreshold;
  85377. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85378. updateShaderUniforms(): void;
  85379. render(useCameraPostProcess?: boolean): void;
  85380. static get PurpleFireColors(): BABYLON.Color3[];
  85381. static get GreenFireColors(): BABYLON.Color3[];
  85382. static get RedFireColors(): BABYLON.Color3[];
  85383. static get BlueFireColors(): BABYLON.Color3[];
  85384. get autoGenerateTime(): boolean;
  85385. set autoGenerateTime(value: boolean);
  85386. get fireColors(): BABYLON.Color3[];
  85387. set fireColors(value: BABYLON.Color3[]);
  85388. get time(): number;
  85389. set time(value: number);
  85390. get speed(): BABYLON.Vector2;
  85391. set speed(value: BABYLON.Vector2);
  85392. get alphaThreshold(): number;
  85393. set alphaThreshold(value: number);
  85394. /**
  85395. * Serializes this fire procedural texture
  85396. * @returns a serialized fire procedural texture object
  85397. */
  85398. serialize(): any;
  85399. /**
  85400. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  85401. * @param parsedTexture defines parsed texture data
  85402. * @param scene defines the current scene
  85403. * @param rootUrl defines the root URL containing fire procedural texture information
  85404. * @returns a parsed Fire Procedural BABYLON.Texture
  85405. */
  85406. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  85407. }
  85408. }
  85409. declare module BABYLON {
  85410. /** @hidden */
  85411. export var grassProceduralTexturePixelShader: {
  85412. name: string;
  85413. shader: string;
  85414. };
  85415. }
  85416. declare module BABYLON {
  85417. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  85418. private _grassColors;
  85419. private _groundColor;
  85420. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85421. updateShaderUniforms(): void;
  85422. get grassColors(): BABYLON.Color3[];
  85423. set grassColors(value: BABYLON.Color3[]);
  85424. get groundColor(): BABYLON.Color3;
  85425. set groundColor(value: BABYLON.Color3);
  85426. /**
  85427. * Serializes this grass procedural texture
  85428. * @returns a serialized grass procedural texture object
  85429. */
  85430. serialize(): any;
  85431. /**
  85432. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  85433. * @param parsedTexture defines parsed texture data
  85434. * @param scene defines the current scene
  85435. * @param rootUrl defines the root URL containing grass procedural texture information
  85436. * @returns a parsed Grass Procedural BABYLON.Texture
  85437. */
  85438. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  85439. }
  85440. }
  85441. declare module BABYLON {
  85442. /** @hidden */
  85443. export var marbleProceduralTexturePixelShader: {
  85444. name: string;
  85445. shader: string;
  85446. };
  85447. }
  85448. declare module BABYLON {
  85449. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  85450. private _numberOfTilesHeight;
  85451. private _numberOfTilesWidth;
  85452. private _amplitude;
  85453. private _jointColor;
  85454. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85455. updateShaderUniforms(): void;
  85456. get numberOfTilesHeight(): number;
  85457. set numberOfTilesHeight(value: number);
  85458. get amplitude(): number;
  85459. set amplitude(value: number);
  85460. get numberOfTilesWidth(): number;
  85461. set numberOfTilesWidth(value: number);
  85462. get jointColor(): BABYLON.Color3;
  85463. set jointColor(value: BABYLON.Color3);
  85464. /**
  85465. * Serializes this marble procedural texture
  85466. * @returns a serialized marble procedural texture object
  85467. */
  85468. serialize(): any;
  85469. /**
  85470. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  85471. * @param parsedTexture defines parsed texture data
  85472. * @param scene defines the current scene
  85473. * @param rootUrl defines the root URL containing marble procedural texture information
  85474. * @returns a parsed Marble Procedural BABYLON.Texture
  85475. */
  85476. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  85477. }
  85478. }
  85479. declare module BABYLON {
  85480. /** @hidden */
  85481. export var normalMapProceduralTexturePixelShader: {
  85482. name: string;
  85483. shader: string;
  85484. };
  85485. }
  85486. declare module BABYLON {
  85487. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  85488. private _baseTexture;
  85489. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85490. updateShaderUniforms(): void;
  85491. render(useCameraPostProcess?: boolean): void;
  85492. resize(size: any, generateMipMaps: any): void;
  85493. get baseTexture(): BABYLON.Texture;
  85494. set baseTexture(texture: BABYLON.Texture);
  85495. /**
  85496. * Serializes this normal map procedural texture
  85497. * @returns a serialized normal map procedural texture object
  85498. */
  85499. serialize(): any;
  85500. /**
  85501. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  85502. * @param parsedTexture defines parsed texture data
  85503. * @param scene defines the current scene
  85504. * @param rootUrl defines the root URL containing normal map procedural texture information
  85505. * @returns a parsed Normal Map Procedural BABYLON.Texture
  85506. */
  85507. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  85508. }
  85509. }
  85510. declare module BABYLON {
  85511. /** @hidden */
  85512. export var perlinNoiseProceduralTexturePixelShader: {
  85513. name: string;
  85514. shader: string;
  85515. };
  85516. }
  85517. declare module BABYLON {
  85518. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  85519. time: number;
  85520. timeScale: number;
  85521. translationSpeed: number;
  85522. private _currentTranslation;
  85523. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85524. updateShaderUniforms(): void;
  85525. render(useCameraPostProcess?: boolean): void;
  85526. resize(size: any, generateMipMaps: any): void;
  85527. /**
  85528. * Serializes this perlin noise procedural texture
  85529. * @returns a serialized perlin noise procedural texture object
  85530. */
  85531. serialize(): any;
  85532. /**
  85533. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  85534. * @param parsedTexture defines parsed texture data
  85535. * @param scene defines the current scene
  85536. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  85537. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  85538. */
  85539. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  85540. }
  85541. }
  85542. declare module BABYLON {
  85543. /** @hidden */
  85544. export var roadProceduralTexturePixelShader: {
  85545. name: string;
  85546. shader: string;
  85547. };
  85548. }
  85549. declare module BABYLON {
  85550. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  85551. private _roadColor;
  85552. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85553. updateShaderUniforms(): void;
  85554. get roadColor(): BABYLON.Color3;
  85555. set roadColor(value: BABYLON.Color3);
  85556. /**
  85557. * Serializes this road procedural texture
  85558. * @returns a serialized road procedural texture object
  85559. */
  85560. serialize(): any;
  85561. /**
  85562. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  85563. * @param parsedTexture defines parsed texture data
  85564. * @param scene defines the current scene
  85565. * @param rootUrl defines the root URL containing road procedural texture information
  85566. * @returns a parsed Road Procedural BABYLON.Texture
  85567. */
  85568. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  85569. }
  85570. }
  85571. declare module BABYLON {
  85572. /** @hidden */
  85573. export var starfieldProceduralTexturePixelShader: {
  85574. name: string;
  85575. shader: string;
  85576. };
  85577. }
  85578. declare module BABYLON {
  85579. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  85580. private _time;
  85581. private _alpha;
  85582. private _beta;
  85583. private _zoom;
  85584. private _formuparam;
  85585. private _stepsize;
  85586. private _tile;
  85587. private _brightness;
  85588. private _darkmatter;
  85589. private _distfading;
  85590. private _saturation;
  85591. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85592. updateShaderUniforms(): void;
  85593. get time(): number;
  85594. set time(value: number);
  85595. get alpha(): number;
  85596. set alpha(value: number);
  85597. get beta(): number;
  85598. set beta(value: number);
  85599. get formuparam(): number;
  85600. set formuparam(value: number);
  85601. get stepsize(): number;
  85602. set stepsize(value: number);
  85603. get zoom(): number;
  85604. set zoom(value: number);
  85605. get tile(): number;
  85606. set tile(value: number);
  85607. get brightness(): number;
  85608. set brightness(value: number);
  85609. get darkmatter(): number;
  85610. set darkmatter(value: number);
  85611. get distfading(): number;
  85612. set distfading(value: number);
  85613. get saturation(): number;
  85614. set saturation(value: number);
  85615. /**
  85616. * Serializes this starfield procedural texture
  85617. * @returns a serialized starfield procedural texture object
  85618. */
  85619. serialize(): any;
  85620. /**
  85621. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  85622. * @param parsedTexture defines parsed texture data
  85623. * @param scene defines the current scene
  85624. * @param rootUrl defines the root URL containing startfield procedural texture information
  85625. * @returns a parsed Starfield Procedural BABYLON.Texture
  85626. */
  85627. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  85628. }
  85629. }
  85630. declare module BABYLON {
  85631. /** @hidden */
  85632. export var woodProceduralTexturePixelShader: {
  85633. name: string;
  85634. shader: string;
  85635. };
  85636. }
  85637. declare module BABYLON {
  85638. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  85639. private _ampScale;
  85640. private _woodColor;
  85641. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  85642. updateShaderUniforms(): void;
  85643. get ampScale(): number;
  85644. set ampScale(value: number);
  85645. get woodColor(): BABYLON.Color3;
  85646. set woodColor(value: BABYLON.Color3);
  85647. /**
  85648. * Serializes this wood procedural texture
  85649. * @returns a serialized wood procedural texture object
  85650. */
  85651. serialize(): any;
  85652. /**
  85653. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  85654. * @param parsedTexture defines parsed texture data
  85655. * @param scene defines the current scene
  85656. * @param rootUrl defines the root URL containing wood procedural texture information
  85657. * @returns a parsed Wood Procedural BABYLON.Texture
  85658. */
  85659. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  85660. }
  85661. }